Module: CitationsHelper

Defined in:
app/helpers/citations_helper.rb

Instance Method Summary (collapse)

Instance Method Details



69
70
71
72
73
# File 'app/helpers/citations_helper.rb', line 69

def add_citation_link(object: nil, attribute: nil)
  link_to('Add citation', new_citation_path(citation: {
      citation_object_type: object.class.base_class.name,
      citation_object_id: object.id})) if object.has_citations?
end

- (Object) citation_annotation_tag(citation)



33
34
35
# File 'app/helpers/citations_helper.rb', line 33

def citation_annotation_tag(citation)
  (:span, citation_source_body(citation), class: [:annotation__citation])
end

- (Object) citation_author_year(citation)



25
26
27
28
29
30
31
# File 'app/helpers/citations_helper.rb', line 25

def citation_author_year(citation)
  if citation.source && citation.source.type == 'Source::Bibtex' && citation.source.author_year.present?
    citation.source.author_year 
  else
    (:span, 'Author, year not yet provided for source.', class: :subtle) 
  end
end

- (Object) citation_author_year_tag(citation)

Used in browse/catalog, try to deprecate



48
49
50
51
52
53
54
55
56
57
58
# File 'app/helpers/citations_helper.rb', line 48

def citation_author_year_tag(citation)
  return nil if citation.nil?
  case citation.source.type
    when 'Source::Verbatim'
      citation.source.verbatim
    when 'Source::Bibtex'
      citation.source.author_year
    else
      'NOT PROVIDED/CACHE ERROR'
  end
end


60
61
62
63
# File 'app/helpers/citations_helper.rb', line 60

def citation_link(citation)
  return nil if citation.nil?
  link_to(citation_tag(citation).html_safe, citation.citation_object.metamorphosize)
end

- (Object) citation_list_tag(object)



37
38
39
40
41
42
43
44
45
# File 'app/helpers/citations_helper.rb', line 37

def citation_list_tag(object)
  return nil unless object.has_citations? && object.citations.any? 
  (:h3, 'Citations') +
    (:ul, class: 'annotations__citation_list') do
    object.citations.collect{|t| 
     (:li, citation_annotation_tag(t)) 
    }.join.html_safe
  end
end

- (Object) citation_source_body(citation)



9
10
11
12
# File 'app/helpers/citations_helper.rb', line 9

def citation_source_body(citation)
  pages = citation.pages unless citation.pages.blank?
  [[citation_author_year(citation), pages].compact.join(':'), citation_topics_tag(citation)].compact.join(' ').html_safe
end

- (Object) citation_tag(citation)



3
4
5
6
7
# File 'app/helpers/citations_helper.rb', line 3

def citation_tag(citation)
  return nil if citation.nil?
  citation_string = citation_author_year(citation)
  [citation.citation_object.class.name, ": ", object_tag(citation.citation_object.metamorphosize), " in ", citation_source_body(citation)].compact.join.html_safe
end

- (Object) citation_topics_tag(citation)



14
15
16
17
18
19
20
21
22
23
# File 'app/helpers/citations_helper.rb', line 14

def citation_topics_tag(citation)
  return nil unless citation.topics.any?
  [
    '[',
    citation.citation_topics.collect{|ct| 
    (:span, (controlled_vocabulary_term_tag(ct.topic.metamorphosize) + (!ct.pages.blank? ? ": #{ct.pages}" : '')), class: [:annotation__citation_topic])
  }.compact.join(', '),
    ']'
  ].join.html_safe
end

- (True) citations_recent_objects_partial

Returns indicates a custom partial should be used, see list_helper.rb

Returns:

  • (True)

    indicates a custom partial should be used, see list_helper.rb



81
82
83
# File 'app/helpers/citations_helper.rb', line 81

def citations_recent_objects_partial
  true 
end

- (Object) citations_search_form



65
66
67
# File 'app/helpers/citations_helper.rb', line 65

def citations_search_form
  render('/citations/quick_search_form')
end


75
76
77
# File 'app/helpers/citations_helper.rb', line 75

def edit_citation_link(citation)
  edit_object_link(citation)
end