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

  1. #!/usr/bin/perl
  2.  
  3. # Default title - will be overwritten by category name
  4. $title = "Home Page";
  5.  
  6. unshift(@INC, "lib");
  7.  
  8. require 'config.pl';
  9. require 'bib.pl';
  10. require 'web.pl';
  11.  
  12. print "Content-type: text/html\n\n";
  13.  
  14. &bib::load("CATEGORY", "KEYWORDS", "TITLE", "AUTHOR", "META");
  15.  
  16. # Get the categories
  17. @categories = &bib::get_categories();
  18. &error($bib::error) unless defined @categories;
  19.  
  20. # Get the keywords
  21. @keywords = &bib::get_keywords(1);
  22. &error($bib::error) unless defined @keywords;
  23.  
  24. # Get the keyword modifiers
  25. @modifiers = &bib::get_modifiers();
  26. &error($bib::error) unless defined @modifiers;
  27.  
  28. # Construct a list of all titles
  29. foreach $category (@categories)
  30. {
  31.     $CATEGORY = uc($category);
  32.     $cats .= ", " if $cats;
  33.     $cats .= sprintf("<A HREF=%s>%s</A>", "$bib::cgi/home2.cgi/$category", $CATEGORY);
  34. }
  35.  
  36. # Get the category from the URL name
  37. ($category = $ENV{PATH_INFO}) =~ s!.*/!!;
  38.  
  39. if ($category)
  40. {
  41.     $CATEGORY = uc($category);
  42.     $title = "$CATEGORY";
  43.  
  44.     $all .= sprintf("<H2>%s</H2>\n", $CATEGORY);
  45.     $all .= "<UL>\n";
  46.     foreach $id (sort bib::id_by_title &bib::get_ids_in_category($category))
  47.     {
  48.         $series .= "$id,";
  49.         next if $bib::db{$id}->{META} =~ /submit|delete/;
  50.  
  51.         $all .= "<LI> <A HREF=\"javascript:display($id)\" onMouseOver=\"window.status='Bibliography entry $id';return true\">" .
  52.           "$bib::db{$id}->{TITLE}</A>";
  53.  
  54.         $all .= ", $bib::db{$id}->{AUTHOR}"
  55.           if $bib::db{$id}->{AUTHOR};
  56.  
  57.         $all .= "\n";
  58.     }
  59.     $all .= "</UL>\n";
  60. }
  61.  
  62. # Convert the categories, keywords, and modifiers to HTML option list
  63. grep(s/.*/<OPTION>$&\n/, @categories);
  64. grep(s/.*/<OPTION>$&\n/, @keywords);
  65. grep(s/.*/<OPTION>$&\n/, @modifiers);
  66.  
  67. # Create the HTML page
  68. print &bib::template("home2.html",
  69.                      "CATEGORIES", "@categories",
  70.                      "KEYWORDS", "@keywords",
  71.                      "MODIFIERS", "@modifiers",
  72.                      "CATS", $cats,
  73.                      "TITLE", $title,
  74.                      "ALL", $all,
  75.                      "SERIES", $series,);
  76. exit 0;
  77.