Module: ApplicationHelper

Defined in:
app/helpers/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#bootstrap_navigation_element(name, path, options = {}) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/helpers/application_helper.rb', line 45

def bootstrap_navigation_element(name, path, options = {})
  a_tag_options = options.delete(:a_tag_options) || {}
  path_to_use = path
  if current_page? path
    options[:class] ||= ''
    options[:class] << ' active'
    a_tag_options[:tabindex] ||= :'-1'
    path_to_use = '#'
  end
  ('li', options) {
    link_to name, path_to_use, a_tag_options
  }.html_safe
end

#classify_for_display(curation_concern) ⇒ Object



41
42
43
# File 'app/helpers/application_helper.rb', line 41

def classify_for_display(curation_concern)
  curation_concern.human_readable_type.downcase
end

#construct_page_title(*elements) ⇒ Object



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

def construct_page_title(*elements)
  (elements.flatten.compact + [application_name]).join(" // ")
end

#curation_concern_attribute_to_html(curation_concern, method_name, label) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'app/helpers/application_helper.rb', line 30

def curation_concern_attribute_to_html(curation_concern, method_name, label)
  markup = ""
  subject = curation_concern.send(method_name)
  return markup unless subject.present?
  markup << %(<dt>#{label}</dt>\n)
  [subject].flatten.compact.each do |value|
    markup << %(<dd class="attribute #{method_name}">#{h(value)}</dd>\n)
  end
  markup.html_safe
end

#curation_concern_page_title(curation_concern) ⇒ Object



14
15
16
17
18
19
20
# File 'app/helpers/application_helper.rb', line 14

def curation_concern_page_title(curation_concern)
  if curation_concern.persisted?
    construct_page_title(curation_concern.title, "#{curation_concern.human_readable_type} [#{curation_concern.to_param}]")
  else
    construct_page_title("New #{curation_concern.human_readable_type}")
  end
end

#default_page_titleObject



22
23
24
25
26
27
28
# File 'app/helpers/application_helper.rb', line 22

def default_page_title
  text = controller_name.singularize.titleize
  if action_name
    text = "#{action_name.titleize} " + text
  end
  construct_page_title(text)
end


59
60
61
62
63
64
65
66
# File 'app/helpers/application_helper.rb', line 59

def link_to_edit_permissions(curation_concern, solr_document = nil)
  markup = <<-HTML
    <a href="#{edit_polymorphic_path([:curation_concern, curation_concern])}" id="permission_#{curation_concern.to_param}">
      #{permission_badge_for(curation_concern, solr_document)}
    </a>
  HTML
  markup.html_safe
end

#permission_badge_for(curation_concern, solr_document = nil) ⇒ Object



68
69
70
71
72
# File 'app/helpers/application_helper.rb', line 68

def permission_badge_for(curation_concern, solr_document = nil)
  solr_document ||= curation_concern.to_solr
  dom_label_class, link_title = extract_dom_label_class_and_link_title(solr_document)
  %(<span class="label #{dom_label_class}" title="#{link_title}">#{link_title}</span>).html_safe
end

#sufiaObject

This is included to hopefully catch most of the sufia method calls that are vestigal for the Sufia engine being included in the Gemfile but unmounted.



6
7
8
# File 'app/helpers/application_helper.rb', line 6

def sufia
  self
end