Skip to content

Commit

Permalink
publication_list: Add support for specifying multiple bibtex files.
Browse files Browse the repository at this point in the history
Close #261
  • Loading branch information
xuhdev committed Mar 28, 2018
1 parent b5e14b7 commit 35303d9
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
7 changes: 0 additions & 7 deletions tests/data/publication_list/test.bib
Expand Up @@ -17,10 +17,3 @@ @book{b2010
publisher = {Nikola Tesla Publishing Group},
fulltext = {http://example.org/b2010.pdf}
}

@inproceedings{p2015,
title = {One Conference in 2015},
booktitle = {Nikola Tesla Conference},
author = {Nikola Tesla},
year = 2015
}
6 changes: 6 additions & 0 deletions tests/data/publication_list/test1.bib
@@ -0,0 +1,6 @@
@inproceedings{p2015,
title = {One Conference in 2015},
booktitle = {Nikola Tesla Conference},
author = {Nikola Tesla},
year = 2015
}
5 changes: 3 additions & 2 deletions tests/test_publication_list.py
Expand Up @@ -43,8 +43,9 @@ def test_default(self):
'<a href="http://example.org/b2010.pdf">full text</a>.*</li>'
'</ul></div>'
)
self.sample = '.. publication_list:: tests/data/publication_list/' + \
'test.bib\n\t:highlight_author: Nikola Tesla'
self.sample = ('.. publication_list:: tests/data/publication_list/test.bib '
'tests/data/publication_list/test1.bib'
'\n\t:highlight_author: Nikola Tesla')
self.deps = 'tests/data/publication_list/test.bib'
self.basic_test()
assert re.search(
Expand Down
7 changes: 6 additions & 1 deletion v7/publication_list/README.md
Expand Up @@ -83,7 +83,12 @@ where `my-publications.bib` contains:
year = 2015
}

A live example is available [here](http://www.shudan.me/).
If you have multiple bibtex files, you can specify them in one line, separated
by spaces. For example:

... publication_list:: my-novels.bib my-research-papers.bib my-collections.bib

A live example of this plugin is available [here](http://www.shudan.me/).

## Customize Details Pages

Expand Down
8 changes: 6 additions & 2 deletions v7/publication_list/publication_list.py
Expand Up @@ -25,6 +25,7 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import os
import sys

from docutils import nodes
from docutils.parsers.rst import Directive, directives
Expand Down Expand Up @@ -76,6 +77,7 @@ class PublicationList(Directive):
"""
has_content = False
required_arguments = 1
optional_arguments = sys.maxsize
option_spec = {
'bibtex_dir': directives.unchanged,
'detail_page_dir': directives.unchanged,
Expand All @@ -95,9 +97,11 @@ def run(self):

parser = Parser()

all_entries = []
for a in self.arguments:
all_entries.extend(parser.parse_file(a).entries.items())
# Sort the publication entries by year reversed
data = sorted(parser.parse_file(self.arguments[0]).entries.items(),
key=lambda e: e[1].fields['year'], reverse=True)
data = sorted(all_entries, key=lambda e: e[1].fields['year'], reverse=True)

html = '<div class="publication-list">\n'
cur_year = None
Expand Down

0 comments on commit 35303d9

Please sign in to comment.