Типа я (zilogic) wrote in changelog,
Типа я
zilogic
changelog

[livejournal] r21104: LJSUP-10691: Image placeholders in comme...

Committer: amyshkin
LJSUP-10691: Image placeholders in comments
U   trunk/cgi-bin/LJ/EmbedModule.pm
U   trunk/cgi-bin/LJ/Entry.pm
U   trunk/cgi-bin/LJ/S2/DayPage.pm
U   trunk/cgi-bin/LJ/S2/EntryPage.pm
U   trunk/cgi-bin/LJ/S2/FriendsPage.pm
U   trunk/cgi-bin/LJ/S2/RecentPage.pm
U   trunk/cgi-bin/LJ/Setting/EmbedPlaceholders.pm
U   trunk/cgi-bin/LJ/User.pm
U   trunk/cgi-bin/cleanhtml.pl
U   trunk/cgi-bin/ljviews.pl
Modified: trunk/cgi-bin/LJ/EmbedModule.pm
===================================================================
--- trunk/cgi-bin/LJ/EmbedModule.pm	2012-02-06 09:24:26 UTC (rev 21103)
+++ trunk/cgi-bin/LJ/EmbedModule.pm	2012-02-06 10:54:03 UTC (rev 21104)
@@ -480,29 +480,16 @@
     return $iframe_tag unless $remote;
     return $iframe_tag if $opts{edit};
 
-    # show placeholder instead of iframe?
-    my $placeholder_prop = $remote->prop('opt_embedplaceholders');
-    my $do_placeholder = $placeholder_prop && $placeholder_prop ne 'N';
+    return $iframe_tag unless $opts{'video_placeholders'};
 
-    # if placeholder_prop is not set, then show placeholder on a friends
-    # page view UNLESS the embedded content is only one embed/object
-    # tag and it's whitelisted video.
-    my $view = LJ::Request->is_inited ? LJ::Request->notes("view") : '';
-    if (! $placeholder_prop && $view eq 'friends') {
-        # show placeholder if this is not whitelisted video
-        $do_placeholder = 1 if $no_whitelist;
-    }
-
-    return $iframe_tag unless $do_placeholder;
-
     # placeholder
     return LJ::placeholder_link(
-                                placeholder_html => $iframe_tag,
-                                width            => $width,
-                                height           => $height,
-                                img              => "$LJ::IMGPREFIX/videoplaceholder.png",
-                                link             => $iframe_link,
-                                );
+        placeholder_html => $iframe_tag,
+        width            => $width,
+        height           => $height,
+        img              => "$LJ::IMGPREFIX/videoplaceholder.png",
+        link             => $iframe_link,
+    );
 }
 
 sub module_content {

Modified: trunk/cgi-bin/LJ/Entry.pm
===================================================================
--- trunk/cgi-bin/LJ/Entry.pm	2012-02-06 09:24:26 UTC (rev 21103)
+++ trunk/cgi-bin/LJ/Entry.pm	2012-02-06 10:54:03 UTC (rev 21104)
@@ -870,20 +870,20 @@
 
     if($opts->{no_cut_expand}) {
         $opts->{expand_cut} = 0;
-        $opts->{cuturl} = $self->prop('reposted_from') || $self->url . '?page=' . $opts->{page} . '&cut_expand=1';
+        $opts->{cuturl}     = $self->prop('reposted_from') || $self->url . '?page=' . $opts->{page} . '&cut_expand=1';
     } elsif (!$opts->{cuturl}) {
         $opts->{expand_cut} = 1;
         $opts->{cuturl}     = $self->prop('reposted_from') || $self->url;
     }
     $opts->{journalid} = $self->journalid;
-    $opts->{posterid} = $self->posterid;
+    $opts->{posterid}  = $self->posterid;
     $opts->{entry_url} = $self->prop('reposted_from') || $self->url;
-    
+
     $self->_load_text unless $self->{_loaded_text};
     my $event = $self->{event};
     LJ::CleanHTML::clean_event(\$event, $opts);
 
-    LJ::expand_embedded($self->{u}, $self->ditemid, LJ::User->remote, \$event);
+    LJ::expand_embedded($self->{u}, $self->ditemid, $remote, \$event, video_placeholders => $opts->{'video_placeholders'} );
     return $event;
 }
 

Modified: trunk/cgi-bin/LJ/S2/DayPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/DayPage.pm	2012-02-06 09:24:26 UTC (rev 21103)
+++ trunk/cgi-bin/LJ/S2/DayPage.pm	2012-02-06 10:54:03 UTC (rev 21104)
@@ -12,8 +12,8 @@
     my ($u, $remote, $opts) = @_;
 
     my $p = Page($u, $opts);
-    $p->{'_type'} = "DayPage";
-    $p->{'view'} = "day";
+    $p->{'_type'}   = "DayPage";
+    $p->{'view'}    = "day";
     $p->{'entries'} = [];
     $p->{'head_content'}->set_object_type( $p->{'_type'} );
 
@@ -23,8 +23,8 @@
     my $get = $opts->{'getargs'};
 
     my $month = $get->{'month'};
-    my $day = $get->{'day'};
-    my $year = $get->{'year'};
+    my $day   = $get->{'day'};
+    my $year  = $get->{'year'};
     my @errors = ();
 
     if ($opts->{'pathextra'} =~ m!^/(\d\d\d\d)/(\d\d)/(\d\d)\b!) {
@@ -32,9 +32,9 @@
     }
 
     $opts->{'errors'} = [];
-    if ($year !~ /^\d+$/) { push @{$opts->{'errors'}}, "Corrupt or non-existant year."; }
-    if ($month !~ /^\d+$/) { push @{$opts->{'errors'}}, "Corrupt or non-existant month."; }
-    if ($day !~ /^\d+$/) { push @{$opts->{'errors'}}, "Corrupt or non-existant day."; }
+    if ( $year !~ /^\d+$/  ) { push @{$opts->{'errors'}}, "Corrupt or non-existant year."; }
+    if ( $month !~ /^\d+$/ ) { push @{$opts->{'errors'}}, "Corrupt or non-existant month."; }
+    if ( $day !~ /^\d+$/   ) { push @{$opts->{'errors'}}, "Corrupt or non-existant day."; }
     if ($month < 1 || $month > 12 || int($month) != $month) { push @{$opts->{'errors'}}, "Invalid month."; }
     if ($year < 1970 || $year > 2038 || int($year) != $year) { push @{$opts->{'errors'}}, "Invalid year: $year"; }
     if ($day < 1 || $day > 31 || int($day) != $day) { push @{$opts->{'errors'}}, "Invalid day."; }
@@ -109,6 +109,8 @@
     my $tags = LJ::Tags::get_logtags($u, \@itemids);
     
     my $userlite_journal = UserLite($u);
+    my $replace_video = $remote ? $remote->opt_embedplaceholders : 0;
+    my $ljcut_disable = $remote ? $remote->{'opt_ljcut_disable_friends'} : undef;
 
   ENTRY:
     foreach my $item (@items)
@@ -152,20 +154,36 @@
         LJ::CleanHTML::clean_subject(\$subject) if $subject;
 
         my $suspend_msg = $entry_obj && $entry_obj->should_show_suspend_msg_to($remote) ? 1 : 0;
-        LJ::CleanHTML::clean_event(\$text, { 'preformatted' => $logprops{$itemid}->{'opt_preformatted'},
-                                             'cuturl' => $entry_obj->prop('reposted_from') || $entry_obj->url,
-                                             'entry_url' => $entry_obj->prop('reposted_from') || $entry_obj->url,
-                                             'ljcut_disable' => $remote ? $remote->{'opt_ljcut_disable_lastn'} : undef,
-                                             'suspend_msg' => $suspend_msg,
-                                             'unsuspend_supportid' => $suspend_msg ? $entry_obj->prop("unsuspend_supportid") : 0, 
-                                             'journalid' => $entry_obj->journalid,
-                                             'posterid' => $entry_obj->posterid,
-                                            });
-        LJ::expand_embedded($u, $ditemid, $remote, \$text);
+        LJ::CleanHTML::clean_event(
+            \$text,
+            {
+                'preformatted'        => $logprops{$itemid}->{'opt_preformatted'},
+                'cuturl'              => $entry_obj->prop('reposted_from') || $entry_obj->url,
+                'entry_url'           => $entry_obj->prop('reposted_from') || $entry_obj->url,
+                'ljcut_disable'       => $ljcut_disable,
+                'suspend_msg'         => $suspend_msg,
+                'unsuspend_supportid' => $suspend_msg ? $entry_obj->prop("unsuspend_supportid") : 0, 
+                'journalid'           => $entry_obj->journalid,
+                'posterid'            => $entry_obj->posterid,
+                'video_placeholders'  => $replace_video,
+            },
+        );
 
-        $text = LJ::ContentFlag->transform_post(post => $text, journal => $u,
-                                                remote => $remote, entry => $entry_obj);
+        LJ::expand_embedded(
+            $u,
+            $ditemid,
+            $remote,
+            \$text,
+            'video_placeholders' => $replace_video,
+        );
 
+        $text = LJ::ContentFlag->transform_post(
+            'post'    => $text,
+            'journal' => $u,
+            'remote'  => $remote,
+            'entry'   => $entry_obj,
+        );
+
         my $nc = "";
         $nc .= "nc=$replycount" if $replycount && $remote && $remote->{'opt_nctalklinks'};
 

Modified: trunk/cgi-bin/LJ/S2/EntryPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/EntryPage.pm	2012-02-06 09:24:26 UTC (rev 21103)
+++ trunk/cgi-bin/LJ/S2/EntryPage.pm	2012-02-06 10:54:03 UTC (rev 21104)
@@ -144,9 +144,11 @@
         my ($self, $destlist, $srclist, $depth) = @_;
 
         my $replace_images_in_comments = 0;
+        my $replace_video_in_comments  = 0;
 
         if( $remote ) {
             $replace_images_in_comments = $remote->opt_placeholders_comments;
+            $replace_video_in_comments  = $remote->opt_videoplaceholders_comments;
         }
 
         foreach my $com (@$srclist) {
@@ -161,11 +163,12 @@
 
             LJ::CleanHTML::clean_comment(
                 \$text, {
-                'preformatted'     => $com->{'props'}->{'opt_preformatted'},
-                'anon_comment'     => (!$pu || $pu->{'journaltype'} eq 'I'),
-                'nocss'            => 1,
-                'posterid'         => $com->{'posterid'},
-                'img_placeholders' => $replace_images_in_comments,
+                'preformatted'       => $com->{'props'}->{'opt_preformatted'},
+                'anon_comment'       => (!$pu || $pu->{'journaltype'} eq 'I'),
+                'nocss'              => 1,
+                'posterid'           => $com->{'posterid'},
+                'img_placeholders'   => $replace_images_in_comments,
+                'video_placeholders' => $replace_video_in_comments,
             });
 
             # local time in mysql format to gmtime
@@ -536,8 +539,9 @@
     my $no_cut_expand = !$get->{cut_expand} && $get->{page} && $get->{page} > 1 ? 1 : 0; 
 
     my $event = $entry->event_html({
-        no_cut_expand   => $no_cut_expand,
-        page            => $get->{page},
+        no_cut_expand      => $no_cut_expand,
+        page               => $get->{page},
+        video_placeholders => $remote ? $remote->opt_embedplaceholders : 0,
     });
     
     if ($get->{'nohtml'}) {

Modified: trunk/cgi-bin/LJ/S2/FriendsPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/FriendsPage.pm	2012-02-06 09:24:26 UTC (rev 21103)
+++ trunk/cgi-bin/LJ/S2/FriendsPage.pm	2012-02-06 10:54:03 UTC (rev 21104)
@@ -215,10 +215,12 @@
         return $lite{$id} = UserLite($posters{$id} || $friends{$id});
     };
 
-    my $eventnum = 0;
+    my $eventnum      = 0;
     my $hiddenentries = 0;
+    my $ljcut_disable = $remote ? $remote->{'opt_ljcut_disable_friends'} : undef;
 
     my $replace_images_in_friendspage = 0;
+    my $replace_video = $remote ? $remote->opt_embedplaceholders : 0;
 
     if( $u->equals($remote) ) {
         $replace_images_in_friendspage = $remote->opt_placeholders_friendspage;
@@ -293,20 +295,31 @@
                  'preformatted'        => $logprops{$datakey}->{'opt_preformatted'},
                  'cuturl'              => $entry_obj->prop('reposted_from') || $entry_obj->url(%urlopts_style),
                  'entry_url'           => $entry_obj->prop('reposted_from') || $entry_obj->url,
-                 'ljcut_disable'       => $remote ? $remote->{'opt_ljcut_disable_friends'} : undef,
+                 'ljcut_disable'       => $ljcut_disable,
                  'suspend_msg'         => $suspend_msg,
                  'unsuspend_supportid' => $suspend_msg ? $entry_obj->prop("unsuspend_supportid") : 0,
                  'journalid'           => $entry_obj->journalid,
                  'posterid'            => $entry_obj->posterid,
                  'img_placeholders'    => $replace_images_in_friendspage,
+                 'video_placeholders'  => $replace_video,
         });
 
-        LJ::expand_embedded($friends{$friendid}, $ditemid, $remote, \$text);
+        LJ::expand_embedded(
+            $friends{$friendid},
+            $ditemid,
+            $remote,
+            \$text,
+            'video_placeholders' => $replace_video,
+        );
 
-        $text = LJ::ContentFlag->transform_post(post => $text, journal => $friends{$friendid},
-                                                remote => $remote, entry => $entry_obj);
+        $text = LJ::ContentFlag->transform_post(
+            'post'    => $text,
+            'journal' => $friends{$friendid},
+            'remote'  => $remote,
+            'entry'   => $entry_obj,
+        );
 
-        my $userlite_poster = $get_lite->($posterid);
+        my $userlite_poster  = $get_lite->($posterid);
         my $userlite_journal = $get_lite->($friendid);
 
         # get the poster user

Modified: trunk/cgi-bin/LJ/S2/RecentPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/RecentPage.pm	2012-02-06 09:24:26 UTC (rev 21103)
+++ trunk/cgi-bin/LJ/S2/RecentPage.pm	2012-02-06 10:54:03 UTC (rev 21104)
@@ -131,24 +131,26 @@
     my $tags = LJ::Tags::get_logtagsmulti($idsbyc);
 
     my $userlite_journal = UserLite($u);
-    my $sticky_appended = !$u->has_sticky_entry() || $skip;
+    my $sticky_appended  = !$u->has_sticky_entry() || $skip;
+    my $ljcut_disable    = $remote ? $remote->prop("opt_ljcut_disable_lastn") : undef;
+    my $replace_video    = $remote ? $remote->opt_embedplaceholders : 0;
 
   ENTRY:
-    foreach my $item (@items)
-    {
+    foreach my $item ( @items ) {
         my ($posterid, $itemid, $security, $allowmask, $alldatepart) =
             map { $item->{$_} } qw(posterid itemid security allowmask alldatepart);
 
-        my $ditemid = $itemid * 256 + $item->{'anum'};
+        my $ditemid   = $itemid * 256 + $item->{'anum'};
         my $entry_obj = LJ::Entry->new($u, ditemid => $ditemid);
-        
+
         next ENTRY unless $entry_obj->visible_to($remote, {'viewall' => $viewall, 'viewsome' => $viewsome});
 
         $entry_obj->handle_prefetched_props($logprops{$itemid});
         my $replycount = $logprops{$itemid}->{'replycount'};
-        my $subject = $logtext->{$itemid}->[0];
-        my $text = $logtext->{$itemid}->[1];
-        if ($get->{'nohtml'}) {
+        my $subject    = $logtext->{$itemid}->[0];
+        my $text       = $logtext->{$itemid}->[1];
+
+        if ( $get->{'nohtml'} ) {
             # quote all non-LJ tags
             $subject =~ s{<(?!/?lj)(.*?)>} {&lt;$1&gt;}gi;
             $text    =~ s{<(?!/?lj)(.*?)>} {&lt;$1&gt;}gi;
@@ -162,8 +164,9 @@
 
         my $date = substr($alldatepart, 0, 10);
         my $new_day = 0;
+
         if ($date ne $lastdate) {
-            $new_day = 1;
+            $new_day  = 1;
             $lastdate = $date;
             $lastentry->{'end_day'} = 1 if $lastentry;
         }
@@ -171,20 +174,36 @@
         LJ::CleanHTML::clean_subject(\$subject) if $subject;
 
         my $suspend_msg = $entry_obj && $entry_obj->should_show_suspend_msg_to($remote) ? 1 : 0;
-        LJ::CleanHTML::clean_event(\$text, { 'preformatted' => $logprops{$itemid}->{'opt_preformatted'},
-                                              'cuturl' => $entry_obj->prop('reposted_from') || $entry_obj->url,
-                                              'entry_url' => $entry_obj->prop('reposted_from') || $entry_obj->url,
-                                              'ljcut_disable' => ($remote) ? $remote->prop("opt_ljcut_disable_lastn") : undef,
-                                              'suspend_msg' => $suspend_msg,
-                                              'unsuspend_supportid' => $suspend_msg ? $entry_obj->prop("unsuspend_supportid") : 0,
-                                              'journalid' => $entry_obj->journalid,
-                                              'posterid' => $entry_obj->posterid,
-                                           });
-        LJ::expand_embedded($u, $ditemid, $remote, \$text);
+        LJ::CleanHTML::clean_event(
+            \$text,
+            {
+                'preformatted'        => $logprops{$itemid}->{'opt_preformatted'},
+                'cuturl'              => $entry_obj->prop('reposted_from') || $entry_obj->url,
+                'entry_url'           => $entry_obj->prop('reposted_from') || $entry_obj->url,
+                'ljcut_disable'       => $ljcut_disable,
+                'suspend_msg'         => $suspend_msg,
+                'unsuspend_supportid' => $suspend_msg ? $entry_obj->prop("unsuspend_supportid") : 0,
+                'journalid'           => $entry_obj->journalid,
+                'posterid'            => $entry_obj->posterid,
+                'video_placeholders'  => $replace_video,
+            },
+        );
 
-        $text = LJ::ContentFlag->transform_post(post => $text, journal => $u,
-                                                remote => $remote, entry => $entry_obj);
+        LJ::expand_embedded(
+            $u,
+            $ditemid,
+            $remote,
+            \$text,
+            'video_placeholders' => $replace_video,
+        );
 
+        $text = LJ::ContentFlag->transform_post(
+            'post'    => $text,
+            'journal' => $u,
+            'remote'  => $remote,
+            'entry'   => $entry_obj,
+        );
+
         my @taglist;
         while (my ($kwid, $kw) = each %{$tags->{"$u->{userid} $itemid"} || {}}) {
             push @taglist, Tag($u, $kwid => $kw);

Modified: trunk/cgi-bin/LJ/Setting/EmbedPlaceholders.pm
===================================================================
--- trunk/cgi-bin/LJ/Setting/EmbedPlaceholders.pm	2012-02-06 09:24:26 UTC (rev 21103)
+++ trunk/cgi-bin/LJ/Setting/EmbedPlaceholders.pm	2012-02-06 10:54:03 UTC (rev 21104)
@@ -26,32 +26,51 @@
     my ($class, $u, $errs, $args) = @_;
     my $key = $class->pkgkey;
 
-    my $embedplaceholders = $class->get_arg($args, "embedplaceholders") || $u->prop("opt_embedplaceholders") eq "Y";
+    my $imgplaceholders = $u->get_opt_videolinks;
+    my( $chk1, $chk2 );
 
-    my $ret = LJ::html_check({
-        name => "${key}embedplaceholders",
-        id => "${key}embedplaceholders",
-        value => 1,
-        selected => $embedplaceholders ? 1 : 0,
-    });
-    $ret .= " <label for='${key}embedplaceholders'>" . $class->ml('setting.embedplaceholders.option') . "</label>";
+    if ( $imgplaceholders =~ /^(\d)\:(\d)$/ ) {
+        $chk1 = $1;
+        $chk2 = $2;
+    }
+    else {
+        $chk1 = 0;
+        $chk2 = 0;
+    }
 
+    my $ret = $class->ml('setting.videoplaceholders.option2')
+        . "<label for='${key}check1'>"
+        . LJ::html_check({
+            selected => $chk1,
+            name     => "${key}check1",
+          })
+        . $class->ml('setting.videoplaceholders.option2.checkbox1')
+        . "</label> "
+        . "<label for='${key}check2'>"
+        . LJ::html_check({
+            selected => $chk2,
+            name     => "${key}check2",
+          })
+        . $class->ml('setting.videoplaceholders.option2.checkbox2')
+        . "</label> ";
+
+    my $errdiv = $class->errdiv($errs, "vidplaceholders");
+    $ret .= "<br />$errdiv" if $errdiv;
+
     return $ret;
 }
 
 sub save {
     my ($class, $u, $args) = @_;
 
-    my $val = $class->get_arg($args, "embedplaceholders") ? "Y" : "N";
+    my @val;
+    push @val, $class->get_arg($args, $_) for map { "check$_" } 1..2;
+    @val = map { $_ eq 'on' ? 1 : 0 } @val;
+
+    my $val = join( ':', @val );
     $u->set_prop( opt_embedplaceholders => $val );
 
     return 1;
 }
 
-sub as_html {
-    my ($class, $u, $errs, $args) = @_;
-
-    return $class->option($u, $errs, $args);
-}
-
 1;

Modified: trunk/cgi-bin/LJ/User.pm
===================================================================
--- trunk/cgi-bin/LJ/User.pm	2012-02-06 09:24:26 UTC (rev 21103)
+++ trunk/cgi-bin/LJ/User.pm	2012-02-06 10:54:03 UTC (rev 21104)
@@ -4061,19 +4061,6 @@
     return $prop eq 'Y';
 }
 
-sub opt_embedplaceholders {
-    my $u = shift;
-
-    my $prop = $u->raw_prop('opt_embedplaceholders');
-
-    if (defined $prop) {
-        return $prop;
-    } else {
-        my $imagelinks = $u->prop('opt_imagelinks');
-        return $imagelinks;
-    }
-}
-
 # opt_imagelinks format:
 # 0|1 - replace images with placeholders at friends page
 # :   - delimiter
@@ -4108,6 +4095,36 @@
     return 0;
 }
 
+sub get_opt_videolinks {
+    my $u = shift;
+    my $opt = $u->raw_prop("opt_embedplaceholders") || "0:0";
+    $opt = "0:0" unless $opt;
+    $opt = "1:0" unless $opt =~ /^\d\:\d$/;
+    return $opt;
+}
+
+sub opt_embedplaceholders {
+    my $u = shift;
+    my $opt = $u->get_opt_videolinks;
+
+    if ( $opt =~ /^(\d)\:\d$/ ) {
+        return $1;
+    }
+
+    return 0;
+}
+
+sub opt_videoplaceholders_comments {
+    my $u = shift;
+    my $opt = $u->get_opt_videolinks;
+
+    if ( $opt =~ /^\d\:(\d)$/ ) {
+        return $1;
+    }
+
+    return 0;
+}
+
 sub opt_showmutualfriends {
     my $u = shift;
     return $u->raw_prop('opt_showmutualfriends') ? 1 : 0;

Modified: trunk/cgi-bin/cleanhtml.pl
===================================================================
--- trunk/cgi-bin/cleanhtml.pl	2012-02-06 09:24:26 UTC (rev 21103)
+++ trunk/cgi-bin/cleanhtml.pl	2012-02-06 10:54:03 UTC (rev 21104)
@@ -452,13 +452,13 @@
                     # start a capture loop, because there won't be a close tag.
                     if ($attr->{'/'}) {
                         $newdata .= LJ::run_hook("transform_embed", [$token],
-                                                 nocheck => $transform_embed_nocheck, wmode => $transform_embed_wmode) || "";
+                                                 nocheck => $transform_embed_nocheck, wmode => $transform_embed_wmode, video_placeholders => $opts->{video_placeholders}) || "";
                         next TOKEN;
                     }
 
                     $start_capture->($tag, $token, sub {
                         my $expanded = LJ::run_hook("transform_embed", \@capture,
-                                                    nocheck => $transform_embed_nocheck, wmode => $transform_embed_wmode);
+                                                    nocheck => $transform_embed_nocheck, wmode => $transform_embed_wmode, video_placeholders => $opts->{video_placeholders});
                         $newdata .= $expanded || "";
                     });
                     next TOKEN;
@@ -1996,6 +1996,7 @@
         'remove_positioning' => 1,
         'posterid'           => $opts->{'posterid'},
         'img_placeholders'   => $opts->{'img_placeholders'},
+        'video_placeholders' => $opts->{'video_placeholders'},
     });
 }
 

Modified: trunk/cgi-bin/ljviews.pl
===================================================================
--- trunk/cgi-bin/ljviews.pl	2012-02-06 09:24:26 UTC (rev 21103)
+++ trunk/cgi-bin/ljviews.pl	2012-02-06 10:54:03 UTC (rev 21104)
@@ -1266,6 +1266,9 @@
             });
     }
 
+    my $ljcut_disable = $remote ? $remote->prop("opt_ljcut_disable_lastn") : undef;
+    my $replace_video = $remote ? $remote->opt_embedplaceholders : 0;
+
     # spit out the S1
 
   ENTRY:
@@ -1334,19 +1337,37 @@
         $lastn_event{'itemargs'} = $itemargs;
 
         my $suspend_msg = $entry_obj && $entry_obj->should_show_suspend_msg_to($remote) ? 1 : 0;
-        LJ::CleanHTML::clean_event(\$event, { 'preformatted' => $logprops{$itemid}->{'opt_preformatted'},
-                                               'cuturl' => $entry_obj->prop('reposted_from') || $entry_obj->url,
-                                               'entry_url' => $entry_obj->prop('reposted_from') || $entry_obj->url,
-                                               'ljcut_disable' => ($remote) ? $remote->{'opt_ljcut_disable_lastn'} : undef,
-                                               'suspend_msg' => $suspend_msg,
-                                               'unsuspend_supportid' => $suspend_msg ? $entry_obj->prop("unsuspend_supportid") : 0,
-                                               'journalid' => $entry_obj->journalid,
-                                               'posterid' => $entry_obj->posterid,
-                                            });
-        LJ::expand_embedded($u, $ditemid, $remote, \$event);
 
-        $event = LJ::ContentFlag->transform_post(post => $event, journal => $u,
-                                                 remote => $remote, entry => $entry_obj);
+        LJ::CleanHTML::clean_event(
+            \$event,
+            {
+                'preformatted'        => $logprops{$itemid}->{'opt_preformatted'},
+                'cuturl'              => $entry_obj->prop('reposted_from') || $entry_obj->url,
+                'entry_url'           => $entry_obj->prop('reposted_from') || $entry_obj->url,
+                'ljcut_disable'       => $ljcut_disable,
+                'suspend_msg'         => $suspend_msg,
+                'unsuspend_supportid' => $suspend_msg ? $entry_obj->prop("unsuspend_supportid") : 0,
+                'journalid'           => $entry_obj->journalid,
+                'posterid'            => $entry_obj->posterid,
+                'video_placeholders'  => $replace_video,
+            },
+        );
+
+        LJ::expand_embedded(
+            $u,
+            $ditemid,
+            $remote,
+            \$event,
+            'video_placeholders' => $replace_video,
+        );
+
+        $event = LJ::ContentFlag->transform_post(
+            'post'    => $event,
+            'journal' => $u,
+            'remote'  => $remote,
+            'entry'   => $entry_obj,
+        );
+
         $lastn_event{'event'} = $event;
 
         my $permalink = "$journalbase/$ditemid.html";
@@ -1785,6 +1806,9 @@
         $replace_images_in_friendspage = $remote->opt_placeholders_friendspage;
     }
 
+    my $ljcut_disable = $remote ? $remote->prop("opt_ljcut_disable_lastn") : undef;
+    my $replace_video = $remote ? $remote->opt_embedplaceholders : 0;
+
     my %friends_events = ();
     my $events = \$friends_events{'events'};
 
@@ -1827,10 +1851,10 @@
             $event = LJ::Lang::ml(
                 'friendsposts.reposted',
                 {
-                    'user'    => $logprops{$datakey}->{'repost_author'},
-                    'subject' => $logprops{$datakey}->{'repost_subject'},
+                    'user'     => $logprops{$datakey}->{'repost_author'},
+                    'subject'  => $logprops{$datakey}->{'repost_subject'},
                     'orig_url' => $logprops{$datakey}->{'repost_url'},
-                    'url'     => $entry_obj->url,
+                    'url'      => $entry_obj->url,
             });
         }
 
@@ -1898,17 +1922,30 @@
                 'preformatted'        => $logprops{$datakey}->{'opt_preformatted'},
                 'cuturl'              => $entry_obj->prop('reposted_from') || $entry_obj->url(%urlopts_style),
                 'entry_url'           => $entry_obj->prop('reposted_from') || $entry_obj->url,
-                'ljcut_disable'       => ($remote) ? $remote->{'opt_ljcut_disable_friends'} : undef,
+                'ljcut_disable'       => $ljcut_disable,
                 'suspend_msg'         => $suspend_msg,
                 'unsuspend_supportid' => $suspend_msg ? $entry_obj->prop("unsuspend_supportid") : 0,
                 'journalid'           => $entry_obj->journalid,
                 'posterid'            => $entry_obj->posterid,
                 'img_placeholders'    => $replace_images_in_friendspage,
+                'video_placeholders'  => $replace_video,
         });
-        LJ::expand_embedded($friends{$friendid}, $ditemid, $remote, \$event);
 
-        $event = LJ::ContentFlag->transform_post(post => $event, journal => $friends{$friendid},
-                                                 remote => $remote, entry => $entry_obj);
+        LJ::expand_embedded(
+            $friends{$friendid},
+            $ditemid,
+            $remote,
+            \$event,
+            'video_placeholders' => $replace_video,
+        );
+
+        $event = LJ::ContentFlag->transform_post(
+            'post' => $event,
+            'journal' => $friends{$friendid},
+            'remote' => $remote,
+            'entry' => $entry_obj,
+        );
+
         $friends_event{'event'} = $event;
 
         # do the picture
@@ -2576,6 +2613,9 @@
     my $events = "";
     my $eventnum = 0;
 
+    my $ljcut_disable = $remote ? $remote->prop("opt_ljcut_disable_lastn") : undef;
+    my $replace_video = $remote ? $remote->opt_embedplaceholders : 0;
+
   ENTRY:
     foreach my $item (@items) {
         my ($itemid, $posterid, $security, $alldatepart, $anum) =
@@ -2619,6 +2659,7 @@
         my %day_event = ();
         $day_event{'itemid'} = $itemid;
         $day_event{'datetime'} = LJ::fill_var_props($vars, 'DAY_DATE_FORMAT', \%day_date_format);
+
         if ($subject ne "") {
             LJ::CleanHTML::clean_subject(\$subject);
             $day_event{'subject'} = LJ::fill_var_props($vars, 'DAY_SUBJECT', {
@@ -2627,23 +2668,40 @@
         }
 
         my $itemargs = "journal=$user&amp;itemid=$ditemid";
-        
+
         $day_event{'itemargs'} = $itemargs;
 
         my $suspend_msg = $entry_obj && $entry_obj->should_show_suspend_msg_to($remote) ? 1 : 0;
-        LJ::CleanHTML::clean_event(\$event, { 'preformatted' => $logprops{$itemid}->{'opt_preformatted'},
-                                              'cuturl' => $entry_obj->prop('reposted_from') || $entry_obj->url,
-                                              'entry_url' => $entry_obj->prop('reposted_from') || $entry_obj->url,
-                                              'ljcut_disable' => ($remote) ? $remote->{'opt_ljcut_disable_lastn'} : undef,
-                                              'suspend_msg' => $suspend_msg,
-                                              'unsuspend_supportid' => $suspend_msg ? $entry_obj->prop("unsuspend_supportid") : 0,
-                                              'journalid' => $entry_obj->journalid,
-                                              'posterid' => $entry_obj->posterid,
-                                            });
-        LJ::expand_embedded($u, $ditemid, $remote, \$event);
-    
-        $event = LJ::ContentFlag->transform_post(post => $event, journal => $u,
-                                                 remote => $remote, entry => $entry_obj);
+
+        LJ::CleanHTML::clean_event(
+            \$event,
+            {
+                'preformatted'        => $logprops{$itemid}->{'opt_preformatted'},
+                'cuturl'              => $entry_obj->prop('reposted_from') || $entry_obj->url,
+                'entry_url'           => $entry_obj->prop('reposted_from') || $entry_obj->url,
+                'ljcut_disable'       => $ljcut_disable,
+                'suspend_msg'         => $suspend_msg,
+                'unsuspend_supportid' => $suspend_msg ? $entry_obj->prop("unsuspend_supportid") : 0,
+                'journalid'           => $entry_obj->journalid,
+                'posterid'            => $entry_obj->posterid,
+                'video_placeholders'  => $replace_video,
+        });
+
+        LJ::expand_embedded(
+            $u,
+            $ditemid,
+            $remote,
+            \$event,
+            'video_placeholders' => $replace_video,
+        );
+
+        $event = LJ::ContentFlag->transform_post(
+            'post'    => $event,
+            'journal' => $u,
+            'remote'  => $remote,
+            'entry'   => $entry_obj,
+        );
+
         $day_event{'event'} = $event;
 
         my $permalink = "$journalbase/$ditemid.html";

Tags: amyshkin, livejournal, pl, pm, zilogic
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