Module: PeopleHelper

Defined in:
app/helpers/people_helper.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) author_annotation_tag(author)



59
60
61
62
# File 'app/helpers/people_helper.rb', line 59

def author_annotation_tag(author)
  return nil if author.nil?
  (:span, author.name, class: [:annotation__author])
end

- (Object) author_list_tag(object)



64
65
66
67
68
69
70
# File 'app/helpers/people_helper.rb', line 64

def author_list_tag(object)
  return nil unless object.authors.any?
  (:h3, 'Authors') +
    (:ul, class: 'annotations_author_list') do
    object.authors.collect{|a| (:li, author_annotation_tag(a)) }.join.html_safe
  end
end

- (Object) editor_list_tag(object)



72
73
74
75
76
77
78
# File 'app/helpers/people_helper.rb', line 72

def editor_list_tag(object)
  return nil unless object.editors.any?
  (:h3, 'Editors') +
    (:ul, class: 'annotations_editor_list') do
    object.editors.collect{|a| (:li, author_annotation_tag(a)) }.join.html_safe
  end
end

- (String?) people_names(people)

Returns A formatted list of people's last names TODO: deprecate for native call

Returns:

  • (String, nil)

    A formatted list of people's last names TODO: deprecate for native call



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

def people_names(people)
  Utilities::Strings.authorship_sentence( people.collect{ |a| a.full_last_name } ) 
end

- (Object) people_search_form



43
44
45
# File 'app/helpers/people_helper.rb', line 43

def people_search_form
  render('/people/quick_search_form')
end

- (Object) person_active_tag(person)



27
28
29
30
31
32
33
34
# File 'app/helpers/people_helper.rb', line 27

def person_active_tag(person)
  return ('active: ' + (:i, 'unknown')).html_safe if person.year_active_start.nil? && person.year_active_end.nil?

  ae = person.year_active_end
  ae = nil if !ae.nil? && ae == person.year_active_start

  'active ~ ' + [ person.year_active_start || '?', ae || '?'].join('-')
end

- (Object) person_autocomplete_tag(person)



12
13
14
15
# File 'app/helpers/people_helper.rb', line 12

def person_autocomplete_tag(person)
  return nil if person.nil?
  person_tag(person) + ' ' + person_timeframe_tag(person) + ' ' + person_used_tag(person)
end


47
48
49
50
# File 'app/helpers/people_helper.rb', line 47

def person_link(person)
  return nil if person.nil?
  link_to(person_tag(person), person.metamorphosize)
end

- (Object) person_lived_tag(person)



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

def person_lived_tag(person)
  'lived: ' + [person.year_born || '?', person.year_died || '?'].join('-') 
end

- (Object) person_tag(person)



3
4
5
6
7
8
9
10
# File 'app/helpers/people_helper.rb', line 3

def person_tag(person)
  return nil if person.nil?
  if person.new_record?
    person.bibtex_name 
  else
    person.cached ? person.cached : 'CACHED VALUE NOT BUILT, CONTACT AN ADMIN.'
  end
end

- (Object) person_timeframe_tag(person)



17
18
19
20
21
# File 'app/helpers/people_helper.rb', line 17

def person_timeframe_tag(person)
  (:span, class: :subtle) do 
    (person_lived_tag(person) + ' ' + person_active_tag(person)).html_safe
  end.html_safe
end

- (Object) person_used_tag(person)



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

def person_used_tag(person)
  t = person.roles.count
  (:span, class: [:subtle, :tiny_space,  (t > 0 ? :success : :warning ) ]) do
    t > 0 ? "#{person.roles.count} #{"use".pluralize(t)}" : 'unused'
  end
end