TBPY

| | Comments (0)

TBPY by Mark Paschal <markpasc@markpasc.org>

tbpy.txt

TBPY is a Trackback server CGI for the rest of your site. Rather than accepting pings for numbered weblog entries, it accepts pings for pages of your static or dynamically generated web site. Invoke TBPY through SSI to include your pages' Trackbacks and the appropriate RDF for automatic Trackback discovery, or include the RDF (static) and Trackbacks (through RSS files) yourself.

URLs ending in index.html are taken to be the same as those missing. If your pages end in .php, you'll have to modify the code.

Installing

  • Get the CGI script.
  • Install the CGI script somewhere it will run (eg: ~/public_html/trackback/tbpy.cgi). Create a data directory below its directory (eg: ~/public_html/trackback/data), with permissions such that your web server can create files there.
  • Configure as described below.

Configuring

To insert the RDF and Trackbacks for the including page with SSI, call the script with include virtual:

<!--#include virtual="/trackback/tbpy.cgi"-->

If you don't have or want to use SSI, insert the appropriate RDF yourself. It looks like this:

<!-- <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"> <rdf:Description rdf:about="URI for this page" dc:identifer="URI for this page" trackback:ping="http://www.foo.com/tb.cgi/5" /> </rdf:RDF> -->

The Trackbacks will be written as RSS 0.91 in .xml files in your data directory, with the absolute URL of the page--slashes and periods replaced with underscores--for the filename. For example, Trackbacks for markpasc.org/code/tbpy/ are saved as code_tbpy_.xml.

When inserting with SSI, TBPY reads an HTML template from the template.html file in the tbpy.cgi script's directory. The first line should be a block header, the last a block footer, and the lines in the middle are repeated for each Trackback. Variables will be replaced in the standard Python % dictionary manner. The term will be replaced with an HTML comment if for some reason the value is not present.

For example, if you don't give a template.html file, TBPY will pretend the file reads:

<div class='tb'><h4>Trackbacks (<a href='%(dataUri)s'>RSS</a>)</h4> <h5><a href='%(link)s'>%(title)s</a></h5> <p>%(description)s</p> <p class='about'>by %(blogName)s at %(date)s</p> </div>

The variables available in the header and footer are:

resourceUri
The absolute URL of the page.
tbUri
The absolute URI to ping, to add a Trackback to the page.
dataUri
The absolute URL of the data RSS file for this page.
title
The title for this page.
description
The description for this page.

A default title ("Trackback for url") and description ("Pages and weblog entries that linked to url") are assigned originally. You can set your own by editing the RSS data file for a given page.

The variables for the individual Trackbacks are:

title
The title of the entry or page linking to the page, as provided in the Trackback ping.
link
The provided backlink URL.
description
The provided excerpt of the entry linking to the page.
blogName
The provided name of the site that sent the ping.
date
When the ping was sent, in YYYY-MM-HHThh:mmZ format.

To-do

  • Recognize index.* as instead of just index.html.

Leave a comment

About this Entry

This page contains a single entry by markpasc published on February 22, 2006 10:16 PM.

POT.py was the previous entry in this blog.

Bubble tip toaster is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Categories

Tag Cloud