Module: PublishMyData::ApplicationHelper

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

Instance Method Summary collapse

Instance Method Details

#annotate_as_uri(s) ⇒ Object



47
48
49
# File 'app/helpers/publish_my_data/application_helper.rb', line 47

def annotate_as_uri(s)
  raw("<span class='pmd_inline_uri'>#{s}</span>")
end

#appnameObject



20
21
22
# File 'app/helpers/publish_my_data/application_helper.rb', line 20

def appname
  PublishMyData.application_name
end

#human_readable_name(resource) ⇒ Object



39
40
41
42
43
44
45
# File 'app/helpers/publish_my_data/application_helper.rb', line 39

def human_readable_name(resource)
  name = resource.human_readable_name
  if resource.human_readable_name_is_uri?
    name = annotate_as_uri(name)
  end
  return name
end

#inside_layout(layout, &block) ⇒ Object



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

def inside_layout(layout, &block)
  layout = "layouts/#{layout}" unless layout =~ %r[\Alayouts/]
  content_for :publish_my_data_content, capture(&block)
  render template: layout
end

#page_description(description) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'app/helpers/publish_my_data/application_helper.rb', line 24

def page_description(description)
  content_for :page_description do
    # should be content_tag(:meta, '', name: 'description', content:description)
    # but content tag doesn't generate valid html accoring to the w3c validator :(
    # content_tag(:meta, '', name: 'description', content: "hello world") => <meta content="hello world" name="description"></meta>
    if (description)
      raw "<meta name='description' content='#{description}'>"
    end
  end
end

#pagination_required?(resources, pagination_params) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'app/helpers/publish_my_data/application_helper.rb', line 35

def pagination_required?(resources, pagination_params)
  (resources.total_count > pagination_params.per_page)
end

#set_page_title(title = nil) ⇒ Object



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

def set_page_title(title=nil)
  content_for :page_title do
    "| #{title}"
  end
end

#set_pmd_page_class(c) ⇒ Object



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

def set_pmd_page_class(c)
  @pmd_page_class = c;
end