From 1d07a97300d48872726edd989f53bf489dc00a41 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Sat, 17 May 2003 06:10:20 +0000 Subject: Initial revision svn:r2 --- perl/pubs-date.cgi | 274 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 274 insertions(+) create mode 100644 perl/pubs-date.cgi (limited to 'perl/pubs-date.cgi') 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 "\n" if $ever; + $y = $d->{'_show_year'}; + $ever = 1; + print "

$y

\n\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 ``$_'' +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 + + + + + + + + +PDOS Publications Search Results + + + + + + + + + + + + + + + + + + + + + + +EOD; + +if (defined($match)) { + print '', "\n"; +} else { + print '', "\n"; +} + +print <<"EOD;"; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +




  MIT > LCS > PDOS Home > 

Publications > 

Search results

By date


+Projects
+People
+Software

+EOD; + +if (defined($match)) { + print 'All by subject
', "\n"; + print 'All by date
', "\n"; +} else { + print 'By subject
', "\n"; +} + +print <<"EOD;"; +

 Publication +search:  
+ + + + + + + + + + + + + + + + +

+ +EOD; + +if (defined($match)) { + print "

Publications matching `$match'

\n"; +} else { + print "

Publications by date

\n"; +} + +$| = 0; + +open(BIB, "$pdos_bib_dir/pdos.bib") + || error_exit("Can't open pdos.bib!"); +$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;"; +

+ + + +EOD; -- cgit v1.2.3-70-g09d2