diff options
author | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2006-06-27 01:13:03 +0000 |
---|---|---|
committer | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2006-06-27 01:13:03 +0000 |
commit | b0e7e2e123079a2e68924cfb90d19c44571b1f65 (patch) | |
tree | 8e6d5ae414e292f4ef564838a3b23858792a63a2 /IkiWiki | |
parent | c0ce99f77c73c4bc616d134151d0145a6b98faea (diff) | |
download | ikiwiki-b0e7e2e123079a2e68924cfb90d19c44571b1f65.tar ikiwiki-b0e7e2e123079a2e68924cfb90d19c44571b1f65.tar.gz |
* Support pinging services such as Technorati using XML-RPC to notify them
about changes to rss feeds.
Diffstat (limited to 'IkiWiki')
-rw-r--r-- | IkiWiki/Plugin/inline.pm | 38 |
1 files changed, 37 insertions, 1 deletions
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 |