MMISoftware Blog
News and views of Mac OS X and iPhone Programming
 
 

I have now taken to blogging using Textmate – why? Well, it has got some great features and I am finding it faster to blog with Textmate than with Ecto. Blogging with Textmate is not for the timid – but if you code and like using a text editor it is the way to go. And, I am particularly enjoying using Markdown.

One thing I was finding frustrating was that Textmate would only return (fetch) the last 20 posts and there was no way to go back and find old posts for cleaning up and editing (which is what we needed to do over at thesnowsite blog). However…

I came across a great post over at plasticular inscriptor, which described how to get TextMate to retrieve blog posts by id.

Now this ‘hack’ is for hardcore users and if you don’t understand what is being said, don’t try the hack. If you want to experiment then go ahead – but backup everything, including TextMate and all TextMate support folders before you start (I usually make zip archives of everything before I start – then that way I can’t ‘accidently’ edit the backup!).

One thing I have done differently to the article is I have worked directly with the “blogging.rb” file in the “Blogging.tmbundle” of TextMate and not moved a copy to the TextMate “Application Support” folder as suggested at plasticular inscriptor. The file to be edited can be found at:

/TextMate.app/Contents/SharedSupport/Bundles/
                        Blogging.tmbundle/Support/lib/blogging.rb

My reasoning for this is that when I update TextMate I would rather break this hack than cause problems with Textmate ‘authorised’ functions if the “blogging.rb” file is repelaced.

The article over at plasticular inscriptor is great and I am not going to repeat all the instructions here, however, I am using TextMate version 1.5.4 there seem to have been some changes to how TextMate works and so I have had to modify the code.

Within the “blogging.rb” file use the following code and not the code outlined at plasticular inscriptor

# fetch_post_page

def fetch_post_page
    begin
        self.post = client.getPost(self.post_id, self.username, self.password)
        TextMate.exit_create_new_document(post_to_document)
        @mw_success = true
        rescue XMLRPC::FaultException => e
        TextMate.exit_show_tool_tip("Error retrieving post. Check your 
             configuration and try again.")
    end
end

# Command: Fetch_By_Id

def fetch_by_id
    if self.post_id
        fetch_post_page()
    else
        TextMate.exit_show_tool_tip("A Post ID is required to fetch the post by id.")
    end
end

(Note: ‘TextMate.exit_show_tool_tip(“Error retrieving post. Check your configuration and try again.”)’ should all be on one line, it has been wrapped above to make it fit!)

When creating the new command in the Blogging section of the Command Editor in TextMate use the following and not the code at at plasticular inscriptor.

#!/usr/bin/env ruby -rjcode -Ku
require "#{ENV['TM_BUNDLE_SUPPORT']}/lib/blogging.rb"
Blogging.new.fetch_by_id

The ‘Input’ for the Bundle command should be set to ‘Entire Document’ and the ‘Output’ to ‘Create New Document’.

That should be it. To get a blog post by id just open an new document in TextMate and type:

Post: 123

(where 123 is the id number for the blog post)

and the select ‘Fetch Post by Id’ from the Bundles Blogging menu…

You will then be asked from which blog (if you are running more than one blog from TextMate) and the post should appear in a new window.

Have fun!

Leave a Reply

Search


 

Subscribe

    Subscribe to MMI news

    Enter your email address:

    Delivered by FeedBurner

    AddThis Social Bookmark Button
 

Categories

 

Archives

 

Spam caught:

 
 

MMISoftware Blog is proudly powered by WordPress
Domain services and hosting by MMISoftware
Entries (RSS) and Comments (RSS).