aboutsummaryrefslogtreecommitdiffstats
path: root/perl/pubs-date.cgi
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2003-05-17 06:10:20 +0000
committerNick Mathewson <nickm@torproject.org>2003-05-17 06:10:20 +0000
commit1d07a97300d48872726edd989f53bf489dc00a41 (patch)
treebaa19dd713b183d6694364251b6e17afe9195b0f /perl/pubs-date.cgi
parent11fddbc0273c37d651399ec782c57065f8030a76 (diff)
downloadanonbib-1d07a97300d48872726edd989f53bf489dc00a41.tar.gz
Initial revision
svn:r2
Diffstat (limited to 'perl/pubs-date.cgi')
-rw-r--r--perl/pubs-date.cgi274
1 files changed, 274 insertions, 0 deletions
diff --git a/perl/pubs-date.cgi b/perl/pubs-date.cgi
new file mode 100644
index 0000000..aa64932
--- /dev/null
+++ b/perl/pubs-date.cgi
@@ -0,0 +1,274 @@
+#!/usr/local/bin/perl
+# CGI script: PDOS publications by date
+# Eddie Kohler, June 10, 1999
+
+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'} =~ /to appear/i) {
+ push @date, 12*$current_year + 12;
+ $d->{'_show_year'} = $current_year;
+ } else {
+ push @date, 12*$d->{'year'} + $date_back{$d->{'month'}};
+ $d->{'_show_year'} = ($d->{'year'} ? $d->{'year'} : 'unknown');
+ }
+ 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'} 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>PDOS Publications 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>&nbsp;&nbsp;<a href="http://web.mit.edu/">MIT</a>&nbsp;&gt;&nbsp;<a href="http://www.lcs.mit.edu/">LCS</a>&nbsp;&gt;&nbsp;<a href="/">PDOS&nbsp;Home</a>&nbsp;&gt;&nbsp;</p></td>
+<td bgcolor="#ffffcc"><p><a href="$main_dir/pubs.html">Publications</a>&nbsp;&gt;&nbsp;</p></td>
+EOD;
+
+if (defined($match)) {
+ print '<td bgcolor="#ffffcc"><p><b>Search&nbsp;results</b></p></td>', "\n";
+} else {
+ print '<td bgcolor="#ffffcc"><p><b>By&nbsp;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&nbsp;by&nbsp;subject</a><br>', "\n";
+ print '<a href="/cgi-bin/pubs-date.cgi">All&nbsp;by&nbsp;date</a><br>', "\n";
+} else {
+ print '<a href="', $main_dir, '/pubs.html">By&nbsp;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>&nbsp;Publication
+search:</strong><small>&nbsp;&nbsp;<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>
+
+
+<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 "<h1>Publications matching `<tt>$match</tt>'</h1>\n";
+} else {
+ print "<h1>Publications by date</h1>\n";
+}
+
+$| = 0;
+
+open(BIB, "$pdos_bib_dir/pdos.bib")
+ || error_exit("Can't open <tt>pdos.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 $e->{$key}->{'www_section'} eq '';
+}
+
+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;