1 # Blosxom Plugin: flavourpathinfo
2 # Author(s): Gavin Carr <gavin@openfusion.com.au>
4 # Documentation: 'perldoc flavourpathinfo'
6 package flavourpathinfo;
10 # --- Configurable variables -----
14 # --------------------------------
16 my $package = 'flavourpathinfo';
18 my ($level, @msg) = @_;
20 if ($debug_level >= $level) {
21 print STDERR "$package debug $level: @msg\n";
26 my $path_info = $blosxom::path_info;
27 debug(1, "original path_info: $path_info");
28 return 1 if -e "$blosxom::datadir/$path_info";
30 # Remove any trailing /
31 $path_info =~ s! /$ !!x;
33 # Check file/flavour variant
34 if ($path_info =~ m! ^ (.*) / ([^/]+) $ !x) {
36 my $path_info_new = "$1.$flavour";
37 my $path_file = "$1.$blosxom::file_extension";
39 debug(2, "path_file: $path_file, path_info_new: $path_info_new");
41 if (-f "$blosxom::datadir/$path_file") {
42 debug(1, "\$path_info_new exists - updating \$blosxom::path_info");
43 $blosxom::path_info = $path_info_new;
44 $blosxom::flavour = $flavour;
45 $blosxom::path_info_yr = undef;
50 # Check dir/flavour variant (implying index.flavour)
51 if ($path_info =~ m! ^ (?: (.*) / )? ([^/]+) $ !x) {
54 debug(2, "dir: $dir, flavour: $flavour");
56 # Check there isn't an entry matching this
57 if (-f "$blosxom::datadir$dir/$flavour.$blosxom::file_extension") {
58 debug(2, "entry $blosxom::datadir/$dir/$flavour.$blosxom::file_extension found - skipping");
62 # Check $dir is a directory (sanity check - overly aggressive?)
63 if ($dir && ! -d "$blosxom::datadir/$dir") {
64 debug(2, "dir '$dir' is set but not a directory");
68 debug(1, "dir '$dir' not set or exists and directory - setting \$blosxom::path_info");
69 $blosxom::path_info = $dir;
70 $blosxom::flavour = $flavour;
71 $blosxom::path_info_yr = undef;
84 flavourpathinfo - allows flavour designation via a trailing path component
85 instead of via a file extension
89 flavourpathinfo is a syntactic sugar plugin that allows flavour designation
90 via a trailing path component instead of via a file extension e.g.
92 http://blog.example.com/category/post/html
93 http://blog.example.com/category/post/atom
94 http://blog.example.com/category/post/trackback
96 instead of the more typical:
98 http://blog.example.com/category/post.html
99 http://blog.example.com/category/post.atom
100 http://blog.example.com/category/post.trackback
102 With index pages, the 'index' portion can also be omitted, if desired:
104 http://blog.example.com/category/html
105 http://blog.example.com/category/atom
109 http://blog.example.com/category/index.html
110 http://blog.example.com/category/index.atom
114 Should be loaded early as it manipulates $blosxom::path_info
115 e.g. as 00flavourpathinfo.
121 Blosxom: http://blosxom.sourceforge.net/
125 Please report bugs either directly to the author or to the blosxom
126 development mailing list: <blosxom-devel@lists.sourceforge.net>.
130 Gavin Carr <gavin@openfusion.com.au>, http://www.openfusion.net/
134 Copyright 2007 Gavin Carr.
136 This plugin is licensed under the same terms as blosxom itself i.e.
138 Permission is hereby granted, free of charge, to any person obtaining a
139 copy of this software and associated documentation files (the "Software"),
140 to deal in the Software without restriction, including without limitation
141 the rights to use, copy, modify, merge, publish, distribute, sublicense,
142 and/or sell copies of the Software, and to permit persons to whom the
143 Software is furnished to do so, subject to the following conditions:
145 The above copyright notice and this permission notice shall be included
146 in all copies or substantial portions of the Software.
148 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
149 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
150 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
151 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
152 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
153 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
154 OTHER DEALINGS IN THE SOFTWARE.