Browse Source

Merge b6278cc392 into 31cb3ab81b

pull/82/merge
Chris 7 years ago
committed by GitHub
parent
commit
a1ee7118ef
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      .gitignore
  2. 177
      bibtexbrowser.php

13
.gitignore

@ -0,0 +1,13 @@
# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Thumbs.db
# other files to ignore #
# emacs
*~
bibtexbrowser*.dat

177
bibtexbrowser.php

@ -2669,7 +2669,9 @@ if (!function_exists('bibtexbrowser_top_banner')) {
function javascript() { function javascript() {
// we use jquery with the official content delivery URLs // we use jquery with the official content delivery URLs
// Microsoft and Google also provide jquery with their content delivery networks // Microsoft and Google also provide jquery with their content delivery networks
?><script type="text/javascript" src="<?php echo JQUERY_URI ?>"></script>
$JQUERY_URI = JQUERY_URI;
print <<<JS
<script type="text/javascript" src="$JQUERY_URI"></script>
<script type="text/javascript" ><!-- <script type="text/javascript" ><!--
// Javascript progressive enhancement for bibtexbrowser // Javascript progressive enhancement for bibtexbrowser
$('a.biburl').each(function() { // for each url "[bibtex]" $('a.biburl').each(function() { // for each url "[bibtex]"
@ -2695,9 +2697,8 @@ $('a.biburl').each(function() { // for each url "[bibtex]"
biburl.attr('bibtexbrowser','done'); biburl.attr('bibtexbrowser','done');
} // end if biburl.bibtexbrowser; } // end if biburl.bibtexbrowser;
}); });
--></script><?php
--></script>
JS;
} // end function javascript } // end function javascript
@ -3959,8 +3960,7 @@ class BibDataBase {
/** returns the default CSS of bibtexbrowser */ /** returns the default CSS of bibtexbrowser */
function bibtexbrowserDefaultCSS() { function bibtexbrowserDefaultCSS() {
?>
$css = <<<CSS
/* title */ /* title */
.bibtitle { font-weight:bold; } .bibtitle { font-weight:bold; }
/* author */ /* author */
@ -4086,8 +4086,8 @@ dd {
.bibentry-reference { margin-bottom:15px; padding:10px; background: none repeat scroll 0 0 #F5F5F5; border: 1px solid #DDDDDD; } .bibentry-reference { margin-bottom:15px; padding:10px; background: none repeat scroll 0 0 #F5F5F5; border: 1px solid #DDDDDD; }
.btb-nav { text-align: right; } .btb-nav { text-align: right; }
<?php
CSS;
return $css;
} // end function bibtexbrowserDefaultCSS } // end function bibtexbrowserDefaultCSS
/** encapsulates the content of a delegate into full-fledged HTML (&lt;HTML>&lt;BODY> and TITLE) /** encapsulates the content of a delegate into full-fledged HTML (&lt;HTML>&lt;BODY> and TITLE)
@ -4102,61 +4102,57 @@ usage:
getRSS() getRSS()
getTitle() getTitle()
* $title: title of the page * $title: title of the page
*/
function HTMLTemplate($content) {
// when we load a page with AJAX
// the HTTP header is taken into account, not the <meta http-equiv>
header('Content-type: text/html; charset='.OUTPUT_ENCODING);
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n";
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo OUTPUT_ENCODING ?>"/>
<meta name="generator" content="bibtexbrowser v__GITHUB__" />
<?php
// if ($content->getRSS()!='') echo '<link rel="alternate" type="application/rss+xml" title="RSS" href="'.$content->getRSS().'&amp;rss" />';
?>
<?php
*/
function HTMLTemplate($content) {
// we may add new metadata tags // we may add new metadata tags
$metatags = array(); $metatags = array();
if (method_exists($content, 'metadata')) { if (method_exists($content, 'metadata')) {
$metatags = $content->metadata(); $metatags = $content->metadata();
}
}
$htmlMetatags = "";
foreach($metatags as $item) { foreach($metatags as $item) {
list($name,$value) = $item; list($name,$value) = $item;
echo '<meta name="'.$name.'" property="'.$name.'" content="'.$value.'"/>'."\n";
$htmlMetatags .= '<meta name="'.$name.'" property="'.$name.'" content="'.$value.'"/>'."\n";
} // end foreach } // end foreach
// now the title // now the title
if (method_exists($content, 'getTitle')) { if (method_exists($content, 'getTitle')) {
echo '<title>'.strip_tags($content->getTitle()).'</title>';
$htmlTitle = '<title>'.strip_tags($content->getTitle()).'</title>';
} }
// now the CSS
echo '<style type="text/css"><!-- '."\n";
if (method_exists($content, 'getCSS')) { if (method_exists($content, 'getCSS')) {
echo $content->getCSS();
$htmlCSS = $content->getCSS();
} else if (is_readable(dirname(__FILE__).'/bibtexbrowser.css')) { } else if (is_readable(dirname(__FILE__).'/bibtexbrowser.css')) {
readfile(dirname(__FILE__).'/bibtexbrowser.css');
$htmlCSS = readfile(dirname(__FILE__).'/bibtexbrowser.css');
} }
else { bibtexbrowserDefaultCSS(); }
else { $htmlCSS = bibtexbrowserDefaultCSS(); }
$OUTPUT_ENCODING = OUTPUT_ENCODING;
// when we load a page with AJAX
// the HTTP header is taken into account, not the <meta http-equiv>
header('Content-type: text/html; charset='.OUTPUT_ENCODING);
print <<<HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=$OUTPUT_ENCODING"/>
<meta name="generator" content="bibtexbrowser v__GITHUB__" />
$htmlMetatags
$htmlTitle
<style type="text/css">
$htmlCSS
</style>
</head>
<body>
HTML;
echo "\n".' --></style>';
// if ($content->getRSS()!='') echo '<link rel="alternate" type="application/rss+xml" title="RSS" href="'.$content->getRSS().'&amp;rss" />';
?>
</head>
<body>
<?php
// configuration point to add a banner // configuration point to add a banner
echo bibtexbrowser_top_banner(); echo bibtexbrowser_top_banner();
?>
<?php
if (method_exists($content, 'getTitle')) { if (method_exists($content, 'getTitle')) {
echo "<div class=\"rheader\">" . $content->getTitle() . "</div>"; echo "<div class=\"rheader\">" . $content->getTitle() . "</div>";
} }
@ -4369,42 +4365,43 @@ class RSSDisplay {
$this->entries = $entries; $this->entries = $entries;
} }
function setWrapper($x) { $x->wrapper = 'NoWrapper'; }
function setWrapper($x) { $x->wrapper = 'NoWrapper'; }
function display() {
header('Content-type: application/rss+xml');
echo '<?xml version="1.0" encoding="'.OUTPUT_ENCODING.'"?>';
function display() {
foreach($this->entries as $bibentry) {
$bibEntryKey = urlencode(@$_GET[Q_FILE].'::'.$bibentry->getKey());
$bibEntryUrl = $bibentry->getURL();
$bibEntryTitle = $this->text2rss($bibentry->getTitle());
$bibEntryAbstract = $this->text2rss(bib2html($bibentry)."\n".$bibentry->getAbstract());
// //
$rssItems .= <<<RSS
<item>
<title>$bibEntryTitle</title>
<link>$bibEntryUrl</link>
<description>$bibEntryAbstract</description>
<guid isPermaLink="false">$bibEntryKey</guid>
</item>
RSS;
}
?>
header('Content-type: application/rss+xml');
echo '<?xml version="1.0" encoding="'.OUTPUT_ENCODING.'"?>';
$rssLink = 'http://' . @$_SERVER['HTTP_HOST'].htmlentities(@$_SERVER['REQUEST_URI']);
$atomLink = 'http://' . @$_SERVER['HTTP_HOST'].htmlentities(@$_SERVER['REQUEST_URI']);
print <<<RSS
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel> <channel>
<title><?php echo $this->title;?></title>
<link>http://<?php echo @$_SERVER['HTTP_HOST'].htmlentities(@$_SERVER['REQUEST_URI']);?></link>
<atom:link href="http://<?php echo @$_SERVER['HTTP_HOST'].htmlentities(@$_SERVER['REQUEST_URI']);?>" rel="self" type="application/rss+xml" />
<title>$this->title</title>
<link>$rssLink</link>
<atom:link href="$atomLink" rel="self" type="application/rss+xml" />
<description></description> <description></description>
<generator>bibtexbrowser v__GITHUB__</generator> <generator>bibtexbrowser v__GITHUB__</generator>
<?php
foreach($this->entries as $bibentry) {
?>
<item>
<title><?php echo $this->text2rss($bibentry->getTitle());?></title>
<link><?php echo $bibentry->getURL();?></link>
<description>
<?php
// we are in XML, so we cannot have HTML entitites
echo $this->text2rss(bib2html($bibentry)."\n".$bibentry->getAbstract());
?>
</description>
<guid isPermaLink="false"><?php echo urlencode(@$_GET[Q_FILE].'::'.$bibentry->getKey());?></guid>
</item>
<?php } /* end foreach */?>
$rssItems
</channel> </channel>
</rss> </rss>
<?php
//exit;
RSS;
} }
} }
@ -4421,6 +4418,7 @@ usage:
$x->main(); $x->main();
</pre> </pre>
*/ */
class Dispatcher { class Dispatcher {
/** this is the query */ /** this is the query */
@ -4740,23 +4738,28 @@ class Dispatcher {
exit; exit;
} }
function frameset() { ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="bibtexbrowser v__GITHUB__" />
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo OUTPUT_ENCODING ?>"/>
<title>You are browsing <?php echo htmlentities($_GET[Q_FILE], ENT_QUOTES); ?> with bibtexbrowser</title>
</head>
<frameset cols="15%,*">
<frame name="menu" src="<?php echo '?'.Q_FILE.'='. urlencode($_GET[Q_FILE]).'&amp;menu'; ?>" />
<frame name="main" src="<?php echo '?'.Q_FILE.'='. urlencode($_GET[Q_FILE]).'&amp;'.BIBTEXBROWSER_DEFAULT_FRAME?>" />
</frameset>
</html>
<?php
function frameset() {
$OUTPUT_ENCODING = OUTPUT_ENCODING;
$BIBTEXBROWSER_DEFAULT_FRAME = BIBTEXBROWSER_DEFAULT_FRAME;
$bibFilename = htmlentities($_GET[Q_FILE], ENT_QUOTES);
$uriFrameMenu = '?'.Q_FILE.'='. urlencode($_GET[Q_FILE]).'&amp;menu';
$uriFrameMain = '?'.Q_FILE.'='. urlencode($_GET[Q_FILE]).'&amp;'.BIBTEXBROWSER_DEFAULT_FRAME;
//
print <<<HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="bibtexbrowser v__GITHUB__" />
<meta http-equiv="Content-Type" content="text/html; charset=$OUTPUT_ENCODING"/>
<title>You are browsing $bibFilename with bibtexbrowser</title>
</head>
<frameset cols="15%,*">
<frame name="menu" src="$uriFrameMenu" />
<frame name="main" src="$uriFrameMain" />
</frameset>
</html>
HTML;
//
return 'END_DISPATCH'; return 'END_DISPATCH';
} }

Loading…
Cancel
Save