Module: Archangel::ApplicationHelper

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

Overview

Application helpers

Instance Method Summary collapse

Instance Method Details

#active_backend_menu_for(ctrlr) ⇒ Boolean

Check if active backend menu for a controller

Example

<%= active_backend_menu_for("users") %> #=> true
<%= active_backend_menu_for("pages") %> #=> false

Returns:

  • (Boolean)

    if current controller



64
65
66
# File 'app/helpers/archangel/application_helper.rb', line 64

def active_backend_menu_for(ctrlr)
  params.fetch(:controller) == "archangel/backend/#{ctrlr}"
end

#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('amazing/grace') %> #=> /amazing/grace
<%= frontend_resource_path(@page) %> #=> /amazing/grace

Returns:

  • (String)

    frontend resource permalink



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).sub("%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"

Returns:

  • (String)

    site locale



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"

Returns:

  • (String)

    language direction



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

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