#!/usr/bin/perl # Blosxom Plugin: autopreview # Author: Max Barry # Version: 2004-03-18 (0.1) # License: GPL # Documentation: See the bottom of this file or type: perldoc preview package autopreview; # --- Configurable variables ----- # The password to display preview $password = 'yes'; # Number of seconds to hold back new content $delay = 300; # -------------------------------- # defaults $password ||= 'yes'; $delay = 300 unless ($delay); my $cgipassword; use CGI qw/:standard/; sub start { return $blosxom::static_or_dynamic eq 'dynamic' ? 1 : 0; } sub filter { my ($pkg, $files_ref) = @_; my $t = time; # If the preview pw is supplied, don't modify anything return 1 if ( $cgipassword = param('preview') and $cgipassword eq $password ); # Otherwise, hide new file(s) foreach my $fn ( keys %$files_ref ) { if ($t - $files_ref->{$fn} < $delay) { delete $files_ref->{$fn}; } } } 1; __END__ =head1 NAME - autopreview Blosxom Plug-in: autopreview =head1 SYNOPSIS Hides new posts for a few minutes to everyone who doesn't supply a special preview query string. This lets you make sure your latest post looks right before it becomes publicly viewable. It is similar to the 'preview' plugin by Jason Thaxter, but doesn't require you to do anything if your blog looks fine in preview. =head1 USAGE To preview your blog, add C to the query string (e.g. C). If the preview looks fine, do nothing: the new item (or items) will become globally viewable ("published") after 300 seconds (or whatever you set the delay to) have passed. If you wish to correct something, simply editing the blog's file will reset the preview clock. Both the preview password and the amount of time the autopreview lasts for are configurable by editing this file. =head1 VERSION Version 0.1 =head1 AUTHOR Max Barry , http://www.maxbarry.com/ =head1 SEE ALSO Blosxom Home/Docs/Licensing: http://www.blosxom.com/ Blosxom Plugin Docs: http://www.blosxom.com/plugins/ Preview Plugin for Blosxom by Jason Thaxter: http://ahab.com/x/lint/preview.html =head1 BUGS None known. =head1 LICENSE Copyright 2004 Max Barry 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.