#!/usr/gnu/bin/perl5 -- -*- Perl -*- #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # news.cgi # # Displays news items. # # Author: Reid Rivenburgh (reid@lanl.gov) # # Created: 5/24/95 # #------------------------------------------------------------------------------ # Set up the require path. if ($0 =~ /\//) { $0 =~ /^(.*)\/[^\/]*$/; $programPath = $1; } else { $programPath = "."; } push(@INC, $programPath."/lib"); require "news-lib.pl"; require "news-date.pl"; #------------------------------------------------------------------------------ # Pump STDERR into output stream so we know what happens #------------------------------------------------------------------------------ open(STDERR,">&STDOUT") || die "Can't dup stdout: $!\n"; select(STDERR); $| = 1; # Make unbuffered. select(STDOUT); $| = 1; # Make unbuffered. #------------------------------------------------------------------------------ # Get the passed variable use routine from cgi-lib.pl #------------------------------------------------------------------------------ &ReadParse; #------------------------------------------------------------------------------ # Setup today #------------------------------------------------------------------------------ ($sec,$min,$hour,$thisday,$thismon,$thisyear,$wday,$yday,$isdst) = localtime(time); $thismon++; # 0 based $thisyear += 1900; $today = $weekday[$wday].", ".$monthname[$thismon-1]." ".$thisday.", ".$thisyear; $currentdate=sprintf("%4.4d-%2.2d-%2.2d",$cyear,$cmon,$cday); #------------------------------------------------------------------------------ # Print the header. #------------------------------------------------------------------------------ &printHeader("$organization News and Events"); print <The following are the news items for today, $today. See the "Help" page for instructions on how to use this service (including how to add your own news items), and the "About" page for general information.

You can also view the $organization calendar.

EOF opendir(NEWSDIR, "$newsDir"); # Get all of the news files in the news directory, minus '.' and '..'. @newsFiles = grep(!/^(\.\.?)|(CVS)$/, readdir(NEWSDIR)); closedir(NEWSDIR); # Sort the files by reverse date. @newsFiles = sort(SortReverseDate @newsFiles); # Print the headlines. print "
Headlines

\n"; $itemCount = 1; foreach $file (@newsFiles) { (print "
    \n") if ($itemCount == 1); $_ = $file; ($date) = /(.*)_/; $date =~ s/(\d+)-(\d+)-(\d+)/$2\/$3\/$1/; open (NEWS, "$newsDir/$_"); $/ = "\n---\n"; while () { ($newsTitle) = /Title: (.*)/; print "
  1. $date - $newsTitle\n"; $itemCount++; } close(NEWS); } if ($itemCount == 1) { print <
  2. There is no news. Group members can add news items with the "Add" link at the top of the page. EOF } else { print "
\n"; } $i = 1; print "
    \n"; for (@newsFiles) { open (NEWS, "$newsDir/$_"); $/ = "\n---\n"; while () { $news = $_; # $news =~ s/Title:(.*)/\Title:$1\<\/a\>/; $news = &MarkupNews($news); print "
  1. $news\n"; print "
    Return to headlines...
    \n"; $i++; } close(NEWS); } print "
\n"; #------------------------------------------------------------------------------ # Print the footer. #------------------------------------------------------------------------------ &printFooter();