Henry Lyne (henrylyne) wrote in changelog,
Henry Lyne
henrylyne
changelog

[livejournal] r15634: PubSubHubbub Pinging support.

Committer: henrylyne
PubSubHubbub Pinging support.

Courtesy of brad

A   trunk/bin/worker/ping-hubbub
U   trunk/cgi-bin/ljfeed.pl
U   trunk/cgi-bin/ljprotocol.pl
U   trunk/cvs/multicvs.conf
Added: trunk/bin/worker/ping-hubbub
===================================================================
--- trunk/bin/worker/ping-hubbub	                        (rev 0)
+++ trunk/bin/worker/ping-hubbub	2009-08-25 14:12:06 UTC (rev 15634)
@@ -0,0 +1,14 @@
+#!/usr/bin/perl
+use strict;
+use lib "$ENV{LJHOME}/cgi-bin";
+require 'ljlib.pl';
+use LJ::NewWorker::TheSchwartz;
+use TheSchwartz::Worker::PubSubHubbubPublish;
+
+LJ::NewWorker::TheSchwartz::PubSubHubbubPublish->start();
+
+package LJ::NewWorker::TheSchwartz::PubSubHubbubPublish;
+use base 'LJ::NewWorker::TheSchwartz';
+sub capabilities { [ 'TheSchwartz::Worker::PubSubHubbubPublish' => '' ] }
+
+1;


Property changes on: trunk/bin/worker/ping-hubbub
___________________________________________________________________
Added: svn:executable
   + *

Modified: trunk/cgi-bin/ljfeed.pl
===================================================================
--- trunk/cgi-bin/ljfeed.pl	2009-08-25 12:37:06 UTC (rev 15633)
+++ trunk/cgi-bin/ljfeed.pl	2009-08-25 14:12:06 UTC (rev 15634)
@@ -291,7 +291,9 @@
     # header
     $ret .= "<?xml version='1.0' encoding='$opts->{'saycharset'}' ?>\n";
     $ret .= LJ::run_hook("bot_director", "<!-- ", " -->") . "\n";
-    $ret .= "<rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/' xmlns:media='http://search.yahoo.com/mrss/'>\n";
+    $ret .= "<rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/' " .
+            "xmlns:media='http://search.yahoo.com/mrss/' " .
+            "xmlns:atom10='http://www.w3.org/2005/Atom'>\n";
 
     # channel attributes
     $ret .= "<channel>\n";
@@ -307,6 +309,10 @@
     $ret .= "  <copyright>" . $copyright . "</copyright>\n" if $copyright;
     # TODO: add 'language' field when user.lang has more useful information
 
+    foreach my $hub (@LJ::HUBBUB_HUBS) {
+        $ret .= "  <atom10:link rel='hub' href='" . LJ::exml($hub) . "' />\n";
+    }
+
     ### image block, returns info for their current userpic
     if ($u->{'defaultpicid'}) {
         my $pic = {};
@@ -412,7 +418,7 @@
         my ( $rel, $type, $href, $title ) = @_;
         my $link = XML::Atom::Link->new( Version => 1 );
         $link->rel($rel);
-        $link->type($type);
+        $link->type($type) if $type;
         $link->href($href);
         $link->title( $title ) if $title;
         return $link;
@@ -478,6 +484,10 @@
                 'Create a new entry'
             )
         ) if $opts->{'apilinks'};
+
+        foreach my $hub (@LJ::HUBBUB_HUBS) {
+            $feed->add_link($make_link->('hub', undef, $hub));
+        }
     }
 
     my $posteru = LJ::load_userids( map { $_->{posterid} } @$cleanitems);

Modified: trunk/cgi-bin/ljprotocol.pl
===================================================================
--- trunk/cgi-bin/ljprotocol.pl	2009-08-25 12:37:06 UTC (rev 15633)
+++ trunk/cgi-bin/ljprotocol.pl	2009-08-25 14:12:06 UTC (rev 15634)
@@ -1547,7 +1547,7 @@
         'req'       => $req,
         'res'       => $res,
     });
-    
+
     # cluster tracking
     LJ::mark_user_active($u, 'post');
     LJ::mark_user_active($uowner, 'post') unless LJ::u_equals($u, $uowner);
@@ -1560,12 +1560,35 @@
     push @jobs, LJ::Event::UserNewEntry->new($entry)->fire_job if (!$LJ::DISABLED{'esn-userevents'} || $LJ::_T_FIRE_USERNEWENTRY);
     push @jobs, LJ::EventLogRecord::NewEntry->new($entry)->fire_job;
 
+    # PubSubHubbub Support
+    unless ($LJ::DISABLED{'hubbub'}) {
+        foreach my $hub (@LJ::HUBBUB_HUBS) {
+            my $make_hubbub_job = sub {
+                my $type = shift;
+
+                my $topic_url = $uowner->journal_base . "/data/$type";
+                return TheSchwartz::Job->new(
+                    funcname => 'TheSchwartz::Worker::PubSubHubbubPublish',
+                    arg => {
+                        hub => $hub,
+                        topic_url => $topic_url,
+                    },
+                    coalesce => $hub,
+                );
+            };
+
+            push @jobs, $make_hubbub_job->("rss");
+            push @jobs, $make_hubbub_job->("atom");
+        }
+    }
+
     my $sclient = LJ::theschwartz();
     if ($sclient && @jobs) {
         my @handles = $sclient->insert_jobs(@jobs);
         # TODO: error on failure?  depends on the job I suppose?  property of the job?
     }
 
+
     return $res;
 }
 

Modified: trunk/cvs/multicvs.conf
===================================================================
--- trunk/cvs/multicvs.conf	2009-08-25 12:37:06 UTC (rev 15633)
+++ trunk/cvs/multicvs.conf	2009-08-25 14:12:06 UTC (rev 15634)
@@ -34,6 +34,7 @@
 SVN(Test-FakeApache)      = http://code.livejournal.org/svn/Test-FakeApache/trunk/
 SVN(LJ-UserSearch)        = http://code.livejournal.org/svn/LJ-UserSearch/trunk/
 SVN(TheSchwartz-Worker-SendEmail) = http://code.livejournal.org/svn/TheSchwartz-Worker-SendEmail/trunk/
+SVN(hubbub)               = http://pubsubhubbub.googlecode.com/svn/trunk/publisher_clients/
 
 livejournal                                   .
 
@@ -79,6 +80,9 @@
 
 dmtp/server/dmtpd                             bin/dmtpd
 
+hubbub/perl/lib/Net/PubSubHubbub/Publisher.pm cgi-bin/Net/PubSubHubbub/Publisher.pm
+hubbub/perl-schwartz/lib/TheSchwartz/Worker/PubSubHubbubPublish.pm  cgi-bin/TheSchwartz/Worker/PubSubHubbubPublish.pm
+
 mogilefs/api/perl/MogileFS-Client/lib         cgi-bin
 mogilefs/utils/mogadm                         bin/mogadm
 mogilefs/utils/mogtool                        bin/mogtool

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 5 comments