1. 'Standard' Comment Markup?

    body

    What would be the benefits of standardising our comment markup? Well, that all depends on who you are. With the advent of comment crawling services a standard markup would really help them do their job. If your blogging platform offers no syndication options a standard comment markup could allow you to generate comment feeds yourself (using Blogger Recent Comments or similar). A standard markup about which we can make certain assuptions would also help the less technically inclined with implementing comment-centric hacks.

    So, the natural first place to look is microformats.org. Nada, yet. Falling back to my own work with XOXO I have encapsulated comments as part of the XOXO Blog Format. Testing that with a comment crawler I find that it recognises the data 'as is' just fine. If you mix it with hAtom it is recognised by Blogger Recent Comments (more on this in a later post). It also provides many of the things we hackers like in comment hacks — an item surrounding the whole comment and the comment text, and a way of identifying some of the meta-type links.

    Thus this proposed 'standard' is both based on microformats (XOXO) and fits the three major reasons we would even want any sort of structure to our comment markup. The markup should be on the main page for crawlers et al, but need not be visible. Now to how to add it to your blog. Advanced users can probably figure it out from teh XOXO Blog Format, for others here are simple instructions for both Blogger and WordPress:

    Blogger
    Go to your blog template and find the section that begins with <BlogItemComments> and ends with </BlogItemComments>. Replace it with this code:

    <script type="text/javascript">
    //<![CDATA[
    posturl = "<$BlogItemPermalinkUrl$>";
    //]]>
    </script>

          <ul class="xoxo comments">
    <BlogItemComments>
             <li id="c<$BlogCommentNumber$>" class="commentelem">Comment at <a href="#c<$BlogCommentNumber$>" title="<$BlogCommentNumber$>0"><$BlogCommentDateTime$></a> by
                <$BlogCommentAuthor$>
    <a name="<$BlogCommentNumber$>"> </a>
    <!– JS HERE –>
                <dl>
                   <dt class="body">body</dt>
                      <dd class="body"><$BlogCommentBody$></dd>
                </dl>
    <$BlogCommentDeleteIcon$>
    <br />
             </li>
    </BlogItemComments>
          </ul>

    If you are going to be visibly displaying comments on your main page it is reccomended you replace the <!– JS HERE –> in the above with:

    <script type="text/javascript">
    //<![CDATA[
      commentlink = xget('//li[@id="c<$BlogCommentNumber$>"]//a');
      if(commentlink) {
       fragment = commentlink.href.split('#')[1];
       commentlink.href = posturl+'#'+fragment;
      }//end if commentlink
    //]]>
    </script>

    And add the following to your <head> section:

    <script type="text/javascript">
    //<![CDATA[
    function xget(xpathSelector) {
      var it = document.evaluate( xpathSelector, document, null,
          XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null );
      if(it.snapshotLength)
        return it.snapshotItem(0);
      return '';
    }//end function xget
    //]]>
    </script>

    Now to style this to look like we are used to having comments look. Skip past WordPress to Styling.

    WordPress
    To use this code on WordPress blogs, edit your theme and go to the 'comments.php' file. Find the section that starts <ol> and ends </ol>. Replace it with:

       <ol class="xoxo comments commentlist">

       <?php foreach ($comments as $comment) : ?>

          <li class="commentelem <?php echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">
             <?php if ($comment->comment_approved == '0') : ?>
             <em>Your comment is awaiting moderation.</em>
             <?php endif; ?>
             Comment at <a href="<?php the_permalink() ?>#comment-<?php comment_ID() ?>" title="<?php echo strtotime(get_comment_date().' '.get_comment_time()); ?>"><?php comment_date('F jS, Y') ?>  <?php comment_time() ?></a>
    by <?php comment_author_link() ?>
    <br /><?php edit_comment_link('e',","); ?>

                            <dl>
                               <dt class="body">body</dt>
                                  <dd class="body"><?php comment_text() ?></dd>
                            </dl>

          </li>

       <?php /* Changes every other comment to a different class */
          if ('alt' == $oddcomment) $oddcomment = ";
          else $oddcomment = 'alt';
       ?>

       <?php endforeach; /* end for each comment */ ?>

       </ol>

    This code seems to work with the most common themes. Now to styling so that we get back our old look:

    Styling
    Add this code to your <head> section:

    <style type="text/css">
       .comments {
          list-style-type: none;
          margin-left: 0px;
          margin-top: 0.5em;
       }
       .comments li {
          display: block;
          margin-left: 0px;
          margin-bottom: 1em;
       }
       .comments dl {
          display: inline;
       }
       .comments dd {
          margin-left: 0px;
       }
       .comments dt {
          display: none;
       }
       .comments dd.author {
          display: inline;
          font-size: 1em;
       }
       .comments dd.body {
          display: block;
          margin-top: 0.5em;
       }
    </style>
    Tags:
    Creative Commons Licence © 2006-2008 Stephen Paul Weber. Some Rights Reserved.
  2. OpenID for WordPress

    body

    Someone else has written a (imho) better plugin. I have a backlog of tweaks to do to this plugin to make it work on more systems which I haven't got around to blogging/integrating. Note that this new plugin does not support using your blog as an OpenID server. It does, however, support sreg (but not hCard) and integrates into the WordPress account system.

    I have modified Alexander Nikulin's plugin for WordPress that enables users to leave authenticated comments using OpenID and enables blog owners/contributors to use the blog as their OpenId. I have made the plugin compatible with WordPress 2.0, cleaned up the validity of the XHTML produced, and fixed a bug that kept some sites from finding the server.

    It is reccomended that when using the server the blog admin use the blogs main URL as their OpenID but that other users/contributors use BLOGURL/?author_name=USERNAME.

    When returning to the post page after posting a comment, if the comment was held for moderation ?moderated=true is appended to the URL. Adding code like the following will alert your users to this fact:

    <?php if($_GET['moderated'] == 'true') echo '<div style="display:block;padding:20px;background-color:#; font-weight:bold;font-family:sans-serif;font-size:12pt;"> Your comment is awaiting moderation.</div>'; ?>

    Possible future features:

    • Support for sreg / hCards to get an actual name for the commentor instead of just using their URL
    • Support for sreg / hCards in the server implementation
    • Support for YADIS

    Download the plugin

    To install the plugin:

    1. Download the gzip from the link above and unzip it
    2. Upload the resulting folder into your /wp-content/plugins/ directory
    3. Edit your template and replace your comments form code (likely in comments.php) with
      <?php include dirname(__FILE__).'/../../plugins/openid/openidform.php'; ?>
    Creative Commons Licence © 2006-2008 Stephen Paul Weber. Some Rights Reserved.
  3. YubNub LocationBar

    body

    My previous YubNub extension suffered from several glitches. While it was useful, it annoyed me enough to get me to research a new format. So I have written a new extension. This one functions a little differently and so I will leave the old one up. This extension modifies the standard FireFox location bar to support YubNub commands. If the entered text is determined to be a URL the location bar will function as normal, otherwise the text is passed to YubNub. No more second bar, no more glitchy locationbar behaviour, just straight YubNub integration. All YubNub commands will work, including single-word commands without parameters.

    Download YubNub Locationbar

    Version 0.11 has been released which fixes a glitch that broke access to about:config and typeing some javascript: URLs

    Version 0.12 has been released which fixes a flitch that caused commands that are passed URLs not to work

    Version 0.13 has been released which adds a command history feature. Simply push your up/down arrow keys while in the location bar to access the command history.

    Version 0.14 has been released which fixes some minor bugs with navigating to local IPs, and also allows defined FireFox keyword bookmarks to supercede YubNub commands.

    Version 0.15 has been released which has some minor improvements to the look and feel of the extension, and also now allows local firefox bookmarks to use switches (using the same syntax as YubNub proper). It also stores up to 50 commands from your command history between sessions now.

    Version 0.16 has been released. Support for non-standard URLs (such as those from nic.d. Arrow-key history navigation broke some default Firefox features, so it is now Ctrl+Arrow Key. A hackish integration with Firefox auto-complete history has also been coded. Type y: before a command to have the auto-complete work (or just to force it into YubNub mode).

    Version 0.17 has been released which fixes some minor URL resolution bugs.

    Version 0.19 (0.18 was released silently) fixes some minor bugs noted in the comments. There is also now an entry at mozilla. Please review there if you find this useful!

    Creative Commons Licence © 2006-2008 Stephen Paul Weber. Some Rights Reserved.