Class Webgen::SourceHandler::Feed
In: lib/webgen/sourcehandler/feed.rb
Parent: Object
Error RenderError CommandNotFoundError LoadError NodeCreationError ::Rake::TaskLib WebgenTask Context\n[lib/webgen/context.rb\nlib/webgen/context/nodes.rb\nlib/webgen/context/render.rb\nlib/webgen/context/tags.rb] Node Tree FileSystem Sitemap Coderay Sitemap IncludeFile Langbar BreadcrumbTrail TikZ Menu Feed Copy Virtual Sitemap Directory Page Fragment Template Metainfo Memory Resource Tags Fragments Website Tidy Head Kramdown Less Xmllint Blocks Helpers Configuration Comparable Language Path StandardError CmdParse::CommandParser CommandParser CmdParse::Command RunCommand WebguiCommand CreateCommand ApplyCommand ExecuteCommand Link Date Relocatable Metainfo WebsiteAccess Main Loggable OutputPathHelpers ::Kramdown::Converter::Html KramdownHtmlConverter Cache Blackboard WebsiteManager Logger Page ProxyNode Utils TarArchive Stacked FileSystem RDoc Sass Erb RDiscount Erubis Haml Maruku Builder RedCloth AccessHash lib/webgen/cache.rb lib/webgen/error.rb lib/webgen/languages.rb lib/webgen/blackboard.rb lib/webgen/website.rb lib/webgen/tree.rb lib/webgen/websitemanager.rb lib/webgen/logger.rb lib/webgen/configuration.rb lib/webgen/context/tags.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/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/includefile.rb lib/webgen/tag/link.rb lib/webgen/tag/date.rb lib/webgen/tag/tikz.rb lib/webgen/tag/sitemap.rb Base Tag lib/webgen/sourcehandler/memory.rb lib/webgen/sourcehandler/metainfo.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/source/tararchive.rb lib/webgen/source/stacked.rb lib/webgen/source/resource.rb lib/webgen/source/filesystem.rb Source lib/webgen/contentprocessor/less.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 Loggable Webgen dot/m_81_0.png

Source handler for creating atom and/or rss feeds.

Methods

Included Modules

Webgen::WebsiteAccess Base

Constants

MANDATORY_INFOS = %W[site_url author entries]   The mandatory keys that need to be set in a feed file.

Public Instance methods

Return the rendered feed represented by node.

[Source]

    # File lib/webgen/sourcehandler/feed.rb, line 44
44:     def content(node)
45:       website.cache[[:sourcehandler_feed, node.node_info[:src]]] = feed_entries(node).map {|n| n.alcn}
46: 
47:       block_name = node.node_info[:feed_type] + '_template'
48:       if node.node_info[:feed].blocks.has_key?(block_name)
49:         node.node_info[:feed].blocks[block_name].render(Webgen::Context.new(:chain => [node])).content
50:       else
51:         chain = [node.resolve("/templates/#{node.node_info[:feed_type]}_feed.template"), node]
52:         node.node_info[:used_nodes] << chain.first.alcn
53:         chain.first.node_info[:page].blocks['content'].render(Webgen::Context.new(:chain => chain)).content
54:       end
55:     end

Create atom and/or rss feed files from path.

[Source]

    # File lib/webgen/sourcehandler/feed.rb, line 19
19:     def create_node(path)
20:       page = page_from_path(path)
21:       path.meta_info['link'] ||= path.parent_path
22: 
23:       if MANDATORY_INFOS.any? {|t| path.meta_info[t].nil?}
24:         raise Webgen::NodeCreationError.new("At least one of #{MANDATORY_INFOS.join('/')} is missing",
25:                                             self.class.name, path)
26:       end
27: 
28:       create_feed_node = lambda do |type|
29:         path.ext = type
30:         super(path) do |node|
31:           node.node_info[:feed] = page
32:           node.node_info[:feed_type] = type
33:         end
34:       end
35: 
36:       nodes = []
37:       nodes << create_feed_node['atom'] if path.meta_info['atom']
38:       nodes << create_feed_node['rss'] if path.meta_info['rss']
39: 
40:       nodes
41:     end

Return the content of an entry of the feed node.

[Source]

    # File lib/webgen/sourcehandler/feed.rb, line 73
73:     def entry_content(node, entry)
74:       entry.node_info[:page].blocks[node['content_block_name'] || 'content'].render(Webgen::Context.new(:chain => [entry])).content
75:     end

Return the entries for the feed node.

[Source]

    # File lib/webgen/sourcehandler/feed.rb, line 58
58:     def feed_entries(node)
59:       nr_items = (node['number_of_entries'].to_i == 0 ? 10 : node['number_of_entries'].to_i)
60:       patterns = [node['entries']].flatten.map {|pat| Webgen::Path.make_absolute(node.parent.alcn, pat)}
61: 
62:       node.tree.node_access[:alcn].values.
63:         select {|node| patterns.any? {|pat| node =~ pat} && node.node_info[:page]}.
64:         sort {|a,b| a['modified_at'] <=> b['modified_at']}.reverse[0, nr_items]
65:     end

Return the feed link URL for the feed node.

[Source]

    # File lib/webgen/sourcehandler/feed.rb, line 68
68:     def feed_link(node)
69:       Webgen::Node.url(File.join(node['site_url'], node.tree[node['link']].path), false)
70:     end

Private Instance methods

Check if the any of the nodes used by this feed node have changed and then mark the node as dirty.

[Source]

    # File lib/webgen/sourcehandler/feed.rb, line 83
83:     def node_changed?(node)
84:       return if node.node_info[:processor] != self.class.name
85:       entries = node.feed_entries
86:       node.flag(:dirty) if entries.map {|n| n.alcn } != website.cache[[:sourcehandler_feed, node.node_info[:src]]] ||
87:         entries.any? {|n| n.changed?}
88:     end

[Validate]