about standards, webdesign, usability and open source

Trackback and XmlHttpRequest

A couple of days ago I enabled Trackbacks on this weblog. Nucleus does not support this out of the box, but thanks the NP_Trackback plugin you can easily add this functionality. The plugin is easy to install and work pretty good. I did notice some things that could be improved, most notable the Trackback auto-discovery.

Auto-discovery is actually pretty simple. If you use a link to a page on another weblog, the plugin will visit that page and look through the HTML source code in an attempt to find a small snippet of RDF code. The RDF snippet contains the Trackback URL which the plugin uses to post the Trackback. Auto-discovery saves some time because previously you had to manually look for the Trackback URL.

Auto-discovery also had a big drawback. Everytime you try to edit an entry, the plugin would go through the links and try to discover the Trackback URLs.

Update: Thing are getting pretty stable, so I’ve uploaded a test version. Try it out, but don’t blame me if your server catches fire.

Currently I am working on an updated version of the Trackback plugin. The big change is that auto-discovery doesn’t happen before you edit an item, or after you add a new item, but during the editing of an item. A small piece of client-side Javascript extracts all the links from the edit fields and for each URL it uses the XmlHttpRequest object to retrieve the Trackback URL. So you basically start typing and when you are finished with your story, the list of Trackbacks is already properly detected and waiting for you.

In addition to this big change, I’ve also made some smaller refinements. For example, auto-discovery will no longer try to detect a Trackback URL for every link in your story. Before retrieving the contents of the link it will first sent out a HEAD request to determine whether or not the link points to a HTML page or not. It’s is pretty useless, and more importantly, very time consuming to try to detect Trackbacks in non-HTML links, such as MP3 files or large pictures.

A second small refinement is caching of the auto-detected Trackback URLs. Currently, every time an item is edited on your site, the Trackbacks redetected. I’ve added a new database table which will hold the auto-detected Trackback URLs, so once a link has been processed by the auto-detection routines it will no longer need to contact the page to which the link points. This should result in a speed-up for editing existing stories.

21 Responses to “Trackback and XmlHttpRequest”

  1. TeRanEX wrote on January 24th, 2005 at 9:34 pm

    Woow looks very promosing! I can’t week to try this version :)
    BTW: using HttpXmlRequest also solves another issue imho: some ISP’s don’t allow users to open pages from external servers, so currently autodiscovery does not work. With httpxmlrequest it will work, right? :)
    If your version is ready I (or Admun) will add the changes to CVS and we can release it as the official version 1.6 if that is ok for you?

  2. TeRanEX wrote on January 24th, 2005 at 9:35 pm

    hmm.. i meant xmlhttprequest ofcourse :oops:…

  3. rakaz wrote on January 24th, 2005 at 10:04 pm

    XmlHttpRequest won’t help in those cases. Even when using XmlHttpRequest the actual detection goes through the server, because the XmlHttpRequest object is limited to retrieving data from the same domain as the webpage. What I currently do is use XmlHttpRequest to call action.php with the proper parameters, including the URL of a link. The plugin then opens a connection to the external server and does the autodetection. The plugin then sends a small bit of Javascript code back tot he XmlHttpRequest object, which will be evaluated.

  4. jess wrote on January 24th, 2005 at 11:46 pm

    This sounds great! I just started my own Nucleus blog, and even before reading this article I had downloaded the CVS version of the plugin and have been testing it out. Looking forward to seeing your changes implemented!

  5. Hello..and you are? wrote on January 24th, 2005 at 11:53 pm

    Rakaz posts that he will be working on updates to the NP_Trackback plugin for Nucleus. Looks like some great changes! Should make things snappier and more efficient when using auto-discovery.


  6. jess wrote on January 25th, 2005 at 12:01 am

    Interesting. I posted an entry on my site with a trackback to this entry and some links to other pages that you have in this post. After posting the entry on my site, I can’t pull it back up to edit it. I wonder if that is related to the changes you are looking to make..

  7. rakaz wrote on January 25th, 2005 at 6:11 pm

    I’ve uploaded a test version of the modified Trackback plugin. All the changed listed above are working quit stable.

    I’m also working on creating a complete administration section for Trackbacks, including the ability edit the templates.

  8. jess wrote on January 26th, 2005 at 1:06 am

    That’s awesome. I know I’m looking forward to all your changes including the admin section.

  9. Roel wrote on January 31st, 2005 at 11:38 pm

    I want to do an ‘omkat’, and after that I am definitely going to install this plugin :)

    Btw, Rakaz, what do you think about the thinking we did on improvements to the usability of Nucleus?

  10. anand wrote on February 1st, 2005 at 10:23 am

    Great job, Rakaz!

    One possible improvement the trackback plugin can have is to merge trackback and comments in one single chronological listing ..

  11. stefan wrote on February 1st, 2005 at 10:39 am

    I am just looking for some installation docs? the zip doesn’t really list anything. how do I add the trackback url to my posts? I tried using the link you have on this post, but there is no action.php in my nucleus…

  12. ezhuthapurangal wrote on February 1st, 2005 at 10:39 am

    I am still very much alive. These days, time is mostly spent in excel sheets and microsoft project documents :(

    Took a few photographs during my trip to trivandrum. One of my personal favourites…

  13. rakaz wrote on February 1st, 2005 at 12:16 pm

    Stefan: There are no installation instructions, because at this time, the plugin is still in a testing stage. Also, this plugin is not a completely new plugin, but a modification of an already existing plugin. Information about that plugin can be found here: http://plugins.nucleuscms.o

  14. admun wrote on February 2nd, 2005 at 4:50 pm

    good stuff! I keep trying to start working on a new revision but yet to fine time (… I’m so guilty…)


  15. admun wrote on February 2nd, 2005 at 5:25 pm

    BTW, I was plaaning to work NP_Trackback, maybe I will shared here a list of
    problems found/todo (hints to radaz, maybe you can help with some of them?? 8)

    * %image(20040529-sandcastle.jpg |82|98|sandcastle)%> – this is included into
    a description, perharps you should make a regexp and filter out all Nucleus
    image and popup pseudo tags, as it will not look good on other web
    * article URL for type=pingform is created like http://localhost/blog//item/36 9
    – notice double URLs after /blog//item
    * for pingformlink and manualpingform link, I believe this should NOT echo only
    raw URL, rather echo complete link only for admins:
    global $member;
    if ($member->isAdmin() && $member->isLoggedIn())
    echo " – getPingFormLink($tb_id)." ‘>TB

    * same applies for manualpingformlink:
    global $member;
    if ($member->isAdmin() && $member->isLoggedIn())
    echo " – getManualPingFormLink($tb_id). "’>TB

    * <%TrackBack(tbcode)%> does not seem to insert any RDF anymore, while
    <%TrackBack(code)%> does http://forum.nucleuscms.org/vi

    * encoding is sometimes set to UTF-8, sometimes to ISO-8859-1!, completely
    ignoring BLOG OWN encoding! (rssResponse vs. xmlResponse)

    * this should go FINALLY into plugin options, to allow local languages mods
    without going into plugin code:
    function init() {
    $this->template = array(
    ‘LIST_HEADER’ => ‘

    * i guess there should be around trackback autodiscovery RDF code??
    * what is the difference (and purpose) between <%TrackBack(tbcode)%> and
    <%TrackBack(code)%>, except that "tbcode" is missing
    description and date?
    * it would be nice to include RSS feed of latest 10 TrackBacks.. See e.g.
    NP_CommentControl or NP_RSSBlog for RSS feeds I have created for "pending
    comments" and "last 20 comments"
    * a suggestion: automatic discovery of trackback links is great (on item edit)
    but please exclude files with extension avi, mpg, mp3, … from this
    * "AD in progress please wait…" window/message
    * verbose mode in count mode

    These are extracted from the forum thread on TB 1.5.


  16. admun wrote on February 2nd, 2005 at 5:26 pm

    and then some more…. sorry.

    * – when error on sending ping, return error message instead of "an error occurred"
    * – not possible in Nucleus (maybe later):
    * + move templates to plugin-options
    * + optional deletion of plugin table on uninstal
    * – rel="nofollow"
    * – admin menu to show list of trackback

  17. admun wrote on February 2nd, 2005 at 5:47 pm

    I open a new thread on the forum for this beta version. http://forum.nucleuscms.org


  18. TeRanEX wrote on February 3rd, 2005 at 11:25 pm

    Rakaz, I installed your version but i had/have two problems with it:
    * (already know i think): in the RDF code the rdf:about and dc:identifier evaluate to ‘/weblog/item/87′, instead of the full url. This is because createItemLink uses $CONF['ItemURL'], which uses $CONF['Self']. By default this is set to ‘index.php’. This can be solved by changing $CONF['Self'] to the full url of the blog, *or* by adding echo ‘http://’,$_SERVER['HTTP_HOST'],createItemLink(…); (at least this works for me)
    * when i ping one of my own items the ping is accepted, but it does not accept the content, so i only see [geen titel] etc. See an example at http://budts.be/weblog/item… (and yes, my testitems both contained a title and a body ;))

  19. rakaz wrote on February 3rd, 2005 at 11:53 pm

    TeRanEX: I had already noticed the missing content bug earlier today. Haven’t found a solution yet, but I’ll take a look at it.

    The other behavoir is different from what I see here, but I’ll take also take a look at it.

  20. rakaz wrote on February 9th, 2005 at 3:36 pm

    I’ve created a new story to track the development of the Trackback plugin: http://www.rakaz.nl/nucleus

  21. TheMM or us? wrote on February 12th, 2005 at 10:34 am

    dank :=)rakaz gibt es auf dieser seite jetzt wieder trackbacks (diesmal in einigermassen spamsicher) und einen feinen aggregated newsfeed auf der linken seite. jedem Nucleus blogger kann ich die ve…