mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)
Mark Smith ([staff profile] mark) wrote in [site community profile] changelog2009-03-31 05:10 am

[dw-free] Add more meta links

[commit: http://hg.dwscoalition.org/dw-free/rev/65b474f1b6de]

http://bugs.dwscoalition.org/show_bug.cgi?id=562

Add more meta links to S2 output pages.

Patch by [personal profile] afuna.

Files modified:
  • cgi-bin/LJ/S2.pm
  • cgi-bin/LJ/S2/DayPage.pm
  • cgi-bin/LJ/S2/EntryPage.pm
  • cgi-bin/LJ/S2/FriendsPage.pm
  • cgi-bin/LJ/S2/MonthPage.pm
  • cgi-bin/LJ/S2/RecentPage.pm
  • cgi-bin/LJ/S2/YearPage.pm
--------------------------------------------------------------------------------
diff -r d0e44df5951e -r 65b474f1b6de cgi-bin/LJ/S2.pm
--- a/cgi-bin/LJ/S2.pm	Tue Mar 31 05:05:24 2009 +0000
+++ b/cgi-bin/LJ/S2.pm	Tue Mar 31 05:10:56 2009 +0000
@@ -2032,6 +2032,9 @@ sub Page
     # OpenID information if the caller asked us to include it here.
     $p->{'head_content'} .= $u->openid_tags if $opts && $opts->{'addopenid'};
 
+    # other useful link rels
+    $p->{head_content} .= qq{<link rel="help" href="$LJ::SITEROOT/support/faq" />\n};
+
     # Control strip
     my $show_control_strip = LJ::run_hook( 'show_control_strip' );
     if ($show_control_strip) {
diff -r d0e44df5951e -r 65b474f1b6de cgi-bin/LJ/S2/DayPage.pm
--- a/cgi-bin/LJ/S2/DayPage.pm	Tue Mar 31 05:05:24 2009 +0000
+++ b/cgi-bin/LJ/S2/DayPage.pm	Tue Mar 31 05:10:56 2009 +0000
@@ -258,6 +258,9 @@ sub DayPage
     $p->{'next_url'} = defined $next ? ("$u->{'_journalbase'}/$next") : '';
     $p->{'next_date'} = $ndate;
 
+    $p->{head_content} .= qq{<link rel="prev" href="$p->{prev_url}" />\n} if $p->{prev_url};
+    $p->{head_content} .= qq{<link rel="next" href="$p->{next_url}" />\n} if $p->{next_url};
+
     return $p;
 }
 
diff -r d0e44df5951e -r 65b474f1b6de cgi-bin/LJ/S2/EntryPage.pm
--- a/cgi-bin/LJ/S2/EntryPage.pm	Tue Mar 31 05:05:24 2009 +0000
+++ b/cgi-bin/LJ/S2/EntryPage.pm	Tue Mar 31 05:10:56 2009 +0000
@@ -48,6 +48,12 @@ sub EntryPage
     if ($LJ::UNICODE) {
         $p->{'head_content'} .= '<meta http-equiv="Content-Type" content="text/html; charset='.$opts->{'saycharset'}."\" />\n";
     }
+    
+    my $prev_url = S2::Builtin::LJ::Entry__get_link( $opts->{ctx}, $s2entry, "nav_prev" )->{url};
+    $p->{head_content} .= qq{<link rel="prev" href="$prev_url" />\n} if $prev_url;
+    
+    my $next_url = S2::Builtin::LJ::Entry__get_link( $opts->{ctx}, $s2entry, "nav_next" )->{url};
+    $p->{head_content} .= qq{<link rel="next" href="$next_url" />\n} if $next_url;
 
     # quickreply js libs
     LJ::need_res(qw(
diff -r d0e44df5951e -r 65b474f1b6de cgi-bin/LJ/S2/FriendsPage.pm
--- a/cgi-bin/LJ/S2/FriendsPage.pm	Tue Mar 31 05:05:24 2009 +0000
+++ b/cgi-bin/LJ/S2/FriendsPage.pm	Tue Mar 31 05:10:56 2009 +0000
@@ -406,6 +406,7 @@ sub FriendsPage
         $nav->{'forward_url'} = LJ::make_link($base, \%linkvars);
         $nav->{'forward_skip'} = $newskip;
         $nav->{'forward_count'} = $itemshow;
+        $p->{head_content} .= qq{<link rel="next" href="$nav->{forward_url}" />\n}
     }
 
     ## unless we didn't even load as many as we were expecting on this
@@ -422,6 +423,7 @@ sub FriendsPage
         $nav->{'backward_url'} = LJ::make_link($base, \%linkvars);
         $nav->{'backward_skip'} = $newskip;
         $nav->{'backward_count'} = $itemshow;
+        $p->{head_content} .= qq{<link rel="prev" href="$nav->{backward_url}" />\n};
     }
 
     $p->{'nav'} = $nav;
diff -r d0e44df5951e -r 65b474f1b6de cgi-bin/LJ/S2/MonthPage.pm
--- a/cgi-bin/LJ/S2/MonthPage.pm	Tue Mar 31 05:05:24 2009 +0000
+++ b/cgi-bin/LJ/S2/MonthPage.pm	Tue Mar 31 05:10:56 2009 +0000
@@ -249,6 +249,9 @@ sub MonthPage
         }
     }
 
+    $p->{head_content} .= qq{<link rel="prev" href="$p->{prev_url}" />\n} if $p->{prev_url};
+    $p->{head_content} .= qq{<link rel="next" href="$p->{next_url}" />\n} if $p->{next_url};
+
     return $p;
 }
 
diff -r d0e44df5951e -r 65b474f1b6de cgi-bin/LJ/S2/RecentPage.pm
--- a/cgi-bin/LJ/S2/RecentPage.pm	Tue Mar 31 05:05:24 2009 +0000
+++ b/cgi-bin/LJ/S2/RecentPage.pm	Tue Mar 31 05:10:56 2009 +0000
@@ -272,6 +272,7 @@ sub RecentPage
                                                                    tag      => (LJ::eurl($get->{tag})      || ""),
                                                                    security => (LJ::eurl($get->{security}) || "") });
         $nav->{'forward_count'} = $itemshow;
+        $p->{head_content} .= qq{<link rel="next" href="$nav->{forward_url}" />\n}
     }
 
     # unless we didn't even load as many as we were expecting on this
@@ -290,6 +291,7 @@ sub RecentPage
                                                                           security => (LJ::eurl($get->{security}) || "") });
             $nav->{'backward_skip'} = $newskip;
         }
+        $p->{head_content} .= qq{<link rel="prev" href="$nav->{backward_url}" />\n};
     }
 
     $p->{'nav'} = $nav;
diff -r d0e44df5951e -r 65b474f1b6de cgi-bin/LJ/S2/YearPage.pm
--- a/cgi-bin/LJ/S2/YearPage.pm	Tue Mar 31 05:05:24 2009 +0000
+++ b/cgi-bin/LJ/S2/YearPage.pm	Tue Mar 31 05:10:56 2009 +0000
@@ -38,9 +38,18 @@ sub YearPage
 
     $p->{'year'} = $year;
     $p->{'years'} = [];
-    foreach (@years) {
-        push @{$p->{'years'}}, YearYear($_, "$p->{'base_url'}/$_/", $_ == $p->{'year'});
+
+    my $displayed_index;
+    for my $i ( 0..$#years ) {
+        my $year = $years[$i];
+        push @{$p->{'years'}}, YearYear($year, "$p->{'base_url'}/$year/", $year == $p->{'year'});
+        $displayed_index = $i if $year == $p->{year};
     }
+
+    $p->{head_content} .= qq{<link rel="prev" href="$p->{years}->[$displayed_index-1]->{url}" />\n} 
+        if $displayed_index > 0;
+    $p->{head_content} .= qq{<link rel="next" href="$p->{years}->[$displayed_index+1]->{url}" />\n} 
+        if $displayed_index < $#years; 
 
     $p->{'months'} = [];
 
--------------------------------------------------------------------------------
ext_78: A picture of a plush animal. It looks a bit like a cross between a duck and a platypus. (Default)

[identity profile] pne.livejournal.com 2009-03-31 08:51 am (UTC)(link)
Ooh. That seems like an obvious enough thing to do, in hindsight.

Thanks!