<commit_before>module Fae
  module ApplicationHelper

    def form_header(name)
      name = name.class.name.split('::').last unless name.is_a? String
      form_title = "#{params[:action]} #{name}".titleize
      form_title = form_title.singularize if params[:action] == 'edit'
      content_tag :h1, form_title
    end

    def markdown_helper(links: true, formatting: true, emphasis: true, headers: true, list: true, paragraph: true)
      helper = "<h3>Markdown Options</h3>"
      helper += "<h4>Links</h4>
            <p>
              To link text, place a [bracket] around the link title and use a (/url) to house the url.<br>
              <br>
              Internal Link: [link to about](/about)<br>
              External link: [link to about](http://www.google.com/about)
            </p>" if links
      helper += "<h4>Formatting</h4>
            <p>
              Emphasize text in a variety of ways by placing **asterisks** to bold, _underscores_ to italicize.<br>
              <br>
              Bold  **bold**<br>
              Italicize _italic_
            </p>" if formatting || emphasis
      helper += "<h4>Headers</h4>
            <p>
              Use up to six hashtags to identify the importance of the section header.<br>
              <br>
              Page Header: # Page Header<br>
              Sub Header: ## Sub Header
            </p>" if headers
      helper += "<h4>List</h4>
            <p>
              Format lists by swapping out the characters that lead the list item.</br>
              <br>
              <span>Bulleted List:</span><br>
              * bullet<br>
              * bullet 2<br>
              <br>
              <span>Numbered List:</span><br>
              1. line item<br>
              2. line item
            </p>" if list
      helper += "<h4>Paragraph Break</h4>
            <p>
              Adding a blank line in between your paragraphs makes a paragraph break.
            </p>" if paragraph
      helper.html_safe
    end

    def require_locals(local_array, local_assigns)
      local_array.each do |loc|
        raise "#{loc} is a required local, please define it when you render this partial" unless local_assigns[loc.to_sym].present?
      end
    end

    def col_name_or_image(item, attribute)
      # if item's attribute is an association
      if item.class.reflections.include?(attribute)
        if item.send(attribute).class.name == 'Fae::Image'
          # display image thumbnail
          image_tag(item.send(attribute).asset.thumb.url)
        else
          # display associaiton's fae_display_field
          item.send(attribute).fae_display_field
        end
      else
        # otherwise it's an attribute so display it's value
        item.send(attribute)
      end
    end

    def fae_scope
      fae.root_path.gsub('/', '')
    end

    def page_title
      if @page_title.present?
        @page_title
      else
        default_page_title
      end
    end

    def body_class
      @body_class.present? ? @body_class : "#{controller_name} #{action_name}"
    end

    private

    def nav_path_current?(path)
      current_page?(path) || path[1..-1].classify == params[:controller].classify
    end<commit_msg>updated helper to detect date time<commit_after>module Fae
  module ApplicationHelper

    def form_header(name)
      name = name.class.name.split('::').last unless name.is_a? String
      form_title = "#{params[:action]} #{name}".titleize
      form_title = form_title.singularize if params[:action] == 'edit'
      content_tag :h1, form_title
    end

    def markdown_helper(links: true, formatting: true, emphasis: true, headers: true, list: true, paragraph: true)
      helper = "<h3>Markdown Options</h3>"
      helper += "<h4>Links</h4>
            <p>
              To link text, place a [bracket] around the link title and use a (/url) to house the url.<br>
              <br>
              Internal Link: [link to about](/about)<br>
              External link: [link to about](http://www.google.com/about)
            </p>" if links
      helper += "<h4>Formatting</h4>
            <p>
              Emphasize text in a variety of ways by placing **asterisks** to bold, _underscores_ to italicize.<br>
              <br>
              Bold  **bold**<br>
              Italicize _italic_
            </p>" if formatting || emphasis
      helper += "<h4>Headers</h4>
            <p>
              Use up to six hashtags to identify the importance of the section header.<br>
              <br>
              Page Header: # Page Header<br>
              Sub Header: ## Sub Header
            </p>" if headers
      helper += "<h4>List</h4>
            <p>
              Format lists by swapping out the characters that lead the list item.</br>
              <br>
              <span>Bulleted List:</span><br>
              * bullet<br>
              * bullet 2<br>
              <br>
              <span>Numbered List:</span><br>
              1. line item<br>
              2. line item
            </p>" if list
      helper += "<h4>Paragraph Break</h4>
            <p>
              Adding a blank line in between your paragraphs makes a paragraph break.
            </p>" if paragraph
      helper.html_safe
    end

    def require_locals(local_array, local_assigns)
      local_array.each do |loc|
        raise "#{loc} is a required local, please define it when you render this partial" unless local_assigns[loc.to_sym].present?
      end
    end

    def col_name_or_image(item, attribute)
      # if item's attribute is an association
      if item.class.reflections.include?(attribute)
        if item.send(attribute).class.name == 'Fae::Image'
          # display image thumbnail
          image_tag(item.send(attribute).asset.thumb.url)
        else
          # display associaiton's fae_display_field
          item.send(attribute).fae_display_field
        end
      # if item is a date or a time adjust to timezone
      elsif item.send(attribute).kind_of?(Date) || item.send(attribute).kind_of?(Time)
          item.last_modified.in_time_zone(@option.time_zone)
      else
        # otherwise it's an attribute so display it's value
        item.send(attribute)
      end
    end

    def fae_scope
      fae.root_path.gsub('/', '')
    end

    def page_title
      if @page_title.present?
        @page_title
      else
        default_page_title
      end
    end

    def body_class
      @body_class.present? ? @body_class : "#{controller_name} #{action_name}"
    end

    private

    def nav_path_current?(path)
      current_page?(path) || path[1..-1].classify == params[:controller].classify
    end
{'fraction_non_alphanumeric': 0.10493827160493827, 'fraction_numerical': 0.005420054200542005, 'mean_word_length': 1.9341872791519434, 'pattern_counts': {'":': 0, '<': 89, '<?xml version=': 0, '>': 89, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4922425', 'n_tokens_mistral': 1948, 'n_tokens_neox': 1903, 'n_words': 559}