diff options
Diffstat (limited to 'perl-v2/pubs-date.cgi')
| -rw-r--r-- | perl-v2/pubs-date.cgi | 288 |
1 files changed, 288 insertions, 0 deletions
diff --git a/perl-v2/pubs-date.cgi b/perl-v2/pubs-date.cgi new file mode 100644 index 0000000..fe37b34 --- /dev/null +++ b/perl-v2/pubs-date.cgi @@ -0,0 +1,288 @@ +#!/usr/local/bin/perl -wT +# CGI script: PDOS publications by date +# Eddie Kohler, June 10, 1999 + +#use lib '.'; +#use lib '/home/am0/httpd/htdocs/pdosbib'; +#use lib '/u/eddietwo/www/pdos/pdosbib'; +use BibTeX; +use PDOSBib; +use PDOSCGI; + +%date_back = + ('January' => 1, 'February' => 2, + 'March' => 3, 'April' => 4, + 'May' => 5, 'June' => 6, + 'July' => 7, 'August' => 8, + 'September' => 9, 'October' => 10, + 'November' => 11, 'December' => 12); + +sub do_entries () { + my($key, $d, @x, @d, @date, @permute, $x, $y, $i, $ever); + my($current_year) = (gmtime())[5] + 1900; + + foreach $key (@{$e->{'_'}}) { + $d = BibTeX::expand($e, $key); + next if dont_print($d); + $x = $y = htmlize_entry $d; + if (defined $match) { + $y =~ s/&([\w])\w+;/$1/g; + $y =~ s/<.*?>//g; + next if !&matcher($y); + } + push @x, $x; + push @d, $d; + if ($d->{'year'} and $d->{'year'} =~ /to appear/i) { + push @date, 12*$current_year + 12; + $d->{'_show_year'} = $current_year; + } elsif ($d->{'year'}) { + push @date, 12*$d->{'year'} + $date_back{($d->{'month'} or "January")}; + $d->{'_show_year'} = ($d->{'year'} ? $d->{'year'} : 'unknown'); + } else { + push @date, 0; + $d->{'_show_year'} = "(No date)"; + } + push @permute, $#x; + } + + # permute the list, sort by date + @permute = reverse sort { $date[$a] <=> $date[$b] } @permute; + undef $y; + + # print entries + foreach $i (@permute) { + $d = $d[$i]; + if ($d->{'_show_year'} and $d->{'_show_year'} ne $y || !$ever) { + print "</ul>\n" if $ever; + $y = $d->{'_show_year'}; + $ever = 1; + print "<h2>$y</h2>\n<ul class=\"expand\">\n"; + } + print $x[$i]; + } + + print "</ul>\n" if $ever; + print "No matches.\n" if !$ever; +} + +##### +# PROCESS_QUERY + +sub process_query ($) { + my($q) = $_[0]; + while ($q =~ /^\&?([^\&]+)(.*)/) { + $_ = url_translate($1); + $q = $2; + if (/^match=(.*)$/) { + $match = $1; + $match =~ s/\///g; + # my name gets mangled a lot... decouto + $match =~ s/decouto/De Couto/i; + } else { + error_exit('Bad Query', <<"EOD;"); +I don't understand part of your query -- specifically, the ``<tt>$_</tt>'' +part. +EOD; + } + } +} + +## +# INITIALIZATION & READING + +$index_url = "http://$ENV{'SERVER_NAME'}$ENV{'REQUEST_URI'}"; +$index_url =~ s#/[^/]+$#/#; + +&process_query($ENV{'QUERY_STRING'}) if exists $ENV{'QUERY_STRING'}; + +## PRINT DATA + +$| = 1; +print <<"EOD;"; +Content-type: text/html + +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> +<html><head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> +<meta http-equiv="Content-Style-Type" content="text/css"> + +<!-- Generated by `pubs-date.cgi' + -- (c) Eddie Kohler 1999-2000 --> + +<title>Anonymity Bibliography: Search Results</title> + +<link rel="stylesheet" type="text/css" href="$css_dir/main.css"> +<link rel="stylesheet" type="text/css" href="$css_dir/pubs.css"> + +</head> +<body bgcolor="#ffffff" text="#000000" link="#bb0000" vlink="#990099" +alink="#ff9900" marginheight="0" marginwidth="0"> + +<!-- +<table cellspacing="0" cellpadding="0" border="0" align="center"> + +<tr valign="top"> +<td rowspan="8" width="134"><div align="right"><a href="/"><img +src="/img/pdostab.gif" width="134" height="61" border="0" +alt="PDOS Home"></a></div></td> +<td rowspan="8" width="1" bgcolor="#92a6a4"><img src="/img/emptydot.gif" +width="1" height="1" alt=""></td> +<td bgcolor="#ffffcc"><p><br></p></td> +<td bgcolor="#ffffcc"><p><br></p></td> +<td bgcolor="#ffffcc"><p><br></p></td> +<td rowspan="4" width="8" bgcolor="#ffffcc"><img src="/img/emptydot.gif" +width="8" height="1" alt=""></td> +<td rowspan="6" width="1" bgcolor="#92a6a4"><img src="/img/emptydot.gif" +width="1" height="1" alt=""></td> +</tr> + +<tr valign="top"> +<td bgcolor="#ffffcc"><p> <a href="http://web.mit.edu/">MIT</a> > <a href="http://www.lcs.mit.edu/">LCS</a> > <a href="/">PDOS Home</a> > </p></td> +<td bgcolor="#ffffcc"><p><a href="$main_dir/pubs.html">Publications</a> > </p></td> +EOD; + +if (defined($match)) { + print '<td bgcolor="#ffffcc"><p><b>Search results</b></p></td>', "\n"; +} else { + print '<td bgcolor="#ffffcc"><p><b>By date</b></p></td>', "\n"; +} + +print <<"EOD;"; +</tr> + +<tr valign="top"> +<td bgcolor="#ffffcc"><p><br></p></td> +<td bgcolor="#ffffcc"><p class="crumbbreadth"> +<a href="$main_dir/projects.html">Projects</a><br> +<a href="$main_dir/people.html">People</a><br> +<a href="$main_dir/software.html">Software</a></p></td> +<td bgcolor="#ffffcc"><p class="crumbbreadth"> +EOD; + +if (defined($match)) { + print '<a href="', $main_dir, '/pubs.html">All by subject</a><br>', "\n"; + print '<a href="/cgi-bin/pubs-date.cgi">All by date</a><br>', "\n"; +} else { + print '<a href="', $main_dir, '/pubs.html">By subject</a><br>', "\n"; +} + +print <<"EOD;"; +</p></td> +</tr> + +<tr valign="top"> +<td colspan="2" height="8" bgcolor="#ffffcc"><img src="/img/emptydot.gif" +width="1" height="8" alt=""></td> +<td height="8" bgcolor="#ffffcc"><img src="/img/emptydot.gif" +width="100" height="8" alt=""></td> +</tr> + +<tr valign="top"> +<td colspan="4" height="1" bgcolor="#92a6a4"><img src="/img/emptydot.gif" +width="1" height="1" alt=""></td> +</tr> + +<tr valign="top"> +<td rowspan="2" colspan="3" bgcolor="#ccffff"><form action="/cgi-bin/pubs-date.cgi" +method="get"><strong> Publication +search:</strong><small> <input type="entry" +name="match" size="15" value="$match"> <input type="submit" +value="Go"><br></small></form></td> + +<td width="8" bgcolor="#ccffff"><img src="/img/emptydot.gif" +width="8" height="1" alt=""></td> +</tr> + +<tr valign="bottom"> +<td rowspan="2" colspan="2" width="9" height="9" bgcolor="#ccffff" background="/img/nineborder.gif"><img src="/img/whitecorner.gif" width="9" height="9" alt=""></td> +</tr> + +<tr valign="top"> +<td colspan="3" height="1" bgcolor="#92a6a4"><img src="/img/emptydot.gif" +width="1" height="1" alt=""></td> +</tr> + +</table> +--> + +<h1 align="center">Anonymity Bibliography</h1> +<form action="/cgi-bin/pubs-date.cgi" method="get"> +<p align="center"><strong><a href="$main_dir/pubs.html">By subject</a> | + <a href="$main_dir/pubs-date.cgi">By date</a> | + Search:<small> <input type="entry" name="match" size="15" value="$match"> + <input type="submit" value="Go"><br></small></strong> +</p></form> + + +<table cellspacing="0" cellpadding="0" border="0" width="100%"> + +<tr valign="top"> +<td width="15%" height="24"><br></td> +</tr> + +<tr valign="top"> +<td></td> + +<td width="70%"> + +EOD; + +if (defined($match)) { + print "<h2>Publications matching `<tt>$match</tt>'</h2>\n"; +} else { + print "<h2>Publications by date</h2>\n"; +} + +$| = 0; + +open(BIB, "$pdos_bib_dir/anonbib.bib") + || error_exit("Can't open <tt>$pdos_bib_dir/anonbib.bib</tt>!"); +$e = BibTeX::parse(*BIB, %initial_strings); +close BIB; + +# make sections +foreach $key (@{$e->{'_'}}) { + next if dont_print($e->{$key}); + $e->{$key}->{'www_section'} = "Miscellaneous" + if (not $e->{$key}->{'www_section'}); +} + +if (defined($match)) { + $sub = 'sub main::matcher ($) { 1'; + if ($match =~ /[\.\^\$\[\](){}*|]/) { + $sub .= " && \$_[0] =~ /$match/oi"; + } elsif ($match eq ':abstract:') { + $sub .= " && \$_[0] =~ /\\(abstract\\b/oi"; + } else { + $_ = $match; + s/\+//; + while ($_ ne '') { + s/^\s+//; + if (/^\"([^\"]+)(.*)/) { + $sub .= " && \$_[0] =~ /$1/oi"; + $_ = $2; + $_ =~ s/^\"//; + } elsif (/^\"\"(.*)/) { + $_ = $2; + } elsif (/^(\S+)(.*)/) { + $sub .= " && \$_[0] =~ /$1/oi"; + $_ = $2; + } + } + } + eval "$sub; }"; +} + +do_entries; + +print <<"EOD;"; +</td> + +<td width="15%"><br></td> + +</tr> +</table> + +</body> +</html> +EOD; |
