#!/usr/bin/perl -w # # myns - Create a MyNetscape RSS/RDF file from a stock HTML file # written March 1999 by Dan Lyke (danlyke@flutterby.com) # # Since Dave Winer (http://www.scripting.com/) has given me some publicity # with this thing I figure I ought to clean it up. # # Flutterby uses a single index file which is written into by a script # called Newwsboy (http://www.flutterby.com/software/newwsboy) (contact # me if you actually plan on using it) to keep track of everything. I # have smartass comments and URLs of note, and then longer "rant" pieces. # # See below for how each of these are handled. # # I'm happy to help make mods to this thing. use strict; my (%siteInfoHash) = ( 'title' => 'Flutterby!', 'link' => 'http://www.flutterby.com/', 'baseurl' => 'http://www.flutterby.com', 'description' => 'Without the fringes the fabric of reality would ' .'be just another dirty washcloth', 'docroot' => '/home/flutterby/public_html/', 'summary' => 'short.html', ); my ($siteInfo) = \%siteInfoHash; sub AddEntry($$$) { my ($title, $link, $baseurl) = @_; $link =~ s/^(\/[a-z0-9_])/$baseurl$1/i; $link =~ s/\&/\>/g; $title = substr($title,0,100) if (length($title) > 100); print < $title $link EOF } print < $siteInfo->{'title'} $siteInfo->{'link'} $siteInfo->{'description'} en-us EOF my $entries; $entries = 0; # First off date the main index file so people know when it's # been updated. use Time::localtime; my @s; @s = stat($siteInfo->{'docroot'}.$siteInfo->{'summary'}); AddEntry('Daily notes last updated ' .ctime($s[9]), $siteInfo->{'baseurl'}.'/'.$siteInfo->{'summary'}, ''); $entries++; # Now look for the "Local rant:" entries if (open(I, '<'.$siteInfo->{'docroot'}.$siteInfo->{'summary'})) { while () { while (s/\Local rant:\<\/B\>\(.*?)\<\/A\>//i) { my ($url, $text); $url = $1; $text = $2; if ($url =~ /^\$/) { } else { $text =~ s/\<.*?\>//g; AddEntry('Local Rant: '.$text, $url, $siteInfo->{'baseurl'}); $entries++; } last if ($entries >= 15); } last if ($entries >= 5); } close I; } else { print "Unable to open $siteInfo->{'docroot'}.$siteInfo->{'summary'}\n"; } if (1) { # Then go back through the file and look for all of the remote links # which might be useful. my %urlsLinked; if (open(I, $siteInfo->{'docroot'}.$siteInfo->{'summary'})) { while () { while (s/(.*?)\<\/A\>//i) { my ($url, $text); $url = $1; $text = $2; if ($url =~ /^\$/) { } elsif ($url =~ /^http\:/) { $text =~ s/\<.*?\>//g; if (!defined($urlsLinked{$url}) && !defined($urlsLinked{lc($text)})) { AddEntry($text, $url, $siteInfo->{'baseurl'}); $entries++; } $urlsLinked{$url} = 1; $urlsLinked{lc($text)} = 2; } last if ($entries >= 15); } last if ($entries >= 15); } close I; } } print "\n";