diff --git a/composer.json b/composer.json index 8d0c94e..feafac6 100644 --- a/composer.json +++ b/composer.json @@ -20,5 +20,9 @@ }, "scripts": { "serve": "@php -S localhost:8080 -t public/" + }, + "require-dev": { + "monolog/monolog": "^1.23", + "kint-php/kint": "^2.2" } } diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..59127f8 --- /dev/null +++ b/composer.lock @@ -0,0 +1,203 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "content-hash": "fa3a6762d454ebe3dce634e74511aae2", + "packages": [], + "packages-dev": [ + { + "name": "kint-php/kint", + "version": "2.2", + "source": { + "type": "git", + "url": "https://github.com/kint-php/kint.git", + "reference": "b091715eadaf6e1a7ef927f3e81d1004611d2aea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kint-php/kint/zipball/b091715eadaf6e1a7ef927f3e81d1004611d2aea", + "reference": "b091715eadaf6e1a7ef927f3e81d1004611d2aea", + "shasum": "" + }, + "require": { + "php": ">=5.1.2" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.0", + "phpunit/phpunit": "^4.0", + "symfony/finder": "^2.6" + }, + "type": "library", + "autoload": { + "files": [ + "init.php" + ], + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Rokas Šleinius", + "homepage": "https://github.com/raveren" + }, + { + "name": "Jonathan Vollebregt", + "homepage": "https://github.com/jnvsor" + }, + { + "name": "Contributors", + "homepage": "https://github.com/kint-php/kint/graphs/contributors" + } + ], + "description": "Kint - debugging tool for PHP developers", + "homepage": "https://kint-php.github.io/kint/", + "keywords": [ + "debug", + "kint", + "php" + ], + "time": "2017-09-06T17:46:03+00:00" + }, + { + "name": "monolog/monolog", + "version": "1.23.0", + "source": { + "type": "git", + "url": "https://github.com/Seldaek/monolog.git", + "reference": "fd8c787753b3a2ad11bc60c063cff1358a32a3b4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/fd8c787753b3a2ad11bc60c063cff1358a32a3b4", + "reference": "fd8c787753b3a2ad11bc60c063cff1358a32a3b4", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "psr/log": "~1.0" + }, + "provide": { + "psr/log-implementation": "1.0.0" + }, + "require-dev": { + "aws/aws-sdk-php": "^2.4.9 || ^3.0", + "doctrine/couchdb": "~1.0@dev", + "graylog2/gelf-php": "~1.0", + "jakub-onderka/php-parallel-lint": "0.9", + "php-amqplib/php-amqplib": "~2.4", + "php-console/php-console": "^3.1.3", + "phpunit/phpunit": "~4.5", + "phpunit/phpunit-mock-objects": "2.3.0", + "ruflin/elastica": ">=0.90 <3.0", + "sentry/sentry": "^0.13", + "swiftmailer/swiftmailer": "^5.3|^6.0" + }, + "suggest": { + "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", + "doctrine/couchdb": "Allow sending log messages to a CouchDB server", + "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", + "ext-mongo": "Allow sending log messages to a MongoDB server", + "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", + "mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver", + "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib", + "php-console/php-console": "Allow sending log messages to Google Chrome", + "rollbar/rollbar": "Allow sending log messages to Rollbar", + "ruflin/elastica": "Allow sending log messages to an Elastic Search server", + "sentry/sentry": "Allow sending log messages to a Sentry server" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Monolog\\": "src/Monolog" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "Sends your logs to files, sockets, inboxes, databases and various web services", + "homepage": "http://github.com/Seldaek/monolog", + "keywords": [ + "log", + "logging", + "psr-3" + ], + "time": "2017-06-19T01:22:40+00:00" + }, + { + "name": "psr/log", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2016-10-10T12:19:37+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=4" + }, + "platform-dev": [] +} diff --git a/public/bibtexbrowser.css b/public/bibtexbrowser.css deleted file mode 100644 index f286b92..0000000 --- a/public/bibtexbrowser.css +++ /dev/null @@ -1,28 +0,0 @@ -.datePublished { - background-color: blue; -} -.btb-header { } -.rheader { - font-size: large -} -.sheader { - padding-top: 10px; -} -.bibref { - /*padding:3px; */ -/* padding-left:15px; */ - vertical-align:top; - color:white;} -/*.bibtitle { font-weight:bold; }*/ -.bibitem { - text-indent:-35px; - padding-left:35px; -} -.bibbooktitle { font-style:italic; } -.count { color:gray } -.sheader { font-weight:bold; font-size: large;} -.volume { font-style: italic; } - -body { - background:green; -} diff --git a/public/index.php b/public/index.php index bf18481..63fcba9 100644 --- a/public/index.php +++ b/public/index.php @@ -1,15 +1,27 @@ "bibacid-utf8.bib", - "all" => 1, - "author" => "", - "academic" => 1 -); +require_once "../src/bibtexbrowser.php"; -$browser = new Monperrus\BibtexBrowser\Bibliography($config); -$browser->print(); + +//require_once "../vendor/autoload.php"; + +// use Monperrus\BibtexBrowser\Bibliography; + + + +// $config = array("bib" => "bibacid-utf8.bib", +// "all" => 1, +// "author" => "", +// "academic" => 1 +// ); + +// $_GET['menu']=1; +// $browser = new Monperrus\BibtexBrowser\Bibliography($config); +// $browser->print(); +//s($_SERVER); diff --git a/src/Definitions.php b/src/Definitions.php index 89a3394..46506a5 100644 --- a/src/Definitions.php +++ b/src/Definitions.php @@ -179,7 +179,8 @@ if (defined('ENCODING')) { // this is usually resolved to bibtexbrowser.php // but can be overridden in bibtexbrowser.local.php // for instance with @define('BIBTEXBROWSER_URL',''); // links to the current page with ? -@define('BIBTEXBROWSER_URL',basename(__FILE__)); +//@define('BIBTEXBROWSER_URL',basename(__FILE__)); +@define('BIBTEXBROWSER_URL',parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)); // *************** END CONFIGURATION diff --git a/src/bibacid-utf8.bib b/src/bibacid-utf8.bib new file mode 100644 index 0000000..1c04146 --- /dev/null +++ b/src/bibacid-utf8.bib @@ -0,0 +1,231 @@ + + +@string{foo="Foo"} +@string{bar=foo#" Bar"} + + +%% test the home page feature +@string{hp_J.Abounader="http://www.google.com"} + +@inproceedings{classical, + author = {J. Abounader and D. Tooj}, + title = bar, + institution = {Queen's University, Kingston, ON.}, + year = {1997} +} + +%% testing the abstract +@inproceedings{with_abstract, + author = {J. Abounader and D. Tooj}, + title = {This is with abstract}, + institution = {Queen's University, Kingston, ON.}, + year = {1997}, + abstract = {This is an abstract + on several lines} +} + + +%% using double quotes +%% also Took test the advanced search +@TECHREPORT{dquotes, + author = "J. Abounader and Tooj, D.", + title = "using double quotes ", + institution = "Queen's University, Kingston, ON.", + year = "1997" +} + + +%% using single value (year) +@TECHREPORT{singlevalue, + author = {The }, + title = {The year}, + institution = {Queen's University, Kingston, ON.}, + year = 1997 +} + + +%% no new line +@TECHREPORT{Abounader1997e, author = {J. Abounader and D. Lamb}, title = "using double quotes", institution = {Queen's University, Kingston, ON.}, year = 1997 } + + + +%% intersting: bibtex does not allow \} in brackets enclosed entries and \" in quotes enclosed entries + +%% escaped quotes +@TECHREPORT{notallowed1, + author = {J. Abounader and D. Lamb}, + title = "escaped \"quotes\"", + institution = {Queen's University, Kingston, ON.}, + year = {1997} +} + +%% escaped braces +@TECHREPORT{notallowed2, + author = {J. Abounader \} and D. Lamb}, + title = "escaped braces", + institution = {Queen's University, Kingston, ON.}, + year = {1997} +} + +@article{testsearch1, + author = {Jacob G{\"o}del}, + title = {using Banach Space}, + year = {1997} +} +@article{testsearch2, + author = {Jacob {G}{\"{o}}del}, + title = {using banach space}, + year = {1997} +} +@article{testsearch3, + author = {Jacob {G\"{o}del}}, + title = {using {Banach} Space}, + year = {1997} +} +@article{testsearch4, + author = {Jacob Gödel}, + title = {using {B}anach Space}, + year = {1997} +} +@article{testsearch5, + author = {Jacob Gödel}, + title = {using {Banach Space}}, + year = {1997} +} + + + +%% bug from Jakob Kellner +%% copied from ams.org +@article {MR1841330, + AUTHOR = {Lejay, Antoine}, + TITLE = {Homogenization of divergence-form operators with lower-order + terms in random media}, + JOURNAL = {Probab. Theory Related Fields}, + FJOURNAL = {Probability Theory and Related Fields}, + VOLUME = {120}, + YEAR = {2001}, + NUMBER = {2}, + PAGES = {255--276}, + ISSN = {0178-8051}, + CODEN = {PTRFEU}, + MRCLASS = {35B27 (31C25 35R60 60H30 60J60)}, + MRNUMBER = {MR1841330 (2002g:35023)}, +MRREVIEWER = {Jean-Fran{\c{c}}ois Clouet}, + DOI = {10.1007/PL00008783}, + URL = {http://dx.doi.org/10.1007/PL00008783}, +} + +@article{serge, + author = "Serge Bug", + title = "curly {braces} in quote", + year = 2010 +} + +@article{cediltest, + author = "Serge Bug", + title = "\ccurly \c{c}urly {\c{c}}urly ", + year = 2010 +} + + +%%%%% now testing the string concatenation +@string{str1="toto"} +@string{str2="titi"} + +@book{stgringconcat:test1, + author = {J. Abounader and D. Lamb}, + title = str1#str2, + institution = {Queen's University, Kingston, ON.}, + year = {1997} +} + +% with space +@bookchapter{stgringconcat:test2, + author = {J. Abounader and D. Lamb}, + title = str1 # str2, + institution = {Queen's University, Kingston, ON.}, + year = {1997} +} + +% with another value +@inbook{stgringconcat:test3, + author = {J. Abounader and D. Lamb}, + title = str1 # {3344}, + institution = {Queen's University, Kingston, ON.}, + year = {1997} +} + + +%% Saturday, October 09 2010 +%% taken from http://en.wikipedia.org/wiki/BibTeX +@PROCEEDINGS {conference:06, + editor = {First Editor and Second Editor}, + title = {Proceedings of the Xth Conference on XYZ}, + booktitle = {Proceedings of the Xth Conference on XYZ}, + year = {2006}, + month = oct, +} + +@INPROCEEDINGS {author:06, + title = {Some publication title}, + author = {First Author and Second Author}, + crossref = {conference:06}, + pages = {330?331}, +} + + +%% Thursday, October 28 2010 +%% two test cases for special key +@INPROCEEDINGS {author+06, + title = {Some publication title}, + author = {First Author and Second Author}, + year = {2011}, +} + +@INPROCEEDINGS { author06 , + title = {Some publication title}, + author = {First Author and Second Author}, + year = {2011}, +} + +%% testing the accented i and j +@INPROCEEDINGS {paper000, + title = {Some publication title}, + author = {F\`\irst A\`{\i}thor and S{\`\i}cond Author\`\I}, + year = {2011}, +} + +%% bug reported by Mark Hereld +@misc{mark, + title = {Bug in Urls}, + author = {Mark Hereld}, + howpublished = {\url{http://foo.com/under_score.html}}, + year = {2011}, +} + +%% handling of percentage +@misc{mark, + title = {Percentage \%}, + abstract = {Percentage \%}, + author = {MM}, + year = {2015}, +} + +% bug https://github.com/monperrus/bibtexbrowser/issues/40 +@Article{Baldwin2014Quantum, + Doi = {10.1103/PhysRevA.90.012110}, + Url = {http://link.aps.org/doi/10.1103/PhysRevA.90.012110} +} + +@article{croatiantest, + author = "Strabi{\'{c}} Strabi\'{c}", + title = "Fancy accents bug", + year = 2015 +} + +@article{kjsdf 8, + title = "Entry with + in the key", + author = "Foo Bar", + year = 2017 +} diff --git a/src/bibtexbrowser.php b/src/bibtexbrowser.php index b00cfe3..f70d564 100755 --- a/src/bibtexbrowser.php +++ b/src/bibtexbrowser.php @@ -49,8 +49,191 @@ function c($key) { // shortcut @include(@$_GET[Q_FILE].'.local.php'); @include(preg_replace('/\.php$/','.local.php',__FILE__)); -require_once "Definitions.php"; +// the encoding of your bibtex file +@define('BIBTEX_INPUT_ENCODING','UTF-8');//@define('BIBTEX_INPUT_ENCODING','iso-8859-1');//define('BIBTEX_INPUT_ENCODING','windows-1252'); +// the encoding of the HTML output +@define('OUTPUT_ENCODING','UTF-8'); + +// print a warning if deprecated variable is used +if (defined('ENCODING')) { + echo 'ENCODING has been replaced by BIBTEX_INPUT_ENCODING and OUTPUT_ENCODING'; +} + +// number of bib items per page +// we use the same parameter 'num' as Google +@define('PAGE_SIZE',isset($_GET['num'])?(preg_match('/^\d+$/',$_GET['num'])?$_GET['num']:10000):14); + +// bibtexbrowser uses a small piece of Javascript to improve the user experience +// see http://en.wikipedia.org/wiki/Progressive_enhancement +// if you don't like it, you can be disable it by adding in bibtexbrowser.local.php +// @define('BIBTEXBROWSER_USE_PROGRESSIVE_ENHANCEMENT',false); +@define('BIBTEXBROWSER_USE_PROGRESSIVE_ENHANCEMENT',true); +@define('BIBLIOGRAPHYSTYLE','DefaultBibliographyStyle');// this is the name of a function +@define('BIBLIOGRAPHYSECTIONS','DefaultBibliographySections');// this is the name of a function +@define('BIBLIOGRAPHYTITLE','DefaultBibliographyTitle');// this is the name of a function +// shall we load MathJax to render math in $…$ in HTML? +@define('BIBTEXBROWSER_RENDER_MATH', true); +@define('MATHJAX_URI', '//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML.js'); + +// the default jquery URI +@define('JQUERY_URI', '//code.jquery.com/jquery-1.5.1.min.js'); + +// can we load bibtex files on external servers? +@define('BIBTEXBROWSER_LOCAL_BIB_ONLY', true); + +// the default view in {SimpleDisplay,AcademicDisplay,RSSDisplay,BibtexDisplay} +@define('BIBTEXBROWSER_DEFAULT_DISPLAY','SimpleDisplay'); + +// the default template +@define('BIBTEXBROWSER_DEFAULT_TEMPLATE','HTMLTemplate'); + +// the target frame of menu links +@define('BIBTEXBROWSER_MENU_TARGET','main'); // might be define('BIBTEXBROWSER_MENU_TARGET','_self'); in bibtexbrowser.local.php + +@define('ABBRV_TYPE','index');// may be year/x-abbrv/key/none/index/keys-index + +// are robots allowed to crawl and index bibtexbrowser generated pages? +@define('BIBTEXBROWSER_ROBOTS_NOINDEX',false); + +//the default view in the "main" (right hand side) frame +@define('BIBTEXBROWSER_DEFAULT_FRAME','year=latest'); // year=latest,all and all valid bibtexbrowser queries + +// Wrapper to use when we are included by another script +@define('BIBTEXBROWSER_EMBEDDED_WRAPPER', 'NoWrapper'); + +// Main class to use +@define('BIBTEXBROWSER_MAIN', 'Dispatcher'); + +// default order functions +// Contract Returns < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal. +// can be @define('ORDER_FUNCTION','compare_bib_entry_by_title'); +// can be @define('ORDER_FUNCTION','compare_bib_entry_by_bibtex_order'); +@define('ORDER_FUNCTION','compare_bib_entry_by_year'); +@define('ORDER_FUNCTION_FINE','compare_bib_entry_by_month'); + +// only displaying the n newest entries +@define('BIBTEXBROWSER_NEWEST',5); + +@define('BIBTEXBROWSER_NO_DEFAULT', false); + +// BIBTEXBROWSER_LINK_STYLE defines which function to use to display the links of a bibtex entry +@define('BIBTEXBROWSER_LINK_STYLE','bib2links_default'); // can be 'nothing' (a function that does nothing) + +// do we add [bibtex] links ? +@define('BIBTEXBROWSER_BIBTEX_LINKS',true); +// do we add [pdf] links ? +@define('BIBTEXBROWSER_PDF_LINKS',true); +// do we add [doi] links ? +@define('BIBTEXBROWSER_DOI_LINKS',true); +// do we add [gsid] links (Google Scholar)? +@define('BIBTEXBROWSER_GSID_LINKS',true); + +// should pdf, doi, url, gsid links be opened in a new window? +@define('BIBTEXBROWSER_LINKS_TARGET','_self');// can be _blank (new window), _top (with frames) + +// should authors be linked to [none/homepage/resultpage] +// none: nothing +// their homepage if defined as @strings +// their publication lists according to this bibtex +@define('BIBTEXBROWSER_AUTHOR_LINKS','homepage'); + +// BIBTEXBROWSER_LAYOUT defines the HTML rendering layout of the produced HTML +// may be table/list/ordered_list/definition/none (for