Benjamin Golub's Blog

JSON output, Ping services

November 17 at 07:53 PM

Migrating from one blogging platform to another can be a pain. I don't want it to be difficult to move away from this one so I've added JSON output. Any page that displays entries can be represented in machine readable JSON by adding ?format=json to the end of the URL.

def render_json(self, entries):
    json_entries = [{
        "title": entry.title,
        "slug": entry.slug,
        "body": entry.body,
        "author": entry.author.nickname(),
        "published": entry.published.isoformat(),
        "updated": entry.updated.isoformat(),
        "tags": entry.tags,
        "link": "http://" + self.request.host + "/e/" + entry.slug,
    } for entry in entries]
    json = {"entries": json_entries}
    self.response.headers["Content-Type"] = "text/javascript"
    self.response.out.write(simplejson.dumps(json))

For example the archives page contains every entry on the blog. So this link is all you need to migrate.

It'll also now ping Google when you publish a new entry. Eventually I'll support more pinging services.

Share on FriendFeed
json code
View comments

Search

Loading

Recent entries

  • Remove trailing slash on App Engine - June 07 at 11:52 AM
  • DIY cheap (or free!) macro photo studio - May 25 at 01:31 PM
  • Requested: My Photography Workflow/Equipment - Aperture - April 26 at 01:34 PM
  • Paris slideshow - March 31 at 11:38 AM
  • Phish is back - My history and Hampton 2009 - March 07 at 10:23 AM

Links

  • Archive
  • Email Benjamin Golub
  • FriendFeed

Photos

Reese getting a hug
Rochester, NY US
©2009 Benjamin Golub - FriendFeed - Creative Commons License - Source - Icons