I have finally gotten around to adding subscription information to my blog entry comments. This is nothing new to you all, but this blog is being built from the ground up for experience, so it's coming in piece by piece. The email that goes out looks pretty lame at the moment, so hopefully I should have some time to spruce it up.
One thing that I want to be able to do is allow users to subscribe to blog comments without having to post a comment first. This should be fairly easy, just a time issue. I see that some people supply an RSS feed just for comments. I might look into that, but that feels like a bit of an overkill at the moment.
Looking For A New Job?
- Back-End Engineer - Node.js & Mongo at Interface Foundry
- Senior ColdFusion Web Developer at HD Web Studio
- In House ColdFusion at Marketing Holdings
As you may have guessed from the Google Reader screenshot I posted yesterday ...
*** I, for one, welcome our new RSS-feeding overlords. ***
If you refactor your existing RSS code into an RSSFromQuery() function then you can easily provide feeds for all comments, comments-per-post, posts-per-tag, posts-per-random-search-term, etc. Refactor again into FeedFromQuery() and subclass to get Atom feeds, RDF feeds, XML feeds, JSON feeds, GData feeds, WDDX feeds, and whatever else.
Feeds are good.
Actually ... you what I would /really/ like to see? (And it would set your blog apart from the rest...)
A way to fetch an RSS feed of comments to posts that I have already commented on.
That would r0xx0r.
That sounds like a cool idea. I can certainly set that up. Just give me some time. I am new to RSS stuff, so I am not sure how would I group the comments by blog entry? or would all the comments come through in one list and then just have a category tag of that given entry? Basically, what structure are you looking for?
Rick - how would the RSS feed work? All comments made after your post? What if you have comments on multiple threads?
Forgive me for trolling for BlogCFC improvements. ;)
No worries on trolling :) Better stuff is better stuff. The more places it shows up, the better. (That might not sound too intelligent, but you get the idea)
Ray and Ben-
What I was envisioning for my idea was as simple as the following pseudo-query:
SELECT e.* /* whatever necessary columns */
FROM Comments AS m /* mine */
INNER JOIN Comments AS e /* everyone */
ON (m.PostID = e.PostID)
WHERE (m.FromEmail = ?) /* cfqueryparam */
ORDER BY e.CommentDate DESC
Sprinkle in a TOP 25 or LIMIT 25 or FETCH FIRST 25 ROWS ONLY as your dbms requires.
Thus, yes, you will get all comments from all entries you've commented on. If you comment on an entry with 50 comments before you, the next time you read the feed, you will see all comments from before you.
I guess if you really wanted to be tricky:
FROM Comments AS e
INNER JOIN (
SELECT PostID, MAX(CommentDate) AS LatestDate
FROM Comments AS c
WHERE FromEmail = ?
GROUP BY PostID
) AS m ON (e.PostID = m.PostID) AND (e.CommentDate = m.LastDate)
Thus, you only get comments after your latest comment. (It makes the assumption that if you comment multiple times, you will catch up on the intervening comments without having to see them in the RSS feed. Otherwise, use MIN instead of MAX.)
You probably already figured it out, but I made a typo on that last part:
AS m ON (e.PostID = m.PostID) AND (e.CommentDate = m.LastDate)
AS m ON (e.PostID = m.PostID) AND (e.CommentDate > m.LastDate)
How would you feel about the comment going in <description> rss field. Then the original blog entry title going in the <category> rss field. That way, I suppose depending on how the RSS reader works, you could view only comments within a given category (ie. blog post)?
Otherwise, the idea looks sound to me and rather easy to implement.
Hmm. I'm torn.
My impulse tells me to put the Post Title in the <item>'s <title> tag (maybe prefixed by "Re:" ?), copy the Post Categories into <category> tags, then put the comment in the <description> and <content:encoded> tags. You'd have to whip up a <guid> and <link> per comment, but I don't imagine that would be too hard. Use a <dc:creator> for the author of the comment.
For the overall feed, might I suggest a <title> of "#SiteName# for #Email#"?
Just thinking out loud.
That could work. But really, that is a minor detail. Once the script is up and running and creating the feed, switching around fields is like zero work. I am just wishing I wasn't at work right now ;)
So guys - I'm still confused. Is this query just for one entry or multiple? Ie, how are you handling the fact that email X may be associated with multiple threads he commented on?
This is what I have so far:
I am basically joining the comments to the blog entries on the id's and the email. I don't bother getting the blog entry content, just the comment content.
Now, this get's ONLY your comments... do you want comments that other people have made on the same entry?
So I have a beta of this up and running at:
Now, as far as the GUID goes for the link, can this include the ## url hash? Or must the script_name / querystring be unique?
I was thinking it should be for any comment to any post that the person had commented on. Not just my comments, but everyone's comments. That is, the entire intent of the feed was so that I could easily see replies to posts that I had replied on. Instead of subscribing via email to replies, I'm insta-subscribed via RSS.
I barely use email for anything these days and do most everything out of Google Reader. Getting a new mail notification every time someone replies to say "how cool is that?!?!" would drive me bonkers.
As I mentioned to Ray, I'm actually more interested in seeing the comments of everyone else, not just my own. But other than that, it worked like a champ in Google Reader! Rock!
As far as the <guid> versus <link> question, I'm pretty sure the # hash can be used in both. But I'm not 100% sure on that.
Ok, it should now return ALL comments for any blog entry that YOU commented on. As far as the limitations, I am only getting the top 50 comments. Its ordered first by:
1. The posting date of the comment DESC
2. The date of the web log entry DESC
3. The time of the web log entry DESC
Does that make sense?
Sounds good to me! I'll be the first to let you know if anything looks screwy with the feed.
Hey Ben, where are you offering this feed? Ie, how do I learn about it/subscribe?
To be clear - this is all so I can ste... innovate it into BlogCFC.
Ok - I see it now. In the email and as a web page. Aren't you going to provide an RSS feed as well? Another issue the P tags are escaped when rendered.
I figure it is good to have it in the outgoing email as you can only really use the RSS feed ONCE you have submitted a comment. But, of course, you can access it as a direct URL without coming from the email.
As far as the P tags being escaped, they might just be escaped on that page, because it is an RSS feed with a stylesheet:
<?xml version="1.0" ?>
<?xml-stylesheet type="text/css" href="http://www.bennadel.com/linked/css/rss.css" ?>
Then, for the content, I just have:
<description><![CDATA[ #REQUEST.CommentQuery.content# ]]></description>
This should not escape anything. My guess is that it's just the way the RSS is getting rendered in the browser? But again, this is my first RSS experience (on this site), so if I am wrong, please let me know.
If you are interested in the query and display pages for this, just let me know and I will email you.
Ah - an RSS feed with style. I didn't realize that. I think you need to make it more clear. I think the route I may take is:
Use a HTML page. On the top of the page, mention the RSS version, and use the Firefox auto-discover meta tag thingy.
I'd like the query for comments if you don't mind. The layout I can handle.
Sent the file. And I like your idea about the HTML page and then the RSS feed. Nicely done :) Cause, I agree, it is not very clear that you are going to an RSS feed.
What is this FireFox auto detect thing you are talking about? Is that the live bookmark thing or something?
What I meant was this meta tag,
<link rel="alternate" type="application/rss+xml" title="Ben Nadel's ColdFusion And Web Development RSS" href="index.cfm?dax=blog.rss">
I called it a 'Firefox' thing cuz in the UI it shows an RSS icon by the address, and I don't believe IE supports it yet.
Ahhh, gotcha. Ok cool.
By the way, gentlemen, Ben's version is working astoundingly well. All of your comments showed up on my Google Reader this afternoon.
The only problem I am now having is one with Google Reader itself, as it does not show the author of the comment. It's in the feed, but Google strips it out. Lame! It makes it a little difficult to figure out who said what, but I'm sure there's probably a hack or something to get Reader to show it.
Thanks again, Ben!
I can put the author as part of the description if you feel it would help.