# Blosxom Plugin: ping_pingomatic_com # Author(s):Rael Dornfest, Modified by Tim # Version: 2.0b4 # Documentation: See the bottom of this file or type: perldoc ping_weblogs_com package ping_pingomatic_com; # --- Configurable variables ----- # What URL should this plugin ping? my $ping_url = "http://pingomatic.com/ping/?title=Tim%27s+Webpage&blogurl=http%3A%2F%2Ftimswebpage.com%2F&chk_weblogscom=on&chk_blogs=on&chk_technorati=on&chk_syndic8=on&chk_newsgator=on&chk_feedster=on&chk_myyahoo=on&chk_pubsubcom=on&chk_blogchatter=on&chk_blogrolling=on&chk_blogstreet=on&Submit=Submit+Pings+"; # What external program should this plugin use to ping Weblogs.com? # 'lynx -source' # 'wget --quiet -U "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" -O -'; # 'curl -m 30 -s' my $get_app = 'curl -m 30 -s'; # -------------------------------- use FileHandle; use File::stat; # Keep track of the newest story's mtime my $newest = 0; sub start { $get_app or return 0; print STDERR "here\n"; 1; } sub filter { my($pkg, $files_ref) = @_; $newest = $files_ref->{( sort { $files_ref->{$b} <=> $files_ref->{$a} } keys %$files_ref )[0]}; 1; } sub end { # If no timestamped touch-file or newest is newer than the touch-file... if ( !-e "$blosxom::plugin_state_dir/.ping_weblogs_com.output" or $newest > stat("$blosxom::plugin_state_dir/.ping_weblogs_com.output")->mtime ) { my $response = ''; my $ping_success = 0; my $fh = new FileHandle; $fh->open(qq{$get_app "$ping_url" |}); while (<$fh>) { $response .= $_; $_ =~ /Back to the form/ and $ping_success++, last; } $fh->close(); $ping_success or return 0; # Touch the touchfile (creates if doesn't already exist) open TOUCH, "> $blosxom::plugin_state_dir/.ping_weblogs_com.output"; print TOUCH $response; close TOUCH; return 1; } return 1; } sub encode { my($string) = @_; my %encodings; for (0..255) { $encodings{chr($_)} = sprintf("%%%02X", $_); } $string =~ s/([^A-Za-z0-9\-_.!~*'()])/$encodings{$1}/g; return $string; } 1; __END__ =head1 NAME Blosxom Plug-in: ping_weblogs_com =head1 SYNOPSIS Purpose: Notifies pingomatic.com [http://www.pingomatic.com] that your weblog has been updated upon encountering any new story. Visit pingomatic.com and select the services that you would like to ping and click submit. Copy the URL of the 'thank you' page to "my $ping_url". Make sure you are pinging the address that is listed with other services. For example, if you claimed your weblog at technorati with the address http://timswebpage.com/, then you should fill in the 'blog url' field on pingomatic with http://timswebpage.com/. Adding the additional cgi-bin/blosxom.cgi/ bit confuses some of the services. Maintains a touch-file ($blosxom::plugin_state_dir/.ping_weblogs_com.output) to which to compare the newest story's creation date. Fills the touch-file with the HTML results of the latest ping. =head1 VERSION 2.0b3 Version number coincides with the version of Blosxom with which the current version was first bundled. =head1 AUTHOR Rael Dornfest , http://www.raelity.org/ =head1 SEE ALSO Blosxom Home/Docs/Licensing: http://www.raelity.org/apps/blosxom/ Blosxom Plugin Docs: http://www.raelity.org/apps/blosxom/plugin.shtml =head1 BUGS Address bug reports and comments to the Blosxom mailing list [http://www.yahoogroups.com/group/blosxom]. =head1 LICENSE Blosxom and this Blosxom Plug-in Copyright 2003, Rael Dornfest Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.