Top Level Namespace
Defined Under Namespace
Modules: Aerogel
Instance Method Summary collapse
-
#admin_pages_link_as_icon_and_text(page_node, lang) ⇒ Object
Returns link and publication state as icon and text.
-
#admin_pages_link_as_text(page_node, lang) ⇒ Object
Returns link to a page for given
lang, with respect to publication state. -
#admin_pages_publication_state_as_icon(page_node, lang) ⇒ Object
Returns publication state as icon, unless it is :published, in which case nothing is rendered.
-
#admin_pages_title_as_icon_and_text(page_node, lang) ⇒ Object
Returns title and publication state as icon and text.
-
#admin_pages_title_as_text(page_node, lang) ⇒ Object
Returns page title for given
lang, with respect to publication state. -
#admin_pages_url_as_text(page_node, lang) ⇒ Object
Returns full path to current page in given
lang, links are generated as icon and text. -
#current_page(page = nil) ⇒ Object
Returns or sets current Page object being served.
-
#current_page_url(opts = {}) ⇒ Object
Returns current page url, if Page is served, plain ULR otherwise.
-
#page_root ⇒ Object
Returns root page in current lang.
Instance Method Details
#admin_pages_link_as_icon_and_text(page_node, lang) ⇒ Object
Returns link and publication state as icon and text.
57 58 59 |
# File 'app/helpers/decorators.rb', line 57 def admin_pages_link_as_icon_and_text( page_node, lang ) admin_pages_publication_state_as_icon( page_node, lang )+" "+admin_pages_link_as_text( page_node, lang ) end |
#admin_pages_link_as_text(page_node, lang) ⇒ Object
Returns link to a page for given lang, with respect to publication state.
44 45 46 47 48 49 50 51 52 53 |
# File 'app/helpers/decorators.rb', line 44 def admin_pages_link_as_text( page_node, lang ) page = page_node.page( lang ) return "<span class='nodata'>no content</span>" if page.blank? case page.publication_state.to_sym when :published then h( page.link ) when :hidden then "<span class='state-hidden'>#{h page.link}</span>" else "<span class='state-not-published'>#{h page.link}</span>" end end |
#admin_pages_publication_state_as_icon(page_node, lang) ⇒ Object
Returns publication state as icon, unless it is :published, in which case nothing is rendered.
4 5 6 7 8 9 10 11 12 13 |
# File 'app/helpers/decorators.rb', line 4 def admin_pages_publication_state_as_icon( page_node, lang ) page = page_node.page( lang ) state = page.try(:publication_state) || :not_published case state.to_sym when :published then '' # icon 'fa-check' when :hidden then icon 'fa-eye', title: 'hidden' else icon 'fa-times', title: 'not published' end end |
#admin_pages_title_as_icon_and_text(page_node, lang) ⇒ Object
Returns title and publication state as icon and text.
37 38 39 |
# File 'app/helpers/decorators.rb', line 37 def admin_pages_title_as_icon_and_text( page_node, lang ) admin_pages_publication_state_as_icon( page_node, lang )+" "+admin_pages_title_as_text( page_node, lang ) end |
#admin_pages_title_as_text(page_node, lang) ⇒ Object
Returns page title for given lang, with respect to publication state.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/helpers/decorators.rb', line 17 def admin_pages_title_as_text( page_node, lang ) page = page_node.page( lang ) if page.nil? publication_state = :not_published other_page = page_node.pages.first if other_page.nil? return "<span class='nodata'>no translation</span>" end return "<span class='nodata'>#{other_page.lang}: #{h other_page.title}</span>" end case page.publication_state.to_sym when :published then h page.title when :hidden then "<span class='state-hidden'>#{h page.title}</span>" else "<span class='state-not-published'>#{h page.title}</span>" end end |
#admin_pages_url_as_text(page_node, lang) ⇒ Object
Returns full path to current page in given lang, links are generated as icon and text
64 65 66 67 68 69 70 71 72 73 |
# File 'app/helpers/decorators.rb', line 64 def admin_pages_url_as_text( page_node, lang ) return '' if page_node.nil? page_node.ancestors_and_self.sort_by(&:depth).map do |pn| if pn.root? icon 'fa-home' else admin_pages_link_as_icon_and_text pn, lang end end.join(" / ") end |
#current_page(page = nil) ⇒ Object
Returns or sets current Page object being served.
9 10 11 12 |
# File 'app/helpers/pages.rb', line 9 def current_page( page = nil ) @current_page = page if page.present? @current_page end |
#current_page_url(opts = {}) ⇒ Object
Returns current page url, if Page is served, plain ULR otherwise.
If opts is specified, tries to find closest page in other lang.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/helpers/pages.rb', line 19 def current_page_url( opts = {} ) if current_page.present? if !opts.key?(:locale) || opts[:locale] == current_page.lang current_page.url else # find this page in other lang other_page = Aerogel::Pages::Traversal.find_closest_in_other_lang( current_page, opts[:locale] ) return nil unless other_page.present? url_to( other_page.url, opts ) end else current_url opts end end |
#page_root ⇒ Object
Returns root page in current lang
3 4 5 |
# File 'app/helpers/pages.rb', line 3 def page_root @current_page_root ||= Page.root( current_locale ) end |