<commit_before>module MesenForms
  module Helpers
    module FormHelper
      def mesen_form_for (object, options = {}, &block)
        options[:builder] = FormBuilder
        options[:url]     = { :action => object.id.nil? ? "create" : "update"}
        options[:html]    = {:class => 'form-horizontal'}
        form_for(object, options, &block)
      end

      def menu_link_to(title,url)
        content_tag(:li, content_tag(:a, I18n.t(title, :scope => [:layouts, :admin]), :href => url), :class => ('active' if (request.original_fullpath.split('/')[2] == url.split('/')[2])))
      end
  
      def submenu_link_to(title, url)
        content_tag(:li, content_tag(:a, I18n.t(title, :scope => [:admin, controller_name]), :href => url), :class => ('active' if current_page?(url)))
      end
  
      def update_info(object)
        who_when object.updated_by, object.updated_at
      end
  
      def create_info(object)
        who_when object.created_by, object.created_at
      end
  
      def who_when(user_id,at)
        str = relative_or_absolute_date(at)
        if user_id
          user_obj = User.find(user_id)
          user = user_obj.fullname
          if !user.blank?
            str = I18n.t(:created_at_by, :scope => [:layouts, :admin], :time => str, :username => user)
          end
        end
        str
      end
  
      def meta_info(object, options = {})
        # defaults
        options.reverse_merge!({:show_delete => true,
                                :title_column => 'title',
                                :admin_path => url_for([:admin, object]),
                                :object_path => object.slug == 'forsiden' ? '/' : url_for(object),
                                :objects_string => I18n.t(object.class.name.underscore.pluralize, :scope => [:activerecord,:models]),
                                :edit_path => url_for([:admin, object.class])})
  
        content_tag(:table, :class => 'table table-condensed meta-info') do
          content_tag(:tr) do
            content_tag(:td, I18n.t(:last_updated, :scope => [:layouts, :admin])) +
            content_tag(:td, update_info(object))
          end+
          content_tag(:tr) do
            content_tag(:td, I18n.t(:created, :scope => [:layouts, :admin])) +
            content_tag(:td, create_info(object))
          end+
          if object.respond_to?(options[:object_path])
            content_tag(:tr) do
              content_tag(:td, I18n.t(:address, :scope => [:layouts, :admin]))+
              content_tag(:td, link_to(options[:object_path], options[:object_path], :target => '_blank'))
            end
          end+
          if options[:show_delete]
            content_tag(:tr) do
              content_tag(:td, I18n.t(:delete, :scope => [:layouts, :admin]))+
              content_tag(:td, link_to(I18n.t(:delete, :scope => [:layouts, :admin]), options[:admin_path], :confirm => I18n.t(:delete_confirmation, :scope => [:layouts, :admin], :title => object.instance_eval(options[:title_column])), :method => :delete, :class => "btn btn-danger btn-mini"))
            end
          end
        end+
        link_to(I18n.t(:show_all, :scope => [:layouts, :admin]) + ' ' + options[:objects_string], options[:edit_path], :class => "btn")
      end
  
      def publish_status(object)
        if ((defined? object.is_published) == nil) || object.is_published
          if ((defined? object.is_published) != nil and object.is_published and (defined? object.published_at) != nil and object.published_at.nil? == false and object.published_at > Time.now)
            status = t :on_hold, :scope => [:layouts, :admin]
            status_class = 'info'
          else<commit_msg>moving the conditional around<commit_after>module MesenForms
  module Helpers
    module FormHelper
      def mesen_form_for (object, options = {}, &block)
        options[:builder] = FormBuilder
        options[:url]     = { :action => object.id.nil? ? "create" : "update"}
        options[:html]    = {:class => 'form-horizontal'}
        form_for(object, options, &block)
      end

      def menu_link_to(title,url)
        content_tag(:li, content_tag(:a, I18n.t(title, :scope => [:layouts, :admin]), :href => url), :class => ('active' if (request.original_fullpath.split('/')[2] == url.split('/')[2])))
      end
  
      def submenu_link_to(title, url)
        content_tag(:li, content_tag(:a, I18n.t(title, :scope => [:admin, controller_name]), :href => url), :class => ('active' if current_page?(url)))
      end
  
      def update_info(object)
        who_when object.updated_by, object.updated_at
      end
  
      def create_info(object)
        who_when object.created_by, object.created_at
      end
  
      def who_when(user_id,at)
        str = relative_or_absolute_date(at)
        if user_id
          user_obj = User.find(user_id)
          user = user_obj.fullname
          if !user.blank?
            str = I18n.t(:created_at_by, :scope => [:layouts, :admin], :time => str, :username => user)
          end
        end
        str
      end
  
      def meta_info(object, options = {})
        # defaults
        options.reverse_merge!({:show_delete => true,
                                :title_column => 'title',
                                :admin_path => url_for([:admin, object]),
                                :object_path => object.slug == 'forsiden' ? '/' : (object.respond_to?(url_for(object)) ? url_for(object) : false),
                                :objects_string => I18n.t(object.class.name.underscore.pluralize, :scope => [:activerecord,:models]),
                                :edit_path => url_for([:admin, object.class])})
  
        content_tag(:table, :class => 'table table-condensed meta-info') do
          content_tag(:tr) do
            content_tag(:td, I18n.t(:last_updated, :scope => [:layouts, :admin])) +
            content_tag(:td, update_info(object))
          end+
          content_tag(:tr) do
            content_tag(:td, I18n.t(:created, :scope => [:layouts, :admin])) +
            content_tag(:td, create_info(object))
          end+
          if options[:object_path]
            content_tag(:tr) do
              content_tag(:td, I18n.t(:address, :scope => [:layouts, :admin]))+
              content_tag(:td, link_to(options[:object_path], options[:object_path], :target => '_blank'))
            end
          end+
          if options[:show_delete]
            content_tag(:tr) do
              content_tag(:td, I18n.t(:delete, :scope => [:layouts, :admin]))+
              content_tag(:td, link_to(I18n.t(:delete, :scope => [:layouts, :admin]), options[:admin_path], :confirm => I18n.t(:delete_confirmation, :scope => [:layouts, :admin], :title => object.instance_eval(options[:title_column])), :method => :delete, :class => "btn btn-danger btn-mini"))
            end
          end
        end+
        link_to(I18n.t(:show_all, :scope => [:layouts, :admin]) + ' ' + options[:objects_string], options[:edit_path], :class => "btn")
      end
  
      def publish_status(object)
        if ((defined? object.is_published) == nil) || object.is_published
          if ((defined? object.is_published) != nil and object.is_published and (defined? object.published_at) != nil and object.published_at.nil? == false and object.published_at > Time.now)
            status = t :on_hold, :scope => [:layouts, :admin]
            status_class = 'info'
          else
{'fraction_non_alphanumeric': 0.1500134661998384, 'fraction_numerical': 0.006463775922434689, 'mean_word_length': 2.357594936708861, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 71, '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': '396029', 'n_tokens_mistral': 2329, 'n_tokens_neox': 2286, 'n_words': 464}