Module: Alchemy::UrlHelper

Included in:
ElementsHelper
Defined in:
app/helpers/alchemy/url_helper.rb

Instance Method Summary collapse

Instance Method Details

#download_alchemy_attachment_path(attachment) ⇒ Object

Returns the path for downloading an alchemy attachment



28
29
30
# File 'app/helpers/alchemy/url_helper.rb', line 28

def download_alchemy_attachment_path(attachment)
  alchemy.download_attachment_path(attachment, attachment.slug)
end

#download_alchemy_attachment_url(attachment) ⇒ Object

Returns the url for downloading an alchemy attachment



33
34
35
# File 'app/helpers/alchemy/url_helper.rb', line 33

def download_alchemy_attachment_url(attachment)
  alchemy.download_attachment_url(attachment, attachment.slug)
end

#show_alchemy_page_path(page, optional_params = {}) ⇒ Object

Returns the path for rendering an alchemy page



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

def show_alchemy_page_path(page, optional_params = {})
  alchemy.show_page_path(show_page_path_params(page, optional_params))
end

#show_alchemy_page_url(page, optional_params = {}) ⇒ Object

Returns the url for rendering an alchemy page



15
16
17
# File 'app/helpers/alchemy/url_helper.rb', line 15

def show_alchemy_page_url(page, optional_params = {})
  alchemy.show_page_url(show_page_path_params(page, optional_params))
end

#show_page_path_params(page, optional_params = {}) ⇒ Object

Returns the correct params-hash for passing to show_page_path

Raises:

  • (ArgumentError)


20
21
22
23
24
25
# File 'app/helpers/alchemy/url_helper.rb', line 20

def show_page_path_params(page, optional_params = {})
  raise ArgumentError, "Page is nil" if page.nil?

  url_params = {urlname: page.urlname}.update(optional_params)
  prefix_locale?(page.language_code) ? url_params.update(locale: page.language_code) : url_params
end