* Support pinging services such as Technorati using XML-RPC to notify them
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Tue, 27 Jun 2006 01:13:03 +0000 (01:13 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Tue, 27 Jun 2006 01:13:03 +0000 (01:13 +0000)
  about changes to rss feeds.

IkiWiki.pm
IkiWiki/Plugin/inline.pm
debian/changelog
debian/control
doc/ikiwiki.setup
doc/install.mdwn
doc/todo/plugin.mdwn
doc/usage.mdwn
ikiwiki

index 76472302e12a9bce6c3989e90969399184a9cafd..a2af406a93a692bdc5743b31e95248804521907f 100644 (file)
@@ -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,
index 9a86aad0bfa4ad7bb8588abf984fc24032f4c349..6bcd59a9fa90ad16c7896de2e2cf61843cf7804f 100644 (file)
@@ -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
index c1bd99da5fa68efce2fe107a71070ac4429e0127..974d3c4b689bb543bfb40b0218913e4f7c5ab26b 100644 (file)
@@ -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 <joeyh@debian.org>  Sun, 25 Jun 2006 03:20:48 -0400
+ -- Joey Hess <joeyh@debian.org>  Mon, 26 Jun 2006 20:41:45 -0400
 
 ikiwiki (1.7) unstable; urgency=low
 
index 1e327c55cca0359f8c77ab6f0bb46e2ab1cda1ac..364c80aedface03a94288c58a0bbe85760098e40 100644 (file)
@@ -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
index 4299a64f6542e0b1c54aa76635df03a678201e50..f13bab8c14b440f78ff27afaa1384d62f8c4e248 100644 (file)
@@ -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)
index 003da0ec712e7aafd074378411187c2d2f018c8e..0aa55fb0b7e9204cc35e547bcc90c53077b3cc3a 100644 (file)
@@ -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.
index 03183d1193b1ba843d7faf526fbe1739d875e896..6e19c7942d1c9ff097eca1b678f3986b472bde16 100644 (file)
@@ -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?
index eec1856a7dfd4c710beb63c709cdeb0ab1724ad6..deb94e415c4214f09c6ceadbf3b1d4c1730f3cdb 100644 (file)
@@ -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 e6c2567baa42ce08e417b3fb2bd2c61b23172999..f32eb4879494861815af296e979377573a1e3d0c 100755 (executable)
--- 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}) {