
This patch was applied to the Pyblosxom contributed plugins pack in revision 973. It's included in version 1.3.3 of the contrib pack.
For the impatient:
Download contrib pack 1.3.3 (includes AJAX support)
PyBlosxom home page
PyBlosxom plugin registry
PyBlosxom, the server software that runs this site, uses a plugin to handle commenting. This patch adds AJAX support to that plugin. Try it!
Specifically, comment previewing and posting can optionally use AJAX, as opposed to full HTTP POST requests. This avoids a full-size roundtrip and re-render, so commenting feels faster and more lightweight.
To enable AJAX comments, set the comment_ajax config parameter in
config.py to True.
AJAX commenting degrades gracefully in older browsers. If JavaScript is
disabled or not supported in the user's browser, or if it doesn't support
XmlHttpRequest, comment posting and preview will use normal HTTP POST.
Feel free to check out the JavaScript.
Also, since the browser window never sends a full POST request, refreshing the page after a preview or comment submission won't re-post the comment, or pop up an annoying "are you sure?" dialog box.
AJAX comment support requires a few elements in the comment-form flavour template. Specifically, the comment-anchor tag must be the first thing in the template:
<a name="comment-anchor" id="comment-anchor"></a>
Also, the buttons in the comment form should include these onsubmit and
onclick attributes:
<form name="comments_form" ... onsubmit="return false;">
<input value="Preview" name="preview" type="submit"
onclick="send_comment('preview');" />
<input value="Submit" name="submit" type="submit"
onclick="send_comment('post');" />
Finally, this script tag must be included somewhere after the </form> tag:
<script type="text/javascript" src="/comments.js"></script>
All of these tags are included in the default comment-form template that comes
with this plugin.
AJAX comment support is copyright 2006 Ryan Barrett, and is distributed under the GPL. Thanks to Todd Warner and Blake Winton for beta testing and improvements.
See also: