Singpolyma

Technical Blog

Commentosphere – Name, URL, Some Other Thoughts

Posted on

I have decided that, at this early stage at least, the name for Commentosphere is rather immaterial. The URL comment.ning.com, is sufficiently abstract, I think, to be maintained no matter what the service ends up being called. Even though the scope of the service may well prove to be outside that of blog comments, the URL works well enough for (as they may be termed) comments on forums and other things as well. Should a move be in order it will be dealt with when the time comes, but I think that, for now at least, the current URL will suffice.

I have been talking some with Yoz Grahame (from Ning) about Commentosphere. Most of this discussion has centred around the methods of getting data into the service. A summation of the results follows, and I will be quick to point out that most of this idea is his with only minor additions of my own.

Write a JavaScript piece that is hosted on Commentosphere and can be included by blog owners in their pages. Then, on the occurance of a comment posting form in the page, a function defined in this JavaScript can be called with a reference to the comment form itself, and to the names of the necessary fields (comment content, poster name) and other data (page title, page url, these cannot be pulled by the JavaScript itself because the script may be running on the blog’s main page). The script then alters the form to include a checkbox (defaultly checked) that turns on/off the automatic posting of any comments entered into that form to Commentosphere. Optionally, fields for tagging the comment and specifying parent(s) may be added by the script. Additionally, a small piece stating wheather or not the user is currently logged in on Ning will be inserted.

If the user is logged in, then when they post the comment to the blog it will automatically also be added to their account on Commentosphere by the method described below. If the user is not logged in, and chooses not to sign in (or has, indeed, no account) the comment will still be added, but to an anonymous account and merely have the user’s name (as specified in the appropriate place on the form) stored for display purposes.

For Blogger blogs that use the Blogger comments form, a simple Greasemonkey script will suffice to inject a script tag into the page calling this same script from Commentosphere with the appropriate data being supplied by the Greasemonkey script instead of the blog template.

The posting method runs as follows : An onsubmit handler is added to the comment posting form. When it is run it creates a new Image object and loads into in an image which is really the result of a PHP script running at Commentosphere. Data is pulled from the form and passed to this script via GET (so the URL to the ‘image’ would be something like http://comment.ning.com/addExternal.php?content The function loops until Image.complete is TRUE, and then returns TRUE, thus waiting until the request to Commentosphere has completed before submitting. If the user is logged in this cookie will be passed with the image request and the script will detect it and add the comment to the correct account. No popup windows.

I can find only one potential problem with this method, and that is that the comment’s permalink URL is not set until it has been posted into the blog system, so how could that be passed to the server beforehand? It warrants some thought, however, because if this worked it would make Commentosphere an almost seamless service.

Tags:

6 Responses

Johan Sundström

I see an additional possible problem with the solution, which is, on the other hand, addressable by a slight change of algorithm. Busy-looping in an event handler in wait of some other asynchronous event (which might even fail) is a source of pain and trouble.

I would add the onsubmit handler, have it generate the image, with an onload and an onerror handler, both of which, when invoked, finally call the form’s submit() method. No busy-wait, less trouble.

The Greasemonkey solution can bypass most of this and only add a bit of logic to pick upp all form variables, store them temporarily along with a timestamp with GM_setValue and retrieve them upon the next pageload to the page where the comment has gone live, where its id also is visible. From there, it’s just to pick it up with the rest of the data we just stored away, and pass it to Ning.

How the non-Greasemonkey solution, if we manage to swing one, is to do this I can not say, but to make things worse, CAPTCHAs could further complicate things — as the initial post of the form might have posted an incorrect CAPTCHA text (I seem to end up with that about 20% of the time), and find something to revise in the comment as well, and do so.

The Greasemonkey solution suggested will be able to catch that (as does my present code — it picks up the comment from the result HTML), whereas a solution that runs only on the form page probably will not. Addressing this issue might be considered a non-problem though for all I know — I just wanted to point it out, for the sake of completeness.

Johan Sundström

Really like your links pane, by the way. Any chances of moving the plus signs up to before the title? (It makes them easier to browse, since you can unfold a few in one go, without precision mouse manoeuvering.)

Singpolyma

RE asynchronous : I like it, and I think it would work very nicely — assuming calling the form’s submit() function does not call the onsubmit handler again?

RE picking up permalink : I actually can’t myself thing how this would work. As I said, it was mostly Yoz’s idea, maybe he’s thought of that… Data can be stored between pages without greasemonkey using cookies… but then you have the problem of browsers with JS on but JS-cookies off.

The idea of using in-page JS and not Greasemonkey-only is that then comment data for users who don’t have a ning account, or who don’t have firefox, or both, can be stored (with permission, via the checkbox), enhancing certain things for the blog, even if the users don’t see the point.

This whole thing, realistically, is still a fair bit ahead of where we are, however. Right now I’m the only one using the system really, so the goals right now are for increased usership — so that the service is even useful, and for a greasemonkey script analogous to your del.icio.us commentblogger.

RE links pane : I’m not all that happy with it, since it takes forever to load. I’m taking the semi-threading code out of my pages too for now, because of the same problem — maybe if we can get some sort of JSON solution working as you suggested I’ll bring it back.

Moving the plus signs to before the links should be easy enough, I’ll do it when I’m removing the code for semi-threading 🙂

Johan Sundström

I agree this is still a bit ahead of us, but it’s good to have an idea of how to get through forthcoming obstacles. I’m not quite sure I see how cookies would solve the problem. Assuming a scenario where the user writes a comment, comes to Blogger’s comment submitted page and then leaves the site, the code that would pick up the cookie and do the real registration work would never run.

As far as I know, you can not inject any code of your own onto those pages, and if you could, it would be a bug that it would be in Blogger’s best interest to fix, so if we found and used one, it is likely it would be fixed, sooner or later.

Or were you planning on using Jasper’s approach, and post the comment to the default Blogger comment-receiving page in a hidden iframe, which upon load completion triggers a reload the blog item page? That approach has other bad side effects to it, such as not alerting the user of any kind of failure dialogs that might have been shown on the page we hid away, at least if CAPTCHAs are turned on. Maybe it’s a non-issue with CAPTCHAs off, though; I admit I have not done much research here.

Singpolyma

Well, as I said in the post, applying this to a blogger blog would ultimately probably require some greasemonkey anyway. A greasemonkey soulution would be required for some blogging services (/other services?) / blogs that didn’t implement any other provided system anyway.

Gekko

Your search returned this blog entry…

Leave a Response