Skip to content
Permalink
Browse files

publication_list: show the link to the pdf if specified.

  • Loading branch information
xuhdev committed Jan 29, 2016
1 parent 001f4a7 commit bcf79414995f11bd26d5b6d14b3b923d2609d298
Binary file not shown.
@@ -4,15 +4,17 @@ @article{a2015
year = 2015,
journal = {Great Journal},
volume = 1,
page = {1--10}
page = {1--10},
pdf = {/pdf/a2015.pdf}
}

@book{b2010,
title = {One Book in 2010},
author = {Nikola Tesla and Isaac Newton},
year = 2010,
isbn = {000-0000000000},
publisher = {Nikola Tesla Publishing Group}
publisher = {Nikola Tesla Publishing Group},
pdf = {http://example.org/b2010.pdf}
}

@inproceedings{p2015,
@@ -31,10 +31,10 @@ def test_default(self):
expected = (
'<div class = "publication-list">'
'<h3>2015</h3><ul>'
'<li class = "publication">.*One article in 2015.*<a href="bibtex/a2015.bib">bibtex</a>.*</li>'
'<li class = "publication">.*One article in 2015.*<a href="bibtex/a2015.bib">bibtex</a>.*<a href="/pdf/a2015.pdf">pdf</a>.*</li>'
'<li class = "publication">.*One conference in 2015.*<a href="bibtex/p2015.bib">bibtex</a>.*</li>'
'</ul><h3>2010</h3><ul>'
'<li class = "publication">.*One Book in 2010.*<a href="bibtex/b2010.bib">bibtex</a>.*</li>'
'<li class = "publication">.*One Book in 2010.*<a href="bibtex/b2010.bib">bibtex</a>.*<a href="http://example.org/b2010.pdf">pdf</a>.*</li>'
'</ul></div>'
)
self.sample = '.. publication_list:: tests/data/publication_list/test.bib'
@@ -23,6 +23,10 @@ The `publication-list` directive accepts multiple options.
publication is generated. If empty, no bibtex file will be created for each
publication. The default is `bibtex`.

Besides the options available above, if a publication entry has specified a
"pdf" field with a URL to a pdf file, a "pdf" link will be shown below the
publication.

## Example

A simple example:
@@ -41,15 +45,17 @@ where `my-publication.bib` contains:
year = 2015,
journal = {Great Journal},
volume = 1,
page = {1--10}
page = {1--10},
pdf = {/pdf/a2015.pdf}
}

@book{b2010,
title = {One Book in 2010},
author = {Nikola Tesla and Isaac Newton},
year = 2010,
isbn = {000-0000000000},
publisher = {Nikola Tesla Publishing Group}
publisher = {Nikola Tesla Publishing Group},
pdf = {http://example.org/b2010.pdf}
}

@inproceedings{p2015,
@@ -89,11 +89,20 @@ def run(self):

html += '<li class = "publication">{}'.format(
list(style.format_entries((entry,)))[0].text.render_as('html'))

extra_links = ""
if bibtex_dir: # write bib files to bibtex_dir for downloading
bib_link = '{}/{}.bib'.format(bibtex_dir, label)
bib_data = BibliographyData(dict({label: entry}))
bib_data.to_file('/'.join([self.output_folder, bib_link]), 'bibtex')
html += '<br/>[<a href="{}">bibtex</a>]'.format(bib_link)
extra_links += '[<a href="{}">bibtex</a>] '.format(bib_link)

if 'pdf' in entry.fields: # the link to the pdf file
extra_links += '[<a href="{}">pdf</a>] '.format(entry.fields['pdf'])

if extra_links:
html += '<br/>' + extra_links

html += '</li>'

if len(data) != 0: # publication list is nonempty

0 comments on commit bcf7941

Please sign in to comment.
You can’t perform that action at this time.