Module: Archangel::ApplicationHelper

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

Overview

Application helpers

Instance Method Summary collapse

Instance Method Details

#frontend_resource_path(resource) ⇒ String

Frontend resource permalink.

Same as `frontend_page_path` except it prints out nested resources in a nice way.

Example

<%= frontend_resource_path('foo/bar') %> #=> /foo/bar
<%= frontend_resource_path(@page) %> #=> /foo/bar

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

def frontend_resource_path(resource)
  permalink_path = proc do |permalink|
    archangel.frontend_page_path(permalink).gsub("%2F", "/")
  end

  return permalink_path.call(resource) unless resource.class == Page
  return archangel.frontend_root_path if resource.homepage?

  permalink_path.call(resource.permalink)
end

#localeString

Site locale. Default `en`

Example

<%= locale %> #=> "en"

39
40
41
# File 'app/helpers/archangel/application_helper.rb', line 39

def locale
  current_site.locale || Archangel::LANGUAGE_DEFAULT
end

#text_directionString

Language direction (“ltr” or “rtl”). Default `ltr`

Example

<%= text_direction %> #=> "ltr"

51
52
53
# File 'app/helpers/archangel/application_helper.rb', line 51

def text_direction
  Archangel.t("language.#{locale}.direction", default: "ltr")
end