root/blosxom_plugins/trunk/redirect_permalink

Revision 12, 0.9 kB (checked in by miya, 3 years ago)

import blosxom plugins

  • Property svn:executable set to
Line 
1 # Blosxom Plugin: redirect_permalink
2 # Author: Gosuke Miyashita <miya@mizzy.org>
3 # Version: 2005-05-04
4 # Blosxom Home/Docs/Licensing: http://www.blosxom.com/
5
6 package redirect_permalink;
7
8 use strict;
9
10 sub start {
11     return 1;
12 }
13
14 sub last {
15     my ($pkg, $ne) = @_;
16     if($ne eq $blosxom::num_entries){
17         my @path_info = split m{/}, &blosxom::path_info() || param('path');
18         my $fn = $path_info[$#path_info];
19         $fn  =~ s/\.$blosxom::flavour//g;
20
21         use vars qw(*name);
22         *name   = *File::Find::name;
23         my $path;
24         File::Find::find(sub { /$fn.$blosxom::file_extension/s and $path = $name;}, "$blosxom::datadir");
25
26         if($path){
27             $path =~ s/$blosxom::datadir//gi;
28             $path =~ s/$blosxom::file_extension//gi;
29             $path .= $blosxom::flavour;
30            
31             $blosxom::header = {
32                 -status => '301 Moved Permanently',
33                 -location => "$blosxom::url$path",
34             };
35         }
36     }
37
38     return 1;
39 }
40
41 1;
Note: See TracBrowser for help on using the browser.