madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r22366: LJSUP-12780: prevent duplicating repost ...

Committer: sbelyaev
LJSUP-12780: prevent duplicating repost information in selected S2 styles
U   trunk/bin/upgrading/s2layers/core1.s2
U   trunk/cgi-bin/LJ/Entry/Repost.pm
U   trunk/cgi-bin/LJ/S2/DayPage.pm
U   trunk/cgi-bin/LJ/S2/FriendsPage.pm
U   trunk/cgi-bin/LJ/S2/RecentPage.pm
U   trunk/cgi-bin/ljviews.pl
Modified: trunk/bin/upgrading/s2layers/core1.s2
===================================================================
--- trunk/bin/upgrading/s2layers/core1.s2	2012-07-02 14:05:53 UTC (rev 22365)
+++ trunk/bin/upgrading/s2layers/core1.s2	2012-07-03 08:02:33 UTC (rev 22366)
@@ -2074,8 +2074,12 @@
 }
 set text_comments_id = "comments";
 
+property bool repost_aware { 
+    des = "When enabled, style is responsible for show reposter name. When disabled, infomration about reposter is  automatically inserted into entry bodies.";
+    noui = 1; 
+} 
+set tags_aware = false; 
 
-
 ###[ global function implementations ]
 
 function prop_init ()

Modified: trunk/cgi-bin/LJ/Entry/Repost.pm
===================================================================
--- trunk/cgi-bin/LJ/Entry/Repost.pm	2012-07-02 14:05:53 UTC (rev 22365)
+++ trunk/cgi-bin/LJ/Entry/Repost.pm	2012-07-03 08:02:33 UTC (rev 22366)
@@ -459,7 +459,7 @@
 }
 
 sub substitute_content {
-    my ($class, $entry_obj, $opts) = @_;
+    my ($class, $entry_obj, $opts, $props) = @_;
 
     my $remote = LJ::get_remote();
     my $original_entry_obj = $entry_obj->original_post;
@@ -563,51 +563,46 @@
         ${$opts->{'eventtime'}} = $entry_obj->eventtime_mysql;
     }
 
-    if ($opts->{'event_raw'}) {
-        my $text_var =  LJ::u_equals($remote, $entry_obj->poster) ? 'entry.reference.journal.owner' :
-                                                                    'entry.reference.journal.guest';
-
-        my $event_text = $original_entry_obj->event_raw;
-        my $event =  LJ::Lang::ml($text_var,
-                                    { 'author'       => LJ::ljuser2($original_entry_obj->poster),
-                                      'reposter'     => LJ::ljuser2($entry_obj->poster),
-                                      'datetime'     => $entry_obj->eventtime_mysql,
-                                      'text'         => $event_text, });
-
-        ${$opts->{'event_raw'}} = $event;
-    }
-
     if ($opts->{'event'}) {
-        my $text_var =  LJ::u_equals($remote, $entry_obj->poster) ? 'entry.reference.journal.owner' : 
-                                                                    'entry.reference.journal.guest';
-
         my $event_text = $original_entry_obj->event_raw;
-        my $event =  LJ::Lang::ml($text_var,  
-                                    { 'author'       => LJ::ljuser2($original_entry_obj->poster),
-                                      'reposter'     => LJ::ljuser2($entry_obj->poster),
-                                      'datetime'     => $entry_obj->eventtime_mysql,
-                                      'text'         => $event_text, });
 
-        ${$opts->{'event'}} = $event;
+        if ($opts->{use_repost_signature}) { 
+            my $text_var =  LJ::u_equals($remote, $entry_obj->poster) ? 'entry.reference.journal.owner' : 
+                                                                        'entry.reference.journal.guest';
+    
+            my $event =  LJ::Lang::ml($text_var,  
+                                        { 'author'       => LJ::ljuser2($original_entry_obj->poster),
+                                          'reposter'     => LJ::ljuser2($entry_obj->poster),
+                                          'datetime'     => $entry_obj->eventtime_mysql,
+                                          'text'         => $event_text, });
+            ${$opts->{'event'}} = $event;
+        } else {
+            ${$opts->{'event'}} = $event_text;
+        }
     }
 
     if ($opts->{'event_friend'}) {
         my $event_text = $original_entry_obj->event_raw;
-        my $journal = $original_entry_obj->journal;
-        
-        my $text_var = $journal->is_community ? 'entry.reference.friends.community' :
-                                                'entry.reference.friends.journal';
 
-        $text_var .= LJ::u_equals($remote, $entry_obj->poster) ? '.owner' : '.guest';
+        if ($opts->{use_repost_signature}) {
+            my $journal = $original_entry_obj->journal;
+            
+            my $text_var = $journal->is_community ? 'entry.reference.friends.community' :
+                                                    'entry.reference.friends.journal';
 
-        my $event = LJ::Lang::ml($text_var, 
-                                   { 'author'           => LJ::ljuser2($original_entry_obj->poster),
-                                     'communityname'    => LJ::ljuser2($original_entry_obj->journal),
-                                     'reposter'         => LJ::ljuser2($entry_obj->poster),
-                                     'datetime'         => $entry_obj->eventtime_mysql,
-                                     'text'             => $event_text, });
+            $text_var .= LJ::u_equals($remote, $entry_obj->poster) ? '.owner' : '.guest';
+    
+            my $event = LJ::Lang::ml($text_var, 
+                                       { 'author'           => LJ::ljuser2($original_entry_obj->poster),
+                                         'communityname'    => LJ::ljuser2($original_entry_obj->journal),
+                                         'reposter'         => LJ::ljuser2($entry_obj->poster),
+                                         'datetime'         => $entry_obj->eventtime_mysql,
+                                         'text'             => $event_text, });
 
-        ${$opts->{'event_friend'}} = $event;
+            ${$opts->{'event_friend'}} = $event;
+        } else {
+            ${$opts->{'event_friend'}} = $event_text;
+        }
     }
 
     if ($opts->{'subject_repost'}) {

Modified: trunk/cgi-bin/LJ/S2/DayPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/DayPage.pm	2012-07-02 14:05:53 UTC (rev 22365)
+++ trunk/cgi-bin/LJ/S2/DayPage.pm	2012-07-03 08:02:33 UTC (rev 22366)
@@ -118,6 +118,8 @@
     my $replace_video = $remote ? $remote->opt_embedplaceholders : 0;
     my $ljcut_disable = $remote ? $remote->{'opt_ljcut_disable_friends'} : undef;
 
+    my $ctx = $opts->{'ctx'};
+
   ENTRY:
     foreach my $item (@items)
     {
@@ -150,13 +152,16 @@
                          'posterid'          => \$posterid,
                          'security'          => \$security,
                          'allowmask'         => \$allowmask,
-                         'event_raw'         => \$text,
+                         'event'             => \$text,
                          'subject'           => \$subject,
                          'reply_count'       => \$replycount,
                          'userlite'          => \$lite_journalu,
                          'removed'           => \$removed, };
 
-        if (LJ::Entry::Repost->substitute_content( $entry_obj, $content )) {
+        my $repost_props = { 'use_repost_signature' => !$ctx->[S2::PROPS]->{'repost_aware'},
+                           };
+
+        if (LJ::Entry::Repost->substitute_content( $entry_obj, $content, $repost_props )) {
             next ENTRY if $removed && !LJ::u_equals($u, $remote);
             next ENTRY unless $entry_obj->visible_to($remote, { 'viewall'  => $viewall,
                                                                 'viewsome' => $viewsome});
@@ -261,7 +266,7 @@
         @taglist = sort { $a->{name} cmp $b->{name} } @taglist;
 
         if ($opts->{enable_tags_compatibility} && @taglist) {
-            $text .= LJ::S2::get_tags_text($opts->{ctx}, \@taglist);
+            $text .= LJ::S2::get_tags_text($ctx, \@taglist);
         }
 
         if ($security eq "public" && !$LJ::REQ_GLOBAL{'text_of_first_public_post'}) {

Modified: trunk/cgi-bin/LJ/S2/FriendsPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/FriendsPage.pm	2012-07-02 14:05:53 UTC (rev 22365)
+++ trunk/cgi-bin/LJ/S2/FriendsPage.pm	2012-07-03 08:02:33 UTC (rev 22366)
@@ -71,7 +71,8 @@
                         confirm.bubble.no/);
     }
 
-    my $itemshow = S2::get_property_value($opts->{'ctx'}, "page_friends_items")+0;
+    my $ctx = $opts->{'ctx'};
+    my $itemshow = S2::get_property_value($ctx, "page_friends_items")+0;
     if ($itemshow < 1) { $itemshow = 20; }
     elsif ($itemshow > 50) { $itemshow = 50; }
 
@@ -283,7 +284,10 @@
                          'removed'           => \$removed,
                          'reply_count'       => \$replycount, };
 
-        if (LJ::Entry::Repost->substitute_content( $entry_obj, $content )) {
+        my $repost_props = { 'use_repost_signature' => !$ctx->[S2::PROPS]->{'repost_aware'},
+                             };
+
+        if (LJ::Entry::Repost->substitute_content( $entry_obj, $content, $repost_props )) {
             next ENTRY if $removed;
             next ENTRY unless $entry_obj->visible_to($remote);
 
@@ -403,7 +407,7 @@
         my $picid = 0;
         my $picu = undef;
 
-        if ($friendid != $posterid && S2::get_property_value($opts->{ctx}, 'use_shared_pic')) {
+        if ($friendid != $posterid && S2::get_property_value($ctx, 'use_shared_pic')) {
             # using the community, the user wants to see shared pictures
             $picu = $friends{$friendid};
 
@@ -450,7 +454,7 @@
         @taglist = sort { $a->{name} cmp $b->{name} } @taglist;
 
         if ($opts->{enable_tags_compatibility} && @taglist) {
-            $text .= LJ::S2::get_tags_text($opts->{ctx}, \@taglist);
+            $text .= LJ::S2::get_tags_text($ctx, \@taglist);
         }
 
         if ($security eq "public" && !$LJ::REQ_GLOBAL{'text_of_first_public_post'}) {

Modified: trunk/cgi-bin/LJ/S2/RecentPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/RecentPage.pm	2012-07-02 14:05:53 UTC (rev 22365)
+++ trunk/cgi-bin/LJ/S2/RecentPage.pm	2012-07-03 08:02:33 UTC (rev 22366)
@@ -69,8 +69,9 @@
         $opts->{'badargs'} = 1;
         return 1;
     }
-    
-    my $itemshow = S2::get_property_value($opts->{'ctx'}, "page_recent_items")+0;
+
+    my $ctx = $opts->{'ctx'}; 
+    my $itemshow = S2::get_property_value($ctx, "page_recent_items")+0;
     if ($itemshow < 1) { $itemshow = 20; }
     elsif ($itemshow > 50 && !$LJ::S2_TRUSTED{ $u->{'userid'} } ) { $itemshow = 50; }
 
@@ -183,13 +184,16 @@
                          'posterid'          => \$posterid,
                          'security'          => \$security,
                          'allowmask'         => \$allowmask,
-                         'event_raw'         => \$text,
+                         'event'             => \$text,
                          'subject'           => \$subject,
                          'reply_count'       => \$replycount,
                          'removed'           => \$removed,
                          'userlite'          => \$lite_journalu, };
 
-        if (LJ::Entry::Repost->substitute_content( $entry_obj, $content )) {
+        my $repost_props = { 'use_repost_signature' => !$ctx->[S2::PROPS]->{'repost_aware'},
+                             };
+
+        if (LJ::Entry::Repost->substitute_content( $entry_obj, $content, $repost_props )) {
             next ENTRY if $removed && !LJ::u_equals($u, $remote);
             next ENTRY unless $entry_obj->visible_to($remote, { 'viewall'  => $viewall,
                                                                 'viewsome' => $viewsome});
@@ -268,7 +272,7 @@
         @taglist = sort { $a->{name} cmp $b->{name} } @taglist;
 
         if ($opts->{enable_tags_compatibility} && @taglist) {
-            $text .= LJ::S2::get_tags_text($opts->{ctx}, \@taglist);
+            $text .= LJ::S2::get_tags_text($ctx, \@taglist);
         }
 
         my $permalink = $removed ? '' : $entry_obj->permalink_url;

Modified: trunk/cgi-bin/ljviews.pl
===================================================================
--- trunk/cgi-bin/ljviews.pl	2012-07-02 14:05:53 UTC (rev 22365)
+++ trunk/cgi-bin/ljviews.pl	2012-07-03 08:02:33 UTC (rev 22366)
@@ -1298,7 +1298,7 @@
                          'journalu'          => \$journalu,
                          'posterid'          => \$posterid,
                          'security'          => \$security,
-                         'event_raw'         => \$event,
+                         'event'             => \$event,
                          'subject'           => \$subject,
                          'removed'           => \$removed,
                          'reply_count'       => \$replycount };
@@ -1895,7 +1895,7 @@
                          'journalu'          => \$journalu,
                          'posterid'          => \$posterid,
                          'security'          => \$security,
-                         'event_raw'         => \$event,
+                         'event'             => \$event,
                          'subject'           => \$subject,
                          'reply_count'       => \$replycount,
                          'cluster_id'        => \$clusterid, };
@@ -2747,7 +2747,7 @@
                          'journalu'          => \$journalu,
                          'posterid'          => \$posterid,
                          'security'          => \$security,
-                         'event_raw'         => \$event,
+                         'event'             => \$event,
                          'subject'           => \$subject,
                          'removed'           => \$removed,
                          'reply_count'       => \$replycount };

Tags: livejournal, madeon, pl, pm, s2, sbelyaev
Subscribe
  • 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 

  • 0 comments