Adding comments

I have a hacked together version of Radiant with the capability of
allowing users to add comments. It’s somewhere between “demo” and
“pre-alpha” quality at the moment. I’ll make the code available (as an
svn diff against HEAD) in the next few days to anybody who’s interested.

Here’s a brain dump of the things I ran into, and my resolutions. I
don’t pretend these are the best solutions, but they’re the ones I got
working first:-)

I gave up the idea of using a comment behavior. I kept running into the
problem that behaviors are conceptually exclusive, as opposed to nesting
or stacking.

Instead, I added a “commentary” page part to each page for which I
wanted to allow comments. This “commentary” part contains only an AJAX
request link to “Add Comment”. Issue: there might have been some way I
could have used the Rails “link_to_remote” helper, but I couldn’t figure
it out. I just wrote the literal link.

Since I wanted to use OpenID instead of the real login system just to
authenticate comments, I added a “commentaries” table, model, and
controller to the system. So far, I’ve not been successful at making
them look like they belong there:-)

So the AJAX request causes the link to be replaced by a text field and
button for OpenID login. On success (the actual authentication is
stubbed in pending some experiments with AJAX and OpenID), this is
replaced by fields for name, email, and comment. When the user clicks
the submit button on this, it all goes back to the original state with
just the “Add Comment” link, which is now below the new comment. This
all works fine.

The solution to rendering the comments, though, is a complete hack. I
added a render_page_commentaries method to behavior.rb that just creates
an ERB template, feeds the page’s commentaries through it, and splurts
out the result. The radius code in page_context.rb
calls this if part_name =~ /commentary/. This is obviously not an ideal
solution, but it was a lot quicker than figuring out how to do it in
Radius:-)

My main conceptual problem in working on this is the lack of model/view
separation when the view IS the model.

So there you go, for what it’s worth. First, get something working:-)
Let me know if you’d like a copy of it when I get it cleaned up a
little.

–Al Evans

Al Evans wrote:

I have a hacked together version of Radiant with the capability of
allowing users to add comments. It’s somewhere between “demo” and
“pre-alpha” quality at the moment. I’ll make the code available (as an
svn diff against HEAD) in the next few days to anybody who’s interested.

Any chance we could see a live demo somewhere along with the diff?


John L.
http://wiseheartdesign.com

John W. Long wrote:

Any chance we could see a live demo somewhere along with the diff?

After I’m a little happier with it, and especially after I have the
async OpenID authentication working, yes. I’ll put it up and post an
announcement.

–Al Evans

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs