20030417 Thursday April 17, 2003

Joe Hewitt Comments I did a bit of research today and it looks fairly simple to incorporate Joe Hewitt-style comments into Roller. The hard part will be figuring out a way to convert an entry's comments into XML. For instance, Joe loads an XML document (sample) that contains all the comments for a given post. This document has a DTD which will hopefully make things easier. Here's what a sample XML-based comment entry looks like:

<comment id="000178">
  <author>Joe Hewitt</author> 
  <email />
  <url />
  <timestamp>April 3, 2003 04:14 PM</timestamp>
  <body>
  <p>I have readers??</p>
  </body>
</comment>

Looks pretty simple eh? So how do we convert comments to XML? Since they're already (or supposed to be) XHTML, should we just use a JSP and JSTL's "x" tag to do a little XSL? That sounds like an easy solution. Or should we figure out a way that we can hit the RSS feed (which could be enhanced to include comments)? Once we've done this, there's some JavaScript to load this document.

  // Make url unique to prevent loading it from cache
  var cacheKiller = new Date().getTime(); 
  // replace this with a link to a JSP or something
  var url = "/content/blog/comments/" + aEntryId + ".xml?" + cacheKiller; 
  loadXMLDocument(url, onCommentsLoaded);

Please comment with any ideas for the comments-to-XML conversion. Posted in Roller at Apr 17 2003, 01:00:34 PM MDT 3 Comments

Comments:

If you can access the comments easily via a URL, perhaps you could use HttpUnit to request the page, extract the information and then subsequently generate the XML. I've just moved over to my own, homegrown, blogger and I really wish I had thought of this sooner as getting comments from Radio was a real pain! ;-)

Posted by Simon Brown on April 17, 2003 at 02:26 PM MDT #

...I've taken a brief look at the JoeHewitt blog, and I don't understand why on earth you would need to turn it into xml. The comments are inside a <div> tag, why don't you just put them directly inside the <div> tag? Or better yet, use an iframe inside the <div> tag that is triggered when the user opens that comments?

Posted by Paul Rivers on April 17, 2003 at 05:33 PM MDT #

Paul, I agree with you, but for me - it's easier to develop based on an example - and enhance later.

Posted by Matt on April 18, 2003 at 02:24 PM MDT #

Post a Comment:
  • HTML Syntax: Allowed