Have username.dreamwidth.org/archive point to current year, instead of
the latest posted year. If there were no entries posted this year,
intelligently fall back onto the last year the user posted or (if there were
none) the earliest year in the future that the user posted. Also updates the
link in the menu to point to /archive instead of calculating the appropriate
year for the user on each page lload, as a performance improvement.
Patch by Erin of <user name="teamdestroyer">.
diffs (61 lines):
diff -r feac9a972529 -r f87a24183cba cgi-bin/DW/Logic/MenuNav.pm
--- a/cgi-bin/DW/Logic/MenuNav.pm Fri Nov 05 16:49:18 2010 +0800
+++ b/cgi-bin/DW/Logic/MenuNav.pm Fri Nov 05 21:25:32 2010 +0800
@@ -178,7 +178,7 @@ sub get_menu_navigation {
display => $loggedin_hasnetwork,
},
{
- url => $u ? $u->archive_current_month : "",
+ url => $u ? $u->journal_base . "/archive" : "",
text => "menunav.read.archive",
display => $loggedin_hasjournal,
},
diff -r feac9a972529 -r f87a24183cba cgi-bin/LJ/S2/YearPage.pm
--- a/cgi-bin/LJ/S2/YearPage.pm Fri Nov 05 16:49:18 2010 +0800
+++ b/cgi-bin/LJ/S2/YearPage.pm Fri Nov 05 21:25:32 2010 +0800
@@ -38,16 +38,22 @@ sub YearPage
my $count = LJ::S2::get_journal_day_counts($p);
my @years = sort { $a <=> $b } keys %$count;
- my $maxyear = @years ? $years[-1] : undef;
my $year = $get->{'year'}; # old form was /users/<user>/calendar?year=1999
# but the new form is purtier: */archive/2001
if (! $year && $opts->{'pathextra'} =~ m!^/(\d\d\d\d)/?\b!) {
$year = $1;
+ } else {
+ my $curyear = $u->time_now->year;
+ foreach (@years) {
+ $year = $_
+ if $_ <= $curyear;
+ }
+
+ # all entries are in the future, so fall back to the earliest year
+ $year = $years[0]
+ unless $year;
}
-
- # else... default to the year they last posted.
- $year ||= $maxyear;
$p->{'year'} = $year;
$p->{'years'} = [];
diff -r feac9a972529 -r f87a24183cba cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm Fri Nov 05 16:49:18 2010 +0800
+++ b/cgi-bin/LJ/User.pm Fri Nov 05 21:25:32 2010 +0800
@@ -1897,15 +1897,6 @@ sub allow_search_by {
}
-# returns a link to the current year and month in the user's archive
-sub archive_current_month {
- my ( $u ) = @_;
- return '' if $u->is_identity; # no archive to read
- my $t = $u->time_now;
- return sprintf( "%s/%02d/%02d/", $u->journal_base, $t->year, $t->mon );
-}
-
-
sub caps {
my $u = shift;
return $u->{caps};
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog