Module: Lib::CatalogHelper

Defined in:
app/helpers/lib/catalog_helper.rb

Overview

Shared helpers for catalog rendering. Params should “generic, i.e. targeting annotations almost exclusively.”

Instance Method Summary collapse

Instance Method Details

#history_citation_notes(citation) ⇒ String?

Returns any Notes on the citation in question

Returns:

  • (String, nil)

    any Notes on the citation in question



28
29
30
31
# File 'app/helpers/lib/catalog_helper.rb', line 28

def history_citation_notes(citation)
  return nil if citation.nil? || !citation.notes.any?
  (:span, citation.notes.collect{|n| note_tag(n)}.join.html_safe, class: 'history__citation_notes') 
end

#history_in(source) ⇒ Object



33
34
35
36
# File 'app/helpers/lib/catalog_helper.rb', line 33

def history_in(source)
  return nil if source.nil?
  return (:span,  (:em, ' in ') + source_author_year_tag(source), class: [:history__in])
end

#history_pages(citation) ⇒ String?

Returns pages from the citation, with prefixed :

Returns:

  • (String, nil)

    pages from the citation, with prefixed :



16
17
18
19
20
21
22
23
24
# File 'app/helpers/lib/catalog_helper.rb', line 16

def history_pages(citation)
  return nil if citation.nil?
  str = citation.source.year_suffix.to_s
  str += ": #{citation.pages}." if citation.pages
#    content_tag(:span, str, class: 'history__pages') unless str.blank?
  unless str.blank?
    link_to((:span, str, title: citation.source.cached, class: 'history__pages'), send(:nomenclature_by_source_task_path, source_id: citation.source.id) )
  end
end

#history_topics(citation) ⇒ String?

Returns:

  • (String, nil)


5
6
7
8
9
10
11
12
# File 'app/helpers/lib/catalog_helper.rb', line 5

def history_topics(citation)
  return nil if citation.nil?
  if t = citation.citation_topics.collect{|t| controlled_vocabulary_term_tag(t.topic)}.join.html_safe
    (:span, t, class: 'history__citation_topics')
  else
    nil
  end
end

#original_citation_css(object, citation) ⇒ String? (protected)

Returns a computed css class, when provided indicates that the citation is the original citation for the object provided

Returns:

  • (String, nil)

    a computed css class, when provided indicates that the citation is the original citation for the object provided



42
43
44
45
# File 'app/helpers/lib/catalog_helper.rb', line 42

def original_citation_css(object, citation)
  return nil if citation.nil?
  'history__original_description' if citation.is_original? && object == citation.citation_object
end