#!/usr/bin/perl ####################################################### # Copyright 2013 Sam Flint, # Project: bibtexonline # File: bibtex.cgi # # Licensed the GNU GPL v3 or later # # # ####################################################### #use YAML qw/LoadFile DumpFile/; use CGI; use BibTeX::Parser; use IO::File; $cgi = CGI->new(); $file = IO::File->new("./library.bib"); $parser = BibTeX::Parser->new($file); if ($cgi->param('search')) { print $cgi->header(); print < BibTeX Web interface

BibTeX Web Interface

Main Listing Advanced Search About
Quick Search: Regex?

eohtml if ($cgi->param('search') eq "all") { searchall(); }elsif ($cgi->param('search') eq "ByID") { searchbyid(); }elsif ($cgi->param('search') eq "author") { searchauthor(); }elsif ($cgi->param('search') eq "title") { searchtitle(); } print < eohtml }elsif ($cgi->param('page')) { print $cgi->header(); print < BibTeX Web interface

BibTeX Web Interface

Main Listing Advanced Search About
Quick Search: Regex?

eohtml if ($cgi->param("page") eq "search") { }elsif ($cgi->param("page") eq "about") { }else { print "

404: Page Not Found








"; } print < eohtml #}elsif ($cgi->param('search')) { }else { print $cgi->header(); print < BibTeX Web interface

BibTeX Web Interface

Main Listing Advanced Search About
Quick Search: Regex?

eohtml while ($entry = $parser->next) { print <Key: $entry->jkey()
Type$entry->type()
Author$entry->field("author")
Title$entry->field("title")
Year$entry->field("year")

eohtml } print < eohtml } sub searchall{ while ($entry = $parser->next()) { if ($entry->raw_bibtex() ~= /$cgi->param("query")/g) { print <Key: $entry->jkey()
Type$entry->type()
Author$entry->field("author")
Title$entry->field("title")
Year$entry->field("year")

eohtml }else { next; } } } sub searchbyid{ while ($entry = $parser->next()) { if ($entry->key() eq $cgi->param("query")) { print <Key: $entry->jkey()
Type$entry->type()
Author$entry->field("author")
Title$entry->field("title")
Year$entry->field("year")

eohtml }else { next; } } } sub searchauthor{ while ($entry = $parser->next()) { if ($entry->field("author") ~= /$cgi->param(query)/gi { print <Key: $entry->jkey()
Type$entry->type()
Author$entry->field("author")
Title$entry->field("title")
Year$entry->field("year")

eohtml }else { next; } } } sub searchtitle{ while ($entry = $parser->next()) { if ($entry->field("title") ~= /$cgi->param(query)/gi { print <Key: $entry->jkey()
Type$entry->type()
Author$entry->field("author")
Title$entry->field("title")
Year$entry->field("year")

eohtml }else { next; } } } __END__