Minor cleanup to make-dist.
[blosxom-plugins.git] / general / google_highlight
blob9f44d8a06ee62078e426f1e4b674073c2cc5f2cf
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
6 package google_highlight;
8 # --- Configurable variables -----
10 # none, null, nada, nothing, zip, zero, zilch
12 # --------------------------------
14 my $query;
16 sub start {
17   my $referer = $ENV{'HTTP_REFERER'};
19   ($query) = $referer =~ m#^http://(?:www\.)?google.*q=([^\&]+)#i or return 0;
20   $query =~ s#['"]##g;
21   $query = join '|', split /[\s,\+\.]+/, $query;
22   
23   1;
26 sub story {
27   my($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_;
29   $$body_ref =~ s#(?<=>)([^<]+)?\b($query)\b#$1<span class="highlight">$2</span>#gis;
34 __END__
36 =head1 NAME
38 Blosxom Plug-in: google_highlight
40 =head1 SYNOPSIS
42 Highlights any Google search terms used to find your weblog. 
44 An adaptation of Dean Allen's [http://www.textism.com/] Google 
45 Hilite [http://www.textism.com/tools/google_hilite/].
47 =head1 VERSION
49 2003-09-09
51 =head1 AUTHOR
53 Rael Dornfest  <rael@oreilly.com>, http://www.raelity.org/
55 =head1 INSTALLATION
57 Drop the interpolate_fancy plug-in into your Blosxom plugins folder.
59 Add a "highlight" style to your document or CSS style sheet, e.g.:
61 <html>
62 <head>
63 <style>
64 .highlight { background-color: #FF9; }
65 </style>
66 </head>
67 <body>
68 ...
69 </body>
70 </html>
72 =head1 USAGE
74 Search Google for something that'll lead you to your weblog.  Follow
75 the Google link and notice the terms used in your search are highlighted
76 in your weblog.
78 =head1 SEE ALSO
80 Blosxom Home/Docs/Licensing: http://blosxom.sourceforge.net/
82 Blosxom Plugin User Docs: 
83   http://blosxom.sourceforge.net/documentation/users/plugins.html
84 Blosxom Plugin Developer Docs: 
85   http://blosxom.sourceforge.net/documentation/developers/plugins.html
87 Dean Allen's Textism [http://www.textism.com/]
88 Dean Allen's Google Hilite [http://www.textism.com/tools/google_hilite/]
90 =head1 BUGS
92 Address bug reports and comments to the Blosxom mailing list 
93 [http://www.yahoogroups.com/group/blosxom].
95 =head1 LICENSE
97 Blosxom and this Blosxom Plug-in
98 Copyright 2003, Rael Dornfest 
100 Permission is hereby granted, free of charge, to any person obtaining a
101 copy of this software and associated documentation files (the "Software"),
102 to deal in the Software without restriction, including without limitation
103 the rights to use, copy, modify, merge, publish, distribute, sublicense,
104 and/or sell copies of the Software, and to permit persons to whom the
105 Software is furnished to do so, subject to the following conditions:
107 The above copyright notice and this permission notice shall be included
108 in all copies or substantial portions of the Software.
110 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
111 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
112 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
113 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
114 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
115 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
116 OTHER DEALINGS IN THE SOFTWARE.