[livejournal] r19469: LJSV-1286: embed video copy to user on r...
Committer: sbelyaev
LJSV-1286: embed video copy to user on repost.U trunk/cgi-bin/LJ/EmbedModule.pm U trunk/htdocs/update.bml
Modified: trunk/cgi-bin/LJ/EmbedModule.pm
===================================================================
--- trunk/cgi-bin/LJ/EmbedModule.pm 2011-07-12 09:27:53 UTC (rev 19468)
+++ trunk/cgi-bin/LJ/EmbedModule.pm 2011-07-13 05:55:26 UTC (rev 19469)
@@ -158,7 +158,15 @@
}
};
+sub add_user_to_embed {
+ my ($class, $u, $postref) = @_;
+ return unless $postref && $$postref;
+
+ my $journal = $u->user;
+ $$postref =~ s/(<lj\-embed\s+id=)/<lj\-embed source_user="$journal" id=/g;
+}
+
# take a scalarref to a post, parses any lj-embed tags, saves the contents
# of the tags and replaces them with a module tag with the id.
# REPLACE
@@ -213,6 +221,26 @@
$embed_attrs{id} = $attr->{id} if $attr->{id};
$embed_attrs{width} = ($attr->{width} > MAX_WIDTH ? MAX_WIDTH : $attr->{width}) if $attr->{width};
$embed_attrs{height} = ($attr->{height} > MAX_HEIGHT ? MAX_HEIGHT : $attr->{height}) if $attr->{height};
+ } elsif ($tag eq 'lj-embed' && $type eq 'S' &&
+ $attr->{'source_user'} && $attr->{'/'}) {
+
+ my $u = LJ::load_user($attr->{'source_user'});
+
+ if ($u) {
+ $newstate = REGULAR;
+ $embed = $class->module_content( moduleid => $attr->{id},
+ journalid => $u->id );
+
+ if ($embed ne "") {
+ if ($attr->{width}) {
+ $embed_attrs{width} = $attr->{width} > MAX_WIDTH ? MAX_WIDTH : $attr->{width};
+ }
+
+ if ($attr->{height}) {
+ $embed_attrs{height} = $attr->{height} > MAX_HEIGHT ? MAX_HEIGHT : $attr->{height};
+ }
+ }
+ }
} elsif (($tag eq 'object' || $tag eq 'embed' || $tag eq 'iframe') && $type eq 'S') {
# <object> or <embed>
# switch to IMPLICIT state unless it is a self-closed tag
Modified: trunk/htdocs/update.bml
===================================================================
--- trunk/htdocs/update.bml 2011-07-12 09:27:53 UTC (rev 19468)
+++ trunk/htdocs/update.bml 2011-07-13 05:55:26 UTC (rev 19469)
@@ -170,8 +170,14 @@
if ($entry->visible_to($remote)){
$subject ||= (LJ::ehtml($entry->subject_orig) || LJ::Lang::ml("repost.default_subject"));
- unless ($event){
+ unless ($event) {
$event = $entry->event_raw;
+ my $journalu = $entry->journal;
+
+ if (!$journalu->equals($remote)) {
+ LJ::EmbedModule->add_user_to_embed($journalu, \$event);
+ }
+
$event = LJ::Lang::ml("repost.wrapper", {
username => $entry->poster->username,
url => $entry->url,
