#!/usr/local/bin/perl # # gettop.pl # # Find the latest top-story article and put the body of the story # into a file to be included in a web page via SSI or clariphoto.pl. # # Version: 2.3 # Last Modified: Nov 8, 1997 # Make sure we search the script's directory for the config file. $SCRIPTDIR = $0 =~ m%^(/.+)/[^/]+$%? $1 : '.'; unshift(@INC, $SCRIPTDIR); $PREFIX = 'custom' unless $PREFIX = $ENV{'CLARIWEB_PREFIX'}; $CONFIG_FILE = "${PREFIX}_config.pl" unless $CONFIG_FILE = $ENV{'CLARIWEB_CONFIG'}; $CUSTOM_FILE = "$SCRIPTDIR/${PREFIX}_gettop.pl"; require $CONFIG_FILE; require $CUSTOM_FILE if -f $CUSTOM_FILE; $DESTINATION = shift; die "Usage: gettop.pl destination-file\n" unless $DESTINATION; $LINK_DIR = "$NDIR/xwd/links"; ($mday, $dmonth) = (localtime(time))[3,4]; $top_story = sprintf("Htopstory.%02d%02d.html", $dmonth+1, $mday); open(TOP, "$LINK_DIR/$top_story") || exit; $_ = join('', ); close(TOP); # Strip everything but the STORY portion of the file. s%.*\n%%s; s%.*%%s; # Strip out the Horizontal Rule and change the header a bit. s%^
%%mgi; s%^(  )+(.*):%
$2
%mg; open(NEWTOP, ">$DESTINATION.new") || die "Unable to write $DESTINATION.new\n"; if (defined(&output_gettop)) { &output_gettop(NEWTOP, $_); } else { print NEWTOP $_; } close(NEWTOP); rename("$DESTINATION.new", $DESTINATION) || die "Unable to rename $DESTINATION.new to $DESTINATION\n";