<commit_before># -*- coding: utf-8 -*-


# Copyright (C) 2007, 2008, 2009, 2010 The Collaborative Software Foundation
#
# This file is part of TriSano.
#
# TriSano is free software: you can redistribute it and/or modify it under the
# terms of the GNU Affero General Public License as published by the
# Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# TriSano is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with TriSano. If not, see http://www.gnu.org/licenses/agpl-3.0.txt.

module LayoutHelper
  extensible_helper

  def render_footer
    result = ""

    result << "<div class='footlogo'>"
    result << image_tag("foot.png", :border => 0)
    result << "</div>"
    result << "<div class='foottext'>"
    result << "<div class='top'>"
    result << "<a href='https://wiki.csinitiative.com/display/tri/TriSano+-+2.5+FINAL+Release+Notes'>#{t('trisano_ce')}</a>"
    result << "</div>"
    result << "<div class='bottom'>"
    result << "<a href='http://www.trisano.org/collaborate/'>#{t('collaborate')}</a>"
    result << "&nbsp;|&nbsp;"
    result << "#{t('user_feedback')} (<a href='http://groups.google.com/group/trisano-user'>#{t('web')}</a>, <a href='mailto:<EMAIL>'>#{t 'email'}</a>)"
    result << "&nbsp;|&nbsp;"
    result << "<a href='http://www.trisano.org'>#{t('about')}</a>"
    result << "&nbsp;|&nbsp;"
    result << "<a href='http://www.trisano.org/collaborate/licenses/'>#{t('license')}</a>"
    result << "&nbsp;|&nbsp;"
    result << "<a href='http://github.com/csinitiative/trisano/tree/master'>#{t('source')}</a>"
    result << "</div>"
    result << "<div class='bottom'>"
    result << t('copyright')
    result << "</div>"
    result << "</div>"

    result
  end

  # some javascript just needs to be in the hosted page
  def embedded_javascripts
    <<-JS
      <script type="text/javascript">
        function loadScript(src) {
          var script = document.createElement('script');
          script.type = 'text/javascript';
          script.src  = src
          document.body.appendChild(script);
        }
      </script>
    JS
  end

  def translations_js
    case I18n.locale
    when :test
      javascript_include_tag("ext/trisano_locales_test/translations_test")
    else
      locale = I18n.locale.to_s
      javascript_include_tag("ext/trisano_#{locale}/translations_#{locale}")
    end
  end

  def render_main_logo
    returning "" do |result|
      result << '<div class="horiz">'
      result << link_to(
        image_tag(main_logo_path, :border => 0),
        home_path, :id => 'logo')
      result << '</div>'
    end
  end

  def main_logo_path
    "logo.png"
  end

  def render_main_menu
    links = main_menu_items.collect do |item|
      item[:options] ||= {}
      text = item[:t] ? t(*item[:t]) : item[:text]
      link_to(text, item[:link], item[:options])
    end
    links.join("&nbsp;|&nbsp;")
  end

  def main_menu_items
    return MenuArray.new unless user = User.current_user
    returning MenuArray.new do |items|
      if user.is_entitled_to? :create_event
        items << {:link => event_search_cmrs_path, :t => :new_cmr}
      end
      if user.is_entitled_to? :manage_staged_message, :write_staged_message
        items << {
          :link => staged_messages_path,
          :t => :staging_area,
          :options => {:rel => "http://trisano.org/relation/staged_messages"}}
      end
      if user.is_entitled_to? :view_event
        items << {:link => cmrs_path_with_defaults, :t => :events}
        items << {:link => search_cmrs_path, :t => :search}
      end
      if user.is_entitled_to? :manage_entities
        items << {:link => people_path, :t => :people}
        items << {:link => places_path, :t => :places}
      end
      if user.is_entitled_to? :access_avr
        items << {
          :link => config_option(:bi_server),
          :t => :avr,
          :options => {:popup => true}}
      end
      if user.is_admin?
        items << {:link => admin_path, :t => :admin}
      end
      items << {:link => settings_path, :t => :settings}
    end
  end

  def render_user_tools(user)
    if allow_user_switching?
      change_user_url = url_for(:controller => :events, :action => :change_user)
      returning "" do |result|
        result << form_tag(change_user_url, :id => 'switch_user', :style => 'display: inline')
        result << "<span id='user_name'>#{current_user_name}:</span>"
        result << select_tag("user_id", options_for_user_select(user), :onchange => 'this.form.submit()', :style => 'display: inline')<commit_msg>AVR link is broken<commit_after># -*- coding: utf-8 -*-


# Copyright (C) 2007, 2008, 2009, 2010 The Collaborative Software Foundation
#
# This file is part of TriSano.
#
# TriSano is free software: you can redistribute it and/or modify it under the
# terms of the GNU Affero General Public License as published by the
# Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# TriSano is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with TriSano. If not, see http://www.gnu.org/licenses/agpl-3.0.txt.

module LayoutHelper
  extensible_helper

  def render_footer
    result = ""

    result << "<div class='footlogo'>"
    result << image_tag("foot.png", :border => 0)
    result << "</div>"
    result << "<div class='foottext'>"
    result << "<div class='top'>"
    result << "<a href='https://wiki.csinitiative.com/display/tri/TriSano+-+2.5+FINAL+Release+Notes'>#{t('trisano_ce')}</a>"
    result << "</div>"
    result << "<div class='bottom'>"
    result << "<a href='http://www.trisano.org/collaborate/'>#{t('collaborate')}</a>"
    result << "&nbsp;|&nbsp;"
    result << "#{t('user_feedback')} (<a href='http://groups.google.com/group/trisano-user'>#{t('web')}</a>, <a href='mailto:<EMAIL>'>#{t 'email'}</a>)"
    result << "&nbsp;|&nbsp;"
    result << "<a href='http://www.trisano.org'>#{t('about')}</a>"
    result << "&nbsp;|&nbsp;"
    result << "<a href='http://www.trisano.org/collaborate/licenses/'>#{t('license')}</a>"
    result << "&nbsp;|&nbsp;"
    result << "<a href='http://github.com/csinitiative/trisano/tree/master'>#{t('source')}</a>"
    result << "</div>"
    result << "<div class='bottom'>"
    result << t('copyright')
    result << "</div>"
    result << "</div>"

    result
  end

  # some javascript just needs to be in the hosted page
  def embedded_javascripts
    <<-JS
      <script type="text/javascript">
        function loadScript(src) {
          var script = document.createElement('script');
          script.type = 'text/javascript';
          script.src  = src
          document.body.appendChild(script);
        }
      </script>
    JS
  end

  def translations_js
    case I18n.locale
    when :test
      javascript_include_tag("ext/trisano_locales_test/translations_test")
    else
      locale = I18n.locale.to_s
      javascript_include_tag("ext/trisano_#{locale}/translations_#{locale}")
    end
  end

  def render_main_logo
    returning "" do |result|
      result << '<div class="horiz">'
      result << link_to(
        image_tag(main_logo_path, :border => 0),
        home_path, :id => 'logo')
      result << '</div>'
    end
  end

  def main_logo_path
    "logo.png"
  end

  def render_main_menu
    links = main_menu_items.collect do |item|
      item[:options] ||= {}
      text = item[:t] ? t(*item[:t]) : item[:text]
      link_to(text, item[:link], item[:options])
    end
    links.join("&nbsp;|&nbsp;")
  end

  def main_menu_items
    return MenuArray.new unless user = User.current_user
    returning MenuArray.new do |items|
      if user.is_entitled_to? :create_event
        items << {:link => event_search_cmrs_path, :t => :new_cmr}
      end
      if user.is_entitled_to? :manage_staged_message, :write_staged_message
        items << {
          :link => staged_messages_path,
          :t => :staging_area,
          :options => {:rel => "http://trisano.org/relation/staged_messages"}}
      end
      if user.is_entitled_to? :view_event
        items << {:link => cmrs_path_with_defaults, :t => :events}
        items << {:link => search_cmrs_path, :t => :search}
      end
      if user.is_entitled_to? :manage_entities
        items << {:link => people_path, :t => :people}
        items << {:link => places_path, :t => :places}
      end
      if user.is_entitled_to? :access_avr
        items << {
          :link => config_option(:bi_server_url),
          :t => :avr,
          :options => {:popup => true}}
      end
      if user.is_admin?
        items << {:link => admin_path, :t => :admin}
      end
      items << {:link => settings_path, :t => :settings}
    end
  end

  def render_user_tools(user)
    if allow_user_switching?
      change_user_url = url_for(:controller => :events, :action => :change_user)
      returning "" do |result|
        result << form_tag(change_user_url, :id => 'switch_user', :style => 'display: inline')
        result << "<span id='user_name'>#{current_user_name}:</span>"
        result << select_tag("user_id", options_for_user_select(user), :onchange => 'this.form.submit()', :style => 'display: inline')
{'fraction_non_alphanumeric': 0.1590277062519312, 'fraction_numerical': 0.005767844268204758, 'mean_word_length': 3.0764063811922755, 'pattern_counts': {'":': 0, '<': 217, '<?xml version=': 0, '>': 127, 'https://': 2, 'lorem ipsum': 0, 'www.': 8, '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': '7571328', 'n_tokens_mistral': 3213, 'n_tokens_neox': 3132, 'n_words': 776}