Module: AttributionsHelper

Defined in:
app/helpers/attributions_helper.rb

Instance Method Summary collapse

Instance Method Details

Returns:

  • (String, nil)


34
35
36
37
38
39
40
41
# File 'app/helpers/attributions_helper.rb', line 34

def attribution_copyright_label(attribution)
  a = attribution.copyright_year
  b = attribution.attribution_copyright_holders
  return nil unless a or b.any?
  s = '(c)'
  s << [a, Utilities::Strings.authorship_sentence(b.collect{|c| c.name})].join(' ')
  s
end


54
55
56
57
58
59
60
61
# File 'app/helpers/attributions_helper.rb', line 54

def attribution_copyright_tag(attribution)
  a = attribution.copyright_year
  b = attribution.attribution_copyright_holders
  return nil unless a or b.any?
  s = '&#169;'
  s << [a, Utilities::Strings.authorship_sentence(b.collect{|c| c.name})].join(' ')
  s.html_safe
end

#attribution_creators_tag(attribution) ⇒ Object



63
64
65
66
67
# File 'app/helpers/attributions_helper.rb', line 63

def attribution_creators_tag(attribution)
  a = attribution.attribution_creators
  return nil unless a.any?
  ('Created by ' + Utilities::Strings.authorship_sentence(a.collect{|b| b.name})).html_safe
end

#attribution_editors_tag(attribution) ⇒ Object



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

def attribution_editors_tag(attribution)
  a = attribution.attribution_editors
  return nil unless a.any?
  ('Edited by ' + Utilities::Strings.authorship_sentence(a.collect{|b| b.name})).html_safe
end

#attribution_list_tag(object) ⇒ String (html)?

Returns a ul/li of tags for the object.

Returns:

  • (String (html), nil)

    a ul/li of tags for the object



83
84
85
86
87
# File 'app/helpers/attributions_helper.rb', line 83

def attribution_list_tag(object)
  return nil unless object.has_attribution? && object.attribution
  (:h3, 'Attribution') +
    attribution_tag(object.attribution)
end

#attribution_nexml_label(attribution) ⇒ Object



43
44
45
46
47
48
49
50
51
52
# File 'app/helpers/attributions_helper.rb', line 43

def attribution_nexml_label(attribution)
  return nil if attribution.nil?
  a = [
    attribution_creators_tag(attribution),
    attribution_owners_tag(attribution),
    attribution.copyright_year
  ]

  a.compact.join(', ').html_safe
end

#attribution_owners_tag(attribution) ⇒ Object



75
76
77
78
79
# File 'app/helpers/attributions_helper.rb', line 75

def attribution_owners_tag(attribution)
  a = attribution.attribution_owners
  return nil unless a.any?
  ('Owned by ' + Utilities::Strings.authorship_sentence(a.collect{|b| b.name})).html_safe
end

#attribution_tag(attribution) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'app/helpers/attributions_helper.rb', line 3

def attribution_tag(attribution)
  return nil if attribution.nil?
  a = [
    attribution_copyright_tag(attribution),
    attribution_creators_tag(attribution),
    attribution_editors_tag(attribution),
    attribution_owners_tag(attribution),
    attribution.license,
  ]

  a.compact.join('. ').html_safe
end

#label_for_attribution(attribution) ⇒ String?

!! if _tag labels add HTML then they must be removed here

Returns:

  • (String, nil)

    no html in _label



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/helpers/attributions_helper.rb', line 19

def label_for_attribution(attribution)
  return nil if attribution.nil?

  a = [
    attribution_copyright_label(attribution),
    attribution_creators_tag(attribution),
    attribution_editors_tag(attribution),
    attribution_owners_tag(attribution),
    attribution.license,
  ]

  a.compact.join('. ').html_safe
end