How to add trackback to your rendered output

a picture of myself

Münsterland.org

PyCS is now able to do trackback. I am currently playing around with Python Desktop Server to get it to render trackback links. A description of how to do it follows.

ATTENTION: This is only needed for version 0.4.20. With version 0.4.21, trackback client support for use with Python Community Server is automatic, so you don't need to patch your themes! I leave this story up, so you can see how to do patches and changes, if you need to.

There are two nuggets you need to create:

You need to call them like the commentsScript and weblogCommentsLink macros in your WeblogRendering.tmpl. Change your WeblogRendering.tmpl as follows:

$macros.commentsScript()
$nuggets.trackbackScript()
<table border=0 width="100%">
#set lastdate = ''
#if $year and $month and $day
#set list = $current.getRecentPosts(year=$year, month=$month, day=$day, onhome=$onhome, category=$category)
#elif $year and $month
#set list = $current.getRecentPosts(year=$year, month=$month, onhome=$onhome, category=$category)
#else
#set list = $current.getRecentPosts(onhome=$onhome, category=$category)
#end if
#for $post in $list
#if $post.pubdate != $lastdate
#if $lastdate
</table>
</td></tr>
<tr><td>&nbsp;</td></tr>
#end if
<tr><td class="whitebox" colspan=2>
<table width="100%">
<tr><td><a href="$current.getCloudUrlForDay($post.pubtime,category=$category)">$post.pubdate</a></td></tr>
#set $lastdate = $post.pubdate
#else
<tr><td>&nbsp;</td></tr>
#end if
#if $post.title
<tr>
#if $post.link
<td><h3><a name="$post.id"></a><a href="$post.link">$post.title</a></h3></td>
#else
<td><h3><a name="$post.id"></a>$post.title</h3></td>
#end if
</tr>
#end if
<tr>
<td>
#if not($post.title)
<a name="$post.id"></a>
#end if
#if $post.rendered
$post.rendered</td>
#else
$post.text</td>
#end if
</tr>
#if $post.source
<tr><td colspan=2 align="right" class="smallfont">$_('Source:')
#if $post.sourceurl
<a target="_new" href="$post.sourceurl">$post.source</a>
#else
$post.source
#end if
</td></tr>
#end if
<tr><td align="left">
<span class="smallfont">
$_('posted at') $macros.Time($post.pubtime)
&nbsp;&nbsp;
$macros.weblogPermaLink($post.id, $post.pubtime, $category)
&nbsp;&nbsp;
$macros.weblogCommentsLink($post.id, $post.pubtime, $category)
&nbsp;&nbsp;
$nuggets.trackbackLink(id=$post.id)
</span>
</td></tr>
#end for
#if $lastdate
</table>
</td></tr>
#end if
</table>

click here to download file

If you want to have trackback links in your RSS feed, you can change your RSSFeedRendering.tmpl as follows:

<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
<channel>
<title>$current.getRSSTitle(category=$category)</title>
<link>$current.getStaticUrl(category=$category)</link>
<description>$current.getRSSDescription(category=$category)</description>
<language>$_PyDS.language</language>
<copyright>$_('Copyright') $request.year $prefs.getXML('private', 'name')</copyright>
<lastBuildDate>$current.getRSSNewestDate(category=$category)</lastBuildDate>
<generator>$tools.version</generator>
<managingEditor>$prefs.getXML('private','email')</managingEditor>
<webMaster>$prefs.getXML('private','email')</webMaster>
<category domain="http://www.weblogs.com/rssUpdates/changes.xml">rssUpdates</category>
#set $skipHours = $current.getRSSSkipHours(category=$category)
#if $skipHours
<skipHours>
#for $hour in $skipHours
<hour>$hour</hour>
#end for
</skipHours>
#end if
#for $item in $current.getRSSItems(category=$category)
<item>
#if $item.title
<title>$item.title</title>
#end if
#if $item.link
<link>$item.link</link>
#end if
<description>$item.description</description>
<guid>$item.guid</guid>
#if $item.comments
<comments>$macros.quoteXML($item.comments)</comments>
#end if
#if $current.name in ('weblog',)
#set $tburl = $macros.unquoteXML($item.comments.replace('comments.py','trackback.py'))
#set $tburl = $tburl[:$tburl.rfind('&link=')]
<trackback:ping rdf:resource="$macros.quoteXML($tburl)"/>
#end if
<pubDate>$item.pubdate</pubDate>
#if $item.source and $item.sourceurl
<source url="$item.sourceurl">$item.source</source>
#end if
</item>
#end for
</channel>
</rss>

click here to download file

last change 2003-04-11 14:09:36

April 2003
MoTuWeThFrSaSu
  1 2 3 4 5 6
7 8 910111213
14151617181920
21222324252627
282930    
Mar
2003
 May
2003

How to set up your PyDS to render trackback links. This can be used when your community server is a python community server. This is only needed for version 0.4.20!


(Donations will be used by the author to buy stuff, fullfill selfish wishes or do other silly recreational things. You have been warned.).
The PyDS is
OSI Certified Open Source Software

Python Powered

XML-Image

© 2003-2007, Georg Bauer