# File lib/nanoc/helpers/blogging.rb, line 150 def build_for_article(a, xml) # Get URL url = url_for(a) return if url.nil? xml.entry do # Add primary attributes xml.id atom_tag_for(a) xml.title a[:title], :type => 'html' # Add dates xml.published attribute_to_time(a[:created_at]).to_iso8601_time xml.updated attribute_to_time(a[:updated_at] || a[:created_at]).to_iso8601_time # Add specific author information if a[:author_name] || a[:author_uri] xml.author do xml.name a[:author_name] || author_name xml.uri a[:author_uri] || author_uri end end # Add link xml.link(:rel => 'alternate', :href => url) # Add content summary = excerpt_proc.call(a) xml.content content_proc.call(a), :type => 'html' xml.summary summary, :type => 'html' unless summary.nil? end end
# File lib/nanoc/helpers/blogging.rb, line 117 def build_for_feed(xml) xml.instruct! xml.feed(:xmlns => 'http://www.w3.org/2005/Atom') do root_url = @site.config[:base_url] + '/' # Add primary attributes xml.id root_url xml.title title # Add date xml.updated(attribute_to_time(last_article[:created_at]).to_iso8601_time) # Add links xml.link(:rel => 'alternate', :href => root_url) xml.link(:rel => 'self', :href => feed_url) # Add author information xml.author do xml.name author_name xml.uri author_uri end # Add icon and logo xml.icon icon if icon xml.logo logo if logo # Add articles sorted_relevant_articles.each do |a| self.build_for_article(a, xml) end end end
# File lib/nanoc/helpers/blogging.rb, line 86 def last_article sorted_relevant_articles.first end
# File lib/nanoc/helpers/blogging.rb, line 80 def sorted_relevant_articles relevant_articles.sort_by do |a| attribute_to_time(a[:created_at]) end.reverse.first(limit) end
# File lib/nanoc/helpers/blogging.rb, line 108 def validate_articles if relevant_articles.empty? raise Nanoc::Errors::GenericTrivial.new('Cannot build Atom feed: no articles') end if relevant_articles.any? { |a| a[:created_at].nil? } raise Nanoc::Errors::GenericTrivial.new('Cannot build Atom feed: one or more articles lack created_at') end end
# File lib/nanoc/helpers/blogging.rb, line 90 def validate_config if @site.config[:base_url].nil? raise Nanoc::Errors::GenericTrivial.new('Cannot build Atom feed: site configuration has no base_url') end end
# File lib/nanoc/helpers/blogging.rb, line 96 def validate_feed_item if title.nil? raise Nanoc::Errors::GenericTrivial.new('Cannot build Atom feed: no title in params, item or site config') end if author_name.nil? raise Nanoc::Errors::GenericTrivial.new('Cannot build Atom feed: no author_name in params, item or site config') end if author_uri.nil? raise Nanoc::Errors::GenericTrivial.new('Cannot build Atom feed: no author_uri in params, item or site config') end end
Generated with the Darkfish Rdoc Generator 2.