[dw-free] move cgi-bin/lj*.pl files into proper modules (in cgi-bin/LJ)
[commit: http://hg.dwscoalition.org/dw-free/rev/99fc8a1e82b3]
http://bugs.dwscoalition.org/show_bug.cgi?id=1726
Update comments and remove trailing whitespace.
Patch by
kareila.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=1726
Update comments and remove trailing whitespace.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- bin/worker/synsuck
- cgi-bin/DW/Controller/Interface/AtomAPI.pm
- cgi-bin/DW/External/XPostProtocol.pm
- cgi-bin/DW/Request/Standard.pm
-------------------------------------------------------------------------------- diff -r 7181c14fbe5a -r 99fc8a1e82b3 bin/worker/synsuck --- a/bin/worker/synsuck Tue Oct 25 17:14:09 2011 +0800 +++ b/bin/worker/synsuck Tue Oct 25 17:18:35 2011 +0800 @@ -50,7 +50,7 @@ die $dbh->errstr if $dbh->err; die "Unable to get syndicated row.\n" unless $row; - # now, all we have to actually do is pass through to the ljfeed code + # now, all we have to actually do is pass through to the LJ::Feed code LJ::SynSuck::update_feed( $row, 1 ); # all good diff -r 7181c14fbe5a -r 99fc8a1e82b3 cgi-bin/DW/Controller/Interface/AtomAPI.pm --- a/cgi-bin/DW/Controller/Interface/AtomAPI.pm Tue Oct 25 17:14:09 2011 +0800 +++ b/cgi-bin/DW/Controller/Interface/AtomAPI.pm Tue Oct 25 17:18:35 2011 +0800 @@ -55,7 +55,7 @@ my ( $message, $status ) = @_; return DW::Template->render_string( $message, - { status => $status || DW::Request->get->NOT_FOUND, + { status => $status || DW::Request->get->NOT_FOUND, content_type => "text/plain", no_sitescheme => 1, } @@ -333,7 +333,7 @@ unless ( defined $ret ) { if ( $op{redir} ) { # this happens if the account was renamed or a syn account. - # the redir URL is wrong because ljfeed.pl is too + # the redir URL is wrong because LJ::Feed is too # dataview-specific. Since this is an admin interface, we can # just fail. return err( qq{The account "$u->{user}" is of a wrong type and does not allow AtomAPI administration.}, $r->NOT_FOUND ); @@ -441,7 +441,7 @@ $len = $r->header_in( "Content-length" ); return err( "Content is too long", $r->HTTP_BAD_REQUEST ) if $len > $LJ::MAX_ATOM_UPLOAD; - + # read the content $r->read( $buff, $len ); } diff -r 7181c14fbe5a -r 99fc8a1e82b3 cgi-bin/DW/External/XPostProtocol.pm --- a/cgi-bin/DW/External/XPostProtocol.pm Tue Oct 25 17:14:09 2011 +0800 +++ b/cgi-bin/DW/External/XPostProtocol.pm Tue Oct 25 17:18:35 2011 +0800 @@ -25,7 +25,7 @@ # returns the given protocol, if configured. sub get_protocol { my ($class, $protocol) = @_; - + return $protocols{$protocol}; } @@ -42,7 +42,7 @@ # success => 0 and error => the error message on failure. # # usage: $protocol->crosspost($extacct, $auth, $entry, $itemid, $delete); -sub crosspost { +sub crosspost { return { success => 0, error => "Crossposting not implemented for this protocol." @@ -55,10 +55,10 @@ my ($self, $entry) = @_; my $event_text = $entry->event_text; - + # clean up any embedded objects LJ::EmbedModule->expand_entry($entry->journal, \$event_text, expand_full => 1); - + # remove polls, then return the text return $self->scrub_polls($event_text); } @@ -66,11 +66,11 @@ # replaces <poll> tags with a link to the original poll sub scrub_polls { my ($self, $entry_text) = @_; - - # taken more or less from cgi-bin/ljfeed.pl + + # taken more or less from cgi-bin/LJ/Feed.pm while ($entry_text =~ /<(?:lj-)?poll-(\d+)>/g) { my $pollid = $1; - + my $name = LJ::Poll->new($pollid)->name; if ($name) { LJ::Poll->clean_poll(\$name); @@ -79,7 +79,7 @@ } my $view_poll = LJ::Lang::ml("xpost.poll.view", { name => $name }); - + $entry_text =~ s!<(lj-)?poll-$pollid>!<div><a href="$LJ::SITEROOT/poll/?id=$pollid">$view_poll</a></div>!g; } return $entry_text; @@ -88,10 +88,10 @@ # creates the footer sub create_footer { my ( $self, $entry, $extacct, $local_nocomments, $disabling_remote_comments ) = @_; - + # are we adding a footer? my $xpostfootprop = $extacct->owner->prop( 'crosspost_footer_append' ) ? $extacct->owner->prop( 'crosspost_footer_append' ) : "D"; # assume old behavior if undefined - + if ( ( $xpostfootprop eq "A" ) || ( ( $xpostfootprop eq "D" ) && $disabling_remote_comments ) ) { # get the default custom footer text my $custom_footer_template; @@ -106,7 +106,7 @@ } else { # did we disable comments on the local entry? tweak language string to match my $footer_text_redirect_key = $local_nocomments ? 'xpost.redirect' : 'xpost.redirect.comment'; - + return "\n\n" . LJ::Lang::ml( $footer_text_redirect_key, { postlink => $entry->url } ); } } elsif ( ( $xpostfootprop eq "N" ) || ( ( $xpostfootprop eq "D" ) && ( ! $disabling_remote_comments ) ) ) { @@ -115,7 +115,7 @@ # fallthrough. shouldn't get here, but in case we do for # some crazy reason, let's assume the old behavior. my $footer_text_redirect_key = $local_nocomments ? 'xpost.redirect' : 'xpost.redirect.comment'; - + return "\n\n" . LJ::Lang::ml( $footer_text_redirect_key, { postlink => $entry->url } ); } } @@ -136,7 +136,7 @@ $footer_text =~ s/%%comment_url%%/$comment_url/gi; $footer_text =~ s/%%comment_image%%/$comment_image/gi; $footer_text = "\n\n" . $footer_text; - + return $footer_text; } @@ -145,21 +145,21 @@ sub validate_server { 1 } # hash the password in a protocol-specific manner -sub encrypt_password { +sub encrypt_password { my ($self, $password) = @_; - + # default implementation; just return the password in plaintext return $password; } # get a challenge for this protocol -sub challenge { +sub challenge { # don't support challenges by default. subclasses will have to override. return 0; } # checks to see if this account supports challenge/response authentication -sub supports_challenge { +sub supports_challenge { # don't support challenges by default. subclasses will have to override. return 0; } diff -r 7181c14fbe5a -r 99fc8a1e82b3 cgi-bin/DW/Request/Standard.pm --- a/cgi-bin/DW/Request/Standard.pm Tue Oct 25 17:14:09 2011 +0800 +++ b/cgi-bin/DW/Request/Standard.pm Tue Oct 25 17:18:35 2011 +0800 @@ -204,10 +204,10 @@ # assume that if there is no X-Forwarded-For or we don't trust it, we just put in # a bogus IP... return '127.0.0.100' unless $LJ::TRUST_X_HEADERS; - + my @ips = split /\s*,\s*/, $self->{req}->header( 'X-Forwarded-For' ); return '127.0.0.101' unless @ips && $ips[0]; - + return $ips[0]; } @@ -257,7 +257,7 @@ # FIXME: this should be pretty easy ... check the If headers (only time ones?) # and see if they're good or not. return proper status code here (OK, NOT_MODIFIED) - # go see the one caller in ljfeed + # go see the one caller in LJ::Feed return 0; } --------------------------------------------------------------------------------