Class: Webgen::Tag::Langbar
- Inherits:
-
Object
- Object
- Webgen::Tag::Langbar
- Includes:
- Base, WebsiteAccess
- Defined in:
- lib/webgen/tag/langbar.rb
Overview
Generates a list with all the languages of the page.
Instance Method Summary collapse
-
#call(tag, body, context) ⇒ Object
Return a list of all translations of the content page.
-
#initialize ⇒ Langbar
constructor
:nodoc:.
Methods included from WebsiteAccess
Methods included from Base
#create_tag_params, #param, #set_params
Methods included from Loggable
Constructor Details
#initialize ⇒ Langbar
:nodoc:
11 12 13 |
# File 'lib/webgen/tag/langbar.rb', line 11 def initialize #:nodoc: website.blackboard.add_listener(:node_changed?, method(:node_changed?)) end |
Instance Method Details
#call(tag, body, context) ⇒ Object
Return a list of all translations of the content page.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/webgen/tag/langbar.rb', line 16 def call(tag, body, context) lang_nodes = all_lang_nodes(context.content_node) (context.dest_node.node_info[:tag_langbar_data] ||= {})[context.content_node.absolute_cn] = lang_nodes.map {|n| n.absolute_lcn} result = lang_nodes. reject {|n| (context.content_node.lang == n.lang && !param('tag.langbar.show_own_lang'))}. sort {|a, b| a.lang <=> b.lang}. collect {|n| context.dest_node.link_to(n, :link_text => (param('tag.langbar.lang_names')[n.lang] || n.lang), :lang => n.lang)}. join(param('tag.langbar.separator')) [(param('tag.langbar.show_single_lang') || lang_nodes.length > 1 ? result : ""), param('tag.langbar.process_output')] end |