<commit_before>require_dependency  'formatting'
require_dependency  'vendor/plugins/questionnaire_engine/app/helpers/application_helper'

# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
  include Formatting
  
  def application_title
    if @eg.try(:pat_title).present?
      @eg.try(:pat_title)
    else
      Pat::CONFIG[:title] || "Project Application Tool"
    end
  end

  # TODO: I would really like to make this actually check for the file, rather than do this silly try to render thing
  def file_exists?(p)
    !render_if_possible(:template => p).nil? || 
      !render_if_possible(:file => p).nil?
  end

  def render_if_possible(params = {})
    begin
      render(params)
    rescue ActionView::MissingTemplate
      return nil
    rescue # any other errors are ok, just a :locals => ... issue
      return ""
    end
  end

  def new_item(title, controller, action = '')
    item_html = "<li "
    title =~ /<img .*>(.*)/
    if (title == @page_title || $1 == @page_title)
      item_html += " class=\"menuactive\""
    else
      item_html += " class=\"menuinactive\""
    end
    item_html += ">"
    
    controller ||= params[:controller]
    #item_html += link_to title, :controller => controller, :action => action
    item_html += "<a href='/#{controller}/#{action}'>#{title}</a>"
    
    item_html += "</li>"
    
    return item_html
  end<commit_msg>require a valid page_title before setting menuactive<commit_after>require_dependency  'formatting'
require_dependency  'vendor/plugins/questionnaire_engine/app/helpers/application_helper'

# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
  include Formatting
  
  def application_title
    if @eg.try(:pat_title).present?
      @eg.try(:pat_title)
    else
      Pat::CONFIG[:title] || "Project Application Tool"
    end
  end

  # TODO: I would really like to make this actually check for the file, rather than do this silly try to render thing
  def file_exists?(p)
    !render_if_possible(:template => p).nil? || 
      !render_if_possible(:file => p).nil?
  end

  def render_if_possible(params = {})
    begin
      render(params)
    rescue ActionView::MissingTemplate
      return nil
    rescue # any other errors are ok, just a :locals => ... issue
      return ""
    end
  end

  def new_item(title, controller, action = '')
    item_html = "<li "
    title =~ /<img .*>(.*)/
    if (@page_title && (title == @page_title || $1 == @page_title))
      item_html += " class=\"menuactive\""
    else
      item_html += " class=\"menuinactive\""
    end
    item_html += ">"
    
    controller ||= params[:controller]
    #item_html += link_to title, :controller => controller, :action => action
    item_html += "<a href='/#{controller}/#{action}'>#{title}</a>"
    
    item_html += "</li>"
    
    return item_html
  end
{'fraction_non_alphanumeric': 0.12593856655290103, 'fraction_numerical': 0.0006825938566552901, 'mean_word_length': 3.157446808510638, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 23, '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': '1189961', 'n_tokens_mistral': 881, 'n_tokens_neox': 880, 'n_words': 248}