Skip to content

Commit

Permalink
publication_list: Support custom links and merge "slides" link with it.
Browse files Browse the repository at this point in the history
  • Loading branch information
xuhdev committed Feb 28, 2017
1 parent 0003d7c commit 704973a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions v7/publication_list/publication_list.py
Expand Up @@ -112,11 +112,16 @@ def run(self):
bibtex_fields = dict(entry.fields) bibtex_fields = dict(entry.fields)
# Remove some fields for the publicly available BibTeX file since they are mostly only # Remove some fields for the publicly available BibTeX file since they are mostly only
# used by this plugin. # used by this plugin.
for field_to_remove in ('abstract', 'fulltext', 'slides'): for field_to_remove in ('abstract', 'fulltext'):
if field_to_remove in bibtex_fields: if field_to_remove in bibtex_fields:
del bibtex_fields[field_to_remove] del bibtex_fields[field_to_remove]
# Collect and remove custom links (fields starting with "customlink")
custom_links = dict()
for key, value in bibtex_fields.items():
if key.startswith('customlink'):
custom_links[key[len('customlink'):]] = value
# Prepare for the bib file. Note detail_page_dir may need bib_data later.
bibtex_entry = Entry(entry.type, bibtex_fields, entry.persons) bibtex_entry = Entry(entry.type, bibtex_fields, entry.persons)
# detail_page_dir may need bib_data later
bib_data = BibliographyData(dict({label: bibtex_entry})) bib_data = BibliographyData(dict({label: bibtex_entry}))
if bibtex_dir: # write bib files to bibtex_dir for downloading if bibtex_dir: # write bib files to bibtex_dir for downloading
bib_link = '{}/{}.bib'.format(bibtex_dir, label) bib_link = '{}/{}.bib'.format(bibtex_dir, label)
Expand All @@ -127,8 +132,9 @@ def run(self):
if 'fulltext' in entry.fields: # the link to the full text, usually a link to the pdf file if 'fulltext' in entry.fields: # the link to the full text, usually a link to the pdf file
extra_links += '[<a href="{}">full text</a>] '.format(entry.fields['fulltext']) extra_links += '[<a href="{}">full text</a>] '.format(entry.fields['fulltext'])


if 'slides' in entry.fields: # the link to the presentation slides # custom fields (custom links)
extra_links += '[<a href="{}">slides</a>] '.format(entry.fields['slides']) for key, value in custom_links.items():
extra_links += '[<a href="{}">{}</a>] '.format(value, key)


if extra_links or detail_page_dir: if extra_links or detail_page_dir:
html += '<br>' html += '<br>'
Expand Down

0 comments on commit 704973a

Please sign in to comment.