diff options
Diffstat (limited to 'perl-v2/bibtex-entry.cgi')
| -rw-r--r-- | perl-v2/bibtex-entry.cgi | 206 |
1 files changed, 206 insertions, 0 deletions
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; |
