Skip to content

Instantly share code, notes, and snippets.

Created November 24, 2010 07:34
  • 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
What would you like to do?
Fetch your posterous theme. my first rb script.
#!/usr/bin/env ruby
# script that goes and fetches your theme file.
require 'net/http'
require 'uri'
require 'rubygems'
require 'json'
# config.rb should contain all the global vars found in this script.
require 'config.rb'
# puts URI.escape($posterous_auth_email)
theme_url = "{$posterous_user_id}/sites/#{$posterous_site_id}/theme?api_token=#{$posterous_api_token}"
# puts theme_url
url = URI.parse(theme_url)
req = + '?'+ url.query)
req.basic_auth $posterous_auth_email, $posterous_auth_pw
res = Net::HTTP.start(, url.port) {|http|
result = res.body
parser = JSON.parse(result)
parser.each do |key, value|
puts 'writing...'
handle ='index.html', 'w') if key == 'raw_theme'
rescue Exception => e
puts 'error: '
puts e
end if key == 'raw_theme'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment