<commit_before>class BlueSparks::PagesController < ApplicationController

  unloadable

  rescue_from ActionView::MissingTemplate do |exception|
    if exception.message =~ %r{Missing template pages/}
      raise ActionController::RoutingError, "No such page: #{params[:slug]}"
    else
      raise exception
    end
  end

  def show
    begin
      render :template => current_page
    rescue
      raise $! unless $!.kind_of? ActionView::MissingTemplate

      render :template => "#{current_page}/index"
    end
  end

  def subnav
    # magic method to render a given folder's subnav partial
    begin
      subnav = render :partial => "#{current_page}/menu", :layout => "menu_template"
      subnav.first unless subnav.nil?
    rescue
      logger.info "subnav error: #{$!}"

      begin
        subnav = render :partial => "#{page_root}/menu", :layout => "menu_template"
      rescue
        logger.info "subnav error: #{$!}"
      end
    end
    logger.info "#{subnav}"
    subnav unless subnav.nil?
  end

protected

  def current_page
    "pages/#{params[:slug].to_s.downcase}"
  end

  def page_root
    "pages/#{params[:slug].to_s.downcase.gsub /^([^\/]+)(\/.+)+$/, '\1'}"
  end

end
<commit_msg>stuff<commit_after>class BlueSparks::PagesController < ApplicationController

  unloadable

  rescue_from ActionView::MissingTemplate do |exception|
    if exception.message =~ %r{Missing template pages/}
      raise ActionController::RoutingError, "No such page: #{params[:slug]}"
    else
      raise exception
    end
  end

  def show
    begin
      render :template => current_page
    rescue
      raise $! unless $!.kind_of? ActionView::MissingTemplate

      render :template => "#{current_page}/index"
    end
  end

  def subnav
    # magic method to render a given folder's subnav partial
    begin
      subnav = render :partial => "#{current_page}/menu", :layout => "menu_template"
      subnav.first unless subnav.nil?
    rescue
      logger.info "subnav error: #{$!}"

      begin
        subnav = render :partial => "#{page_root}/menu", :layout => "menu_template"
      rescue
        logger.info "subnav error: #{$!}"
      end
    end
    logger.info "#{subnav.inspect}"
    subnav.first unless subnav.nil?
  end

protected

  def current_page
    "pages/#{params[:slug].to_s.downcase}"
  end

  def page_root
    "pages/#{params[:slug].to_s.downcase.gsub /^([^\/]+)(\/.+)+$/, '\1'}"
  end

end

{'fraction_non_alphanumeric': 0.1311881188118812, 'fraction_numerical': 0.0008250825082508251, 'mean_word_length': 2.9303079416531603, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '3099212', 'n_tokens_mistral': 767, 'n_tokens_neox': 763, 'n_words': 190}