<commit_before>module UiHelper

  #  This will hide or show a div based on the given condition.
  def hidden_div_if(condition, attributes = {})
    if condition
      attributes["style"] = "display: none"
    end
    attrs = tag_options(attributes.stringify_keys)
    "<div #{attrs}>".html_safe
  end
  
      
  def add_google_analytics
    tracking_id = Settings.google_analytics
    begin 
      user_id = User.find(session[:user_id]).name || 'visitor' 
    rescue
      user_id = 'visitor'
    end
    
    if not tracking_id.blank? then
      data ="<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', '#{tracking_id}', 'auto');
  ga('send', 'pageview');
  ga('set', '&uid', '#{user_id}'); // Set the user ID using signed-in user_id.
</script>".html_safe
      
      return data
    end
  end

  def old_add_google_analytics
    tracking_id = Settings.google_analytics
    if not tracking_id.blank? then
      data = "<script type=\"text/javascript\" async>

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', '#{tracking_id}']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>".html_safe
      return data
    end
    
  end
  
  #  This will autoload css files based on the controller and/or action
  def controller_stylesheet_link_tag
    stylesheet = "#{params[:controller]}.css"
    stylesheet_path = Rails.application.assets.find_asset(stylesheet)

    stylesheetaction = "#{params[:controller]}/#{params[:action]=="index" ? "index_" : params[:action]}.css"
    stylesheetaction_path = Rails.application.assets.find_asset(stylesheetaction)

    stylesheet_return = ""
  
    if  stylesheet_path != nil then
      stylesheet_return = stylesheet_link_tag stylesheet rescue ""
    end
    
    if stylesheetaction_path != nil and (stylesheet_path != stylesheetaction_path) then
      stylesheet_return = stylesheet_return + " " + (stylesheet_link_tag stylesheetaction) rescue ""
    end
    
    if not @style_sheet_custom.nil? and not @style_sheet_custom.blank?  then
      custom_stylesheet = "#{params[:controller]}/#{@style_sheet_custom}"
      custom_stylesheet_path = Rails.application.assets.resolve(custom_stylesheet)
      stylesheet_return <<  (stylesheet_link_tag(custom_stylesheet,"data-turbolinks-track"=>"true")) if  custom_stylesheet_path != nil rescue ""
    end
     
    return stylesheet_return.html_safe if not stylesheet_return.blank?
    
  end
  
  #  This will autoload javascript files based on the controller and/or action 

  def controller_javascript_include_tag
    
    javascript = "#{params[:controller]}.js"
    javascript_path = Rails.application.assets.find_asset(javascript)

    javascriptaction = "#{params[:controller]}/#{params[:action]=="index" ? "index_" : params[:action]}.js"
    javascriptaction_path = Rails.application.assets.find_asset(javascriptaction)

    javascript_return = ""
           
    # Rails.application.assets.find_asset(javascriptaction) != nil

    # if File.exists?(File.join(Rails.root, '/assets/javascripts', javascript))
    if  javascript_path != nil then
      javascript_return = javascript_include_tag(javascript, :async => true) rescue ""
    end

    if javascriptaction_path != nil and (javascript_path != javascriptaction_path) then
      javascript_return = javascript_return + " " + (javascript_include_tag(javascriptaction, :async => true))rescue ""
    end
    
  
    if not @java_script_custom.nil? and not @java_script_custom.blank?  then
      custom_javascriptaction = "#{params[:controller]}/#{@java_script_custom}"
      custom_javascriptaction_path = Rails.application.assets.resolve(custom_javascriptaction)
      javascript_return <<  (javascript_include_tag(custom_javascriptaction,:async => true)) if  custom_javascriptaction_path != nil
    end
    
    return javascript_return.html_safe if not javascript_return.blank?

  end
  <commit_msg>used correct call to test assets existance.<commit_after>module UiHelper

  #  This will hide or show a div based on the given condition.
  def hidden_div_if(condition, attributes = {})
    if condition
      attributes["style"] = "display: none"
    end
    attrs = tag_options(attributes.stringify_keys)
    "<div #{attrs}>".html_safe
  end
  
      
  def add_google_analytics
    tracking_id = Settings.google_analytics
    begin 
      user_id = User.find(session[:user_id]).name || 'visitor' 
    rescue
      user_id = 'visitor'
    end
    
    if not tracking_id.blank? then
      data ="<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', '#{tracking_id}', 'auto');
  ga('send', 'pageview');
  ga('set', '&uid', '#{user_id}'); // Set the user ID using signed-in user_id.
</script>".html_safe
      
      return data
    end
  end

  def old_add_google_analytics
    tracking_id = Settings.google_analytics
    if not tracking_id.blank? then
      data = "<script type=\"text/javascript\" async>

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', '#{tracking_id}']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>".html_safe
      return data
    end
    
  end
  
  #  This will autoload css files based on the controller and/or action
  def controller_stylesheet_link_tag
    stylesheet = "#{params[:controller]}.css"
    stylesheet_path = Rails.application.assets.find_asset(stylesheet)

    stylesheetaction = "#{params[:controller]}/#{params[:action]=="index" ? "index_" : params[:action]}.css"
    stylesheetaction_path = Rails.application.assets.find_asset(stylesheetaction)

    stylesheet_return = ""
  
    if  stylesheet_path != nil then
      stylesheet_return = stylesheet_link_tag stylesheet rescue ""
    end
    
    if stylesheetaction_path != nil and (stylesheet_path != stylesheetaction_path) then
      stylesheet_return = stylesheet_return + " " + (stylesheet_link_tag stylesheetaction) rescue ""
    end
    
    if not @style_sheet_custom.nil? and not @style_sheet_custom.blank?  then
      custom_stylesheet = "#{params[:controller]}/#{@style_sheet_custom}"
      custom_stylesheet_path = Rails.application.assets.find_asset(custom_stylesheet)
      stylesheet_return <<  (stylesheet_link_tag(custom_stylesheet,"data-turbolinks-track"=>"true")) if  custom_stylesheet_path != nil rescue ""
    end
     
    return stylesheet_return.html_safe if not stylesheet_return.blank?
    
  end
  
  #  This will autoload javascript files based on the controller and/or action 

  def controller_javascript_include_tag
    
    javascript = "#{params[:controller]}.js"
    javascript_path = Rails.application.assets.find_asset(javascript)

    javascriptaction = "#{params[:controller]}/#{params[:action]=="index" ? "index_" : params[:action]}.js"
    javascriptaction_path = Rails.application.assets.find_asset(javascriptaction)

    javascript_return = ""
           
    # Rails.application.assets.find_asset(javascriptaction) != nil

    # if File.exists?(File.join(Rails.root, '/assets/javascripts', javascript))
    if  javascript_path != nil then
      javascript_return = javascript_include_tag(javascript, :async => true) rescue ""
    end

    if javascriptaction_path != nil and (javascript_path != javascriptaction_path) then
      javascript_return = javascript_return + " " + (javascript_include_tag(javascriptaction, :async => true))rescue ""
    end
    
  
    if not @java_script_custom.nil? and not @java_script_custom.blank?  then
      custom_javascriptaction = "#{params[:controller]}/#{@java_script_custom}"
      custom_javascriptaction_path = Rails.application.assets.find_asset(custom_javascriptaction)
      javascript_return <<  (javascript_include_tag(custom_javascriptaction,:async => true)) if  custom_javascriptaction_path != nil
    end
    
    return javascript_return.html_safe if not javascript_return.blank?

  end
  
{'fraction_non_alphanumeric': 0.1317786208435617, 'fraction_numerical': 0.0008926578888640928, 'mean_word_length': 4.058126410835214, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, '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': '1843765', 'n_tokens_mistral': 2878, 'n_tokens_neox': 2765, 'n_words': 526}