Skip to content

Commit

Permalink
publication_list: Add support for adding customized pieces in details…
Browse files Browse the repository at this point in the history
… pages.
  • Loading branch information
xuhdev committed Jun 2, 2017
1 parent 9891ae2 commit 722b491
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
11 changes: 11 additions & 0 deletions v7/publication_list/README.md
Expand Up @@ -85,6 +85,17 @@ where `my-publications.bib` contains:

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

## Customize Details Pages

You can also customize details pages. To do that, simply create files named
`publicationlist_label_after_abstract.html` or
`publicationlist_label_after_fulltext.html` in your template directory (usually
named `templates`). The contents in these files will be inserted into the
details page of the paper with that BibTeX label. For example, for a paper with
a BibTeX label `a2015`, you can create files
`publicationlist_a2015_after_abstract.html` and/or
`publicationlist_a2015_after_fulltext.html` to customize its details page.

## Screenshot

![publication-list screenshot](http://plugins.getnikola.com/__data__/publication-list-screenshot.png)
Expand Down
19 changes: 19 additions & 0 deletions v7/publication_list/templates/jinja/publication.tmpl
@@ -1,6 +1,21 @@
{# -*- coding: utf-8 -*- #}
{% extends 'base.tmpl' %}

<%!
import os, mako
%>

{% macro include_if_exists(name) %}
<%
try:
tmpl = self.get_template(name)
except mako.exceptions.TemplateLookupException as e:
pass
else:
tmpl.render_context(context)
%>
{% endmacro %}

{% block extra_head %}
<style>
.publication-abstract {
Expand Down Expand Up @@ -34,6 +49,8 @@
</div>
{% endif %}

{{ include_if_exists("publicationlist_{ }_after_abstract.html".format(label))}}

{% if pdf %}
<h2>Full Text</h2>
<div>
Expand All @@ -43,4 +60,6 @@
<p>[<a href="{{ pdf }}" download="{{ label }}.pdf">download</a>]</p>
</div>
{% endif %}

{{ include_if_exists("publicationlist_{ }_after_fulltext.html".format(label))}}
{% endblock %}
19 changes: 19 additions & 0 deletions v7/publication_list/templates/mako/publication.tmpl
@@ -1,6 +1,21 @@
## -*- coding: utf-8 -*-
<%inherit file="base.tmpl"/>

<%!
import os, mako
%>

<%def name="include_if_exists(name)" buffered="True">
<%
try:
tmpl = self.get_template(name)
except mako.exceptions.TemplateLookupException as e:
pass
else:
tmpl.render_context(context)
%>
</%def>

<%block name="extra_head">
<style>
.publication-abstract {
Expand Down Expand Up @@ -34,6 +49,8 @@
</div>
% endif

${include_if_exists("publicationlist_{}_after_abstract.html".format(label))}

% if pdf:
<h2>Full Text</h2>
<div>
Expand All @@ -43,4 +60,6 @@
<p>[<a href="${pdf}" download="${label}.pdf">download</a>]</p>
</div>
% endif

${include_if_exists("publicationlist_{}_after_fulltext.html".format(label))}
</%block>

0 comments on commit 722b491

Please sign in to comment.