mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)
Mark Smith ([staff profile] mark) wrote in [site community profile] changelog2009-11-10 04:08 am

[dw-free] remove pingback skeleton

[commit: http://hg.dwscoalition.org/dw-free/rev/40c8b868936d]

http://bugs.dwscoalition.org/show_bug.cgi?id=2060

Remove the nonfunctional PingBack code we inherited from LJ.

Patch by [staff profile] denise.

Files modified:
  • bin/upgrading/en.dat
  • bin/upgrading/proplists.dat
  • bin/worker/notify_pingback
  • cgi-bin/LJ/Hooks/PingBack.pm
  • cgi-bin/LJ/PingBack.pm
  • cgi-bin/TheSchwartz/Worker/NotifyPingbackServer.pm
  • t/00-compile.t
--------------------------------------------------------------------------------
diff -r 27534a10aa6a -r 40c8b868936d bin/upgrading/en.dat
--- a/bin/upgrading/en.dat	Tue Nov 10 04:01:14 2009 +0000
+++ b/bin/upgrading/en.dat	Tue Nov 10 04:08:22 2009 +0000
@@ -2287,20 +2287,6 @@ optional=(optional)
 
 password=Password
 
-pingback.ljping.comment.text=User <lj user="[[poster]]"> referenced to your post from <a href="[[sourceURI]]">[[subject]]</a> saying: [...] [[context]] [...]
-
-pingback.option.disabled=Disabled
-
-pingback.option.journal_default=Journal default
-
-pingback.option.lj_only=LJ only
-
-pingback.option.open=Open
-
-pingback.public.comment.text=Pingback from <a href="[[sourceURI]]">[[title]]</a>: [...] [[context]] [...]
-
-pingback.sourceuri.default_title=No title
-
 poll.changevote=Change Your Vote
 
 poll.dberror=Database error: [[errmsg]]
diff -r 27534a10aa6a -r 40c8b868936d bin/upgrading/proplists.dat
--- a/bin/upgrading/proplists.dat	Tue Nov 10 04:01:14 2009 +0000
+++ b/bin/upgrading/proplists.dat	Tue Nov 10 04:08:22 2009 +0000
@@ -1364,18 +1364,3 @@ pollproplist2.unique:
 
 pollproplist2.createdate:
   des: The voter must have created their account by the date specified (Pacific time) in order to vote.  Must be in format YYYY-MM-DD, otherwise there will be no restriction.
-
-userproplist.pingback:
-  cldversion: 0
-  datatype: char
-  des: (O)pen - all links from post should be processed with PingBack. (L)iveJournal - only leading to/from livejournal.com. (D)isabled - pingbacks disabled.
-  indexed: 0
-  multihomed: 0
-  prettyname: PingBack options
-
-logproplist.pingback:
-  datatype: char
-  des: (J)ournal default, (O)pen - all links from post should be processed with PingBack. (L)iveJournal - only leading to/from livejournal.com. (D)isabled - pingbacks disabled.
-  prettyname: PingBack options
-  sortorder: 105
-  ownership: user
diff -r 27534a10aa6a -r 40c8b868936d bin/worker/notify_pingback
--- a/bin/worker/notify_pingback	Tue Nov 10 04:01:14 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-#!/usr/bin/perl
-use strict;
-use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
-use LJ::Worker::TheSchwartz;
-use TheSchwartz::Worker::NotifyPingbackServer;
-
-schwartz_decl('TheSchwartz::Worker::NotifyPingbackServer');
-schwartz_work();
-
diff -r 27534a10aa6a -r 40c8b868936d cgi-bin/LJ/Hooks/PingBack.pm
--- a/cgi-bin/LJ/Hooks/PingBack.pm	Tue Nov 10 04:01:14 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,170 +0,0 @@
-package LJ::Hooks::PingBack;
-use strict;
-use LJ::PingBack;
-
-sub has_pingback {
-    my $u = shift;
-    return 0 unless LJ::is_enabled('pingback');
-    return 0 unless $u->is_in_beta('pingback');
-    return 1;
-}
-
-
-#
-LJ::register_hook("add_extra_options_to_manage_comments", sub {
-    my $u = shift;
-
-    return unless has_pingback($u);
-
-    # PingBack options
-    my $ret = '';
-    $ret .= "<tr><td class='field_name'>" . BML::ml('.pingback') . "</td>\n<td>";
-    $ret .= BML::ml('.pingback.process') . "&nbsp;";
-    $ret .= LJ::html_select({ 'name' => 'pingback', 'selected' => $u->{'pingback'} },
-                              "O" => BML::ml(".pingback.option.open"),
-                              "L" => BML::ml(".pingback.option.lj_only"),
-                              "D" => BML::ml(".pingback.option.disabled"),
-                            );
-    $ret .= "</td></tr>\n";
-    return $ret;
-    
-});
-
-#
-LJ::register_hook("process_extra_options_for_manage_comments", sub {
-    my $u    = shift;
-    my $POST = shift;
-
-    return unless has_pingback($u);
-
-    $POST->{'pingback'} = "D" unless $POST->{'pingback'}  =~ /^[OLD]$/;
-    return 'pingback';
-
-});
-
-
-
-# Draw widget with event's pingback option selector
-LJ::register_hook("add_extra_entryform_fields", sub {
-    my $args     = shift;
-    my $tabindex = $args->{tabindex};
-    my $opts     = $args->{opts};
-
-    return if $opts->{remote} and
-              not has_pingback($opts->{remote});
-    
-    # PINGBACK widget
-    return "
-    <p class='pkg'>
-        <span class='inputgroup-right'>
-        <label for='prop_pingback' class='left options'>" . BML::ml('entryform.pingback') . "</label>
-        " . LJ::html_select({ 'name'     => 'prop_pingback', 
-                              'id'       => 'prop_pingback',
-                              'class'    => 'select',
-                              'selected' => $opts->{'prop_pingback'},
-                              'tabindex' => $tabindex->(),
-                              }, 
-                              { value => "J", text => BML::ml("pingback.option.journal_default") },
-                              { value => "O", text => BML::ml("pingback.option.open") },
-                              { value => "L", text => BML::ml("pingback.option.lj_only") },
-                              { value => "D", text => BML::ml("pingback.option.disabled") },
-                              ) . "
-        " . LJ::help_icon_html("pingback", "", " ") . "
-        </span>
-    </p>
-    ";
-});
-
-# Fetch pingback's option from POST data
-LJ::register_hook("decode_entry_form", sub {
-    my ($POST, $req) = @_;
-    $req->{prop_pingback} = $POST->{prop_pingback};
-    
-});
-
-# Process event's pingback option for new entry
-LJ::register_hook("postpost", sub {
-    my $args     = shift;
-    my $security = $args->{security};
-    my $entry    = $args->{entry};
-    my $journal  = $args->{journal};
-
-    return unless has_pingback($journal);
-
-    # check security
-    return if $security ne 'public';
-    
-    # define pingback prop value
-    my $prop_pingback = $args->{props}->{pingback};
-    if ($prop_pingback eq 'J'){ 
-        # use journal's default
-        $args->{entry}->set_prop('pingback' => undef); # do not populate db with "(J)ournal default" value.
-        $prop_pingback = $journal->prop('pingback');
-    }
-
-    return if $prop_pingback eq 'D'  # pingback is strictly disabled 
-              or not $prop_pingback; # or not enabled.
-
-    #
-    LJ::PingBack->notify(
-        uri  => $entry->url,
-        text => $args->{event},
-        mode => $prop_pingback,
-    );
-    
-});
-
-# Process event's pingback option for updated entry
-LJ::register_hook("editpost", sub {
-    my $entry = shift;
-
-    return unless has_pingback($entry->journal);
-
-    # check security
-    return if $entry->security ne 'public';
-    
-    # define pingback prop value
-    my $prop_pingback = $entry->prop("pingback");
-    if ($prop_pingback eq 'J'){ 
-        # use journal's default
-        $entry->set_prop('pingback' => undef); # do not populate db with "(J)ournal default" value.
-        $prop_pingback = $entry->journal->prop('pingback');
-    }
-
-    return if $prop_pingback eq 'D'  # pingback is strictly disabled 
-              or not $prop_pingback; # or not enabled.
-
-
-    #
-    LJ::PingBack->notify(
-        uri  => $entry->url,
-        text => $entry->event_raw,
-        mode => $entry->prop('pingback'),
-    );
-
-});
-
-
-#
-LJ::register_hook("after_journal_content_created", sub {
-    my $opts     = shift;
-    my $html_ref = shift;
-
-    my $entry = $opts->{ljentry};
-    my $r     = $opts->{r};
-
-    return unless $r;
-    return unless $entry;
-    return unless $r->notes->{view} eq 'entry';
-    return unless has_pingback($entry->journal);
-
-
-    if (LJ::PingBack->should_entry_recieve_pingback($entry)){
-        $r->header_out('X-Pingback', $LJ::PINGBACK->{uri});
-    }
-    
-    
-});
-
-
-1;
diff -r 27534a10aa6a -r 40c8b868936d cgi-bin/LJ/PingBack.pm
--- a/cgi-bin/LJ/PingBack.pm	Tue Nov 10 04:01:14 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,134 +0,0 @@
-package LJ::PingBack;
-use strict;
-use LJ::Entry;
-
-# Add comment to pinged post, if allowed.
-# returns comment object in success,
-# error string otherwise.
-sub ping_post {
-    my $class = shift;
-    my %args  = @_;
-    my $targetURI = $args{targetURI};
-    my $sourceURI = $args{sourceURI};
-    my $context   = $args{context};
-    my $title     = $args{title};
-
-    #
-    my $target_entry = LJ::Entry->new_from_url($targetURI);
-    unless ($target_entry){
-        warn "Unknown entry";
-        return "Unknown entry";
-    }
-
-    # empty object means, that sourceURI is not LJ.com's page.
-    # it's an usual case.
-    my $source_entry = LJ::Entry->new_from_url($sourceURI);
-
-    # can we add pingback comment to post?
-    return "pingbacks are forbidden for the target." 
-        unless $class->should_entry_recieve_pingback($target_entry, $source_entry);
-
-    # bot: pingback_bot
-    # pass: test4test
-    my $poster_u = LJ::load_user($LJ::PINGBACK->{comments_bot_username});
-    unless ($poster_u){
-        warn "Pingback bot user does not exists";
-        return "Pingback bot user does not exists";
-    }
-
-
-    #
-    my $subject = $source_entry
-                    ? ($source_entry->subject_raw || BML::ml("pingback.sourceURI.default_title"))
-                    : ($title || BML::ml("pingback.sourceURI.default_title"));
-
-    my $comment = LJ::Comment->create(
-                    journal      => $target_entry->journal,
-                    ditemid      => $target_entry->ditemid,
-                    poster       => $poster_u,
-
-                    body         => ($source_entry
-                                        ? BML::ml("pingback.ljping.comment.text",
-                                            { context   => $context,
-                                              subject   => $subject,
-                                              sourceURI => $sourceURI,
-                                              poster    => $source_entry->poster->username,
-                                              })
-                                        : BML::ml("pingback.public.comment.text",
-                                            { sourceURI => $sourceURI,
-                                              title     => $subject,
-                                              context   => $context
-                                              })
-                                    ),
-                    subject      => $subject,
-
-                    );
-
-    return $comment;
-    
-}
-
-sub should_entry_recieve_pingback {
-    my $class        = shift;
-    my $target_entry = shift;
-    my $source_entry = shift;
-
-    return 0 unless $target_entry->journal->is_in_beta("pingback");
-    return 0 if $target_entry->is_suspended;
-
-    return 0 unless $target_entry->journal->get_cap('pingback');
-
-    # not RO?
-    return 0 if $target_entry->journal->readonly; # Check "is_readonly".
-
-    # are comments allowed?
-    return 0 if $target_entry->prop('opt_nocomments');
-
-    # did user allow to add pingbacks?
-    # journal's default. We do not store "J" value in DB.
-    my $entry_pb_prop = $target_entry->prop("pingback") || 'J';
-    return 0 if $entry_pb_prop eq 'D';  # disabled
-
-    return 0 if $entry_pb_prop eq 'L'   # author allowed PingBacks only from LJ
-                and not $source_entry;  # and sourceURI is not LJ.com's post
-
-    if ($entry_pb_prop eq 'J'){             
-        my $journal_pb_prop = $target_entry->journal->prop("pingback") || 'D';
-        return 0 if $journal_pb_prop eq 'D'       # pingback disabled
-                    or ($journal_pb_prop eq 'L'   # or allowed from LJ only
-                        and not $source_entry     #    but sourceURI is not LJ page
-                        );
-    }
-    
-    return 1;
-
-}
-
-
-# Send notification to PingBack server
-sub notify {
-    my $class = shift;
-    my %args  = @_;
-
-    my $uri  = $args{uri};
-    my $text = $args{text};
-    my $mode = $args{mode};
-
-    return unless $mode =~ m!^[LO]$!; # (L)ivejournal only, (O)pen.
-    my $sclient = LJ::theschwartz();
-    unless ($sclient){
-        warn "LJ::PingBack: Could not get TheSchwartz client";
-        return;
-    }
-
-    # 
-    my $job = TheSchwartz::Job->new(
-                  funcname  => "TheSchwartz::Worker::NotifyPingbackServer",
-                  arg       => { uri => $uri, text => $text, mode => $mode },
-                  );
-    $sclient->insert($job);
-
-}
-
-
-1;
diff -r 27534a10aa6a -r 40c8b868936d cgi-bin/TheSchwartz/Worker/NotifyPingbackServer.pm
--- a/cgi-bin/TheSchwartz/Worker/NotifyPingbackServer.pm	Tue Nov 10 04:01:14 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-package TheSchwartz::Worker::NotifyPingbackServer;
-use strict;
-use base 'TheSchwartz::Worker';
-use LWP::UserAgent qw();
-use HTTP::Request  qw();
-use JSON;
-
-
-sub work {
-    my ($class, $job) = @_;
-    my $args = $job->arg;
-    my $client = $job->handle->client;
-    my $res = eval {
-        send_ping(uri  => $args->{uri},
-                  text => $args->{text},
-                  mode => $args->{mode},
-                  );
-    };
-    $job->completed if $res;
-
-}
-
-sub send_ping {
-    my %args = @_;
-
-    my $uri  = $args{uri};
-    my $text = $args{text};
-    my $mode = $args{mode};
-    
-    my $pb_server_uri = $LJ::PINGBACK->{uri};
-    my $content = JSON::objToJson({ uri => $uri, text => $text, mode => $mode }) . "\r\n";
-
-    my $headers = HTTP::Headers->new;
-       $headers->header('Content-Length' => length $content);
-
-    my $req = HTTP::Request->new('POST', $pb_server_uri, $headers, $content );
-    my $ua  = LWP::UserAgent->new;
-    my $res = $ua->request($req);
-
-    return 1 if $res->content eq 'OK';
-    return 0;
-
-}
-
-
-
-
-1;
diff -r 27534a10aa6a -r 40c8b868936d t/00-compile.t
--- a/t/00-compile.t	Tue Nov 10 04:01:14 2009 +0000
+++ b/t/00-compile.t	Tue Nov 10 04:08:22 2009 +0000
@@ -26,7 +26,6 @@ my %SKIP = (
 
     'DW/Hooks/NavStrip.pm'    => 'Undefined subroutine &LJ::register_hook',
     'DW/Hooks/SiteScheme.pm'  => 'Undefined subroutine &LJ::register_hook',
-    'LJ/Hooks/PingBack.pm'    => 'Undefined subroutine &LJ::register_hook',
     'DW/Hooks/SSL.pm'         => 'Undefined subroutine &LJ::register_hook',
     'DW/Hooks/Display.pm'     => 'Undefined subroutine &LJ::register_hook',
     'DW/Hooks/Changelog.pm'   => 'Undefined subroutine &LJ::register_hook',
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org