Class Webgen::Common::Sitemap
In: lib/webgen/common/sitemap.rb
Parent: Object
Error RenderError CommandNotFoundError LoadError NodeCreationError ::Rake::TaskLib WebgenTask Node Context\n[lib/webgen/context.rb\nlib/webgen/context/nodes.rb\nlib/webgen/context/render.rb\nlib/webgen/context/tags.rb] Tree FileSystem Sitemap Feed Copy Virtual Sitemap Directory Page Fragment Template Memory Metainfo Coderay Sitemap IncludeFile BreadcrumbTrail Langbar TikZ Menu Tags Fragments Resource Website Tidy Head Less Kramdown Xmllint Blocks Helpers Configuration Comparable Language Path StandardError CmdParse::CommandParser CommandParser CmdParse::Command RunCommand CreateCommand WebguiCommand ApplyCommand WebsiteAccess Main Loggable OutputPathHelpers ExecuteCommand Link Date Relocatable Metainfo ::Kramdown::Converter::Html KramdownHtmlConverter Cache Blackboard WebsiteManager Logger Page ProxyNode Utils Scss RDoc Sass Erb RDiscount Erubis Haml Maruku Builder RedCloth AccessHash TarArchive Stacked FileSystem lib/webgen/cache.rb lib/webgen/error.rb lib/webgen/languages.rb lib/webgen/website.rb lib/webgen/blackboard.rb lib/webgen/tree.rb lib/webgen/websitemanager.rb lib/webgen/logger.rb lib/webgen/context/tags.rb lib/webgen/configuration.rb lib/webgen/path.rb lib/webgen/webgentask.rb lib/webgen/page.rb lib/webgen/node.rb lib/webgen/cli/run_command.rb lib/webgen/cli/utils.rb lib/webgen/cli/apply_command.rb lib/webgen/cli/webgui_command.rb lib/webgen/cli.rb lib/webgen/cli/create_command.rb Color CLI ClassMethods WebsiteAccess LanguageManager lib/webgen/output/filesystem.rb Output lib/webgen/common/sitemap.rb Common lib/webgen/sourcehandler/metainfo.rb lib/webgen/sourcehandler/memory.rb lib/webgen/sourcehandler/copy.rb lib/webgen/sourcehandler/directory.rb lib/webgen/sourcehandler.rb lib/webgen/sourcehandler/page.rb lib/webgen/sourcehandler/template.rb lib/webgen/sourcehandler/fragment.rb lib/webgen/sourcehandler/sitemap.rb lib/webgen/sourcehandler/virtual.rb lib/webgen/sourcehandler/feed.rb OutputPathHelpers Base SourceHandler lib/webgen/tag/coderay.rb lib/webgen/tag/relocatable.rb lib/webgen/tag/menu.rb lib/webgen/tag/langbar.rb lib/webgen/tag/executecommand.rb lib/webgen/tag/breadcrumbtrail.rb lib/webgen/tag/metainfo.rb lib/webgen/tag/link.rb lib/webgen/tag/includefile.rb lib/webgen/tag/date.rb lib/webgen/tag/tikz.rb lib/webgen/tag/sitemap.rb Base Tag lib/webgen/contentprocessor/less.rb lib/webgen/contentprocessor/scss.rb lib/webgen/contentprocessor/blocks.rb lib/webgen/contentprocessor/rdoc.rb lib/webgen/contentprocessor/sass.rb lib/webgen/contentprocessor/erb.rb lib/webgen/contentprocessor/rdiscount.rb lib/webgen/contentprocessor/tags.rb lib/webgen/contentprocessor/erubis.rb lib/webgen/contentprocessor/kramdown/html.rb lib/webgen/contentprocessor/haml.rb lib/webgen/contentprocessor/maruku.rb lib/webgen/contentprocessor/xmllint.rb lib/webgen/contentprocessor/kramdown.rb lib/webgen/contentprocessor/head.rb lib/webgen/contentprocessor/builder.rb lib/webgen/contentprocessor/tidy.rb lib/webgen/contentprocessor/redcloth.rb lib/webgen/contentprocessor/fragments.rb lib/webgen/contentprocessor.rb ContentProcessor lib/webgen/source/tararchive.rb lib/webgen/source/stacked.rb lib/webgen/source/resource.rb lib/webgen/source/filesystem.rb Source Loggable Webgen dot/m_81_0.png

This class provides functionality for creating sitemaps and checking if a sitemap has changed.

Methods

Included Modules

Webgen::WebsiteAccess

Public Instance methods

Return the sitemap tree as Webgen::Tag::Menu::MenuNode created for the node in the language lang using the provided options which can be any configuration option starting with common.sitemap.

[Source]

    # File lib/webgen/common/sitemap.rb, line 20
20:     def create_sitemap(node, lang, options)
21:       @options = options
22:       tree = recursive_create(nil, node.tree.root, lang).sort!
23:       @options = nil
24:       (node.node_info[:common_sitemap] ||= {})[[options.to_a.sort, lang]] = tree.to_lcn_list
25:       tree
26:     end

Private Instance methods

Return true if the child of the node is in the sitemap for the language lang.

[Source]

    # File lib/webgen/common/sitemap.rb, line 47
47:     def in_sitemap?(child, lang, allow_index_file = false)
48:       ((option('common.sitemap.used_kinds').empty? || option('common.sitemap.used_kinds').include?(child['kind']) ||
49:         (child.routing_node(lang, false) != child && in_sitemap?(child.routing_node(lang), lang, true))) &&
50:        (option('common.sitemap.any_lang') || child.lang.nil? || child.lang == lang) &&
51:        (!option('common.sitemap.honor_in_menu') || child['in_menu']) &&
52:        (allow_index_file || child.parent == child.tree.root || child.parent.routing_node(lang) != child))
53:     end

Check if the sitemaps for node have changed.

[Source]

    # File lib/webgen/common/sitemap.rb, line 63
63:     def node_changed?(node)
64:       return if !node.node_info[:common_sitemap]
65: 
66:       node.node_info[:common_sitemap].each do |(options, lang), cached_tree|
67:         @options = options.to_hash
68:         tree = recursive_create(nil, node.tree.root, lang).sort!.to_lcn_list
69:         @options = nil
70: 
71:         if (tree != cached_tree) ||
72:             (tree.flatten.any? do |alcn|
73:                (n = node.tree[alcn]) && (r = n.routing_node(lang)) && r.meta_info_changed?
74:              end)
75:           node.flag(:dirty)
76:           break
77:         end
78:       end
79:     end

Retrieve the configuration option value for name. The value is taken from the current configuration options hash if name is specified there or from the website configuration otherwise.

[Source]

    # File lib/webgen/common/sitemap.rb, line 58
58:     def option(name)
59:       (@options && @options.has_key?(name) ? @options[name] : website.config[name])
60:     end

Recursively create the sitemap.

[Source]

    # File lib/webgen/common/sitemap.rb, line 33
33:     def recursive_create(parent, node, lang, in_sitemap = true)
34:       mnode = Webgen::Tag::Menu::MenuNode.new(parent, node)
35:       node.children.map do |n|
36:         sub_in_sitemap = in_sitemap?(n, lang)
37:         [(!n.children.empty? || sub_in_sitemap ? n : nil), sub_in_sitemap]
38:       end.each do |n, sub_in_sitemap|
39:         next if n.nil?
40:         sub_node = recursive_create(mnode, n, lang, sub_in_sitemap)
41:         mnode.children << sub_node unless sub_node.nil?
42:       end
43:       (mnode.children.empty? && !in_sitemap ? nil : mnode)
44:     end

[Validate]