Pingback and Trackback are two different types of linkback methods, whereby one site can tell another that a link has been made between them. Bloge-Linkback allows PmWiki to automatically handle both types of messages both as a client and as a server.
The recipe has two parts that may be used completely separately from each other.
Bloge-Linkback is a part of Cookbook.Bloge, but may also be used as a standalone recipe.
- download bloge-linkback-client.phpΔ and bloge-linkback-server.phpΔ to your cookbook directory
- add the following lines to a configuration file:
if ($action=='edit') include_once("$FarmD/cookbook/bloge-linkback-client.php"); include_once("$FarmD/cookbook/bloge-linkback-server.php");
Both files may be included in common or per-page/group customization files independently of each other.
The client part of the recipe is triggered when a page is edited and then published (drafts and 'Save and edit' are ignored), in which case the lines that have been changed in the edit are parsed for external links. In other words, internal links and links in unchanged blocks are ignored.
For each link, the actual URL is determined (ie. intermap links are properly processed) and matched against some filter conditions. If it passes, the target is scanned for Pingback and Trackback server autodiscovery. If either is found, the corresponding protocol is used to tell that server that a link has been made.
The actions of the client are logged on the page
Site.LinkbackClientLog (configurable as
$LinkbackClientLogPage). The filter conditions are an array of rules
$LinkbackClientFilterSites in the style of MatchPageNames. By default links to the current domain, pmwiki.org and Wikipedia are excluded.
The server has two functions: first, it adds Pingback and/or Trackback autodiscovery strings to the page, and second, it handles any incoming link announcements. The autodiscovery may be disabled by setting
$LinkbackHeader['pingback'] = 0; and/or
$LinkbackHeader['trackback'] = 0;.
Some sanity checks are made when a linkback request is received, such as verifying that the requesting site has the same IP address as the claimed source, that the source exists, and that the source actually contains a link to the target. Also, setting
$EnableLinkbackBlocklist true will allow blocklists to be used; a value of at least 10 will get PmWiki to update the lists from chongqed.org and MoinMaster.
On a successful linkback reception the linkback is added to the page
Site.Linkbacks (configurable as
$LinkbackPage) using the markup defined in
$LinkbackMarkup. The default markup has been set up so that the directive:
on a page will result in an empty string if no linkbacks have been made and with the following markup if such do exist:
[[#Cookbook--Bloge-Linkback]] !!! Linkbacks * http://example.com/blog/2009-08-09-new-blog-post (2009-08-09 13.43) * http://example.org/wiki/Group/InterestingPages (2009-08-13 00.28)
Group--Name to represent a page is required as PmWiki by default doesn't allow dots in anchor names but does allow hyphens; this should not cause any conflicts as page names can't start or end with a hyphen, or contain two adjacent hyphens.
Markup escaped using
[=...=] will still get parsed for external links. This is a result of only handling the changed portion of each page, and potentially missing some links due to disjoint edits. This and a few other issues could be fixed by properly keeping track of successful linkback announcements.
The Trackback protocol supports a few data fields that are not used by Bloge-Linkback. To add or set these in the client you'll need to modify the source at the commented lines of LinkbackPingLinks().
The Trackback autodiscovery
<rdf> tag does not follow the specifications, which call for a much longer and valid description. However, all of the Trackback autodiscovery parsers that I could find (Drupal, Movable Type and Pligg) will read this just fine. If you can point me at something that should but won't handle it I might try and fix it.
As a whole this recipe has functionality very close to that of Cookbook.Pingback. The differences come meinly from handling Trackback as well as Pingback, and not requiring a whole slew of PEAR extensions. The only dependency the recipe has is for cURL; it would be possible to get the whole thing to work using a more common library, but to be honest I couldn't be bothered.
To customize the format of
Site.Linkbacks you'll need to inspect the server's source and see what happens near the end of the LinkbackExecute() function.
For some reason the
Site.LinkbackClientLog file ends up with no group write permissions at least with my server. This is probably an odd side result of it being created in a function called using register_shutdown_function; the same thing happens with
- Cookbook.Bloge — A bundle of blogging
- Cookbook.Pingback — Pingback - Pingback support for PmWiki
- Cookbook.Bloge-Ping — Notify search engines when a page is modified
See discussion at Bloge-Linkback-Talk