Module: EnjuBiblio::ApplicationHelper

Defined in:
app/helpers/enju_biblio/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#agent_type_icon(agent_type) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'app/helpers/enju_biblio/application_helper.rb', line 26

def agent_type_icon(agent_type)
  case agent_type
  when 'person'
    image_tag('icons/user.png', size: '16x16', class: 'enju_icon', alt: 'Person')
  when 'corporate_body'
    image_tag('icons/group.png', size: '16x16', class: 'enju_icon', alt: 'CorporateBody')
  else
    image_tag('icons/help.png', size: '16x16', class: 'enju_icon', alt: t('page.unknown'))
  end
end

#agents_list(agents = [], options = {}) ⇒ Object



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

def agents_list(agents = [], options = {})
  return nil if agents.blank?
  agents_list = []
  if options[:nolink]
    agents_list = agents.map{|agent| agent.full_name}
  else
    agents_list = agents.map{|agent| link_to(agent.full_name, manifestations_path(query: "\"#{agent.full_name}\""), options)}
  end
  agents_list.join(" ").html_safe
end

#content_type_icon(content_type) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/helpers/enju_biblio/application_helper.rb', line 9

def content_type_icon(content_type)
  case content_type.name
  when 'text'
    image_tag('icons/page_white_text.png', size: '16x16', class: 'enju_icon', alt: content_type.display_name.localize)
  when 'still_image'
    image_tag('icons/picture.png', size: '16x16', class: 'enju_icon', alt: content_type.display_name.localize)
  when 'sounds'
    image_tag('icons/sound.png', size: '16x16', class: 'enju_icon', alt: content_type.display_name.localize)
  when 'two_dimensional_moving_image'
    image_tag('icons/film.png', size: '16x16', class: 'enju_icon', alt: content_type.display_name.localize)
  else
    image_tag('icons/help.png', size: '16x16', class: 'enju_icon', alt: t('page.unknown'))
  end
rescue NoMethodError
  image_tag('icons/help.png', size: '16x16', class: 'enju_icon', alt: t('page.unknown'))
end

#form_icon(carrier_type) ⇒ Object



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

def form_icon(carrier_type)
  image_tag(carrier_type_path(carrier_type, format: :download), size: '16x16', class: 'enju_icon', alt: carrier_type.display_name.localize)
rescue NoMethodError
  image_tag('icons/help.png', size: '16x16', class: 'enju_icon', alt: t('page.unknown'))
end


48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/helpers/enju_biblio/application_helper.rb', line 48

def identifier_link(identifier)
  case identifier.identifier_type.name
  when 'doi'
    link_to identifier.body, "https://doi.org/#{identifier.body}"
  when 'iss_itemno'
    link_to identifier.body, "https://iss.ndl.go.jp/books/#{identifier.body}"
  when 'lccn'
    link_to identifier.body, "https://lccn.loc.gov/#{identifier.body}"
  when 'ncid'
    link_to identifier.body, "https://ci.nii.ac.jp/ncid/#{identifier.body}"
  when 'isbn'
    Lisbn.new(identifier.body).isbn_with_dash
  else
    identifier.body
  end
end