From c3b12457a0e6b758af0a3611043f74602f18c2c7 Mon Sep 17 00:00:00 2001 From: Nicholas Firth-McCoy Date: Wed, 18 Jan 2012 10:55:58 +1100 Subject: [PATCH 1/2] Update Posterous migrator to take an api_token instead of email and pass The Posterous API call for retrieving a user's API token (`/api/2/auth/token`) is no longer supported and returns 410 GONE. This patch updates the #process method to accept an API token instead of an email address and password. A user's API token can be retrieved from http://posterous.com/api. --- lib/jekyll/migrators/posterous.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/jekyll/migrators/posterous.rb b/lib/jekyll/migrators/posterous.rb index 6cfc2430..bd753527 100644 --- a/lib/jekyll/migrators/posterous.rb +++ b/lib/jekyll/migrators/posterous.rb @@ -27,12 +27,10 @@ module Jekyll end end - def self.process(email, pass, blog = 'primary') - @email, @pass = email, pass - @api_token = JSON.parse(self.fetch("/api/2/auth/token").body)['api_token'] + def self.process(api_token, blog = 'primary') FileUtils.mkdir_p "_posts" - posts = JSON.parse(self.fetch("/api/v2/users/me/sites/#{blog}/posts?api_token=#{@api_token}").body) + posts = JSON.parse(self.fetch("/api/v2/users/me/sites/#{blog}/posts?api_token=#{api_token}").body) page = 1 while posts.any? @@ -61,7 +59,7 @@ module Jekyll end page += 1 - posts = JSON.parse(self.fetch("/api/v2/users/me/sites/#{blog}/posts?api_token=#{@api_token}&page=#{page}").body) + posts = JSON.parse(self.fetch("/api/v2/users/me/sites/#{blog}/posts?api_token=#{api_token}&page=#{page}").body) end end end From 19fc8cb4882e8241025dfd59f75bbcc42643ffa6 Mon Sep 17 00:00:00 2001 From: Nicholas Firth-McCoy Date: Wed, 18 Jan 2012 11:08:02 +1100 Subject: [PATCH 2/2] Oops, still need email and pass. Update usage comment --- lib/jekyll/migrators/posterous.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/jekyll/migrators/posterous.rb b/lib/jekyll/migrators/posterous.rb index bd753527..0a2280f2 100644 --- a/lib/jekyll/migrators/posterous.rb +++ b/lib/jekyll/migrators/posterous.rb @@ -5,7 +5,7 @@ require 'net/http' require 'uri' require "json" -# ruby -r './lib/jekyll/migrators/posterous.rb' -e 'Jekyll::Posterous.process(email, pass, blog)' +# ruby -r './lib/jekyll/migrators/posterous.rb' -e 'Jekyll::Posterous.process(email, pass, api_key, blog)' module Jekyll module Posterous @@ -27,10 +27,11 @@ module Jekyll end end - def self.process(api_token, blog = 'primary') + def self.process(email, pass, api_token, blog = 'primary') + @email, @pass, @api_token = email, pass, api_token FileUtils.mkdir_p "_posts" - posts = JSON.parse(self.fetch("/api/v2/users/me/sites/#{blog}/posts?api_token=#{api_token}").body) + posts = JSON.parse(self.fetch("/api/v2/users/me/sites/#{blog}/posts?api_token=#{@api_token}").body) page = 1 while posts.any? @@ -59,7 +60,7 @@ module Jekyll end page += 1 - posts = JSON.parse(self.fetch("/api/v2/users/me/sites/#{blog}/posts?api_token=#{api_token}&page=#{page}").body) + posts = JSON.parse(self.fetch("/api/v2/users/me/sites/#{blog}/posts?api_token=#{@api_token}&page=#{page}").body) end end end