Skip to content

Instantly share code, notes, and snippets.

@photomattmills
Created February 23, 2011 22:29
Show Gist options
  • Save photomattmills/841337 to your computer and use it in GitHub Desktop.
Save photomattmills/841337 to your computer and use it in GitHub Desktop.
simple script to convert an RSS feed to jekyll files.
# from the standard library :
require 'rss/1.0'
require 'rss/2.0'
require 'open-uri'
require 'time'
# gem install to_slug if you don't have it already.
require 'to_slug'
source = "" # put your feed url here
content = "" # this is just initializing the string
open(source) do |s| content = s.read end
rss = RSS::Parser.parse(content, false)
rss.items.each do |item|
filename = "#{item.date.strftime("%Y-%m-%d")}-#{item.title.to_slug.sub(/-\Z/,"")}.html"
file = File.new(filename, "w+")
file.puts "---\nlayout: post\ntitle: #{item.title}\ndate: #{item.date.strftime("%Y-%m-%d")}\n---\n#{item.description}"
file.close
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment