<commit_before>class AjaxHelpController < ApplicationController

  PAGES = [:index, :tour, :public, :accounts, :searching, :uploading, :troubleshooting,
    :modification, :notes, :collaboration, :privacy, :publishing, :api]

  PAGE_TITLES = {
    :index            => 'Introduction',
    :tour             => 'Guided Tour',
    :public           => 'The Public Catalog',
    :accounts         => 'Adding Accounts',
    :searching        => 'Searching Documents and Data',
    :uploading        => 'Uploading Documents',
    :troubleshooting  => 'Troubleshooting Failed Uploads',
    :modification     => 'Document Modification',
    :privacy          => 'Privacy',
    :collaboration    => 'Collaboration',
    :notes            => 'Editing Notes and Sections',
    :publishing       => 'Publishing &amp; Embedding',
    :api              => 'API'
  }

  layout false

  skip_before_action :verify_authenticity_token

  def contact_us
    return bad_request unless params[:message]
    LifecycleMailer.contact_us(current_account, params).deliver
    json nil
  end

  PAGES.each do |resource|
    class_eval "def #{resource}; markdown(:#{resource}); end"
  end

  private

  HELP_DIRECTORY = "#{Rails.root}/app/views/help"

  def help_for_language( language, resource )
    "#{HELP_DIRECTORY}/#{language}/#{resource}.markdown"
  end

  def links_for_language( language, resource )
    "#{HELP_DIRECTORY}/#{language}/#{resource}_ajax_links.markdown"
  end

  def markdown(resource)
    language = logged_in? ? current_account.language : DC::Language::DEFAULT
    if ! File.exists?( help_for_language( language, resource ) ) && language != DC::Language::DEFAULT
      language = DC::Language::DEFAULT
    end
    render not_found and return unless File.exists?( help_for_language( language, resource ) )

    contents = File.read( help_for_language( language, resource ) )
    links = File.exists?( links_for_language( language, resource ) ) ?
      File.read( links_for_language( language, resource ) ) : ""
    render :html => RDiscount.new(contents+links).to_html
  end

end<commit_msg>Use plain rendering for the help files<commit_after>class AjaxHelpController < ApplicationController

  PAGES = [:index, :tour, :public, :accounts, :searching, :uploading, :troubleshooting,
    :modification, :notes, :collaboration, :privacy, :publishing, :api]

  PAGE_TITLES = {
    :index            => 'Introduction',
    :tour             => 'Guided Tour',
    :public           => 'The Public Catalog',
    :accounts         => 'Adding Accounts',
    :searching        => 'Searching Documents and Data',
    :uploading        => 'Uploading Documents',
    :troubleshooting  => 'Troubleshooting Failed Uploads',
    :modification     => 'Document Modification',
    :privacy          => 'Privacy',
    :collaboration    => 'Collaboration',
    :notes            => 'Editing Notes and Sections',
    :publishing       => 'Publishing &amp; Embedding',
    :api              => 'API'
  }

  layout false

  skip_before_action :verify_authenticity_token

  def contact_us
    return bad_request unless params[:message]
    LifecycleMailer.contact_us(current_account, params).deliver
    json nil
  end

  PAGES.each do |resource|
    class_eval "def #{resource}; markdown(:#{resource}); end"
  end

  private

  HELP_DIRECTORY = "#{Rails.root}/app/views/help"

  def help_for_language( language, resource )
    "#{HELP_DIRECTORY}/#{language}/#{resource}.markdown"
  end

  def links_for_language( language, resource )
    "#{HELP_DIRECTORY}/#{language}/#{resource}_ajax_links.markdown"
  end

  def markdown(resource)
    language = logged_in? ? current_account.language : DC::Language::DEFAULT
    if ! File.exists?( help_for_language( language, resource ) ) && language != DC::Language::DEFAULT
      language = DC::Language::DEFAULT
    end
    render not_found and return unless File.exists?( help_for_language( language, resource ) )

    contents = File.read( help_for_language( language, resource ) )
    links = File.exists?( links_for_language( language, resource ) ) ?
      File.read( links_for_language( language, resource ) ) : ""
    render :plain => RDiscount.new(contents+links).to_html
  end

end
{'fraction_non_alphanumeric': 0.1213707758210376, 'fraction_numerical': 0.0, 'mean_word_length': 3.3826903023983315, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5093580', 'n_tokens_mistral': 1297, 'n_tokens_neox': 1252, 'n_words': 291}