#!/usr/bin/perl -w # Blosxom # Author: Rael Dornfest # Version: 0+5i # Home/Docs/Licensing: http://www.oreillynet.com/~rael/lang/perl/blosxom/ # --- Configurable variables ----- # What's this blog's title? my $blog_title = 'Sam Ruby'; # What's this blog's description (for outgoing RSS feed)? my $blog_description = "It's just data"; # What's this blog's primary language (for outgoing RSS feed)? my $blog_language = 'en'; # Where are this blog's entries kept? my $datadir = "/home/rubys/web/intertwingly.net/blosxom/"; my $datadir_current = $datadir; # Should I stick only to the datadir for items or travel down the # directory hierarchy looking for items? If so, to what depth? # 0 = infinite depth (aka grab everything), 1 = datadir only, n = n levels down my $depth = 0; # What should be used as separator in directory paths (the $path variable)? my $path_separator = '/'; # How many entries should I show on the home page? my $num_entries = 20; # -------------------------------- use strict; use FileHandle; use File::Find; use File::stat; use Lucene; use CGI qw/:standard :netscape escape/; use POSIX qw/strftime/; # Escape <, >, and &, and to produce valid RSS my %escape = ('<'=>'<', '>'=>'>', '&'=>'&', '"'=>'"'); my $escape_re = join '|' => keys %escape; my $fh = new FileHandle; my $flavour = "html"; # Bring in the templates my %template = (); while () { last if /^(__END__)?$/; my($ct, $comp, $txt) = /^(\S+)\s(\S+)\s(.*)$/; $txt =~ s/\\n/\n/mg; $template{$ct}{$comp} = $txt; } $template{'html'}{'content_type'}='application/xhtml+xml;charset=iso-8859-1' if $ENV{'HTTP_ACCEPT'} =~ /application\/xhtml\+xml/; $blog_title .= ": Posts by Citation"; chomp(my $content_type = $fh->open("< $datadir_current/content_type.$flavour") || $fh->open("< $datadir/content_type.$flavour") ? <$fh> : ($template{$flavour}{'content_type'} || 'text/plain')); print header($content_type); # determine what dates to include my @files = (); my $ext = 'txt'; find({ wanted => sub { my $curr_depth = $File::Find::dir =~ tr[/][]; return if $depth and $curr_depth > $depth; /.$ext$/ and push @files, $File::Find::name; }, follow_fast => 1 }, $datadir_current); # Header my $head = join '', ($fh->open("< $datadir_current/head.$flavour") || $fh->open("< $datadir/head.$flavour") ? <$fh> : ($template{$flavour}{'head'} || $template{'error'}{'head'})); $head =~ s/(\$\w+)/$1 . "||''"/gee; print $head; my %people; print "

Posts by Citation

\n"; foreach my $blog (@files) { open FILE, $blog; my $title = ; my $entry = join(' ', ); close FILE; $entry =~ s///g; $entry =~ s/ / /msg; $entry =~ s/\s+/ /msg; $entry =~ s/^

?(.*?) ?<\/p>/\1/; (my $cite) = ($entry =~ /^ ?([^<]*?)<\/a>:? ?/); next unless $cite; $cite =~ s/<.*?>//g; $cite =~ s/:? *$//; $cite =~ s/^ //; $cite = lc($cite); $cite =~ s/^jon$/jon udell/; $cite =~ s/^dave$/dave winer/; $cite =~ s/^diveintomark$/mark pilgrim/; $cite =~ s/^burningbird$/shelley powers/; $cite =~ s/^sanjiva$/sanjiva weerawarana/; $cite =~ s/.*decafbad/les orchard/; $cite =~ s/l.m.orchard/les orchard/; $cite =~ s/ernie.*/ernie svenson/; $cite =~ s/\.net guy/brad wilson/; $cite =~ s/dotnetguy/brad wilson/; $cite =~ s/[^\w\s]//g; $people{$cite}++; } my @order = sort {$people{$b} <=> $people{$a} or $a cmp $b} keys %people; my $line = 1; print "

\n"; foreach (@order) { (my $url = escape($_)) =~ s/%20/_/g; print "
$_ ($people{$_})\n"; print "
\n" if $line++ % 5 == 0; } print "
\n"; # Foot my $foot = join '', ($fh->open("< $datadir_current/foot.$flavour") || $fh->open("< $datadir/foot.$flavour") ? <$fh> : ($template{$flavour}{'foot'} || $template{'error'}{'foot'})); $foot =~ s/(\$\w+)/$1 . "||''"/gee; while ( $foot =~ s/^(#include "(.*?)")$/$fh->open("$datadir_current\/$2") ? join "",<$fh> : "$1"/gme ) {} print $foot; # Default HTML and RSS template bits __DATA__ html content_type text/html html head $blog_title $pi_da $pi_mo $pi_yr
$blog_title
$pi_da $pi_mo $pi_yr

html story

$title
$body
Posted at $ti [$path] # G

\n html foot

Powered -- for some narrow definition of powered -- by Blosxom
rss content_type text/xml rss head \n\n\n\n\n \n $blog_title $pi_da $pi_mo $pi_yr\n $url/\n $blog_description\n $blog_language\n rss story \n $title\n $url/$yr/$mo_num/$da#$fn\n $body\n \n rss foot \n error head Error: I'm afraid this is the first I've heard of a "$flavour" flavoured Blosxom. Try dropping the "/+$flavour" bit from the end of the URL.\n\n html content_type text/html