aboutsummaryrefslogtreecommitdiffstats
path: root/perl-v2/PDOSBib.pm
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2003-05-17 06:18:24 +0000
committerNick Mathewson <nickm@torproject.org>2003-05-17 06:18:24 +0000
commit0d6150b63cd5a698e647a4809e65a262f55902cb (patch)
treec2269f85b90faf0585b6ea245b119d75d613ad5e /perl-v2/PDOSBib.pm
parent1d07a97300d48872726edd989f53bf489dc00a41 (diff)
downloadanonbib-0d6150b63cd5a698e647a4809e65a262f55902cb.tar.gz
Adding second version of perl files, css support, first take on anon bib
svn:r6
Diffstat (limited to 'perl-v2/PDOSBib.pm')
-rw-r--r--perl-v2/PDOSBib.pm233
1 files changed, 233 insertions, 0 deletions
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&egrave;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&ouml;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&ntilde;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])/&amp;$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&nbsp;" : ", pages&nbsp;")
+ . $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&nbsp;" : ", pages&nbsp;")
+ . $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&nbsp;" : ", pages&nbsp;")
+ . $d->{'pages'} if $d->{'pages'};
+
+ } else {
+ $x = "&lt;odd type $_type&gt;";
+ }
+
+ $x = '<span class="biblio">' . ($x or "") . ".</span> ";
+ $x .= "<span class=\"availability\">(<a href=\"$cgi_dir/bibtex-entry.cgi?key=";
+ $x .= $d->{'_key'} . "\">BibTeX&nbsp;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&nbsp;PS';
+ if (@availability) {
+ $x .= ' <span class="availability">(';
+ $x .= join(',&nbsp;', @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;