Sha256: 2211654f4316353c0be4ec1c4b9017c75f26d8566adb45f661deb1f3b7734f6d

Contents?: true

Size: 1.76 KB

Versions: 20

Compression:

Stored size: 1.76 KB

Contents

require 'ostruct'

module SearchHelper

  def search_result_target_window
    umlaut_config.lookup!("search.result_link_target","")
  end

  # pass in an openurl context obj.
  # return an OpenStruct with :atitle and :title labels
  #
  # Uses i18n
  #
  # Much of this duplicates Referent.type_thing_name and container_type_of_thing, 
  # although we don't have a Referent here, that logic should be combined. TODO
  def referent_labels(context_obj = @current_context_object)
    ref_meta = context_obj.referent.metadata
    result = OpenStruct.new

    type_of_thing_key = ref_meta['genre']
    type_of_thing_key = context_obj.referent.format if type_of_thing_key.blank?
    type_of_thing_key = type_of_thing_key.downcase

    a_key = type_of_thing_key
    if a_key == "journal" && ref_meta['atitle'].present?
      a_key = "article"
    end
    result.atitle = I18n.t(a_key, :scope => "umlaut.citation.genre", :default => "")

    c_key = type_of_thing_key
    c_key = 'journal' if c_key == "article"
    c_key = 'book'    if c_key == "bookitem"
    result.title =  I18n.t(c_key, :scope => "umlaut.citation.genre", :default => "")

    return result    
  end
  
  # A-Z buttons in search page
  def group_list
    group_list ||= ('A'..'Z').to_a.push('0-9').push(t('umlaut.search.browse_other'))
  end

  # Date dropdowns in search page
  def search_date_select
    years + months + days
  end

  def years
    select_year(nil, {:prompt => true, :start_year => Date.today.year, :end_year => 1950}, {:name => "__year", :class=>"year form-control"})
  end

  def months
    select_month(nil, {:prompt => true, :use_short_month => true}, {:name => "__month", :class=>"month form-control"})
  end

  def days
    select_day(nil, {:prompt => true}, {:name => "__day", :class=>"day form-control"})
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
umlaut-4.1.7 app/helpers/search_helper.rb
umlaut-4.1.6 app/helpers/search_helper.rb
umlaut-4.1.5 app/helpers/search_helper.rb
umlaut-4.1.4 app/helpers/search_helper.rb
umlaut-4.1.3 app/helpers/search_helper.rb
umlaut-4.1.2 app/helpers/search_helper.rb
umlaut-4.1.1 app/helpers/search_helper.rb
umlaut-4.1.0 app/helpers/search_helper.rb
umlaut-4.1.0.pre3 app/helpers/search_helper.rb
umlaut-4.1.0.pre.2 app/helpers/search_helper.rb
umlaut-4.1.0.pre.alpha.1 app/helpers/search_helper.rb
umlaut-4.0.3 app/helpers/search_helper.rb
umlaut-4.0.2 app/helpers/search_helper.rb
umlaut-4.0.1 app/helpers/search_helper.rb
umlaut-4.0.0 app/helpers/search_helper.rb
umlaut-4.0.0.beta5 app/helpers/search_helper.rb
umlaut-4.0.0.beta4 app/helpers/search_helper.rb
umlaut-4.0.0.beta3 app/helpers/search_helper.rb
umlaut-4.0.0.beta2 app/helpers/search_helper.rb
umlaut-4.0.0.beta1 app/helpers/search_helper.rb