[livejournal] r23321: LJSV-1557: Links in links list do not ha...
Committer: sbelyaev
LJSV-1557: Links in links list do not have rel=nofollowU trunk/bin/upgrading/s2layers/core1.s2 U trunk/cgi-bin/LJ/S2.pm
Modified: trunk/bin/upgrading/s2layers/core1.s2
===================================================================
--- trunk/bin/upgrading/s2layers/core1.s2 2012-11-19 12:03:09 UTC (rev 23320)
+++ trunk/bin/upgrading/s2layers/core1.s2 2012-11-19 13:07:01 UTC (rev 23321)
@@ -258,6 +258,7 @@
var readonly bool is_heading "Is this link a heading or category name? If so, it has no url and a list of children.";
var readonly string title "The title or label for the link";
var readonly string url "The url to which the link points";
+ var readonly string attributes "The link attributes for 'a' tag";
var readonly UserLink[] children "Not Implemented: An array of child UserLink objects.";
}
@@ -2616,7 +2617,7 @@
if ($l.is_heading) {
"<b>$l.title</b>";
} else {
- "<a href='$l.url'>$l.title</a>";
+ "<a href='$l.url' $l.attributes>$l.title</a>";
}
}
"<br />";
Modified: trunk/cgi-bin/LJ/S2.pm
===================================================================
--- trunk/cgi-bin/LJ/S2.pm 2012-11-19 12:03:09 UTC (rev 23320)
+++ trunk/cgi-bin/LJ/S2.pm 2012-11-19 13:07:01 UTC (rev 23321)
@@ -2136,8 +2136,12 @@
$stylemodtime = $style->{'modtime'} if $style->{'modtime'} > $stylemodtime;
my $linkobj = LJ::Links::load_linkobj($u);
- my $linklist = [ map { UserLink($_) } @$linkobj ];
+ my $rel = !($u->get_cap('paid') || $u->get_cap('trynbuy')) ? { rel => 'nofollow' } : {};
+ my $opts = { attributes => $rel };
+
+ my $linklist = [ map { UserLink($_, $opts ) } @$linkobj ];
+
my $remote = LJ::get_remote();
my $up = undef;
@@ -2162,6 +2166,7 @@
'friends' => "$base_url/friends",
'tags' => "$base_url/tag",
},
+ 'nofollow' => 1,
'linklist' => $linklist,
'views_order' => [ 'recent', 'archive', 'friends', 'userinfo' ],
'global_title' => LJ::ehtml($u->{'journaltitle'} || $u->{'name'}),
@@ -2321,16 +2326,25 @@
sub UserLink
{
- my $link = shift; # hashref
+ my ($link, $options) = @_;
# a dash means pass to s2 as blank so it will just insert a blank line
$link->{'title'} = '' if $link->{'title'} eq "-";
+ my $attributes_text = '';
+
+ if ($options && $options->{attributes}) {
+ my $attr_data = $options->{attributes};
+ my @attr = keys %{$options->{attributes}};
+ $attributes_text = join(' ',
+ map { "$_=\"" . $attr_data->{$_} . "\"" } @attr);
+ }
return {
'_type' => 'UserLink',
'is_heading' => $link->{'url'} ? 0 : 1,
'url' => LJ::ehtml($link->{'url'}),
'title' => LJ::ehtml($link->{'title'}),
+ 'attributes' => $attributes_text,
'children' => $link->{'children'} || [], # TODO: implement parent-child relationships
};
}
