module Webgen::Tag::Langbar
Generates a list with all the languages of the page.
Public Class Methods
call(tag, body, context)
click to toggle source
Return a rendering of the list of all translations of the content node.
# File lib/webgen/tag/langbar.rb 11 def self.call(tag, body, context) 12 context.website.ext.item_tracker.add(context.dest_node, :nodes, 13 ['Webgen::Tag::Langbar', 'node_translations'], 14 context.content_node.alcn, :meta_info) 15 nodes = node_translations(context.website, context.content_node.alcn) 16 17 if context[:config]['tag.langbar.show_single_lang'] || nodes.length > 1 18 context[:nodes] = nodes. 19 reject {|n| (context.content_node.lang == n.lang && !context[:config]['tag.langbar.show_own_lang'])}. 20 sort {|a, b| a.lang <=> b.lang} 21 Webgen::Tag.render_tag_template(context, 'langbar') 22 else 23 '' 24 end 25 end
node_translations(website, node_alcn)
click to toggle source
Generate the list of node translations given the options.
This method is invoked by Webgen::ItemTracker::NodeList to retrieve the translations nodes when necessary.
# File lib/webgen/tag/langbar.rb 31 def self.node_translations(website, node_alcn) 32 website.tree.translations(website.tree[node_alcn]) 33 end