Dave Johnson on open web technologies, social software and software development
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.website.handle:$entry.anchor",
pubTime:"$entry.pubTime",
title: "$entry.title"},
#end
#end
]
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: http://rollerweblogger.org/roller/page/jsontest
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.
Dave Johnson in General
04:29AM Jan 14, 2007
Comments [1]
Tags:
blogging
json
roller
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!
Dave Johnson in Blogging
05:28PM Jan 09, 2007
Comments [0]
Tags:
blogging
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.
Dave Johnson in Blogging
04:23PM Jan 06, 2007
Comments [0]
Tags:
blogging
java
roller
spam
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 sun.com and blogs.sun.com. 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.
Dave Johnson in Sun
12:14PM Jan 05, 2007
Comments [5]
Tags:
blogging
opensource
roller
sun
Dave Johnson in Blogging
03:16AM Jan 03, 2007
Comments [0]
Tags:
blogging
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:
Dave Johnson in Blogging
03:14AM Jan 03, 2007
Comments [1]
Tags:
atom
blogging
rss
Rich has put together a interesting blogapp that pulls all entries from a blog and turns them into a book, using either cups2pdf or OpenOffice.org 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.
Dave Johnson in Blogging
09:55AM Jan 02, 2007
Comments [0]
Tags:
atom
blogging
rss
sun
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.
Dave Johnson in Blogging
04:06AM Jan 02, 2007
Comments [0]
Tags:
blogging
triangle
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!
Dave Johnson in General
06:11PM Dec 31, 2006
Comments [2]
Tags:
atom
blogging
family
java
roller
rss
sun
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.
Dave Johnson in Blogging
11:50AM Dec 27, 2006
Comments [1]
Tags:
app
atom
blogging
rest
webdev
webservices
If you dig blogs, wikis, feeds, Java and Solaris then you might be interested in the fact that we're hiring. Linda Skrocki's got the scoop on the job opening in Sun's Community Software Engineering team.
Dave Johnson in Java
05:58PM Dec 12, 2006
Comments [0]
Tags:
blogging
java
solaris
sun
Dave Johnson in Blogging
12:29PM Nov 30, 2006
Comments [4]
Tags:
blogging
movabletype
roller
wordpress
Dave Johnson in General
04:28AM Nov 21, 2006
Comments [1]
Tags:
blogging
triangle
In my off-hours, I've started work on Blogapps 2. Blogapps is a collection of RSS/Atom utilities and applications based on the code from RSS and Atom in Action. You can read more about the project in my recent Blogapps article on on Java.net. Up until now, I've been working alone, but now the project now has a couple of committers. Ramesh Mandava (of the Java WSDP team) joined to help with the Blogapps 2 effort.
We're starting with some renaming. Instead of using chapters-oriented directories and package names, we're more logical and intuitive application names. We're also switching from package name com.manning.blogapps to org.blogapps. Later, I hope to update some dependencies (e.g. Apache XML-RPC 3.0), consolidate/streamline some of the utilities and explore alternatives to Tomcat/HSQLDB for the Blogapps server.
Dave Johnson in Java
12:57PM Nov 15, 2006
Comments [0]
Tags:
atom
blogapps
blogging
java
rss
Yes, definitely brilliant. No bias here.Mike Swaine in Dr. Dobb's Journal: But employee blogs are turning out to be a good place to go to track what's really going on. When Sun partnered with the University of Kent on the NetBeans IDE/BlueJ Edition, Ian Utting of U Kent vlogged in Sun's blog space about this beginner's Java tool. Incensed by rumors that Java doesn't work on Windows Vista, Sun's Chet Haase blogged to the contrary. And, responding to a high-news-value development, CEO Jonathan Schwartz links to YouTube video of Jonathan and Sun's Chief Technologist Greg Papadopoulos on Oracle's decision to fork Linux. (Hey, that's Jonathan's choice of words, not mine.)
And maintaining a place for ex-employees to blog is either brilliant or loony. My guess is, brilliant.
Dave Johnson in Blogging
04:44AM Nov 12, 2006
Comments [0]
Tags:
blogging
businessblogging
sun
It's fairly easy to navigate to your old blog entries on a Roller system, but we don't provide an archive page like some blog servers do. Today on JRoller.com, Alex Ruiz explains how to add a nicely styled archives page to your blog using Roller's "big calendar" macro.
Dave Johnson in Roller
04:02PM Nov 06, 2006
Comments [0]
Tags:
blogging
roller
rollerhacks
We've got a new meeting place, Helios Coffee in the Glenwood South area of Raleigh. Please join us to talk blogging, podcasting, politics, tech or whatever else is on your mind.
Time: Tuesday Nov. 7, 2006 - 6:30PM
Place: Helios Coffee, 413 Glenwood Ave, Raleigh, NC (map)
Dave Johnson in Blogging
12:48PM Nov 06, 2006
Comments [0]
Tags:
blogging
triangle
We deployed the Roller 3.1 codebase to blogs.sun.com yesterday so Sun bloggers have got Web 2.0 taggy goodness now. The rest of the Roller-using world will have to wait for Roller 3.1 to make its way through the Apache Incubator release process. Want to know more about 3.1, here's the Roller 3.1 What's New page.
But be warned. If you stand outside the Apache software factory waiting for Roller 3.1 to emerge onto the loading dock, you'll be somewhat disappointed. The next release due out is Roller 3.0 (here's the Roller 3.0 What's New page) -- we just got the votes to make the release so you can expect it in the next couple of days.
Dave Johnson in Roller
06:43AM Nov 03, 2006
Comments [2]
Tags:
bam
blogging
java
roller
Dave Johnson in Blogging
06:41AM Nov 03, 2006
Comments [0]
Tags:
blogging
java
Dave Johnson in Java
06:53PM Oct 31, 2006
Comments [1]
Tags:
atom
blogging
politics
rome
rss
« Previous page | Main | Next page »