/
file-v20030302
33 lines (27 loc) · 900 Bytes
/
file-v20030302
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Blosxom Plugin: file
# Author: Nelson Minar <nelson@monkey.org>
# Version: 20030302
# http://www.nelson.monkey.org/~nelson/weblog/
# License: Public Domain
# Thanks to Randy J. Ray http://www.rjray.org/
# The file plugin loads files from a directory and defines them as
# variables for use in your stories. Ie: if you have a file named
# "foo", then the variable $file::foo will be set to the contents
# of the file "foo" and will be substituted in your stories and such.
# Files are loaded from $plugin_dir/filedata
package file;
my $datadir;
# Startup - scan filedata dir, read files into variables
sub start {
$datadir = $blosxom::plugin_dir . "/filedata";
if ( $datadir and opendir D, $datadir ) {
foreach my $f (grep(/^[A-Za-z_]\w*$/, (readdir D))) {
next unless -f "$datadir/$f";
open F, "$datadir/$f";
$$f = join('', <F>);
close F;
}
}
1;
}
1;