From b0e7e2e123079a2e68924cfb90d19c44571b1f65 Mon Sep 17 00:00:00 2001 From: joey Date: Tue, 27 Jun 2006 01:13:03 +0000 Subject: [PATCH] * Support pinging services such as Technorati using XML-RPC to notify them about changes to rss feeds. --- IkiWiki.pm | 1 + IkiWiki/Plugin/inline.pm | 38 +++++++++++++++++++++++++++++++++++++- debian/changelog | 4 +++- debian/control | 2 +- doc/ikiwiki.setup | 2 ++ doc/install.mdwn | 8 ++++---- doc/todo/plugin.mdwn | 1 - doc/usage.mdwn | 11 ++++++++++- ikiwiki | 3 +++ 9 files changed, 61 insertions(+), 9 deletions(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index 76472302e..a2af406a9 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -36,6 +36,7 @@ sub defaultconfig () { #{{{ svnpath => "trunk", srcdir => undef, destdir => undef, + pingurl => [], templatedir => "/usr/share/ikiwiki/templates", underlaydir => "/usr/share/ikiwiki/basewiki", setup => undef, diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 9a86aad0b..6bcd59a9f 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -9,12 +9,19 @@ use IkiWiki; sub import { #{{{ IkiWiki::hook(type => "preprocess", id => "inline", call => \&IkiWiki::preprocess_inline); + # Hook to change to do pinging since it's called late. + # This ensures each page only pings once and prevents slow + # pings interrupting page builds. + IkiWiki::hook(type => "change", id => "inline", + call => \&IkiWiki::pingurl); } # }}} # Back to ikiwiki namespace for the rest, this code is very much # internal to ikiwiki even though it's separated into a plugin. package IkiWiki; - + +my %toping; + sub preprocess_inline (@) { #{{{ my %params=@_; @@ -72,6 +79,7 @@ sub preprocess_inline (@) { #{{{ if ($config{rss}) { writefile(rsspage($params{page}), $config{destdir}, genrss($params{page}, @pages)); + $toping{$params{page}}=1; } return $ret; @@ -160,4 +168,32 @@ sub genrss ($@) { #{{{ return $template->output; } #}}} +sub pingurl (@) { #{{{ + return unless $config{pingurl} && %toping; + + eval q{require RPC::XML::Client}; + if ($@) { + debug("RPC::XML::Client not found, not pinging"); + } + + foreach my $page (keys %toping) { + my $title=pagetitle(basename($page)); + my $url="$config{url}/".htmlpage($page); + foreach my $pingurl (@{$config{pingurl}}) { + my $client = RPC::XML::Client->new($pingurl); + my $req = RPC::XML::request->new('weblogUpdates.ping', + $title, $url); + debug("Pinging $pingurl for $page"); + my $res = $client->send_request($req); + if (! ref $res) { + debug("Did not receive response to ping"); + } + my $r=$res->value; + if (! exists $r->{flerror} || $r->{flerror}) { + debug("Ping rejected: ".$r->{message}); + } + } + } +} #}}} + 1 diff --git a/debian/changelog b/debian/changelog index c1bd99da5..974d3c4b6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,8 +2,10 @@ ikiwiki (1.8) UNRELEASED; urgency=low * Fix orphans plugin to not count a link to a nonexistant page as a reason for a page not being an orphan. + * Support pinging services such as Technorati using XML-RPC to notify them + about changes to rss feeds. - -- Joey Hess Sun, 25 Jun 2006 03:20:48 -0400 + -- Joey Hess Mon, 26 Jun 2006 20:41:45 -0400 ikiwiki (1.7) unstable; urgency=low diff --git a/debian/control b/debian/control index 1e327c55c..364c80aed 100644 --- a/debian/control +++ b/debian/control @@ -10,7 +10,7 @@ Package: ikiwiki Architecture: all Depends: ${perl:Depends}, markdown, libtimedate-perl, libhtml-template-perl, libhtml-scrubber-perl, libcgi-formbuilder-perl (>= 3.02.02), libtime-duration-perl, libcgi-session-perl, libmail-sendmail-perl, gcc | c-compiler, libc6-dev | libc-dev Recommends: subversion | git-core, hyperestraier -Suggests: viewcvs +Suggests: viewcvs, librpc-xml-perl Description: a wiki compiler ikiwiki converts a directory full of wiki pages into html pages suitable for publishing on a website. Unlike many wikis, ikiwiki does not have its diff --git a/doc/ikiwiki.setup b/doc/ikiwiki.setup index 4299a64f6..f13bab8c1 100644 --- a/doc/ikiwiki.setup +++ b/doc/ikiwiki.setup @@ -63,6 +63,8 @@ use IkiWiki::Setup::Standard { #anonok => 1, # Generate rss feeds for pages? rss => 1, + # Urls to ping with XML-RPC when rss feeds are updated + #pingurl => [qw{http://rpc.technorati.com/rpc/ping}], # Include discussion links on all pages? discussion => 1, # Time format (for strftime) diff --git a/doc/install.mdwn b/doc/install.mdwn index 003da0ec7..0aa55fb0b 100644 --- a/doc/install.mdwn +++ b/doc/install.mdwn @@ -1,9 +1,9 @@ The easiest way to install ikiwiki is using the Debian package. Ikiwiki requires [[MarkDown]] be installed, and also uses the following -perl modules: `CGI::Session` `CGI::FormBuilder` (version 3.02.02 or -newer) `HTML::Template` `Mail::SendMail` `Time::Duration` `Date::Parse` -(libtimedate-perl), `HTML::Scrubber` +perl modules if available: `CGI::Session` `CGI::FormBuilder` (version +3.02.02 or newer) `HTML::Template` `Mail::SendMail` `Time::Duration` +`Date::Parse` (libtimedate-perl), `HTML::Scrubber`, `RPC::XML` If you want to install from the tarball, you should make sure that the required perl modules are installed, then run: @@ -11,4 +11,4 @@ If you want to install from the tarball, you should make sure that the required make make install -See [[download]] for where to get it. \ No newline at end of file +See [[download]] for where to get it. diff --git a/doc/todo/plugin.mdwn b/doc/todo/plugin.mdwn index 03183d119..6e19c7942 100644 --- a/doc/todo/plugin.mdwn +++ b/doc/todo/plugin.mdwn @@ -36,5 +36,4 @@ Suggestions of ideas for plugins: All the kinds of plugins that blogging software has is also a possibility: * Blog post calendar -* technocrati pinger * Tag stuff? diff --git a/doc/usage.mdwn b/doc/usage.mdwn index eec1856a7..deb94e415 100644 --- a/doc/usage.mdwn +++ b/doc/usage.mdwn @@ -128,7 +128,16 @@ These options configure the wiki. If rss is set, ikiwiki will generate rss feeds for pages that inline a [[blog]]. -* --url http://url/ +* --pingurl url + + Set this to the url to an XML-RPC service to ping when an RSS feed is + updated. For example, to ping Technorati, use the url + http://rpc.technorati.com/rpc/ping + + This parameter can be specified multiple times to specify more than one + url to ping. + +* --url url Specifies the url to the wiki. This is a required parameter in [[CGI]] mode. diff --git a/ikiwiki b/ikiwiki index e6c2567ba..f32eb4879 100755 --- a/ikiwiki +++ b/ikiwiki @@ -59,6 +59,9 @@ sub getconfig () { #{{{ "disable-plugin=s@" => sub { $config{plugin}=[grep { $_ ne $_[1] } @{$config{plugin}} ]; }, + "pingurl" => sub { + push @{$config{pingurl}}, $_[1]; + } ) || usage(); if (! $config{setup}) { -- 2.44.0