UPDATE (2007.03.20.084041): Don’t do this. It’s an awful hack and will grind your computer to a halt.
I want to hack the textmate blogging bundle to do a full download of all posts in a blog and save those posts to local disk.
First, I just hacked the bundle to allow user to fetch any post from the blog.
Note: This is a slow hack and should only sparingly be used.
Knud M√∂ller talks about using XMLRPC to get all posts from a blog. I opted to use the “number of post requests is ridiculously large” approach. Mephisto implements the GetRecentPost call with a limit indicating number of posts to retrieve, so it’s still only one database hit (but creates a whole lot more objects in memory).
/Applications/TextMate.app/Contents/SharedSupport/Bundles/Blogging.tmbundle/Support/lib/blogging.rbdef fetch begin # Makes sure endpoint is determined and elements are parsed current_password = self.password require "#{ENV['TM_SUPPORT_PATH']}/lib/progress.rb" result = nil TextMate.call_with_progress(:title => "Fetch Post", :message => "Contacting Server “#{@host}”…") do result = self.client.getRecentPosts(self.blog_id, self.username, current_password, 100000) # HERE IS WHERE YOU SPECIFY NUMBER OF POSTS TO RETRIEVE end if !result || !result.length TextMate.exit_show_tool_tip("No posts are available!") end @mw_success = true if self.post = select_post(result) TextMate.exit_create_new_document(post_to_document()) else TextMate.exit_discard end rescue XMLRPC::FaultException => e TextMate.exit_show_tool_tip("Error retrieving posts. Check your configuration and try again.") end end
This works fine. Next up:
- Create a separate command for Fetch latest 20 and Fetch All
- Create command to “create index listing”
- Create command to “Fetch All Posts and then save each post to separate file in specified directory”