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
-
#history_citation_notes(citation) ⇒ String?
Any Notes on the citation in question.
- #history_in(source) ⇒ Object
-
#history_pages(citation) ⇒ String?
Pages from the citation, with prefixed :.
- #history_topics(citation) ⇒ String?
-
#original_citation_css(object, citation) ⇒ String?
protected
A computed css class, when provided indicates that the citation is the original citation for the object provided.
-
#paper_history_pages(citation) ⇒ String?
Pages from the citation, with prefixed :.
- #paper_history_topics(citation) ⇒ String?
Instance Method Details
#history_citation_notes(citation) ⇒ String?
Returns any Notes on the citation in question.
47 48 49 50 |
# File 'app/helpers/lib/catalog_helper.rb', line 47 def history_citation_notes(citation) return nil if citation.nil? || !citation.notes.any? content_tag(:span, citation.notes.collect{|n| note_tag(n)}.join.html_safe, class: 'history__citation_notes') end |
#history_in(source) ⇒ Object
52 53 54 55 |
# File 'app/helpers/lib/catalog_helper.rb', line 52 def history_in(source) return nil if source.nil? return history_link(source) end |
#history_pages(citation) ⇒ String?
Returns pages from the citation, with prefixed :.
26 27 28 29 30 31 32 33 34 |
# File 'app/helpers/lib/catalog_helper.rb', line 26 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? if str.present? link_to(content_tag(: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?
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 content_tag(: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.
61 62 63 64 |
# File 'app/helpers/lib/catalog_helper.rb', line 61 def original_citation_css(object, citation) return nil if citation.nil? 'history__original_description' if citation.is_original? && object == citation.citation_object end |
#paper_history_pages(citation) ⇒ String?
Returns pages from the citation, with prefixed :.
38 39 40 41 42 43 |
# File 'app/helpers/lib/catalog_helper.rb', line 38 def paper_history_pages(citation) return nil if citation.nil? str = citation.source.year_suffix.to_s str += ": #{citation.pages}." if citation.pages str end |
#paper_history_topics(citation) ⇒ String?
15 16 17 18 19 20 21 22 |
# File 'app/helpers/lib/catalog_helper.rb', line 15 def paper_history_topics(citation) return nil if citation.nil? if s = citation.citation_topics.collect{|t| label_for_controlled_vocabulary_term(t.topic)}.join('; ').html_safe ' ' + s # TODO: if paper_line_tag is refactored more consistently, remove space else nil end end |