<commit_before># A Rails controller which maps static content to actual template files in the
# <tt>RAILS_ROOT/app/views/pages</tt> directory.
class Ignition::PagesController < ApplicationController
  caches_action :show, :layout => false

  # Attempts to show the page specified by the <tt>params[:id]</tt> parameter.
  def show
    id = params[:id]

    check_path! id

    begin
      render :template => "pages/#{id}"
    rescue ActionView::MissingTemplate
      raise create_exception(id)
    end
  end

  private
    # Checks that the page with the specified <tt>id</tt> is valid and does not
    # map to a template outside of the <tt>RAILS_ROOT/app/views/pages</tt>
    # directory. If it does, an exception is thrown.
    def check_path!(id)
      base = File.expand_path('app/views/pages', ::Rails.root.to_s)
      current = File.expand_path(id, base)

      if not current.starts_with? base
        raise create_exception(id)
      end<commit_msg>Caching caused some problems with title code in my apps, disabled for now.<commit_after># A Rails controller which maps static content to actual template files in the
# <tt>RAILS_ROOT/app/views/pages</tt> directory.
class Ignition::PagesController < ApplicationController
  # Attempts to show the page specified by the <tt>params[:id]</tt> parameter.
  def show
    id = params[:id]

    check_path! id

    begin
      render :template => "pages/#{id}"
    rescue ActionView::MissingTemplate
      raise create_exception(id)
    end
  end

  private
    # Checks that the page with the specified <tt>id</tt> is valid and does not
    # map to a template outside of the <tt>RAILS_ROOT/app/views/pages</tt>
    # directory. If it does, an exception is thrown.
    def check_path!(id)
      base = File.expand_path('app/views/pages', ::Rails.root.to_s)
      current = File.expand_path(id, base)

      if not current.starts_with? base
        raise create_exception(id)
      end
{'fraction_non_alphanumeric': 0.09555785123966942, 'fraction_numerical': 0.0, 'mean_word_length': 3.3236607142857144, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 22, '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': '7049020', 'n_tokens_mistral': 589, 'n_tokens_neox': 577, 'n_words': 195}