Skip to content

Hack to get all posts with Textmate/Blogging Fetch

David Nunez
David Nunez
1 min read

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.rb`

def 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”

David Nunez Twitter

Dir of Technology at the MIT Museum • Writing about emerging tech's impact on your life • Speculative insights on the intersection of humanity and technology 🤖

Comments


Related Posts

Members Public

FCC's Vote against Net Nuetrality is a disservice to museums

Yesterday, the FCC voted to repeal the 2015 Open Internet Order and dismantle the order’s strong net neutrality rules (New York Times summary of what happened). You have probably read about how this might impact broadband quality for things like streaming television or even basic websites via tiered access

FCC's Vote against Net Nuetrality is a disservice to museums
Members Public

Requiem for Rhinos - behind the scenes video

Members Public

Automatically Unshortening Links in Wordpress Posts

On this site, I have the Broken Links Checker Plugin chugging away in the background. He tirelessly checks and rechecks every link in every post to find URLs that no longer work; pages sometimes just disappear. In most cases, I’m able to use the Internet Archive Wayback Machine to

Automatically Unshortening Links in Wordpress Posts