adds support for opengraph metadata
This commit is contained in:
@@ -10,15 +10,8 @@ This documentation is collaborative, you can improve it using a [[https://github
|
|||||||
|
|
||||||
+++TOC+++
|
+++TOC+++
|
||||||
|
|
||||||
=====Major features=====
|
=====Features=====
|
||||||
* bibtexbrowser generates [[http://www.monperrus.net/martin/accurate+bibliographic+metadata+and+google+scholar|Google Scholar metadata]] so as to improve the visibility of your papers on Google Scholar.
|
* **(02/2016)** support for [[http://ogp.me/|OpenGraph metadata]]
|
||||||
* More and more academics use bibliographic software like [[http://www.zotero.org/|Zotero]] or [[http://www.mendeley.com/|Mendeley]]. bibtexbrowser generates [[http://ocoins.info/|COinS]] for automatic import of bibliographic entries with [[http://www.zotero.org/|Zotero]] and [[http://www.mendeley.com/|Mendeley]].
|
|
||||||
* People can subscribe to the RSS publication feed of an individual or a group so as to being kept up-to-date: bibtexbrowser generates RSS feeds for all queries (simply add &rss at the end of the URL)! [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=monperrus.bib&all&rss|demo]]
|
|
||||||
* bibtexbrowser can display all entries for an author with an academic style (i.e book, articles, conference, workshop): [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=metrics.bib&academic=Ducasse|demo]]
|
|
||||||
* bibtexbrowser can be used to embed a publication list into another page: [[http://www.monperrus.net/martin/publications|demo]]
|
|
||||||
* bibtexbrowser is easy to install: just a single file.
|
|
||||||
|
|
||||||
=====Other features=====
|
|
||||||
* **(10/2015)** support for filtering bibtex fields
|
* **(10/2015)** support for filtering bibtex fields
|
||||||
* **(10/2013)** support for localization (see below)
|
* **(10/2013)** support for localization (see below)
|
||||||
* **(07/2012)** new label types (see config value ABBRV_TYPE)
|
* **(07/2012)** new label types (see config value ABBRV_TYPE)
|
||||||
@@ -28,13 +21,17 @@ This documentation is collaborative, you can improve it using a [[https://github
|
|||||||
* **(09/2010)** bibtexbrowser now supports multiple bibtex files (''bibtexbrowser.php?bib=file1.bib;file2.bib'')
|
* **(09/2010)** bibtexbrowser now supports multiple bibtex files (''bibtexbrowser.php?bib=file1.bib;file2.bib'')
|
||||||
* **(05/2010)** bibtexbrowser adds links to your co-author pages if you define the corresponding @string (see function addHomepageLink)
|
* **(05/2010)** bibtexbrowser adds links to your co-author pages if you define the corresponding @string (see function addHomepageLink)
|
||||||
* **(01/2010)** bibtexbrowser can handle user-defined bibliographic styles
|
* **(01/2010)** bibtexbrowser can handle user-defined bibliographic styles
|
||||||
|
* bibtexbrowser generates publication RSS feeds (simply add &rss at the end of the URL)! [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=monperrus.bib&all&rss|demo]]
|
||||||
* **(10/2009)** bibtexbrowser is able to generate a bibtex file containing only the selected entries (simply add &astext at the end of the link)
|
* **(10/2009)** bibtexbrowser is able to generate a bibtex file containing only the selected entries (simply add &astext at the end of the link)
|
||||||
* **(10/2009)** bibtexbrowser is now independent of the configuration of register_globals
|
* **(10/2009)** bibtexbrowser is now independent of the configuration of register_globals
|
||||||
* **(01/2009)** bibtexbrowser allows multi criteria search, e.g. [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=metrics.bib&type=inproceedings&year=2004|demo]]
|
* **(01/2009)** bibtexbrowser allows multi criteria search, e.g. [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=metrics.bib&type=inproceedings&year=2004|demo]]
|
||||||
|
* bibtexbrowser generates [[http://ocoins.info/|COinS]] for automatic import of bibliographic entries with [[http://www.zotero.org/|Zotero]] and [[http://www.mendeley.com/|Mendeley]].
|
||||||
|
* bibtexbrowser generates [[http://www.monperrus.net/martin/accurate+bibliographic+metadata+and+google+scholar|Google Scholar metadata]] so as to improve the visibility of your papers on Google Scholar.
|
||||||
* bibtexbrowser replaces constants defined in @STRING
|
* bibtexbrowser replaces constants defined in @STRING
|
||||||
* bibtexbrowser is very fast because it keeps a compiled version of the bibtex file (PHP object serialized)
|
* bibtexbrowser is very fast because it keeps a compiled version of the bibtex file (PHP object serialized)
|
||||||
* bibtexbrowser is compatible with PHP 4.x and PHP 5.x
|
* bibtexbrowser is compatible with PHP 4.x and PHP 5.x
|
||||||
* bibtexbrowser can display the menu and all entries without filtering from the file name passed as parameter [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=metrics.bib|demo]]
|
* bibtexbrowser can display the menu and all entries without filtering from the file name passed as parameter [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=metrics.bib|demo]]
|
||||||
|
* bibtexbrowser can display all entries for an author with an academic style (i.e book, articles, conference, workshop): [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=metrics.bib&academic=Ducasse|demo]]
|
||||||
* bibtexbrowser can display all entries out of a bibtex file [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=metrics.bib&all|demo]]
|
* bibtexbrowser can display all entries out of a bibtex file [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=metrics.bib&all|demo]]
|
||||||
* bibtexbrowser can display all entries for a given year [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=metrics.bib&year=2004|demo]]
|
* bibtexbrowser can display all entries for a given year [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=metrics.bib&year=2004|demo]]
|
||||||
* bibtexbrowser can display a single bibtex entry [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=metrics.bib&key=monperrus08d|demo]]
|
* bibtexbrowser can display a single bibtex entry [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=metrics.bib&key=monperrus08d|demo]]
|
||||||
@@ -43,6 +40,7 @@ This documentation is collaborative, you can improve it using a [[https://github
|
|||||||
* bibtexbrowser outputs valid XHTML 1.0 Transitional
|
* bibtexbrowser outputs valid XHTML 1.0 Transitional
|
||||||
* bibtexbrowser can display all entries for an author [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=metrics.bib&author=Barbara+A.+Kitchenham|demo]]
|
* bibtexbrowser can display all entries for an author [[http://www.monperrus.net/martin/bibtexbrowser.php?bib=metrics.bib&author=Barbara+A.+Kitchenham|demo]]
|
||||||
* bibtexbrowser can be used with different encodings (change the default iso-8859-1 encoding if your bib file is in UTF-8 ''define('BIBTEX_INPUT_ENCODING','UTF-8')'' )
|
* bibtexbrowser can be used with different encodings (change the default iso-8859-1 encoding if your bib file is in UTF-8 ''define('BIBTEX_INPUT_ENCODING','UTF-8')'' )
|
||||||
|
* bibtexbrowser is easy to install: just a single file.
|
||||||
|
|
||||||
|
|
||||||
=====Download=====
|
=====Download=====
|
||||||
|
|||||||
@@ -163,6 +163,25 @@ class BTBTest extends PHPUnit_Framework_TestCase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_metadata_opengraph() {
|
||||||
|
$test_data = fopen('php://memory','x+');
|
||||||
|
fwrite($test_data, "@article{aKey,title={A Book},author={Martin Monperrus},url={http://foo.com/},publisher={Springer},year=2009,pages={42--4242},number=1}\n".
|
||||||
|
"@String{x=2008}\n"
|
||||||
|
);
|
||||||
|
fseek($test_data,0);
|
||||||
|
$db = new BibDataBase();
|
||||||
|
$db->update_internal("inline", $test_data);
|
||||||
|
$dis = new BibEntryDisplay($db->getEntryByKey('aKey'));
|
||||||
|
$metadata = $dis->metadata_dict();
|
||||||
|
|
||||||
|
//print_r($metadata);
|
||||||
|
$this->assertEquals("A Book",$metadata['og:title']);
|
||||||
|
$this->assertEquals("article",$metadata['og:type']);
|
||||||
|
$this->assertTrue(1 == preg_match("/http:.*author=Martin\+Monperrus/",$metadata['og:author']));
|
||||||
|
$this->assertEquals("2009",$metadata['og:published_time']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function test_math_cal() {
|
function test_math_cal() {
|
||||||
$test_data = fopen('php://memory','x+');
|
$test_data = fopen('php://memory','x+');
|
||||||
fwrite($test_data, "@book{aKey,title={{A Book{} $\mbox{foo}$ tt $\boo{t}$}} ,author={Martin Monperrus},publisher={Springer},year=2009}\n".
|
fwrite($test_data, "@book{aKey,title={{A Book{} $\mbox{foo}$ tt $\boo{t}$}} ,author={Martin Monperrus},publisher={Springer},year=2009}\n".
|
||||||
|
|||||||
+27
-1
@@ -200,6 +200,7 @@ if (defined('ENCODING')) {
|
|||||||
@define('MULTIPLE_BIB_SEPARATOR',';');
|
@define('MULTIPLE_BIB_SEPARATOR',';');
|
||||||
@define('METADATA_GS',true);
|
@define('METADATA_GS',true);
|
||||||
@define('METADATA_DC',true);
|
@define('METADATA_DC',true);
|
||||||
|
@define('METADATA_OPENGRAPH',true);
|
||||||
@define('METADATA_EPRINTS',false);
|
@define('METADATA_EPRINTS',false);
|
||||||
|
|
||||||
// define sort order for special values in 'year' field
|
// define sort order for special values in 'year' field
|
||||||
@@ -1257,6 +1258,13 @@ class BibEntry {
|
|||||||
return $lastname;
|
return $lastname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the first name of an author name.
|
||||||
|
*/
|
||||||
|
function getFirstName($author){
|
||||||
|
list($firstname, $lastname) = splitFullName($author);
|
||||||
|
return $firstname;
|
||||||
|
}
|
||||||
|
|
||||||
/** Has this entry the given field? */
|
/** Has this entry the given field? */
|
||||||
function hasField($name) {
|
function hasField($name) {
|
||||||
@@ -3219,6 +3227,10 @@ class BibEntryDisplay {
|
|||||||
$result = $this->metadata_dublin_core($result);
|
$result = $this->metadata_dublin_core($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (METADATA_OPENGRAPH) {
|
||||||
|
$result = $this->metadata_opengraph($result);
|
||||||
|
}
|
||||||
|
|
||||||
if (METADATA_EPRINTS) {
|
if (METADATA_EPRINTS) {
|
||||||
$result = $this->metadata_eprints($result);
|
$result = $this->metadata_eprints($result);
|
||||||
}
|
}
|
||||||
@@ -3226,6 +3238,20 @@ class BibEntryDisplay {
|
|||||||
return $result;
|
return $result;
|
||||||
} // end function metadata
|
} // end function metadata
|
||||||
|
|
||||||
|
function metadata_opengraph($result) {
|
||||||
|
// Facebook metadata
|
||||||
|
// see http://ogp.me
|
||||||
|
// https://developers.facebook.com/tools/debug/og/object/
|
||||||
|
$result[] = array('og:type','article');
|
||||||
|
$result[] = array('og:title',$this->bib->getTitle());
|
||||||
|
foreach($this->bib->getRawAuthors() as $author) {
|
||||||
|
// opengraph requires a URL as author value
|
||||||
|
$result[] = array('og:author',"http://".@$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'].'?bib='.urlencode($this->bib->filename).'&author='.urlencode($author));
|
||||||
|
}
|
||||||
|
$result[] = array('og:published_time',$this->bib->getYear());
|
||||||
|
return $result;
|
||||||
|
} // end function metadata_opengraph
|
||||||
|
|
||||||
function metadata_dublin_core($result) {
|
function metadata_dublin_core($result) {
|
||||||
// Dublin Core should not be used for bibliographic metadata
|
// Dublin Core should not be used for bibliographic metadata
|
||||||
// according to several sources
|
// according to several sources
|
||||||
@@ -3874,7 +3900,7 @@ if (method_exists($content, 'metadata')) {
|
|||||||
}
|
}
|
||||||
foreach($metatags as $item) {
|
foreach($metatags as $item) {
|
||||||
list($name,$value) = $item;
|
list($name,$value) = $item;
|
||||||
echo '<meta name="'.$name.'" content="'.$value.'"/>'."\n";
|
echo '<meta name="'.$name.'" property="'.$name.'" content="'.$value.'"/>'."\n";
|
||||||
} // end foreach
|
} // end foreach
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user