Files
oddmuse/modules/page-trail.pl

59 lines
1.7 KiB
Perl
Raw Normal View History

2004-01-30 21:35:44 +00:00
# Copyright (C) 2004 Alex Schroeder <alex@emacswiki.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
2004-01-30 21:35:44 +00:00
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2004-01-30 21:35:44 +00:00
use strict;
use v5.10;
AddModuleDescription('page-trail.pl', 'Page Trail Extension');
our ($q, %CookieParameters);
2015-04-10 13:31:28 +03:00
our ($PageTrailLength);
2004-01-30 11:53:18 +00:00
$PageTrailLength = 10;
$CookieParameters{trail} = '';
my @PageTrail;
*OldPageTrailBrowsePage = \&BrowsePage;
*BrowsePage = \&NewPageTrailBrowsePage;
2004-01-30 11:53:18 +00:00
sub NewPageTrailBrowsePage {
my ($id, @rest) = @_;
2004-01-30 11:53:18 +00:00
UpdatePageTrail($id);
OldPageTrailBrowsePage($id, @rest);
2004-01-30 11:53:18 +00:00
}
sub UpdatePageTrail {
my $id = shift;
my @trail = ($id);
foreach my $page (split(/ /, GetParam('trail', ''))) {
push(@trail, $page) unless $page eq $id;
}
@trail = @trail[0..$PageTrailLength-1] if $trail[$PageTrailLength];
$q->param('trail', join(' ', @trail));
@PageTrail = @trail;
2004-01-30 11:53:18 +00:00
}
*OldPageTrailGetGotoBar = \&GetGotoBar;
*GetGotoBar = \&NewPageTrailGetGotoBar;
2004-01-30 11:53:18 +00:00
sub NewPageTrailGetGotoBar {
my $bar = OldPageTrailGetGotoBar(@_);
$bar .= $q->span({-class=>'trail'}, $q->br(), T('Trail:') . ' ',
2004-01-30 11:53:18 +00:00
map { GetPageLink($_) } reverse(@PageTrail))
if @PageTrail;
return $bar;
}