Refactor the xpost details into LJ::currents.
Patch by kareila.
diffs (121 lines):
diff -r 8b0182046c0d -r 42ace13d0436 cgi-bin/LJ/Entry.pm
--- a/cgi-bin/LJ/Entry.pm Mon Jul 05 16:56:57 2010 +0800
+++ b/cgi-bin/LJ/Entry.pm Mon Jul 05 17:06:28 2010 +0800
@@ -1083,6 +1083,7 @@ use Carp qw(confess);
use Carp qw(confess);
use LJ::Poll;
use LJ::EmbedModule;
+use DW::External::Account;
# <LJFUNC>
# name: LJ::get_logtext2multi
@@ -2278,6 +2279,20 @@ sub currents {
$current{Location} = $loc->as_html_current if $loc;
}
+ # Crossposts
+ if ( my $xpost = $props->{"${key}xpostdetail"} ) {
+ my $xposthash = DW::External::Account->xpost_string_to_hash( $xpost );
+ my $xpostlinks = "";
+ foreach my $xpostvalue ( values %$xposthash ) {
+ if ( $xpostvalue->{url} ) {
+ my $xpost_url = LJ::no_utf8_flag( $xpostvalue->{url} );
+ $xpostlinks .= " " if $xpostlinks;
+ $xpostlinks .= "<a href='$xpost_url'>$xpost_url</a>";
+ }
+ }
+ $current{Xpost} = $xpostlinks if $xpostlinks;
+ }
+
return %current;
}
diff -r 8b0182046c0d -r 42ace13d0436 cgi-bin/LJ/S2.pm
--- a/cgi-bin/LJ/S2.pm Mon Jul 05 16:56:57 2010 +0800
+++ b/cgi-bin/LJ/S2.pm Mon Jul 05 17:06:28 2010 +0800
@@ -33,7 +33,6 @@ use LJ::S2::EntryPage;
use LJ::S2::EntryPage;
use LJ::S2::ReplyPage;
use LJ::S2::TagsPage;
-use DW::External::Account;
use Storable;
use Apache2::Const qw/ :common /;
use POSIX ();
@@ -1874,25 +1873,6 @@ sub Entry
my %current = LJ::currents( $p, $m_arg, { s2imgref => \$img_arg } );
$e->{metadata}->{lc $_} = $current{$_} foreach keys %current;
$e->{mood_icon} = Image( @$img_arg ) if defined $img_arg;
-
- # check for xpost values
- if ( $p->{xpostdetail} ) {
- my $xposthash = DW::External::Account->xpost_string_to_hash(
$p->{xpostdetail} );
- my $xpostlinks = "";
- foreach my $xpostkey ( keys %$xposthash ) {
- my $xpostvalue = $xposthash->{$xpostkey};
- if ( $xpostvalue->{url} ) {
- my $xpost_url = LJ::no_utf8_flag( $xpostvalue->{url} );
- if ( $xpostlinks ) {
- $xpostlinks = $xpostlinks . " ";
- }
- $xpostlinks = $xpostlinks . '<a href = "' . $xpost_url . '">'
. $xpost_url . '</a>';
- }
- }
- if ( $xpostlinks ) {
- $e->{metadata}->{xpost} = $xpostlinks;
- }
- }
my $r = BML::get_request();
diff -r 8b0182046c0d -r 42ace13d0436 htdocs/talkpost.bml
--- a/htdocs/talkpost.bml Mon Jul 05 16:56:57 2010 +0800
+++ b/htdocs/talkpost.bml Mon Jul 05 17:06:28 2010 +0800
@@ -285,22 +285,6 @@ body<=
my $group_names = $entry->group_names;
$current{'Groups'} = $group_names if $group_names;
- if ($props->{xpostdetail} ) {
- my $xposthash = DW::External::Account->xpost_string_to_hash(
$props->{xpostdetail} );
- my $xpostlinks = "";
- foreach my $xpostkey ( keys %$xposthash ) {
- my $xpostvalue = $xposthash->{$xpostkey};
- if ( $xpostvalue->{url} ) {
- my $xpost_url = LJ::no_utf8_flag( $xpostvalue->{url} );
- if ( $xpostlinks ) {
- $xpostlinks = $xpostlinks . " ";
- }
- $xpostlinks = $xpostlinks . '<a href = "' . $xpost_url . '">'
. $xpost_url . '</a>';
- }
- }
- $current{Xpost} = $xpostlinks;
- }
-
$ret .= "<div id='entry' class='usercontent' style='margin-left: 30px'>";
### currents
diff -r 8b0182046c0d -r 42ace13d0436 htdocs/talkread.bml
--- a/htdocs/talkread.bml Mon Jul 05 16:56:57 2010 +0800
+++ b/htdocs/talkread.bml Mon Jul 05 17:06:28 2010 +0800
@@ -305,22 +305,6 @@ body<=
map { "<a href='$base/tag/" . LJ::eurl($_) .
"'>" . LJ::ehtml($_) . "</a>" }
sort values %{$logtags->{$itemid}}
);
- }
-
- if ($props->{xpostdetail} ) {
- my $xposthash = DW::External::Account->xpost_string_to_hash(
$props->{xpostdetail} );
- my $xpostlinks = "";
- foreach my $xpostkey ( keys %$xposthash ) {
- my $xpostvalue = $xposthash->{$xpostkey};
- if ( $xpostvalue->{url} ) {
- my $xpost_url = LJ::no_utf8_flag( $xpostvalue->{url} );
- if ( $xpostlinks ) {
- $xpostlinks = $xpostlinks . " ";
- }
- $xpostlinks = $xpostlinks . '<a href = "' . $xpost_url . '">'
. $xpost_url . '</a>';
- }
- }
- $current{Xpost} = $xpostlinks;
}
$ret .= "<div id='entry' class='usercontent' style='margin-left: 30px'>";
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog