Skip to content

Commit bcf7941

Browse files
committedJan 29, 2016
publication_list: show the link to the pdf if specified.
1 parent 001f4a7 commit bcf7941

File tree

5 files changed

+24
-7
lines changed

5 files changed

+24
-7
lines changed
 
17.1 KB
Loading

‎tests/data/publication_list/test.bib

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ @article{a2015
44
year = 2015,
55
journal = {Great Journal},
66
volume = 1,
7-
page = {1--10}
7+
page = {1--10},
8+
pdf = {/pdf/a2015.pdf}
89
}
910

1011
@book{b2010,
1112
title = {One Book in 2010},
1213
author = {Nikola Tesla and Isaac Newton},
1314
year = 2010,
1415
isbn = {000-0000000000},
15-
publisher = {Nikola Tesla Publishing Group}
16+
publisher = {Nikola Tesla Publishing Group},
17+
pdf = {http://example.org/b2010.pdf}
1618
}
1719

1820
@inproceedings{p2015,

‎tests/test_publication_list.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ def test_default(self):
3131
expected = (
3232
'<div class = "publication-list">'
3333
'<h3>2015</h3><ul>'
34-
'<li class = "publication">.*One article in 2015.*<a href="bibtex/a2015.bib">bibtex</a>.*</li>'
34+
'<li class = "publication">.*One article in 2015.*<a href="bibtex/a2015.bib">bibtex</a>.*<a href="/pdf/a2015.pdf">pdf</a>.*</li>'
3535
'<li class = "publication">.*One conference in 2015.*<a href="bibtex/p2015.bib">bibtex</a>.*</li>'
3636
'</ul><h3>2010</h3><ul>'
37-
'<li class = "publication">.*One Book in 2010.*<a href="bibtex/b2010.bib">bibtex</a>.*</li>'
37+
'<li class = "publication">.*One Book in 2010.*<a href="bibtex/b2010.bib">bibtex</a>.*<a href="http://example.org/b2010.pdf">pdf</a>.*</li>'
3838
'</ul></div>'
3939
)
4040
self.sample = '.. publication_list:: tests/data/publication_list/test.bib'

‎v7/publication_list/README.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ The `publication-list` directive accepts multiple options.
2323
publication is generated. If empty, no bibtex file will be created for each
2424
publication. The default is `bibtex`.
2525

26+
Besides the options available above, if a publication entry has specified a
27+
"pdf" field with a URL to a pdf file, a "pdf" link will be shown below the
28+
publication.
29+
2630
## Example
2731

2832
A simple example:
@@ -41,15 +45,17 @@ where `my-publication.bib` contains:
4145
year = 2015,
4246
journal = {Great Journal},
4347
volume = 1,
44-
page = {1--10}
48+
page = {1--10},
49+
pdf = {/pdf/a2015.pdf}
4550
}
4651

4752
@book{b2010,
4853
title = {One Book in 2010},
4954
author = {Nikola Tesla and Isaac Newton},
5055
year = 2010,
5156
isbn = {000-0000000000},
52-
publisher = {Nikola Tesla Publishing Group}
57+
publisher = {Nikola Tesla Publishing Group},
58+
pdf = {http://example.org/b2010.pdf}
5359
}
5460

5561
@inproceedings{p2015,

‎v7/publication_list/publication_list.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,20 @@ def run(self):
8989

9090
html += '<li class = "publication">{}'.format(
9191
list(style.format_entries((entry,)))[0].text.render_as('html'))
92+
93+
extra_links = ""
9294
if bibtex_dir: # write bib files to bibtex_dir for downloading
9395
bib_link = '{}/{}.bib'.format(bibtex_dir, label)
9496
bib_data = BibliographyData(dict({label: entry}))
9597
bib_data.to_file('/'.join([self.output_folder, bib_link]), 'bibtex')
96-
html += '<br/>[<a href="{}">bibtex</a>]'.format(bib_link)
98+
extra_links += '[<a href="{}">bibtex</a>] '.format(bib_link)
99+
100+
if 'pdf' in entry.fields: # the link to the pdf file
101+
extra_links += '[<a href="{}">pdf</a>] '.format(entry.fields['pdf'])
102+
103+
if extra_links:
104+
html += '<br/>' + extra_links
105+
97106
html += '</li>'
98107

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

0 commit comments

Comments
 (0)
Please sign in to comment.