Update perldocs in general plugins to point to current website/mailing list.
[matthijs/upstream/blosxom-plugins.git] / general / google_highlight
1 # Blosxom Plugin: google_highlight
2
3 Blosxom Home/Docs/Licensing: http://blosxom.sourceforge.net/
4
5 Blosxom Plugin Docs: http://blosxom.sourceforge.net/documentation/users/plugins.html
6 # Author(s): Rael Dornfest <rael@oreilly.com> 
7 # Version: 2003-09-09
8 # Documentation: See the bottom of this file or type: perldoc google_highlight
9
10 package google_highlight;
11
12 # --- Configurable variables -----
13
14 # none, null, nada, nothing, zip, zero, zilch
15
16 # --------------------------------
17
18 my $query;
19
20 sub start {
21   my $referer = $ENV{'HTTP_REFERER'};
22
23   ($query) = $referer =~ m#^http://(?:www\.)?google.*q=([^\&]+)#i or return 0;
24   $query =~ s#['"]##g;
25   $query = join '|', split /[\s,\+\.]+/, $query;
26   
27   1;
28 }
29
30 sub story {
31   my($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_;
32
33   $$body_ref =~ s#(?<=>)([^<]+)?\b($query)\b#$1<span class="highlight">$2</span>#gis;
34 }
35
36 1;
37
38 __END__
39
40 =head1 NAME
41
42 Blosxom Plug-in: google_highlight
43
44 =head1 SYNOPSIS
45
46 Highlights any Google search terms used to find your weblog. 
47
48 An adaptation of Dean Allen's [http://www.textism.com/] Google 
49 Hilite [http://www.textism.com/tools/google_hilite/].
50
51 =head1 VERSION
52
53 2003-09-09
54
55 =head1 AUTHOR
56
57 Rael Dornfest  <rael@oreilly.com>, http://www.raelity.org/
58
59 This plugin is now maintained by the Blosxom Sourceforge Team,
60 <blosxom-devel@lists.sourceforge.net>.
61
62 =head1 INSTALLATION
63
64 Drop the interpolate_fancy plug-in into your Blosxom plugins folder.
65
66 Add a "highlight" style to your document or CSS style sheet, e.g.:
67
68 <html>
69 <head>
70 <style>
71 .highlight { background-color: #FF9; }
72 </style>
73 </head>
74 <body>
75 ...
76 </body>
77 </html>
78
79 =head1 USAGE
80
81 Search Google for something that'll lead you to your weblog.  Follow
82 the Google link and notice the terms used in your search are highlighted
83 in your weblog.
84
85 =head1 SEE ALSO
86
87 Blosxom Home/Docs/Licensing: http://blosxom.sourceforge.net/
88
89 Blosxom Plugin User Docs: 
90   http://blosxom.sourceforge.net/documentation/users/plugins.html
91
92 Blosxom Plugin Developer Docs: 
93   http://blosxom.sourceforge.net/documentation/developers/plugins.html
94
95 Dean Allen's Textism [http://www.textism.com/]
96 Dean Allen's Google Hilite [http://www.textism.com/tools/google_hilite/]
97
98 =head1 BUGS
99
100 None known; please send bug reports and feedback to the Blosxom
101 development mailing list <blosxom-devel@lists.sourceforge.net>.
102
103 =head1 LICENSE
104
105 Blosxom and this Blosxom Plug-in
106 Copyright 2003, Rael Dornfest 
107
108 Permission is hereby granted, free of charge, to any person obtaining a
109 copy of this software and associated documentation files (the "Software"),
110 to deal in the Software without restriction, including without limitation
111 the rights to use, copy, modify, merge, publish, distribute, sublicense,
112 and/or sell copies of the Software, and to permit persons to whom the
113 Software is furnished to do so, subject to the following conditions:
114
115 The above copyright notice and this permission notice shall be included
116 in all copies or substantial portions of the Software.
117
118 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
119 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
120 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
121 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
122 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
123 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
124 OTHER DEALINGS IN THE SOFTWARE.