When publishing an entry, everything seems to work fine, the answer is a 204. But the hub don't find any debug-information to any of my feeds.
My changes: The funtions_entry.inc.php and this publisher, which is modified (without php5-parts, as far as I can tell), and of course changes to the feeds.
Here the diffs to get a better overview:
Code: Select all
diff -Nur serendipity-nightly/include/functions_entries.inc.php functions_entries.inc.txt
--- serendipity-nightly/include/functions_entries.inc.php 2009-11-25 21:41:43.000000000 +0100
+++ functions_entries.inc.txt 2010-01-18 17:09:16.000000000 +0100
@@ -1400,6 +1400,24 @@
// Now that plugins are executed, we go ahead into the Temple of Doom and send possibly failing trackbacks.
// First, original list of references is restored (inside the function call)
serendipity_handle_references($entry['id'], $serendipity['blogTitle'], $drafted_entry['title'], $drafted_entry['body'] . $drafted_entry['extended'], false);
+ include_once 'publisher.php';
+ $hub_url = 'http://pubsubhubbub.appspot.com/';
+ $topic_url = array();
+ $topic_url[] = $serendipity['baseURL'] . serendipity_rewriteURL(PATH_FEEDS .'/index.rss2', 'serendipityHTTPPath');
+ $topic_url[] = $serendipity['baseURL'] . serendipity_rewriteURL(PATH_FEEDS .'/atom10.xml', 'serendipityHTTPPath');
+
+ foreach($categories as $category) {
+ #entries without a category don't belong to a category-feed
+ if ($category > 0) {
+ $topic_url[] = $serendipity['baseURL'] . serendipity_feedCategoryURL($category, 'serendipityHTTPPath');
+ }
+ }
+ $p = new Publisher($hub_url);
+ if (! $p->publish_update($topic_url)) {
+ echo "Publishing to hub failed!";
+ print_r($p->last_response());
+ }
+
}
return (int)$entry['id'];
Code: Select all
cat /var/www/bundled-libs/publisher.php
<?php
// a PHP client library for pubsubhubbub
// as defined at http://code.google.com/p/pubsubhubbub/
// original written by Josh Fraser | joshfraser.com | josh@eventvue.com
// Released under Apache License 2.0
class Publisher {
var $hub_url;
var $last_response;
// create a new Publisher
function __construct($hub_url) {
if (!isset($hub_url))
throw new Exception('Please specify a hub url');
if (!preg_match("|^https?://|i",$hub_url))
throw new Exception('The specified hub url does not appear to be valid: '.$hub_url);
$this->hub_url = $hub_url;
}
// accepts either a single url or an array of urls
function publish_update($topic_urls, $http_function = false) {
if (!isset($topic_urls))
throw new Exception('Please specify a topic url');
// check that we're working with an array
if (!is_array($topic_urls)) {
$topic_urls = array($topic_urls);
}
// check each topic url
foreach ($topic_urls as $topic_url) {
// lightweight check that we're actually working w/ a valid url
if (!preg_match("|^https?://|i",$topic_url))
throw new Exception('The specified topic url does not appear to be valid: '.$topic_url);
}
return $this->http_post($this->hub_url, $topic_urls);
}
// returns any error message from the latest request
function last_response() {
return $this->last_response;
}
// default http function that uses curl to post to the hub endpoint
private function http_post($url, $topic_urls) {
@include_once 'HTTP/Request.php';
if (!class_exists('HTTP_Request')) {
return false;
}
$sender = &new HTTP_Request($url);
$sender->setMethod(HTTP_REQUEST_METHOD_POST);
$sender->addPostData('hub.mode', 'publish');
foreach ($topic_urls as $topic_url) {
$sender->addPostData('hub.url', $topic_url);
}
$sender->addHeader('hub', 'application/x-www-form-urlencoded');
$sender->sendRequest();
$this->last_response = $sender->getResponseBody();
if ($sender->getResponseCode() == 204) {
return true;
}
return false;
}
}
?>
Code: Select all
diff -Nur serendipity-nightly/templates/default/feed_2.0.tpl /var/www/templates/default/feed_2.0.tpl
--- serendipity-nightly/templates/default/feed_2.0.tpl 2006-07-25 11:42:28.000000000 +0200
+++ /var/www/templates/default/feed_2.0.tpl 2010-01-15 15:03:31.000000000 +0100
@@ -9,6 +9,7 @@
xmlns:content="http://purl.org/rss/1.0/modules/content/"
{$namespace_display_dat}>
<channel>
+ <atom:link rel="hub" href="http://pubsubhubbub.appspot.com/" xmlns:atom="http://www.w3.org/2005/Atom" />
<title>{$metadata.title}</title>
<link>{$metadata.link}</link>
<description>{$metadata.description}</description>
Code: Select all
diff -Nur serendipity-nightly/templates/default/feed_atom1.0.tpl /var/www/templates/default/feed_atom1.0.tpl
--- serendipity-nightly/templates/default/feed_atom1.0.tpl 2008-03-17 15:34:16.000000000 +0100
+++ /var/www/templates/default/feed_atom1.0.tpl 2010-01-15 15:17:51.000000000 +0100
@@ -9,6 +9,7 @@
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/">
<link href="{$self_url}" rel="self" title="{$metadata.title}" type="application/atom+xml" />
+ <link rel="hub" href="http://pubsubhubbub.appspot.com/" />
<link href="{$serendipityBaseURL}" rel="alternate" title="{$metadata.title}" type="text/html" />
<link href="{$serendipityBaseURL}rss.php?version=2.0" rel="alternate" title="{$metadata.title}" type="application/rss+xml" />
<title type="html">{$metadata.title}</title>