1 # Blosxom Plugin: flavourpathinfo
2 # Author(s): Gavin Carr <gavin@openfusion.com.au>
4 # Documentation: 'perldoc flavourpathinfo'
5 # Follows: extensionless
7 package flavourpathinfo;
11 # --- Configurable variables -----
15 # --------------------------------
17 # use Blosxom::Debug debug_level => 1;
20 my $path_info = $blosxom::path_info;
22 # Remove any trailing /
23 $path_info =~ s! /$ !!x;
25 my $path_file = $blosxom::path_info;
26 $path_file =~ s/\.\w+$/.$blosxom::file_extension/;
27 return 1 if -e "$blosxom::datadir/$path_info" || -f "$blosxom::datadir/$path_file";
29 # debug(1, "original path_info: $path_info");
31 # Check file/flavour variant
32 if ($path_info =~ m! ^ (.*) / ([^/]+) $ !x) {
34 my $path_info_new = "$1.$flavour";
35 my $path_file = "$1.$blosxom::file_extension";
37 # debug(2, "path_file: $path_file, path_info_new: $path_info_new");
39 if (-f "$blosxom::datadir/$path_file") {
40 # debug(1, "\$path_info_new exists - updating \$blosxom::path_info");
41 $blosxom::path_info = $path_info_new;
42 $blosxom::flavour = $flavour;
43 $blosxom::path_info_yr = undef;
48 # Check dir/flavour variant (implying index.flavour)
49 if ($path_info =~ m! ^ (?: (.*) / )? ([^/]+) $ !x) {
52 # debug(2, "dir: $dir, flavour: $flavour");
54 # Check there isn't an entry matching this
55 if (-f "$blosxom::datadir$dir/$flavour.$blosxom::file_extension") {
56 # debug(2, "entry $blosxom::datadir/$dir/$flavour.$blosxom::file_extension found - skipping");
60 # Check $dir is a directory (sanity check - overly aggressive?)
61 if ($dir && ! -d "$blosxom::datadir/$dir") {
62 # debug(2, "dir '$dir' is set but not a directory");
66 # debug(1, "dir '$dir' not set or exists and directory - setting \$blosxom::path_info");
67 $blosxom::path_info = $dir;
68 $blosxom::flavour = $flavour;
69 $blosxom::path_info_yr = undef;
82 flavourpathinfo - allows flavour designation via a trailing path component
83 instead of via a file extension
87 flavourpathinfo is a syntactic sugar plugin that allows flavour designation
88 via a trailing path component instead of via a file extension e.g.
90 http://blog.example.com/category/post/html
91 http://blog.example.com/category/post/atom
92 http://blog.example.com/category/post/trackback
94 instead of the more typical:
96 http://blog.example.com/category/post.html
97 http://blog.example.com/category/post.atom
98 http://blog.example.com/category/post.trackback
100 With index pages, the 'index' portion can also be omitted, if desired:
102 http://blog.example.com/category/html
103 http://blog.example.com/category/atom
107 http://blog.example.com/category/index.html
108 http://blog.example.com/category/index.atom
112 If used with the 'extensionless' plugin, it should be loaded
113 *after* extensionless.
115 But should be loaded early as it manipulates $blosxom::path_info
116 e.g. as 02flavourpathinfo.
122 Blosxom: http://blosxom.sourceforge.net/
126 Please report bugs either directly to the author or to the blosxom
127 development mailing list: <blosxom-devel@lists.sourceforge.net>.
131 Gavin Carr <gavin@openfusion.com.au>, http://www.openfusion.net/
135 Copyright 2007 Gavin Carr.
137 This plugin is licensed under the same terms as blosxom itself i.e.
139 Permission is hereby granted, free of charge, to any person obtaining a
140 copy of this software and associated documentation files (the "Software"),
141 to deal in the Software without restriction, including without limitation
142 the rights to use, copy, modify, merge, publish, distribute, sublicense,
143 and/or sell copies of the Software, and to permit persons to whom the
144 Software is furnished to do so, subject to the following conditions:
146 The above copyright notice and this permission notice shall be included
147 in all copies or substantial portions of the Software.
149 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
150 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
151 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
152 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
153 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
154 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
155 OTHER DEALINGS IN THE SOFTWARE.