Permalink
Browse files

publication_list: Add support for adding customized pieces in details…

… pages.
  • Loading branch information...
1 parent 9891ae2 commit 722b49146de2b48135747fc379efee1eeb04e03a @xuhdev xuhdev committed Jun 2, 2017
@@ -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)
@@ -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 {
@@ -34,6 +49,8 @@
</div>
{% endif %}
+ {{ include_if_exists("publicationlist_{ }_after_abstract.html".format(label))}}
+
{% if pdf %}
<h2>Full Text</h2>
<div>
@@ -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 %}
@@ -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 {
@@ -34,6 +49,8 @@
</div>
% endif
+ ${include_if_exists("publicationlist_{}_after_abstract.html".format(label))}
+
% if pdf:
<h2>Full Text</h2>
<div>
@@ -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.