Skip to content

Instantly share code, notes, and snippets.

Created September 17, 2012 07:19
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save douo/3736010 to your computer and use it in GitHub Desktop.
ruhoh's compiler plugin use to compile site's rss
require 'nokogiri'
class Ruhoh
module Compiler
# the origin rss compiler is provided by David Long
# Thanks David!
# this rss compiler is modified by Douo
# use page.render_content instead of page.render
# add some useful tag
# todo: add some configuration to site.yml
module Rss
# TODO: This renders the page content even though we already need to
# render the content to save to disk. This will be a problem when posts numbers expand. Merge this in later.
def, page)
feed = do |xml|
xml.rss(:version => '2.0',
'xmlns:dc' => "",
'xmlns:content' => ""
) { {
xml.lastBuildDate_"%a, %d %b %Y %H:%M:%S %z")
Ruhoh::DB.posts['chronological'].each do |post_id|
post = Ruhoh::DB.posts['dictionary'][post_id]
xml.item {
xml.title_ post['title'] "#{['config']['production_url']}#{post['url']}"
xml.pubDate_ Time.parse(post['date']).strftime("%a, %d %b %Y %H:%M:%S %z")
# xml.guid(:isPermalink => 'false'){
# xml.text "#{['config']['production_url']}/?id=#{post_id}"
# }
# append categories and tags
post['categories'].each do |c|
xml.category {
xml.cdata c
post['tags'].each do |t|
xml.category {
xml.cdata t
xml.description_ post['description']
xml['content'].encoded {
xml.cdata page.render_content
end, 'rss.xml'), 'w'){ |p| p.puts feed.to_xml }
end #Rss
end #Compiler
end #Ruhoh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment