<commit_before>module TypusHelper

  ##
  # Applications list on the dashboard
  #
  def applications

    html = "<div id=\"list\">"

    if Typus.applications.empty?
      return display_error("There are not defined applications in config/typus.yml")
    end

    Typus.applications.each do |module_name|

      enabled = false

      html_module = <<-HTML
        <table>
          <tr>
            <th colspan="2">#{module_name}</th>
          </tr>
      HTML

      Typus.modules(module_name).each do |model|
        if @current_user.resources.include? model
          description = Typus.module_description(model)
          html_module << "<tr class=\"#{cycle('even', 'odd')}\">\n"
          html_module << "<td>#{link_to model.titleize.pluralize, "/admin/#{model.tableize}"}<br /><small>#{description}</small></td>\n"
          html_module << "<td align=\"right\" style=\"vertical-align: bottom;\"><small>"
          html_module << "#{link_to 'Add', "/admin/#{model.tableize}/new"}" if @current_user.can_perform?(model, 'create')
          html_module << "</small></td>\n"
          html_module << "</tr>"
          enabled = true
        end
      end

      html_module << <<-HTML
        </table>
        <br />
        <div style="clear"></div>
      HTML

      html << html_module if enabled

    end

    html << "</div>"

  end

  ##
  # Resources (wich are not models) on the dashboard.
  #
  def resources

    available = []

    Typus.resources.each do |resource|
      available << resource if @current_user.resources.include?(resource)
    end
<commit_msg>Refactored<commit_after>module TypusHelper

  ##
  # Applications list on the dashboard
  #
  def applications

    if Typus.applications.empty?
      return display_error("There are not defined applications in config/typus.yml")
    end

    html = "<div id=\"list\">"

    Typus.applications.each do |module_name|

      available = []

      Typus.modules(module_name).each do |resource|
        available << resource if @current_user.resources.include?(resource)
      end

      if !available.empty?

        html << <<-HTML
          <table>
            <tr>
              <th colspan="2">#{module_name}</th>
            </tr>
        HTML

        available.each do |model|
          description = Typus.module_description(model)
          html << "<tr class=\"#{cycle('even', 'odd')}\">\n"
          html << "<td>#{link_to model.titleize.pluralize, "/admin/#{model.tableize}"}<br /><small>#{description}</small></td>\n"
          html << "<td align=\"right\" style=\"vertical-align: bottom;\"><small>"
          html << "#{link_to 'Add', "/admin/#{model.tableize}/new"}" if @current_user.can_perform?(model, 'create')
          html << "</small></td>\n"
          html << "</tr>"
        end

        html << <<-HTML
          </table>
          <br />
          <div style="clear"></div>
        HTML

      end

    end

    html << "</div>"

  end

  ##
  # Resources (wich are not models) on the dashboard.
  #
  def resources

    available = []

    Typus.resources.each do |resource|
      available << resource if @current_user.resources.include?(resource)
    end

{'fraction_non_alphanumeric': 0.1557454890788224, 'fraction_numerical': 0.0006331117442228553, 'mean_word_length': 2.241025641025641, 'pattern_counts': {'":': 0, '<': 97, '<?xml version=': 0, '>': 47, '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': '5740171', 'n_tokens_mistral': 963, 'n_tokens_neox': 931, 'n_words': 214}