Module: PagesCore::ApplicationHelper
Instance Method Summary
collapse
#page_path, #page_url
#dynamic_image_tag, #image_caption, #image_figure, #original_dynamic_image_tag, #picture, #picture_tag, #uncropped_dynamic_image_tag
#attachment_path, #download_attachment_path
Instance Method Details
#page_link(page, options = {}) ⇒ Object
21
22
23
24
25
26
27
28
29
|
# File 'app/helpers/pages_core/application_helper.rb', line 21
def page_link(page, options = {})
link_locale = options[:locale] || locale
page.localize(link_locale) do |p|
title = options[:title] || p.name.to_s
return title unless conditional_options?(options)
link_to(title, page_link_path(link_locale, p), class: options[:class])
end
end
|
#safe_url(url) ⇒ Object
11
12
13
14
15
16
17
18
19
|
# File 'app/helpers/pages_core/application_helper.rb', line 11
def safe_url(url)
str = url.to_s.strip
return str if str.start_with?("/", "#")
scheme = URI.parse(str).scheme&.downcase
%w[data http https mailto tel].include?(scheme) ? str : "#"
rescue URI::InvalidURIError
"#"
end
|
#unique_page(page_name) ⇒ Object
31
32
33
34
35
36
37
38
|
# File 'app/helpers/pages_core/application_helper.rb', line 31
def unique_page(page_name, &)
page = Page.where(unique_name: page_name).first
if page && block_given?
output = capture(page.localize(content_locale), &)
concat(output)
end
page&.localize(content_locale)
end
|