# Blosxom plug-in: wazzup # Author: Stu MacKenzie # Version: v0.5 2005-05-22 (6) # License: MIT/Public Domain # wazzup home: http://www.enilnomi.net/download.html # Documentation at the bottom of this file or type: perldoc wazzup package wazzup; # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = # # Configuration Section # # = = = = = = = = = = = = = = = = # # Number of titles to display # Sets the number of most-recent story titles that # will display; 0 (zero) means "display all titles" $num_titles = 5 unless defined $num_titles; # # Pre- and Post- links markup # wazzup flavours (templates) do *not* enclose the # returned set of links in any kind of "block" markup # (,

...

, etc.). If needed, you # can add enclosing tags to your head or foot templates, # or you can provide them here (between the braces {} ) # Ex: $pre_links_markup = "

" # $post_links_markup = "

" $pre_links_markup = qq {

} unless defined $pre_links_markup; # $post_links_markup = qq {

} unless defined $post_links_markup; # # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = use strict; # call $wazzup::recent_entries in your head or foot flavour use vars qw { $recent_entries $num_titles $pre_links_markup $post_links_markup $count }; $count = 0; my $i = 0; my $output = ""; sub start { 1; } sub head { my ($pkg, $dir, $head_ref) = @_; $num_titles||= $blosxom::num_entries; my $mark = rand(7); # make a marker that's (99.999) unique to $head while ($$head_ref =~ m/$mark/) {$mark += rand(7);} $recent_entries = ""; while () { # read in the default template bits last if /^(__END__)?$/; my ($flavor, $comp, $txt) = split ' ', $_, 3; $txt =~ s:\\n:\n:g; # expand newlines # add our new bits to blosxom's %template hash $blosxom::template{$flavor}{"$pkg.$comp"} = $txt; } 1; } sub story { my ($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_; $count++; # report actual number of stories my $tmp = $$title_ref; $$title_ref =~ s/<[\S\/].*?>//g; # crudely remove valid markup $i < $num_titles and # add the interpolated wazzup template to output $output .= &$blosxom::interpolate($blosxom::template->('', "$pkg.recent_entries", $blosxom::flavour)); $$title_ref = $tmp; # restore markup $i++; #$str =~ s/((\$[\w:]+)|(\$\{[\w:]+\}))/$1 . "||''"/gee; # DIY interpolation 1; } sub foot { my ($pkg, $dir, $foot_ref) = shift; $count > $num_titles and $count = $num_titles; $pre_links_markup = &$blosxom::interpolate($pre_links_markup); $post_links_markup = &$blosxom::interpolate($post_links_markup); # replace our head marker $blosxom::output =~ s/$recent_entries/$pre_links_markup$output$post_links_markup/s; $recent_entries = $output; # ready for foot 1; } 1; __DATA__ error recent_entries $title
rss story \n $title\n $url/$yr/$mo_num/$da#$fn\n __END__ =head1 NAME Blosxom plug-in: wazzup =head1 SYNOPSIS The wazzup plugin displays a list of links to the most-recent entries made to the blog; users configure the number of new entries to list. The form of the list (lines, paragraphs, list items, etc.) can be set with a flavour file, or left for the built-in templates. The list can be displayed in either the head or foot section of the blog (or both). =head1 DESCRIPTION Blosxom's flow is to: 1) generate a head; 2) sort entries; 3) read entry files, processing date, title, and story for each; 4) generate a foot; 5) spit out a page. Since getting an entry title requires reading an entry file, you can see that a plugin wanting to make some links-to-recent-entries available to the head are fighting an uphill battle -- the plugin is going to have to do its own sorting and its own file reading, because blosxom does them "too late." But what a waste. All the space and time used for sorting and reading, to get just a few lines of content. wazzup takes a different approach: it hitches a ride on blosxom's sorting and file reading, gathering titles in the story() sub. The display list is generated in the foot() sub, and then "back-patched" into the head. To provide flexibility, the plugin's output is controlled by flavour files. (Defaults are provided for rss and every- thing else.) =head1 INSTALLATION Enter configuration info as instructed, then drop this file into your blosxom plugins folder. Blog on. =head1 CONFIGURATION With any luck, the instructions in the "Configuration Section" at the top of this file are sufficient; if more information is needed, see the documentation at: http://www.enilnomi.net/dltext/wazzup.dl =head1 USAGE Simply call $wazzup::recent_entries in your head or foot flavour (or both). You'll p'bly want to add some sort of block around the links in the head or foot flavours.... The plugin produces a number of links to recent entries; the content and appearance of those links is controlled by flavour files, just like blosxom's flavour files (templates). There are two default flavours provided: one for blosxom's default rss, and one for everything else. Recent-entries flavours are called from either head or foot flavours (or both) with the variable "$wazzup::recent-entries". To make a recent-entries flavour, create a text file named "wazzup.recent_entries.html" (or whatever flavour extension you're making), and enter the markup, variables, and text you want displayed. Here's a couple of examples: -1- # this produces lines of links (this is the default flavour) $title
when called from a head template like this:

$wazzup::recent-entries

wazzup inserts this into the head:

Digital Rover . . .

-2- # this produces an unordered list of links
  • $title
  • when called from a head template like this: wazzup inserts this: NOTE: interpolate_fancy or interpolate_conditional should be unfazed by wazzup; it uses blosxom to do its interpolating. Let me know (see below) if wazzup causes problems; thanx. =head1 BUGS Address bug reports and comments to the Blosxom mailing list: http://www.yahoogroups.com/group/blosxom =head1 VERSION 2005-05-22 (v0.5) - add interpolation for $pre- and $post_links_markup; hack in $count 2005-05-04 (v0.4) - add vars for enclosing tags; strip title markup; documentation 2005-05-02 (v0.3) - it's alive =head1 LICENSE this Blosxom Plug-in Copyright 2005, Stu MacKenzie 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.