Generating JSON for your Roller blog

One question that came up recently on the Roller mailing lists was how to generate JSON for a Roller blog. Roller 3.0's new rendering system makes it easy to generate just about any representation of your blog, so JSON is no problem at all. In fact, any Roller user can do it via the Roller UI by simply creating a new page template.

For example, what if you wanted to generate a JSON array of blog entries with id, pubTime and title for each entry, like what's shown below: 

{id: "roller:open_source_ghetto_at_javaone",
pubTime:"2007-01-12 12:57:17.0",
title: "Open source ghetto at JavaOne?"},
{id: "roller:iphone_don_t_think_of",
pubTime:"2007-01-11 17:43:29.0",
title: "iPhone: don't think of it as a computer"},
{id: "roller:iphone_apple_apps_only",
pubTime:"2007-01-09 23:06:15.0",
title: "iPhone: Apple apps only?"}
... etc...

To do that, you can use the Roller Preferences->Template menu to create a page template like so:

  #set($pager = $model.getWeblogEntriesPager())
  #set($map = $pager.getEntries())
  #foreach($day in $map.keySet())
  #set($entries = $map.get($day))  
  #foreach($entry in $entries)
      {id:     "$$entry.anchor",
       title:  "$entry.title"},

The code above is a little tricky because of the way the entry pager returns entries. To make it easy to display entries by day, the $pager.getEntries() method returns entries in a ordered java.util.Hashmap. The map contains lists of entries, one for each day, and the map is keyed by date objects. To get entries out of the pager you must iterate through the day-date keys, get then entry list for each and then iterate through the entries of that day.

If you create the above template and save it with the name "jsontest" your new page will be available at /<bloghandle>/page/jsontest. And because the $pager object understands the standard Roller request parameters date, cat and page you can subset the data by date and category, and you can page through the results. For example:

   /<handle>/page/jsontest?cat=roller - latest entries in category 'roller'
   /<handle>/page/jsontest?cat=roller?page=1 - first page of entries in category 'roller'
   /<handle>/page/jsontest?date=200601  - Entries from January 2006

Try it on my blog: 

In a future post I'll show how to use Roller-generated JSON data in a sophisticated JavaScript widget. I'm working on an example that uses Dojo and specifically the FilteredTable widget to present a pageable table of Roller blog entries.


For more information on Roller page template programming see the docs for the Apache Velocity template language and see the Roller 3.0 Template Author Guide for details on the Roller objects and macros available within Roller templates.

Open source ghetto at JavaOne?

Geir's got a great idea for JavaOne. Hope it's not too late for 2007.

iPhone: don't think of it as a computer

Via Rafe Colburn I just found a NY Times article that confirms Apple will tightly restrict what apps are allowed on the iPhone: 

Steve Jobs: "I don’t want people to think of this as a computer [...] These are devices that need to work, and you can’t do that if you load any software on them [...] That doesn’t mean there’s not going to be software to buy that you can load on them coming from us. It doesn’t mean we have to write it all, but it means it has to be more of a controlled environment."

Controlled environment? You mean like a Java VM? Probably not. I suspect what Mr. Jobs means is that 3rd party software vendors will have to pay Apple for the right to  develop software for the iPhone, but details of that plan have not yet been worked out.

iPhone: Apple apps only?

Sun alum Adrian Cockcroft lists some important but unanswered questions about the new Apple iPhone, Apple's sleek new phone-ipod-camera combo due out in June (for about $600 + Cingular Service plan). Adrian wonders "Is it open for more applications to be loaded? [...] or is it locked down?" and "what is the model for developers to extend the platform?" Rick Ross wonders why nothing was said about Java support and OSNews noticed the very same thing.

Josh optimistically points out the upside of "a real OS, real apis, and a real web browser capable of running real web applications - all delivered by a company that isn't going to fight us every step of the way." Yep, that would rock.

So what's the deal? Does Jupiter Research's Michael Gartenberg, who says the iPhone is "not extensible by third parties, only Apple," have the inside scoop?

Akismet works

Since I deployed Roller 3.2-dev Saturday no spam has slipped pass Roller's new Akismet plugin, so I've opened up all my past entries for comments again. Spammers, bring it on!


I spent a fair amount of holiday time trying to figure out how to share and backup the important files on our various home computers. The solution I settled on was geeky bordering on goofy:

  • A Linksys NSLU2 "Slug" running Unslung Linux, Apache HTTPD and Subversion
  • One 200GB USB drive hooked up to Slug (formatted with Linux ext)
  • Two 200GB USB drives one for each of our Mac laptops

For documents I use Subversion. On each computer, each user's files are kept in a directory that is under Subversion source code control. Since nobody else in the family knows about Subversion (yet), I have to visit each computer periodically and commit any new files or changes. I had hoped that approach would work for all of my files, but Subversion on the Slug is way too sluggish when it comes to big files.

So, for photos and other big binary files I use the Slug as a simple file-server. I make sure my photos and videos are organized into directories that are roughly DVD-size directories (i.e. about 8GB)  and I periodically copy them to the Slug and make DVDs for off-site storage.

And finally, for full backups I use disk "cloning" software. Every month or so I use Carbon Copy Cloner to make a full-disk backup our two Mac laptops to a USB drive.

Sounds like a total pain in the ass doesn't it? But a growing number of folks have multiple computers and piles of photos and videos to backup, so my problems are far from unique. That's why I think Windows Home Server is going to be a hit.

Windows Home Server concept design (as seen on CrunchGear)

It's a server appliance with no monitor or keyboard. You just plug it into your home network, put it in a corner and it solve all of your PC backup problems. It quietly makes full-disk image backups of each of your Windows PCs and it gives you a place to share files with other folks at home and over the net. It's of no use to me since most of my home computers run some form of UNIX, but 95% of the world is hooked on Windows -- they're gonna want this thing. Check out Paul Thurrott's Windows Home Server Preview for more details.

Akismet support for Roller

This week I've been working on a new feature for Roller called Comment Validators, which makes it possible for Roller site admins to plugin validation rules to be run against comments. If a comment fails validation it is marked as spam, put into the blog's moderation queue and the blog's owner is notified with a list of the reasons that validation failed.

I commited the work to SVN yesterday, so now we've got an excess-size validator that checks for comments larger than a threshold, an excess links validator that checks for comments with too many links and what may be the most useful validator of all the AkismetCommentValidator -- which checks comments against the Akismet anti-spam service. I'm not sure how stable the Roller trunk is right now, but I decided to risk a deploy so now this blog is protected by Akismet.

Update 1: Yowza. The site crashed last night and after a little googling, I think I may have run into a Hibernate bug (HH-1579). I turned on the JVM -server option. Let's see how that goes.

Update 2: The JVM -server flag seems to fix the Hibernate problem. I wrote a note about the problem on the roller-dev mailing-list just in-case somebody else runs into it.

New job at Sun

I mentioned that I've got a new job at Sun and it begins Monday, so I guess it's time to explain.

Since I joined Sun two years ago I've been working in the .Sun Engineering organization, the team that runs and In that time we've taken Roller through three major releases, made massive improvements to the Roller code-base, helped grow the Roller community at Apache and delivered new features and improvements on a monthly basis. It's been a truly wonderful experience and I've learned a lot from Will Snow's amazing team, but now that Roller has matured and stabilized I'm ready to start working in some new directions.

On Monday I'll move to the Java EE organization (under Tony Ng) where Sun's working on some very interesting and very cool technologies from server-side scripting with Phobos and JRuby on Rails, RESTful approaches to web services and client-side UI goodness with JMaki. I'm very excited about the move and getting a chance to get involved with those technologies, but I can't talk yet about the specific product(s) I'll be working on. I can say this: I'll continue to be very closely involved with Roller development and I'll continue my work with RSS/Atom, ROME and the Blogapps project. And, of course, I'll continue blogging Roller so stay tuned.

Latest links: 2007 predictions edition

The Corporate Blogging Show

Six Apart's Anil Dash was interviewed on The Corporate Blogging Show, which is the Voice America show associated with the blog associated with the book. It's worth a listen if you're interested in corporate blogging or what's going on with SixApart, the company behind Movable Type, LiveJournal, Typepad and Vox.


Placeblogger is a new blog and aggregation site that's all about local blogging from Lisa Williams and friends. It's powered by Bryte, which is based on the Drupal content management system and offers blogs, feed aggregations, photo galleries and polls.

You can help build the database by submitting your favorite place blogs. The database supports a number of different "blog types." You can add aggregations, so Joe's local planets would be suitable, and you can add community sites so Orange Politics would fit right in too. I submitted Raleighing.

Here's some more reading on the topic:

Dear, please fix your MetaWeblog API support


I'm one of the developers of the Apache Roller (incubating) software used by Sun and IBM and others for employee blogging. Our users want to be able to post via, but your MetaWeblog API support is lacking.

Roller is not one of the blog servers listed in the Digg Profile area, so we have to use the "manual setup" option, but in manual setup option, you give users the abilty to set only:
- username
- password
- blog URL
- Metaweblog API URL

That won't work. Each of our users can have multiple blogs, so needs to tell Roller which blog to post to. The standard way to do that is to use the blogid argument of the MetaWeblog API, but you don't support that -- you don't give users a way to set the blogid to be posted to.

Please add proper support for the MetaWeblog API blogid field so Roller users can blog via Digg.

I'd be glad to help you get this right and tested.

Sincerely, Dave Johnson

PS. I sent this to in September but got no response at all.

PPS. If you want the problem to be fixed, please Digg this post. I'm not sure it'll work, but don't know how else to get through to the folks at Digg.

Rich Burridge's blog-to-book blogapp

Rich has put together a interesting blogapp that pulls all entries from a blog and turns them into a book, using either cups2pdf or Writer. I had the same idea when I was writing RSS and Atom in Action, but I was going to go the DocBook route and eventually dropped the idea because DocBook seemed a bit too complex.

I don't think Rich's work is Roller-specific. Rich used Grabber to get the entries out of Roller and into simple HTML files, so the approach should work with other blog servers that support the MetaWeblog API.

19 days until the NC Science Blogging Conference

The North Carolina Science Blogging Conference, Saturday, January 20, 2007. This is a free, open and public event for scientists, educators, students, journalists, bloggers and anyone interested in discussing science communication, education and literacy on the Web.

See Bora's blog for an update on sessions, sponsors and ways you can help.

OpenSolaris in 2007

Paul Murphy: By the end of the year the OpenSolaris community will be widely recognised as larger and more active than the Linux community - and every competing OS developer community except Microsoft's will have copied the key ideas including its organisational structure, the core provisions in the community development license, and Solaris specific technologies including ZFS and Dtrace.

That's a nice way to start the new year. No doubt plenty of Sun bloggers will be linking to Paul's predictions.

Farewell to 2006

I've been too busy with year-end projects to blog over the past couple of days and now suddenly, it's time to say farewell to 2006. So I'll do that with a quick summary of the year.

2006 was a pretty good year for me. I published my first book: RSS and Atom in Action. Roller is still growing, reached 3.0 status and is now very close to becoming a top level Apache project. IBM started contributing to and announced a Web 2.0 product suite that will include Roller. I did my first solo JavaOne presentation and spoke at both ApacheCon EU and ApacheCon US. And, I haven't mentioned it yet, but I also landed a new job inside Sun, which starts on January 8th (more about that later).

On the home-front: the boys (now 4, 8 and 10) are all healthy, happy and doing well in school. We celebrated my dad's 70th birthday and Alex's 10th birthday. We took family trips to Ocracoke, Atlanta, Austin, Northern Virginia and made numerous visits to the in-laws beach house near Topsail Island. Plus, Andi and I escaped from the kids for a week in Ireland to celebrate our 15th wedding anniversary -- our first kidless vacation in about ten years.

I hope you had a good year too and will have an even better 2007. Happy new years!

New Atom protocol spec draft and Queen City planets

Joe Gregorio announces a new Atom Publishing Protocol Spec (draft #12) and he says it might end up being the final. I guess it's time for a new Blogapps release with APP draft #12 and ROME 0.9 support.

Plus, Joe has put together a set of new planet sites for towns in the Charlotte, NC area; all based on feeds from Google Base, Google Blogs, Google News, Craigs List, Flickr and the Weather Service. The sites look useful, but the ads combined with the minimalist design make them look a little spammy on first glance. Perhaps a short "about this site" paragraph is in order.

Smithsonian Air & Space Udvar-Hazy Center

The Smithsonian Air & Space Udvar-Hazy Center at Dulles airport is simply amazing. The center "provides enough space for the Smithsonian to display the thousands of aviation and sapce artifacts  that cannot be exhibited on the National Mall." I could have spent a lot more time there, but not everybody in the family shares my fascination with air, space and military history.

Here's a mosaic I created from some of the photos I uploaded to my Flickr account (I used Mosaic Maker to put this together).

Mosaic of photos from Air & Space museum

Christmas loot and NoVa

We opened presents in Chapel Hill on Xmas eve, at home in Raleigh on Xmas day and then drove up to Northern Virginia for one last round of paper ripping, twisty-tie unfastening and worship of the one deity that really matters to the kids: the good lord Lego. Lego ruled christmas here again and this year, for our kids the holy trinity is Lego, Star Wars and the Cars movie.

Lego's hegemony over the Johnson playroom has some history. Long time readers may remember the Jack Stone incident. Jack Stone has been replaced by a series of increasingly complex Lego Star Wars vehicles for the older boys and an oddly intense Lego Boba and Jango Fett fetish on the part of our four year old. And Lego is also serving as a gateway-drug -- Alex (10) got Lego Mindstorms earlier this month and has been spending hours building bots and some pretty complex programs.
Leo holds a Lego Boba Fett figure

I had to include the Cars movie in the holy trinity because Leo eats, sleeps and drinks it now. I'm almost too embarrassed to admit that he's got Cars movie plastic cars, die-cast metal cars, carrying case, models, pajamas, a blanket (known as fuzzy), socks, shoes, underwear and pull-ups -- but no Cars movie Legos (yet).

I got a couple of nice gifts too. As usual my brother gave me some user-generated content; his year he put together a wonderful CD full of about 30 Who covers. I also got a couple of books: Innovation Happens Elsewhere and The Innovators Dilemma.

We'll be in the Northern Virginia area for the next couple of days. After a short pilgrimage to the Lego store today we'll head over to the new Air & Space museum at Dulles airport. Tomorrow, we're expecting good weather so we'll head down to DC to check out the National Mall.

Jingle bells

Here's a little video gem I found while working on our annual video review DVD; a little spontaneous singing and cuteness from the kids on Christmas eve last year. It's my first YouTube upload:

« Previous page | Main | Next page »