Skip to content

Instantly share code, notes, and snippets.

@stengland
Last active December 16, 2015 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stengland/5396986 to your computer and use it in GitHub Desktop.
Save stengland/5396986 to your computer and use it in GitHub Desktop.
Use the tumblr_client Gem to export some posts to Tumblr. I'm using sequel but with a bit of tweking you could use this in a rails app.
require './sequel_config'
require './tumblr_config'
desc 'Export posts to Tumblr'
task :export_to_tumblr do
client = Tumblr::Client.new
Post.order(:published_at).each do |p|
begin
resp = client.text('some_tumblog',{
title: p.title,
body: p.body,
date: p.published_at,
format: 'markdown'
})
if resp['id']
puts "Exported post #{p.title}: #{resp['id']}"
else
puts "Failed export post #{p.title}: #{resp}"
end
rescue => e
puts "Error for post #{p.title}: #{e}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment