home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / skeptic / bibliography / whatsnew.cgi < prev   
Text File  |  2009-08-26  |  2KB  |  83 lines

  1. #!/usr/bin/perl
  2.  
  3. # $rcs = ' $Id: whatsnew.cgi,v 1.4 1998/06/20 07:15:03 fitz Exp $ ' ;
  4.  
  5. unshift(@INC, "lib");
  6.  
  7. require 'config.pl';
  8. require 'bib.pl';
  9. require 'web.pl';
  10.  
  11. # Maximum number of entries to display
  12. $max = 1000;
  13. if ($ENV{PATH_INFO} =~ /.*\/(\d+)/)
  14. {
  15.     $max = $1;
  16. }
  17.  
  18. print "Content-type: text/html\n\n";
  19.  
  20. &bib::load("META", "DATE", "TITLE", "AUTHOR")
  21.   || &error("Database error: $bib::error");
  22.  
  23. foreach $id (sort by_date_then_title keys %bib::db)
  24. {
  25.     next if $bib::db{$id}->{META} =~ /submit|delete/;
  26.  
  27.     $series .= "$id,";
  28.  
  29.     if ($bib::db{$id}->{DATE} =~ /^\s*(\d\d\d\d)(\d\d)(\d\d)\s*$/)
  30.     {
  31.         $date = "$2/$3/$1";
  32.     }
  33.     else
  34.     {
  35.         next;
  36.     }
  37.  
  38.     if ($date ne $olddate)
  39.     {
  40.         $all .= "</UL>\n\n" if $olddate;
  41.  
  42.         $all .= "<STRONG>$date</STRONG>\n<UL>\n";
  43.  
  44.         $olddate = $date;
  45.     }
  46.  
  47.     $all .= " <LI> " . &bib::link_to_id($id);
  48.  
  49.     last if ++$count > $max;
  50. }
  51.  
  52. $all .= "<LI> ..." if $count > $max;
  53.  
  54. $all .= "</UL>" if $olddate;
  55.  
  56. # Create the HTML page
  57. print &bib::template("basic.html",
  58.                      "TITLE", "What's New",
  59.                      "DATA",
  60.                      &bib::template("whatsnew.html",
  61.                                     "DATA", $all,
  62.                                     "SERIES", $series,
  63.                                     "MAX", $max,));
  64.  
  65. exit 0;
  66.  
  67.  
  68. sub by_date_then_title
  69. {
  70.     if ($bib::db{$b}->{DATE} == $bib::db{$a}->{DATE})
  71.     {
  72.         $bib::a = $a;
  73.         $bib::b = $b;
  74.         return &bib::id_by_title();
  75.     }
  76.     else
  77.     {
  78.         return $bib::db{$b}->{DATE} <=> $bib::db{$a}->{DATE};
  79.     }
  80.  
  81.     return 0;
  82. }
  83.