diff options
| author | Nick Mathewson <nickm@torproject.org> | 2003-05-17 06:18:24 +0000 |
|---|---|---|
| committer | Nick Mathewson <nickm@torproject.org> | 2003-05-17 06:18:24 +0000 |
| commit | 0d6150b63cd5a698e647a4809e65a262f55902cb (patch) | |
| tree | c2269f85b90faf0585b6ea245b119d75d613ad5e /perl-v2 | |
| parent | 1d07a97300d48872726edd989f53bf489dc00a41 (diff) | |
| download | anonbib-0d6150b63cd5a698e647a4809e65a262f55902cb.tar.gz | |
Adding second version of perl files, css support, first take on anon bib
svn:r6
Diffstat (limited to 'perl-v2')
| -rw-r--r-- | perl-v2/BibTeX.pm | 303 | ||||
| -rw-r--r-- | perl-v2/PDOSBib.pm | 233 | ||||
| -rw-r--r-- | perl-v2/PDOSCGI.pm | 69 | ||||
| -rw-r--r-- | perl-v2/bibtex-entry.cgi | 206 | ||||
| -rw-r--r-- | perl-v2/mkpdospubs.pl | 242 | ||||
| -rw-r--r-- | perl-v2/pubs-date.cgi | 288 |
6 files changed, 1341 insertions, 0 deletions
diff --git a/perl-v2/BibTeX.pm b/perl-v2/BibTeX.pm new file mode 100644 index 0000000..17bc392 --- /dev/null +++ b/perl-v2/BibTeX.pm @@ -0,0 +1,303 @@ +package BibTeX; +use Symbol 'qualify_to_ref'; + +%bibtex_prototypes = ('string' => 'p', 'preamble' => 'v', '_' => 'kp*'); + +sub parse_bibtex_key ($) { + my($fh) = @_; + $_ = <$fh> while ((/^\s+$/s || /^\s+%/) && !eof $fh); + if (/^\s*([^"#%'(),={}\s]+)(.*)/s) { + $_ = $2; + lc($1); + } else { + print STDERR "no key at line $.\n"; + ""; + } +} + +sub parse_bibtex_value ($$) { + my($fh, $strings) = @_; + my($data) = ""; + my($bracelevel, $line); + + # loop over concatenation + while (1) { + + # loop over lines + $_ = <$fh> while ((/^\s+$/s || /^\s+%/) && !eof $fh); + s/^\s+//; + if (eof $fh) { + print STDERR "unexpected end of file\n"; + return $data; + } + + # check type of thing + if (/^\"(.*)/s) { + $_ = $1; + $bracelevel = 0; + $line = $.; + while (1) { + if (!$bracelevel && /^([^{}\"]*)\"(.*)/s) { + $data .= $1; + $_ = $2; + last; + } elsif ($bracelevel && /^([^{}]*\})(.*)/s) { + $data .= $1; + $_ = $2; + $bracelevel--; + } elsif (/^([^{}]*\{)(.*)/s) { + $data .= $1; + $_ = $2; + $bracelevel++; + } else { + $data .= $_; + die "end of file within quotes started at line $line" if eof $fh; + $_ = <$fh>; + } + } + + } elsif (/^\{(.*)/s) { + $_ = $1; + $bracelevel = 1; + $line = $.; + while ($bracelevel) { + if (/^([^{}]*)\}(.*)/s) { + $data .= $1; + $data .= "}" if $bracelevel > 1; + $_ = $2; + $bracelevel--; + } elsif (/^([^{}]*\{)(.*)/s) { + $data .= $1; + $_ = $2; + $bracelevel++; + } else { + $data .= $_; + die "end of file within braces started at line $line" if eof $fh; + $_ = <$fh>; + } + } + + } elsif (/^\#/) { + # do nothing + print STDERR "warning: odd concatenation at line $.\n"; + } elsif (/^[\},]/) { + print STDERR "no data after field at line $.\n" if $data eq ''; + return $data; + } elsif (/^([^\s\},]+)(.*)/s) { + if ($strings->{lc($1)}) { + $data .= $strings->{lc($1)}; + } else { + $data .= $1; + } + $_ = $2; + } + + # got a single string, check for concatenation + $_ = <$fh> while ((/^\s+$/s || /^\s+%/) && !eof $fh); + s/^\s+//; + if (/^\#(.*)/s) { + $_ = $1; + } else { + return $data; + } + } +} + +sub parse_bibtex_entry ($$$$) { + # uses caller's $_ + my($fh, $name, $strings, $entries) = @_; + my($entryline) = $.; + + $_ = <$fh> while /^\s+$/ && !eof $fh; + if (/^\s*\{(.*)/s) { + $_ = $1; + } else { + print STDERR "no open brace after \@$name starting at line $entryline\n"; + return []; + } + + # get prototype + my($prototype) = $bibtex_prototypes{$name}; + $prototype = $bibtex_prototypes{'_'} if !defined $prototype; + + # parse entry into `@v' + my(@v, $a, $b); + while (!eof $fh) { + $_ = <$fh> while /^\s*$/ && !eof $fh; + if (/^\s*\}(.*)/s) { + $_ = $1; + last; + } elsif ($prototype =~ /^k/) { + push @v, parse_bibtex_key($fh); + } elsif ($prototype =~ /^v/) { + push @v, parse_bibtex_value($fh, $strings); + } elsif ($prototype =~ /^p/) { + push @v, parse_bibtex_key($fh); + $_ = <$fh> while /^\s+$/ && !eof $fh; + s/^\s+\=?//; + push @v, parse_bibtex_value($fh, $strings); + } + $_ = <$fh> while /^\s*$/ && !eof $fh; + s/^\s*,?//; + $prototype = substr($prototype, 1) + if $prototype && $prototype !~ /^.\*/; + } + print STDERR "missing args to \@$name at line $.\n" + if $prototype && $prototype !~ /^.\*/; + + # do something with entry + if ($name eq 'string') { + $strings->{$v[0]} = $v[1]; + } elsif ($name eq 'preamble') { + # do nothing + } else { + my($key) = shift @v; + $entries->{$key} = {@v}; + $entries->{$key}->{'_type'} = $name; + $entries->{$key}->{'_key'} = $key; + push @{$entries->{'_'}}, $key; + } +} + +sub parse (*;\%) { + my($fh) = qualify_to_ref(shift, caller); + my($initial_strings) = @_; + my($strings) = $initial_strings; + + my($curname, $garbage, %entries); + local($_) = ''; + while (<$fh>) { + + if (/^\s*[%\#]/ || /^\s*$/) { + # comment + + } elsif (/^\s*\@([^\s\"\#%\'(),={}]+)(.*)/s) { + $curname = lc($1); + $_ = $2; + parse_bibtex_entry($fh, $curname, $strings, \%entries); + + } else { + print STDERR "garbage at line $.\n" if !defined $garbage; + $garbage = 1; + } + } + + \%entries; +} + +sub expand ($$) { + my($e, $key) = @_; + my(%d) = %{$e->{$key}}; + while ($d{'crossref'}) { + my($v) = $d{'crossref'}; + delete $d{'crossref'}; + %d = (%{$e->{$v}}, %d); + } + \%d; +} + + +sub split_von ($$$@) { + my($f, $v, $l, @x) = @_; + my(@pre, $t, $in_von, $tt); + while (@x) { + $t = $tt = shift @x; + if ($tt =~ /^\{\\/) { + $tt =~ s/\\[A-Za-z@]+//g; + $tt =~ s/\\.//g; + $tt =~ tr/{}//d; + } + if ($tt =~ /^[a-z]/) { + push @$v, $t; + $in_von = 1; + } elsif ($in_von || !ref($f)) { + push @$l, $t, @x; + return; + } else { + push @$f, $t; + } + } + if (!$in_von) { + push @$l, (pop @$f); + } +} + +sub parse_author ($) { + local($_) = $_[0]; + my(@x) = (); + my($pos, $pos0, $t, $bracelevel); + + $bracelevel = 0; + + # move text into @x + while (!/^\s*$/) { + s/^\s+//; + $pos = 0; + while ($pos < length) { + $t = substr($_, $pos, 1); + if ($t eq '{') { + $bracelevel++; + } elsif ($t eq '}') { + $bracelevel--; + } elsif ($bracelevel <= 0) { + last if ($t =~ /[\s,]/); + } + $pos++; + } + + push @x, substr($_, 0, $pos); + if ($t eq ',') { + push @x, ','; + $pos++; + } + $_ = substr($_, $pos); + } + + # split @x into arrays based on `and' + my(@aa) = ([]); + foreach $t (@x) { + if ($t eq 'and') { + push @aa, [] if @{$aa[-1]} > 0; + } else { + push @{$aa[-1]}, $t; + } + } + + # massage each subarray into four parts: first, von, last, jr + my(@aaa) = (); + foreach $t (@aa) { + my(@fvl, @vl, @v, @l, @f, @j, $cur, $commas); + $cur = \@fvl; $commas = 0; + + # split into subarrays if possible + foreach $x (@$t) { + if ($x eq ',') { + if ($commas == 0) { + @vl = @fvl; + @fvl = (); + $cur = \@f; + } else { + push @j, @f; + @f = (); + } + $commas++; + } else { + push @$cur, $x; + } + } + + # split out the `von' part + if ($commas == 0) { + split_von(\@f, \@v, \@l, @fvl); + } else { + split_von(0, \@v, \@l, @vl); + } + + # store as an array of arrays + push @aaa, [[@f], [@v], [@l], [@j]]; + } + + @aaa; +} + +1; diff --git a/perl-v2/PDOSBib.pm b/perl-v2/PDOSBib.pm new file mode 100644 index 0000000..013cfbe --- /dev/null +++ b/perl-v2/PDOSBib.pm @@ -0,0 +1,233 @@ +package main; + +# maps regexps, which are applied to authors, to their home page URLs +@author_urls = + ( + 'Berthold' => 'http://page.inf.fu-berlin.de/~berthold/', + 'Chaum' => 'http://www.chaum.org', + 'Dingledine' => 'http://www.freehaven.net/~arma/cv.html', + 'Desmedt' => 'http://www.cs.fsu.edu/~desmedt/', + 'Jakobsson' => 'http://www.cs.ucsd.edu/users/markus/', + 'K.*Kurosawa' => 'http://kuro.cis.ibaraki.ac.jp/~kurosawa/', + 'Mathewson' => 'http://www.wangafu.net/~nickm/', + 'Mazières' => 'http://www.scs.cs.nyu.edu/~dm/', + 'A.*Pfitzmann' => 'http://dud.inf.tu-dresden.de/~pfitza/', + 'B.*Pfitzmann' => 'http://www.zurich.ibm.com/~bpf/', + 'Rivest' => 'http://theory.lcs.mit.edu/~rivest/', + 'Serjantov' => 'http://www.cl.cam.ac.uk/users/aas23/', + 'Syverson' => 'http://www.syverson.org/', + 'David.*Wagner' => 'http://www.cs.berkeley.edu/~daw/', + 'Shoup' => 'http://www.shoup.net/', + 'B.*Möller' => 'http://www.informatik.tu-darmstadt.de/TI/Mitarbeiter/moeller.html', + + +# From the old PDOS file... + 'Engler' => 'http://www.pdos.lcs.mit.edu/~engler/', + 'Kaashoek' => 'http://www.pdos.lcs.mit.edu/~kaashoek/', + 'Blake' => 'http://www.pdos.lcs.mit.edu/cb/', + + 'Ganger' => 'http://www.ece.cmu.edu/~ganger/', + 'Grimm' => 'http://www.cs.washington.edu/homes/rgrimm/', + 'Hsieh' => 'http://www2.cs.utah.edu/~wilson/', + 'Briceño' => 'http://mit.edu/hbriceno/www/', + 'Wallach' => 'http://www.pdos.lcs.mit.edu/~kerr/', + 'Candea' => 'http://www.cs.stanford.edu/~candea/', + 'Kohler' => 'http://www.pdos.lcs.mit.edu/~eddietwo/', + 'Kirk.*Johnson' => 'http://www.cs.colorado.edu/~tuna/', + 'Weihl' => 'http://www.research.digital.com/SRC/staff/weihl/', + 'Nygren' => 'http://www.mit.edu/people/nygren/', + 'Anthony.*Joseph' => 'http://www.cs.berkeley.edu/~adj/', + 'Poletto' => 'http://www.pdos.lcs.mit.edu/~maxp/', + 'Kaminsky' => 'http://www.pdos.lcs.mit.edu/~kaminsky/', + 'Morris' => 'http://www.pdos.lcs.mit.edu/~rtm/', + 'Jannotti' => 'http://www.jannotti.com/', + 'Benjie' => 'http://www.pdos.lcs.mit.edu/~benjie/', + 'Jinyang' => 'http://www.pdos.lcs.mit.edu/~jinyang/', + 'Douglas.*outo' => 'http://www.pdos.lcs.mit.edu/~decouto/', + 'Kevin.*Fu' => 'http://snafu.fooworld.org/~fubob/', + 'Karger' => 'http://theory.lcs.mit.edu/~karger/', + 'Dabek' => 'http://pdos.lcs.mit.edu/~fdabek/', + 'Brunskill' => 'http://pdos.lcs.mit.edu/~emma/', + 'Balakrishnan' => 'http://nms.lcs.mit.edu/~hari/', + 'Stoica' => 'http://www.cs.berkeley.edu/~istoica/', + 'Andersen' => 'http://nms.lcs.mit.edu/~dga/', + 'Snoeren' => 'http://nms.lcs.mit.edu/~snoeren/', + 'Freedman' => 'http://www.pdos.lcs.mit.edu/~mfreed/', + 'Emil.*Sit' => 'http://www.mit.edu/~sit/', + 'Nick.*Feamster' => 'http://nms.lcs.mit.edu/~feamster/', + ); + +# don't print entries for these types, which are only used for crossreferences +%dont_print = + ('proceedings' => 1, 'journal' => 1); + +%initial_strings = + ('jan' => 'January', 'feb' => 'February', + 'mar' => 'March', 'apr' => 'April', + 'may' => 'May', 'jun' => 'June', + 'jul' => 'July', 'aug' => 'August', + 'sep' => 'September', 'oct' => 'October', + 'nov' => 'November', 'dec' => 'December'); + + +sub dont_print ($) { + my($d) = @_; + $dont_print{$d->{'_type'}} || + ($d->{'www_show'} && ($d->{'www_show'} eq 'no')); +} + +sub htmlize ($) { + my($x) = @_; + $x =~ s/&([^a-z0-9])/&$1/g; + $x =~ s/\\i([^a-zA-Z@])/i$1/g; + $x =~ s/\\'(.)/&$1acute;/g; + $x =~ s/\\`(.)/&$1grave;/g; + $x =~ s/\\~(.)/&$1tilde;/g; + $x =~ s/\\\^(.)/&$1circ;/g; + $x =~ s/\\"(.)/&$1uml;/g; + $x =~ s/\\[a-zA-Z@]+//g; + $x =~ s/\\.//g; + $x =~ tr/{}//d; + $x =~ s/(\d)--(\d)/$1-$2/g; + $x; +} + +sub htmlize_author ($) { + my($aaa) = @_; + my($x) = join(' ', @{$aaa->[0]}, @{$aaa->[1]}, @{$aaa->[2]}); + if (@{$aaa->[3]}) { + $x .= ', ' . join(' ', @{$aaa->[3]}); + } + htmlize($x); +} + +sub push_availability ($$\@$) { + my($d, $key, $availability, $name) = @_; + if ($d->{$key}) { + my($url) = $d->{$key}; + $url = $server_url . $url if $url =~ /^\//; + push @$availability, '<a href="' . $url . '">' . $name . '</a>'; + } +} + +sub htmlize_biblio_info ($) { + my($d) = @_; + my($_type) = $d->{'_type'}; + my($x, $i); + + if ($_type eq 'inproceedings') { + $x = "In the " . $d->{'booktitle'}; + if ($d->{'bookurl'}) { + if ($x =~ /^(in the proceedings of( the)? )(.*)/i + || $x =~ /^(in the workshop record of( the)? )(.*)/i) { + $x = $1 . "<a href=\"$d->{'bookurl'}\">" . $3 . "</a>"; + } else { + $x = "In the <a href=\"$d->{'bookurl'}\">$d->{'booktitle'}</a>"; + } + } + $x .= ", " . $d->{'edition'} if $d->{'edition'}; + $x .= ", " . $d->{'address'} if $d->{'address'}; + $x .= ", " . ($d->{'month'} or "") . " " . ($d->{'year'} or "") + if $d->{'month'} || $d->{'year'}; + $x .= ($d->{'pages'} =~ /^\d+$/ ? ", page " : ", pages ") + . $d->{'pages'} if $d->{'pages'}; + + } elsif ($_type eq 'article') { + $x = "In " . $d->{'journal'}; + if ($d->{'journalurl'}) { + $x =~ s/^(in )(.*)$/$1<a href="$d->{'journalurl'}">$2<\/a>/; + } + $x .= " <b>" . $d->{'volume'} . "</b>" if $d->{'volume'}; + $x .= "(" . $d->{'number'} . ")" if $d->{'number'}; + $x .= ", " . ($d->{'month'} or "") . " " . ($d->{'year'} or "") + if $d->{'month'} || $d->{'year'}; + $x .= ($d->{'pages'} =~ /^\d+$/ ? ", page " : ", pages ") + . $d->{'pages'} if $d->{'pages'}; + + } elsif ($_type eq 'techreport') { + $x = $d->{'institution'}; + $x .= " " . ($d->{'type'} ? $d->{'type'} : "technical report"); + $x .= " " . $d->{'number'}; + $x .= ", " . $d->{'month'} . " " . $d->{'year'} + if $d->{'month'} || $d->{'year'}; + + } elsif ($_type eq 'mastersthesis' || $_type eq 'phdthesis') { + $x = ($_type eq 'mastersthesis' ? "Master's thesis" : "Ph.D. thesis"); + $x = $d->{'type'} if $d->{'type'}; + $x .= ", " . $d->{'school'} if $d->{'school'}; + $x .= ", " . $d->{'month'} . " " . $d->{'year'} + if $d->{'month'} || $d->{'year'}; + + } elsif ($_type eq 'misc') { + $x = $d->{'howpublished'}; + $x .= ", " . $d->{'month'} . " " . $d->{'year'} + if $d->{'month'} || $d->{'year'}; + $x .= ($d->{'pages'} =~ /^\d+$/ ? ", page " : ", pages ") + . $d->{'pages'} if $d->{'pages'}; + + } else { + $x = "<odd type $_type>"; + } + + $x = '<span class="biblio">' . ($x or "") . ".</span> "; + $x .= "<span class=\"availability\">(<a href=\"$cgi_dir/bibtex-entry.cgi?key="; + $x .= $d->{'_key'} . "\">BibTeX entry</a>)</span>"; + htmlize($x); +} + +sub htmlize_entry ($) { + my($d) = @_; + my(@availability, @a, $a, $i, $j, $x); + + # print title + $x .= '<li><p class="entry"><span class="title">' . htmlize($d->{'title'}) . ".</span>"; + + # print availability + @availability = (); + push_availability $d, 'www_abstract_url', @availability, 'abstract'; + push_availability $d, 'www_html_url', @availability, 'HTML'; + push_availability $d, 'www_txt_url', @availability, 'TXT'; + push_availability $d, 'www_pdf_url', @availability, 'PDF'; + push_availability $d, 'www_ps_url', @availability, 'PS'; + push_availability $d, 'www_ps_gz_url', @availability, 'gzipped PS'; + if (@availability) { + $x .= ' <span class="availability">('; + $x .= join(', ', @availability) . ")</span>"; + } + $x .= "<br>\n"; + + # print authors + $x .= '<span class="author">by '; + @a = BibTeX::parse_author($d->{'author'}); + foreach $i (0..$#a) { + $x .= ", " if ($i > 0 && $i < $#a); + $x .= " and " if ($i == $#a && $#a == 1); + $x .= ", and " if ($i == $#a && $#a > 1); + $a = htmlize_author($a[$i]); + for ($j = 0; $j < @author_urls; $j += 2) { + if ($a =~ /$author_urls[$j]/) { + $x .= '<a href="' . $author_urls[$j+1] . '">' . $a . '</a>'; + undef $a; + last; + } + } + $x .= $a if defined $a; + } + $x .= "." if (defined $a and $a !~ /\.$/); + $x .= "</span><br>\n"; + + $x .= htmlize_biblio_info($d); + $x .= "</p></li>\n\n"; + + $x; +} + + +sub url_untranslate ($) { + my($x) = $_[0]; + $x =~ s/ /+/g; + $x =~ s/([%<>])/sprintf("%02x", chr($1))/eg; + $x; +} + +1; diff --git a/perl-v2/PDOSCGI.pm b/perl-v2/PDOSCGI.pm new file mode 100644 index 0000000..bb081bb --- /dev/null +++ b/perl-v2/PDOSCGI.pm @@ -0,0 +1,69 @@ +package main; + +##### +# SERVER DATA + +$server_url = "http://www.pdos.lcs.mit.edu"; +$img_dir = "/img"; +$cgi_dir = "/cgi-bin"; +$main_dir = ""; # == top dir +$css_dir = ""; # == top dir +#$pdos_bib_dir = "/home/am0/httpd/htdocs/pdosbib"; +$pdos_bib_dir = "."; + + +##### +# ERROR_EXIT +# &error_exit($title, $message...) prints an HTML document summarizing the +# error and exits. + +sub error_exit ($@) { + my($title) = $_[0]; + my($message) = join('', @_[1..$#_]); + print <<"EOD;"; +Content-type: text/html + +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> +<html><head><title>PDOS CGI Error</title></head> +<body> + +<h1>$title</h1> + +<p>$message + +<p><a href="$server_url">PDOS home page</a> + +</body> +</html> +EOD; + exit 0; +} + +##### +# HTTP_DATE +# Given a time value (seconds since 00:00:00 UTC, Jan 1, 1970), formats an +# HTTP date and returns it. Useful for Expires:. + +@PDOSCGI::weekdays = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'); +@PDOSCGI::months = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', + 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); + +sub http_date ($) { + my($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = + gmtime($_[0]); + sprintf("%s, %02d %s %d %02d:%02d:%02d GMT", + $PDOSCGI::weekdays[$wday], $mday, $PDOSCGI::months[$mon], + $year, $hour, $min, $sec); +} + +##### +# URL_TRANSLATE + +sub url_translate ($) { + my($x) = $_[0]; + $x =~ s/\+/ /g; + $x =~ s/%(\w\w)/pack('C', hex($1))/eg; + $x; +} + +1; diff --git a/perl-v2/bibtex-entry.cgi b/perl-v2/bibtex-entry.cgi new file mode 100644 index 0000000..8c166fa --- /dev/null +++ b/perl-v2/bibtex-entry.cgi @@ -0,0 +1,206 @@ +#!/usr/bin/perl +# CGI script: PDOS publication BibTeX entry +# Eddie Kohler, June 10, 1999 + +use lib '/home/am3/httpd/htdocs/pdosbib'; +#use lib '/u/eddietwo/www/pdos/pdosbib'; +use BibTeX; +use PDOSCGI; + +%initial_strings = + ('jan' => 'January', 'feb' => 'February', + 'mar' => 'March', 'apr' => 'April', + 'may' => 'May', 'jun' => 'June', + 'jul' => 'July', 'aug' => 'August', + 'sep' => 'September', 'oct' => 'October', + 'nov' => 'November', 'dec' => 'December'); + +open(BIB, "$pdos_bib_dir/pdos.bib") + || error_exit("Can't open <tt>pdos.bib</tt>!"); +$e = BibTeX::parse(*BIB, %initial_strings); +close BIB; + +##### +# PROCESS_QUERY + +sub process_query ($) { + my($q) = $_[0]; + while ($q =~ /^\&?([^\&]+)(.*)/) { + $_ = url_translate($1); + $q = $2; + if (/^key=(.*)$/) { + $bibtex_key = $1; + } 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 <<"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 `bibtex-entry.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> <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> +<td bgcolor="#ffffcc"><p><b>BibTeX entry</b></p></td> +</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"> +<a href="$main_dir/pubs.html">By subject</a><br> +<a href="/cgi-bin/pubs-date.cgi">By date</a><br> +</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> <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; + +$type = ($bibtex_key ? "<tt>`$bibtex_key'</tt>" : "all entries"); +print "<h1>BibTeX entry server: results for $type</h1>\n"; + +sub break_lines ($$) { + my($t, $l) = @_; + my($s, $f, $p, $x) = (0, 0, 0, ""); + while ($p < length $t) { + if (substr($t, $p, 1) =~ /\s/) { + $s = $p; + } elsif ($f + $l <= $p && $s > $f) { + $x .= substr($t, $f, $s - $f) . "\n"; + $s = $f = $s + 1; + } + $p++; + } + $x .= substr($t, $f); + $x; +} + +if ($bibtex_key && $e->{$bibtex_key}) { + $d = BibTeX::expand($e, $bibtex_key); + $k = "\@" . $d->{'_type'} . "{" . $bibtex_key . ",\n"; + foreach $i ('title', 'author', 'journal', 'booktitle', 'school', 'institution', 'organization', 'volume', 'number', 'year', 'month', 'address', 'chapter', 'edition', 'pages', 'editor', 'howpublished', 'key', 'publisher', 'type', 'note') { + if (exists $d->{$i}) { + $k .= break_lines(" " . $i . " = {" . $d->{$i} . "},\n", 80); + } + } + $k .= "}\n"; +} elsif ($bibtex_key) { + print "<p>There is no PDOS paper with key `<tt>$bibtex_key</tt>'.\n"; + undef $k; +} else { + $k = `cat pdos.bib`; +} +if (defined $k) { + $k =~ s/&/&/g; + $k =~ s/</</g; + $k =~ s/>/>/g; + print "<p><pre>$k</pre>\n"; +} + + +print <<"EOD;"; +</td> + +<td width="15%"><br></td> + +</tr> +</table> + +</body> +</html> +EOD; diff --git a/perl-v2/mkpdospubs.pl b/perl-v2/mkpdospubs.pl new file mode 100644 index 0000000..777386a --- /dev/null +++ b/perl-v2/mkpdospubs.pl @@ -0,0 +1,242 @@ +#!/usr/local/bin/perl -w +# *** +# *** CGI script: static PDOS publication list +# *** Eddie Kohler, June 10, 1999 +# *** +# *** Take a look at PDOSBib.pm +# *** to change things like people's URLs +# *** and how different bibliography entries are generated +# *** +# *** Take a look at PDOSCGI.pm +# *** to change where files are located +# *** + +#use lib '/home/am0/httpd/htdocs/pdosbib'; +use BibTeX; +use PDOSBib; +use PDOSCGI; + +sub do_entries () { + my($section, $key, $d); + foreach $section (@sections) { + # print section header + print '<h3><a name="', url_untranslate($section), '">'; + print $section, "</a></h3>\n"; + print "<ul class=\"expand\">\n"; + + # print all papers in that section + foreach $key (@{$e->{'_'}}) { + $d = BibTeX::expand($e, $key); + next if dont_print($d) || $d->{'www_section'} ne $section; + print htmlize_entry $d; + } + + print "</ul>\n"; + } +} + + +sub do_sections () { + foreach $section (@sections) { + print '<p class="l2"><a href="#', url_untranslate($section); + print '">', $section, "</a></p>\n"; + } +} + + +# main program +if (@ARGV > 0) { + open(BIB, $ARGV[0]) || die "can't open $ARGV[0]"; +} else { + open(BIB, "<&STDIN"); +} +$e = BibTeX::parse(*BIB, %initial_strings); +close BIB; + +if (@ARGV > 1) { + open(STDOUT, ">$ARGV[1]") || die "can't open $ARGV[1]"; +} + +# make sections +@sections = (); +foreach $key (@{$e->{'_'}}) { + next if dont_print($e->{$key}); + $section = $e->{$key}->{'www_section'}; + if (not $section) { + $e->{$key}->{'www_section'} = $section = "Miscellaneous"; + } + + if (!exists $sections{$section}) { + push @sections, $section if $section ne ''; + $sections{$section} = 1; + } +} +push @sections, 'Miscellaneous' + if $sections{''} && !$sections{'Miscellaneous'}; + +## PRINT STUFF! +$argv_string = join(' ', 'mkpdospubs.pl', @ARGV); +print <<"EOD;"; +<!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"> + +<!-- *** I AM MACHINE GENERATED! DO NOT EDIT ME! + -- *** EDIT THE .bib FILE INSTEAD! + -- + -- Generated by `$argv_string' + -- (c) Eddie Kohler 1999-2000 --> + +<title>Anonymity Bibliography</title> + +<link rel="stylesheet" type="text/css" href="main.css"> +<link rel="stylesheet" type="text/css" href="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="5" 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="5" 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="3" width="8" bgcolor="#ffffcc"><img src="/img/emptydot.gif" +width="8" height="1" alt=""></td> +<td rowspan="3" 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><b>Publications</b> > </p></td> +<td bgcolor="#ffffcc"><p><b>By subject</b></p></td> +</tr> + +<tr valign="top"> +<td bgcolor="#ffffcc"><p><br></p></td> +<td bgcolor="#ffffcc"><p class="crumbbreadth"> +<a href="projects.html">Projects</a><br> +<a href="people.html">People</a><br> +<a href="software.html">Software</a></p></td> +<td bgcolor="#ffffcc"><p class="crumbbreadth"> +<a href="/cgi-bin/pubs-date.cgi">By date</a></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 colspan="1" height="8" bgcolor="#ffffcc"><img src="/img/emptydot.gif" +width="100" height="8" alt=""></td> +<td colspan="2" rowspan="2" width="9" height="9" bgcolor="#ffffcc"><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> +<p align="center">By subject | <a href="/cgi-bin/pubs-date.cgi">By date</a></p> + +<table cellspacing="0" cellpadding="0" border="0" width="100%"> + +<tr valign="top"> +<td width="10%" height="24"><br></td> +</tr> + +<tr valign="top"> +<td><div align="right"> +<table cellspacing="0" cellpadding="0" border="0" width="161"> + +<tr valign="top"> +<td rowspan="6" width="8"><img src="/img/emptydot.gif" +width="8" height="1" alt=""></td> +<td colspan="4" height="1" bgcolor="#92a6a4"><img src="/img/emptydot.gif" +width="1" height="1" alt=""></td> +</tr> + +<tr valign="top"> +<td rowspan="5" width="1" bgcolor="#92a6a4"><img src="/img/emptydot.gif" +width="1" height="1" alt=""></td> + +<td bgcolor="#ccffff"><p class="l1"><br><form action="/cgi-bin/pubs-date.cgi" +method="get"><strong>Publication search:</strong><br> +<small><input type=entry name=match size=15> <input type=submit +value="Go"><br></small></form></p></td> + +<td width="8" bgcolor="#ccffff"><img src="/img/emptydot.gif" +width="8" height="1" alt=""></td> +<td rowspan="3" width="1" bgcolor="#92a6a4"><img src="/img/emptydot.gif" +width="1" height="1" alt=""></td> +<td rowspan="3" width="12"><img src="/img/emptydot.gif" +width="12" height="1" alt=""></td> +</tr> + +<tr valign="top"> +<td colspan="2" height="1" bgcolor="#92a6a4"><img src="/img/emptydot.gif" +width="1" height="1" alt=""></td> +</tr> + +<tr valign="top"> +<td bgcolor="#ccffff"><p class="l1"><br><form action="/cgi-bin/pubs-date.cgi" +method="get"><strong>Subjects:</strong><br> +EOD; + +## PRINT SECTIONS +do_sections; + +print <<"EOD;"; +</p></td> + +<td width="8" bgcolor="#ccffff"><img src="/img/emptydot.gif" +width="8" height="1" alt=""></td> +</tr> + +<tr valign="top"> +<td height="8" bgcolor="#ccffff"><img src="/img/emptydot.gif" +width="1" height="8" alt=""></td> +<td colspan="2" rowspan="2" width="9" height="9" bgcolor="#ccffff"><img +src="/img/whitecorner.gif" width="9" height="9" alt=""></td> +</tr> + +<tr valign="top"> +<td height="1" bgcolor="#92a6a4"><img src="/img/emptydot.gif" +width="1" height="1" alt=""></td> +</tr> + +</table> +</div></td> + +<td width="75%"> + +<h2>Publications by subject</h2> + +EOD; + +## PRINT ENTRIES +do_entries; + +print <<"EOD;"; +</td> + +<td width="15%"><br></td> + +</tr> +</table> + +</body> +</html> +EOD; 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; |
