<commit_before># Any way to not require render_page?
# Should provide sensible default if page is missing? Or just a 404?

# Thinking we have a catch-all controller that uses render inline,
# but could use a template handler with a comple method that queries DB?
# Template-finding seems to assume a file, though
class PagesController < ApplicationController
  def show
    if params[:path]
      path_params = Array.wrap(params[:path].dup)
      last_path = path_params.pop
      if last_path
        last_path.gsub!(/.html$/, "")
        if last_path && last_path != "index"
          path_params << last_path
        end
      end
      path = path_params.join("/")
    else
      path = ""
    end
    
    @page = Page.find_by_path(path)

    # Seems to be the best way to trigger a conventional Rails 404
    raise ActiveRecord::RecordNotFound.new("No page for /#{path}") unless @page

    render(:inline => @page.body, :layout => "application")
  end  
end<commit_msg>Expect Rails 3 path globbing API (string, not array)<commit_after># Any way to not require render_page?
# Should provide sensible default if page is missing? Or just a 404?

# Thinking we have a catch-all controller that uses render inline,
# but could use a template handler with a comple method that queries DB?
# Template-finding seems to assume a file, though
class PagesController < ApplicationController
  def show
    if params[:path]
      path = params[:path].dup
      if path
        path.gsub!(/.html$/, "")
        path.gsub!(/\/index$/, "")
      end
    else
      path = ""
    end
    
    @page = Page.find_by_path!(path)

    render :inline => @page.body, :layout => "application"
  end  
end
{'fraction_non_alphanumeric': 0.09549228944246738, 'fraction_numerical': 0.005931198102016607, 'mean_word_length': 2.9232558139534883, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1865605', 'n_tokens_mistral': 495, 'n_tokens_neox': 473, 'n_words': 185}