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/bibtex-entry.cgi | 206 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 206 insertions(+) create mode 100644 perl/bibtex-entry.cgi (limited to 'perl/bibtex-entry.cgi') diff --git a/perl/bibtex-entry.cgi b/perl/bibtex-entry.cgi new file mode 100644 index 0000000..8c166fa --- /dev/null +++ b/perl/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 pdos.bib!"); +$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 ``$_'' +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 + + + + + + + + +PDOS Publications Search Results + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +




  MIT > LCS > PDOS Home > 

Publications > 

BibTeX entry


+Projects
+People
+Software

+By subject
+By date
+

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

+ +EOD; + +$type = ($bibtex_key ? "`$bibtex_key'" : "all entries"); +print "

BibTeX entry server: results for $type

\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 "

There is no PDOS paper with key `$bibtex_key'.\n"; + undef $k; +} else { + $k = `cat pdos.bib`; +} +if (defined $k) { + $k =~ s/&/&/g; + $k =~ s//>/g; + print "

$k
\n"; +} + + +print <<"EOD;"; +

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