<commit_before>module LayoutHelper

  ##########################################
  # BREADCRUMBS and CONTEXT
  
  def bread
    @breadcrumbs
  end
  
  def link_to_breadcrumbs
    if @breadcrumbs and @breadcrumbs.length > 1
      @breadcrumbs.collect{|b| link_to b[0],b[1]}.join ' &raquo; ' 
    end
  end
  
  def first_breadcrumb
    @breadcrumbs.first.first if @breadcrumbs.any?
  end
 
  def first_context
    @context.first.first if @context.any?
  end

  #########################################
  # TITLE
  
  def title_from_context
    (
      [@html_title] +
      (@context||[]).collect{|b|truncate(b[0])}.reverse +
      [Crabgrass::Config.site_name]
    ).compact.join(' - ')
  end
    
  #########################################
  # SIDEBAR 
  
  def leftbar 
    @leftbar ? "<div id='leftbar'>\n#{render :partial => @leftbar}</div>\n" : ''
  end
  
  def rightbar
    @rightbar ? "<div id='rightbar'>\n#{render :partial => @rightbar}</div>\n" : ''
  end

  def sidebar
    leftbar + rightbar
  end
  
  def sidebar_space
    style = ''
    style += "margin-left: 0;" unless @leftbar
    style += "margin-right: 0;" unless @rightbar
    style
  end
    
  ###########################################
  # STYLESHEET
  
  # custom stylesheet
  # rather than include every stylesheet in every request, some stylesheets are 
  # only included if they are needed. a controller can set a custom stylesheet
  # using 'stylesheet' in the class definition, or an action can set @stylesheet.
  # you can't do both at the same time.
  def stylesheet
    if @stylesheet
      @stylesheet # set for this action
    else
      controller.class.stylesheet # set for this controller
    end
  end
  
  def http_plain
    'http://' + controller.request.host_with_port
  end
  
  def optional_stylesheet
    stylesheet_link_tag(*(stylesheet.to_a+[:cache => true])) if stylesheet
  end
    
  ############################################
  # JAVASCRIPT
  
  def optional_javascript
    javascript_include_tag('effects', 'dragdrop', 'controls', :cache => true) if need_extra_javascript?
  end
    
  def need_extra_javascript?
    if @javascript
      @javascript == :extra
    else
      controller.class.javascript == :extra
    end
  end

#  def get_unobtrusive_javascript
#    controller.get_unobtrusive_javascript
# end
  
  ############################################
  # BANNER<commit_msg>fixed problem with stylesheets/javascript and :cache => true<commit_after>module LayoutHelper

  ##########################################
  # BREADCRUMBS and CONTEXT
  
  def bread
    @breadcrumbs
  end
  
  def link_to_breadcrumbs
    if @breadcrumbs and @breadcrumbs.length > 1
      @breadcrumbs.collect{|b| link_to b[0],b[1]}.join ' &raquo; ' 
    end
  end
  
  def first_breadcrumb
    @breadcrumbs.first.first if @breadcrumbs.any?
  end
 
  def first_context
    @context.first.first if @context.any?
  end

  #########################################
  # TITLE
  
  def title_from_context
    (
      [@html_title] +
      (@context||[]).collect{|b|truncate(b[0])}.reverse +
      [Crabgrass::Config.site_name]
    ).compact.join(' - ')
  end
    
  #########################################
  # SIDEBAR 
  
  def leftbar 
    @leftbar ? "<div id='leftbar'>\n#{render :partial => @leftbar}</div>\n" : ''
  end
  
  def rightbar
    @rightbar ? "<div id='rightbar'>\n#{render :partial => @rightbar}</div>\n" : ''
  end

  def sidebar
    leftbar + rightbar
  end
  
  def sidebar_space
    style = ''
    style += "margin-left: 0;" unless @leftbar
    style += "margin-right: 0;" unless @rightbar
    style
  end
    
  ###########################################
  # STYLESHEET
  
  # custom stylesheet
  # rather than include every stylesheet in every request, some stylesheets are 
  # only included if they are needed. a controller can set a custom stylesheet
  # using 'stylesheet' in the class definition, or an action can set @stylesheet.
  # you can't do both at the same time.
  def stylesheet
    if @stylesheet
      @stylesheet # set for this action
    else
      controller.class.stylesheet # set for this controller
    end
  end
  
  def http_plain
    'http://' + controller.request.host_with_port
  end
  
  def optional_stylesheet
    stylesheet_link_tag(*(stylesheet.to_a)) if stylesheet
  end
    
  ############################################
  # JAVASCRIPT
  
  def optional_javascript
    javascript_include_tag('effects', 'dragdrop', 'controls') if need_extra_javascript?
  end
    
  def need_extra_javascript?
    if @javascript
      @javascript == :extra
    else
      controller.class.javascript == :extra
    end
  end

#  def get_unobtrusive_javascript
#    controller.get_unobtrusive_javascript
# end
  
  ############################################
  # BANNER
{'fraction_non_alphanumeric': 0.19508128386827844, 'fraction_numerical': 0.0025010421008753647, 'mean_word_length': 3.2319223985890653, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 20, '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': '6316426', 'n_tokens_mistral': 1533, 'n_tokens_neox': 1467, 'n_words': 366}