about search post article Documentation Mailing Lists Bug Tracking Development Installation Upgrading Download admin rdf |
from the not-that-kinda-ping dept. Last year, the authors of MovableType (a popular CMS oriented to weblogs) came up with the concept of trackback: "[...] it's a way of recording who has linked to your posts and notifying others that you've linked to them" (from hitormiss.org) This article aims to describe a basic implementation of trackback for Squishdot-powered weblogs. Trackback pings Suppose you wrote an article in your Squishdot based site. Another weblogger read the piece and posted a link to it on her weblog along with some related comments. Here is where trackback enters: in addition to linking to your article, she could ping it. That way, you and your readers would know that another person wrote something about the topic of your posting. Then, trackback, in addition to traditional HTML linking, is another way of communication between weblogs. The Trackback Development weblog at movabletype.org could serve as a working example of this. ImplementationAny trackback-enabled weblog system should be able to:
A trackback ping is just an HTTP POST request to a given URL. According to the official specification, the POSTed variables should be:
Every posting must provide an URL to receive pings. If the Squishdot site is at http://www.example.com/, this URL will be of the form: For storing pings, we will use the ubiquitous TinyTablePlus product from Endicor and Shane Hathaway. First of all, create a Folder named trackback in the Squishdot root. This will contain the instance of TinyTablePlus and another scripts. Then create an instance of TinyTablePlus and name it trackbackStore. Type the following in the Columns text field: id:int post_id:int url title excerpt blog_name added:datetime Pings will come from Anonymous requests, so anonymous users must be allowed to query the table for both reading and writing. Go to the Security tab of the trackbackStore object and check the boxes in the Anonymous column for "Change TinyTable" and "Query TinyTable Data" permissions. Go back to your sites root folder and create a new instance of "Script (Python)". Name it tb. This script will be responsible of receiving the trackback ping, checking the POSTed variables and creating a new row in trackback.trackbackStore if everything is correct. tb (Python Script): request = container.REQUEST # ID of pinged posting post_id = int(context.id) # POSTed variables dictionary tbargs = {} tbargs['blog_name'] = "" tbargs['title'] = "" tbargs['excerpt'] = "" try: tbargs['url'] = getattr(request,"url") except: print context.trackback.responseXML(1,"URL is missing") return printed if hasattr(request, "blog_name"): tbargs['blog_name'] = getattr(request, "blog_name") if hasattr(request, "title"): tbargs['title'] = getattr(request, "title") if hasattr(request, "excerpt"): tbargs['excerpt'] = getattr(request, "excerpt") # Store the ping context.trackback.trackbackStore.setRow(id = len(context.trackback.trackbackStore())+ 1, post_id = post_id, url = tbargs['url'], title = tbargs['title'], excerpt = tbargs['excerpt'], blog_name = tbargs['blog_name'], added = context.ZopeTime()) print context.trackback.responseXML(0,"") return printed # ---- * ---- As you may have noticed, this script uses something we havent defined yet: context.trackback.responseXML(). That object (a Python Script) will generate the response for the received ping. Ping responses are a little chunk of XML. If weve received a "correct" ping, the response will be:
If theres any error, for instance omitting the url variable, this will be the answer:
Create an instance of "Script (Python)" inside the trackback folder you created and name it 'responseXML'. This script must accept two input parameters: errorCode and errorMsg. responseXML (Python Script): container.REQUEST.RESPONSE.setHeader('Content-Type','text/xml') resp = '\n' resp += 'Displaying pings In this section well see how to retrieve and display stored pings for a given post. Each Squishdot site has a particular visual appearance, so the following examples just suggest how to show the data. This DTML snippet will list how many trackback pings were received by each of the postings returned by item_list (a list containing the newest postings, provided by the Squishdot API):
If we want to actually fetch and display the list of pings that a given posting has received, we can write something like this: (let postID be the actual ID of a particular posting)
Actually, you cant send trackback pings directly from Squishdot. But you can use Matt Croydon's Trackback library (http://www.postneo.com/projects/tblib/). Final RemarksI wrote this scripts to give my weblog (http://jazzido.freezope.org) trackback support. < | >
|
|
|||||||||||
|