Moving My Blog to the Toto Ruby Blog
Dusty Candland |
|
blog, ruby, toto
I’ve decided to switch this blog off wordpress and go w/ something closer to the metal. Toto is a rack based blogging engine that uses markdown and basic test files. This is a good approach because you get complete control, but also an editing environment that’s close to normal coding. Heres some links that helped me get up and running.
require 'rubygems'
require 'fastercsv'
require 'xmlrpc/client'
USERID = '<userid>'
PASSWORD = '<password>'
# http://www.eggheadcafe.com/microsoft/Ruby/36270580/xmlrpc-rexml-incorrectly-handles-utf8-data.aspx
# http://tedwise.com/2010/05/25/blogging-with-toto/
module XMLRPCWorkAround
def do_rpc(request, async=false)
data = super
data.force_encoding("UTF-8")
data
end
end
def getPages(blog)
blog.call("wp.getPages", 0, USERID, PASSWORD, 1000)
end
def getPosts(blog)
blog.call("metaWeblog.getRecentPosts", 0, USERID, PASSWORD, 1000)
end
def slugify(title)
title.downcase.gsub(/[ \._]/, '-')
end
blog = XMLRPC::Client.new3(:host => "<your-wordpress-blog.com>", :path => "/xmlrpc.php")
blog.extend(XMLRPCWorkAround)
begin
puts "Logging into blog and getting the list of posts..."
posts = getPosts(blog)
puts " response received, found #{posts.size} posts"
`mkdir articles`
posts.each do |post|
permaLink = post['permaLink']
puts permaLink
dateAndName = permaLink.gsub(/http:\/\/your-wordpress-blog\.com\//, '').split('/')
postFilename = 'articles/' + dateAndName.join('-') + '.txt'
postDate = dateAndName[0] + '/' + dateAndName[1] + '/' + dateAndName[2]
escapedTitle = post['title'].gsub(/"/, '\\"')
File.open(postFilename, "w") do |postFile|
postFile.puts("title: \"#{escapedTitle}\"")
postFile.puts("author: dusty candland")
postFile.puts("date: #{postDate}")
postFile.puts("slug: #{dateAndName[3]}")
puts "#{post['title']} - #{postDate}"
postFile.puts("categories: #{post['categories']}")
postFile.puts("keywords: #{post['mt_keywords']}")
postFile.puts
postFile.puts post['description']
end
end
rescue XMLRPC::FaultException => e
puts "ERROR: Code: #{e.faultCode}"
puts "ERROR: Msg.: #{e.faultString}"
end
Webmentions
These are webmentions via the IndieWeb and webmention.io. Mention this post from your site: