Module: CitationsHelper

Defined in:
app/helpers/citations_helper.rb

Instance Method Summary (collapse)

Instance Method Details



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

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_author_year_tag(citation)



41
42
43
44
45
46
47
48
49
50
51
# File 'app/helpers/citations_helper.rb', line 41

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


22
23
24
25
# File 'app/helpers/citations_helper.rb', line 22

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

- (Object) citation_tag(citation)



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/helpers/citations_helper.rb', line 4

def citation_tag(citation)
  return nil if citation.nil?
  citation_string = (
    (citation.source.type == 'Source::Bibtex' && citation.source.try(:author_year)) ? 
    citation.source.author_year : 
    (:span, 'author, year not yet provided for source', class: :subtle) 
  )
 
  str = [citation.citation_object.class.name, ": ", object_tag(citation.citation_object.metamorphosize).html_safe, " in ", citation_string].join
  str = str + ": #{citation.pages}." if !citation.pages.blank?
  if citation.citation_topics.any? 
    str = str + ' [' + citation.citation_topics.collect{|ct| ct.topic.name + (ct.pages? ? ": #{ct.pages}" : "")}.join(', ') + ']' 
  end
  str += '.' 
#    str += citation.is_original? ? ' ORIGINAL' : ' SUBSEQUENT'
  str.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



55
56
57
# File 'app/helpers/citations_helper.rb', line 55

def citations_recent_objects_partial
  true 
end

- (Object) citations_search_form



27
28
29
# File 'app/helpers/citations_helper.rb', line 27

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


37
38
39
# File 'app/helpers/citations_helper.rb', line 37

def edit_citation_link(citation)
  edit_object_link(citation)
end