Committer: janineSupport for overriding the profile and/or journal URLs for the spotlight/sponsored community ljuser tags.
Also support for adding a small image next to the description.
http://rt.livejournal.org/Ticket/Display.html?id=3646 U branches/r4/bin/upgrading/update-db-local.pl
U branches/r4/cgi-bin/LJ/JournalSpotlight.pm
U branches/r4/cgi-bin/LJ/Widget/AddJournalSpotlight.pm
U branches/r4/cgi-bin/LJ/Widget/JournalSpotlight.pm
Modified: branches/r4/bin/upgrading/update-db-local.pl
===================================================================
--- branches/r4/bin/upgrading/update-db-local.pl 2007-03-22 10:18:10 UTC (rev 4625)
+++ branches/r4/bin/upgrading/update-db-local.pl 2007-03-22 21:58:22 UTC (rev 4626)
@@ -1022,7 +1022,15 @@
"ADD PRIMARY KEY (userid, domain)");
}
+ unless (column_type("journal_spotlight", "profile_url")) {
+ do_alter("journal_spotlight",
+ "ALTER TABLE journal_spotlight
+ ADD( profile_url varchar(255) DEFAULT NULL,
+ journal_url varchar(255) DEFAULT NULL,
+ small_img_url varchar(255) DEFAULT NULL )");
+ }
+
});
1; # true
Modified: branches/r4/cgi-bin/LJ/JournalSpotlight.pm
===================================================================
--- branches/r4/cgi-bin/LJ/JournalSpotlight.pm 2007-03-22 10:18:10 UTC (rev 4625)
+++ branches/r4/cgi-bin/LJ/JournalSpotlight.pm 2007-03-22 21:58:22 UTC (rev 4626)
@@ -238,8 +238,8 @@
# update existing spotlight
$dbh->do("REPLACE INTO journal_spotlight SET userid=?, time_start=?, " .
- "time_end=?, active=?, des=?, domain=?",
- undef, $u->id, (map { $vals{$_} } qw(time_start time_end active desc domain)))
+ "time_end=?, active=?, des=?, domain=?, profile_url=?, journal_url=?, small_img_url=?",
+ undef, $u->id, (map { $vals{$_} } qw(time_start time_end active desc domain profile_url journal_url small_img_url)))
or die "Error updating journal_spotlight: " . $dbh->errstr;
# clear cache
@@ -339,6 +339,19 @@
return $rv;
}
+# parse the given URL
+# * replace '[[uniq]]' with a unique identifier
+sub parse_url {
+ my $class = shift;
+ my $u = shift;
+ my $url = shift;
+
+ my $uniq = ($u ? $u->id : "") . time() . LJ::rand_chars(8);
+ $url =~ s/\[\[uniq\]\]/$uniq/g;
+
+ return $url;
+}
+
# To make the JournalSpotlight widget look like the one on the homepage
# FIXME: this is ghetto, do we need a stripped-down admin look file?
sub need_res {
Modified: branches/r4/cgi-bin/LJ/Widget/AddJournalSpotlight.pm
===================================================================
--- branches/r4/cgi-bin/LJ/Widget/AddJournalSpotlight.pm 2007-03-22 10:18:10 UTC (rev 4625)
+++ branches/r4/cgi-bin/LJ/Widget/AddJournalSpotlight.pm 2007-03-22 21:58:22 UTC (rev 4626)
@@ -120,6 +120,27 @@
( name => 'domain',
value => $domain || 'lj' );
+ $ret .= "Leave the fields below blank for default values
";
+ $ret .= "Use [[uniq]] in the URLs to have a unique identifier placed there automatically.";
+
+ $ret .= "Replace Journal/Community Profile URL with:
";
+ $ret .= $class->html_text
+ ( name => 'profile_url',
+ size => 30,
+ maxlength => 255 ) . "";
+
+ $ret .= "Replace Journal/Community Journal URL with:
";
+ $ret .= $class->html_text
+ ( name => 'journal_url',
+ size => 30,
+ maxlength => 255 ) . "";
+
+ $ret .= "Add a 1x1 image with this URL:
";
+ $ret .= $class->html_text
+ ( name => 'small_img_url',
+ size => 30,
+ maxlength => 255 ) . "";
+
$ret .= "";
$ret .= $class->html_submit('Submit') . "";
$ret .= "";
@@ -169,7 +190,10 @@
time_end => $time_end->epoch,
active => 'Y',
desc => $post->{desc},
- domain => $post->{domain});
+ domain => $post->{domain},
+ profile_url => $post->{profile_url},
+ journal_url => $post->{journal_url},
+ small_img_url => $post->{small_img_url});
return;
}
Modified: branches/r4/cgi-bin/LJ/Widget/JournalSpotlight.pm
===================================================================
--- branches/r4/cgi-bin/LJ/Widget/JournalSpotlight.pm 2007-03-22 10:18:10 UTC (rev 4625)
+++ branches/r4/cgi-bin/LJ/Widget/JournalSpotlight.pm 2007-03-22 21:58:22 UTC (rev 4626)
@@ -107,14 +107,27 @@
my $u = $us->{$row->{userid}};
next unless $u;
+ my ($profile_url, $journal_url, $small_img_url);
+ if ($row->{profile_url}) {
+ $profile_url = LJ::JournalSpotlight->parse_url($u, $row->{profile_url});
+ }
+ if ($row->{journal_url}) {
+ $journal_url = LJ::JournalSpotlight->parse_url($u, $row->{journal_url});
+ }
+ if ($row->{small_img_url}) {
+ $small_img_url = LJ::JournalSpotlight->parse_url($u, $row->{small_img_url});
+ }
+
$ret .= "
";
if ($show_userpics) {
my $userpic = $u->userpic;
$ret .= "" . $userpic->imgtag . ""
if $userpic;
}
- $ret .= "" . $u->ljuser_display . "
";
- $ret .= "
" . LJ::ehtml($row->{des}) . "
";
+ $ret .= "" . $u->ljuser_display({profile_url => $profile_url, journal_url => $journal_url}) . "
";
+ $ret .= "
" . LJ::ehtml($row->{des});
+ $ret .= $small_img_url ? "
" : '';
+ $ret .= "
";
$ret .= "";
}