<commit_before>class PagesController < ApplicationController

  def show
    @page_name = params[:page_name].to_s.gsub(/\W/,'')

    unless partial_exists? @page_name
      render 'missing', status: 404
    end
  end

  private

  def partial_exists?(partial)
    VALID_PARTIALS.include?(partial)
  end

  def self.find_partials
    Dir.glob(Rails.root.join('app', 'views', 'pages', '_*.haml')).map do |file|
      file = Pathname.new(file).basename.to_s
      # Strip leading _ and then everything from the first . to the end of the name
      file.sub(/^_/, '').sub(/\..+$/, '')
    end
  end

  # Do this once on boot
  VALID_PARTIALS = PagesController.find_partials
end<commit_msg>simplify PagesController<commit_after>class PagesController < ApplicationController
  rescue_from ActionView::MissingTemplate, with: :missing

  def show
    @page_name = params[:page_name].to_s.gsub(/\W/,'')
  end

  private

  def missing
    render 'missing', status: 404
  end
end
{'fraction_non_alphanumeric': 0.12074303405572756, 'fraction_numerical': 0.006191950464396285, 'mean_word_length': 3.511627906976744, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '4650622', 'n_tokens_mistral': 333, 'n_tokens_neox': 310, 'n_words': 78}