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