Revert rss20 to using $ENV{PATH_INFO} in self link.
[blosxom-plugins.git] / barijaona / prefs
blobf6c95a05b6febb95e5c1ef283a14e1cf1c73d83a
1 # Blosxom Plugin: prefs
2 # Author(s): Barijaona Ramaholimihaso <blosxom@barijaona.com>
3 # based on config plugin authored by Rael Dornfest <rael@oreilly.com> 
4 # Version: 2005-11-20
5 # Documentation: See the bottom of this file or type: perldoc prefs
7 # WARNING: DO NOT PUT PREFERENCE FILES IN WORLD-READABLE PLACES SUCH AS WITHIN
8 # YOUR DOCUMENT ROOT.  IF YOUR $DATADIR IS LOCATED WITHIN YOUR DOCUMENT ROOT,
9 # I HEARTILY ADVISE THAT YOU MOVE IT.  WHILE MOST OF THE CONFIGURATION 
10 # DIRECTIVES ARE INNOCUOUS ENOUGH, IT'S A SLIPPERY SLOPE AND YOU MIGHT WELL
11 # FIND YOU'VE EXPOSED YOUR STATIC PASSWORD OR INTERNAL DIRECTORY STRUCTURE
12 # TO ANYONE WITH A WEB BROWSER!
14 package prefs;
16 # --- Configurable variables -----
17 # where are located the preference files
19 # I prefer to have mines in my flavour directory
20 # $basepath = "/Users/barijaon/blosxom/flavours";
22 $basepath = $blosxom::datadir unless defined $basepath ;
23 # --------------------------------
25 sub start {
26   1;
29 sub head {
31 $path='/';
32 $path_find = $blosxom::path_info ;
33 do {
34       $file = "$basepath$path"."pageprefs";
35       if (-r $file) { unless ($return = do $file) {
36             warn "Couldn't parse $file: $@" if $@;
37         }}
40       $file .= ".$blosxom::flavour";
41       if (-r $file) { unless ($return = do $file) {
42             warn "Couldn't parse $file: $@" if $@;
43         }}
44         }
45                 while ($path_find =~ s#/?([^/]*)##) and $1 and ($path .= $1."/" );
49 sub story {
51 my ($pkg, $path_find, $filename, $story_ref, $title_ref, $body_ref)= @_;
52 $path='/';
53 do {
54       $file = "$basepath$path"."storyprefs";
55       if (-r $file) { unless ($return = do $file) {
56             warn "Couldn't parse $file: $@" if $@;
57         }}
60       $file .= ".$blosxom::flavour";
61       if (-r $file) { unless ($return = do $file) {
62             warn "Couldn't parse $file: $@" if $@;
63         }}
64         }
65                 while ($path_find =~ s#/?([^/]*)##) and $1 and ($path .= $1."/" );
71 __END__
73 =head1 NAME
75 Blosxom Plug-in: prefs
77 =head1 SYNOPSIS
79 Override Blosxom's inline configuration settings on a per-directory, per-flavour, and per-directory-per-flavour basis.
81 For each generated page, looks for B<pageprefs> and B<pageprefs.flavour> files which should contain valid Perl instructions.
83 For each story, looks for B<storyprefs> and B<storyprefs.flavour> files which should contain valid Perl instructions.
85 Prefs has a purpose very similar to Rael Dornfest's B<config> plugin, but was written because in static rendering, B<config> uses the same config file for all pages.
87 When Blosxom process a page or a story, all prefs files (pageprefs, pageprefs.flavour, storyprefs, storyprefs.flavour) in the directory tree for this page or story are executed. Prefs files for a specific flavour override prefs files applying to all flavours, and prefs files in subdirectories override prefs files in their parents.
89 pageprefs are executed once per page (when the head of the page is generated), and storyprefs are executed once per story (allowing a per story tuning inside a page).
91 It is recommanded that you prefix the name of the plugin with a number (for instance, naming it 10prefs) so that it loads before other Blosxom plugins (but after the B<meta> plugin if you use it).
93 =head1 VERSION
95 2005-11-20
97 Version number is the date on which this version of the plug-in was created.
99 =head1 AUTHOR
101 Barijaona Ramaholimihaso <prefs@barijaona.com>
103 Prefs is based on the config plugin written by Rael Dornfest  <rael@oreilly.com>, http://www.raelity.org/
106 =head1 SEE ALSO
108 Blosxom Home/Docs/Licensing: http://blosxom.sourceforge.net
110 Blosxom Plugin Docs: http://blosxom.sourceforge.net/plugins/
112 =head1 BUGS
114 None known; please send bug reports and feedback to the Blosxom development mailing list <blosxom-devel@lists.sourceforge.net>.
116 =head1 LICENSE
118 Prefs plugin
119 Copyright 2003-2005, Barijaona Ramaholimihaso
121 Blosxom and config Plug-in
122 Copyright 2003, Rael Dornfest 
124 Permission is hereby granted, free of charge, to any person obtaining a
125 copy of this software and associated documentation files (the "Software"),
126 to deal in the Software without restriction, including without limitation
127 the rights to use, copy, modify, merge, publish, distribute, sublicense,
128 and/or sell copies of the Software, and to permit persons to whom the
129 Software is furnished to do so, subject to the following conditions:
131 The above copyright notice and this permission notice shall be included
132 in all copies or substantial portions of the Software.
134 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
135 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
136 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
137 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
138 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
139 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
140 OTHER DEALINGS IN THE SOFTWARE.