Add a bunch of Rael plugins.
[matthijs/upstream/blosxom-plugins.git] / general / absolute
1 # Blosxom Plugin: absolute
2 # Author(s): Rael Dornfest <rael@oreilly.com> 
3 # Version: 2.0b3-4
4 # Documentation: See the bottom of this file or type: perldoc readme
5
6 package absolute;
7
8 # --- Configurable variables -----
9
10 # What's the URL of your images directory?
11 my $image_url = "";
12 # e.g. http://www.example/images
13
14 # What's the URL of your $datadir, if publicly-accessible?
15 my $datadir_url = "";
16 # e.g. http://www.example/blosxom
17
18 # --------------------------------
19
20 $image_url =~ s!/$!!; $datadir_url =~ s!/$!!;
21
22 sub start {
23   1;
24 }
25
26 sub story {
27   my($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_;
28
29   $$body_ref =~ s!(<a.+?href\s*=\s*(["']))(/.+?)\2(.*?)>!$1$blosxom::url$3$2$4>!sig;
30
31   $image_url and $$body_ref =~ s!(<img.+?src=(["']))(/.+?)\2(.*?)>!$1$image_url$3$2$4>!sig;
32
33   $datadir_url and $$body_ref =~ s!(<img.+?src=(["']))([^\/]+?)\2(.*?)>!$1$datadir_url$path/$3$2$4>!sig;
34
35   return 1;
36 }
37
38 1;
39
40 __END__
41
42 =head1 NAME
43
44 Blosxom Plug-in: absolute
45
46 =head1 SYNOPSIS
47
48 Replaces <a href="/relative/path/to/something.html"> with the fully-qualified/
49 absolute <a href="$blosxom::url/relative/path/to/something.html">, especially 
50 important for RSS feeds, since most RSS readers don't make these absolute 
51 themselves.
52
53 Optionally replaces <img src="/relative/path/to/image.gif"> with the 
54 fully-qualified/absolute <img src="$image_url/relative/path/to/image.gif">.
55
56 For those who have their $datadir publicly-available (i.e. under their
57 Web server's document root), also optionally adds fully-qualified/absolute
58 paths to images.  So mention of <img src="something.gif"> in 
59 /relative/path/to/something.txt will be replaced with
60 <img src="$datadir_url/relative/path/to/something.gif">.
61
62 The plug-in also should preserve any attributes included in the <a /> or
63 <img /> tags.
64
65 =head1 VERSION
66
67 2.0b3-4
68
69 Version number coincides with the version of Blosxom with which the 
70 current version was first bundled.
71
72 =head1 AUTHOR
73
74 Rael Dornfest  <rael@oreilly.com>, http://www.raelity.org/
75
76 =head1 SEE ALSO
77
78 Blosxom Home/Docs/Licensing: http://www.raelity.org/apps/blosxom/
79
80 Blosxom Plugin Docs: http://www.raelity.org/apps/blosxom/plugin.shtml
81
82 =head1 BUGS
83
84 Address bug reports and comments to the Blosxom mailing list 
85 [http://www.yahoogroups.com/group/blosxom].
86
87 =head1 LICENSE
88
89 Blosxom and this Blosxom Plug-in
90 Copyright 2003, Rael Dornfest 
91
92 Permission is hereby granted, free of charge, to any person obtaining a
93 copy of this software and associated documentation files (the "Software"),
94 to deal in the Software without restriction, including without limitation
95 the rights to use, copy, modify, merge, publish, distribute, sublicense,
96 and/or sell copies of the Software, and to permit persons to whom the
97 Software is furnished to do so, subject to the following conditions:
98
99 The above copyright notice and this permission notice shall be included
100 in all copies or substantial portions of the Software.
101
102 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
103 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
104 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
105 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
106 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
107 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
108 OTHER DEALINGS IN THE SOFTWARE.