Added full_output method.
This commit is contained in:
parent
3c0221ebf7
commit
adc6716fd8
|
@ -7,7 +7,7 @@ from lektor.pluginsystem import Plugin
|
|||
|
||||
class CitationPlugin(Plugin):
|
||||
name = 'lektor-citation'
|
||||
description = u'This Plugin should extend lektor with APA-style citations using bibtex files. It is based on the known lektor-bibtex-support plugin by arunpersaud.'
|
||||
description = u'This Plugin should extend lektor with APA-styled citations using bibtex files. It was based on the known lektor-bibtex-support plugin by arunpersaud.'
|
||||
|
||||
|
||||
def __init__(self, env, id):
|
||||
|
@ -39,7 +39,15 @@ class CitationPlugin(Plugin):
|
|||
for item in prelast:
|
||||
authors += "{i} ".format(i = str(item))
|
||||
authors += str(author.last_names[0])
|
||||
|
||||
first = author.first_names
|
||||
if len(first) > 0 :
|
||||
authors += ","
|
||||
for item in first:
|
||||
authors += " {i}.".format(i = str(item[:1]))
|
||||
middle = author.middle_names
|
||||
if len(middle) > 0 :
|
||||
for item in middle:
|
||||
authors += " {i}.".format(i = str(item[:1]))
|
||||
|
||||
if len(lAuthor) > 1:
|
||||
|
||||
|
@ -55,7 +63,7 @@ class CitationPlugin(Plugin):
|
|||
edition = ""
|
||||
if 'edition' in e.fields.keys():
|
||||
edition = e.fields['edition']
|
||||
edition = " ({ed}. Aufl.)".format(ed = edition)
|
||||
edition = " ({ed}. Ed.)".format(ed = edition)
|
||||
else:
|
||||
edition = ""
|
||||
|
||||
|
@ -73,6 +81,100 @@ class CitationPlugin(Plugin):
|
|||
output = '<li id="{eid}"><a href="{link}" class="litref">{authors} ({pubYear}).</a> <em>{title}</em>{edition}. {publisher}'.format(eid = id, link = link, authors = authors, pubYear = year, title = e.fields['title'], edition = edition, publisher = publisher)
|
||||
return output
|
||||
|
||||
def citation_full_output(self, id):
|
||||
e = self.citation_entry(id)
|
||||
if "url" in e.fields.keys() and len(e.fields['url']) > 0:
|
||||
link = e.fields['url']
|
||||
else:
|
||||
link = "?"
|
||||
|
||||
def circle_people(lAuthor):
|
||||
authors = ""
|
||||
n = 1
|
||||
for author in lAuthor:
|
||||
first = author.first_names
|
||||
if len(first) > 0 :
|
||||
for item in first:
|
||||
authors += "{i} ".format(i = str(item))
|
||||
middle = author.middle_names
|
||||
if len(middle) > 0 :
|
||||
for item in middle:
|
||||
authors += "{i} ".format(i = str(item))
|
||||
|
||||
prelast = author.prelast_names
|
||||
if len(prelast) > 0:
|
||||
for item in prelast:
|
||||
authors += "{i} ".format(i = str(item))
|
||||
authors += str(author.last_names[0])
|
||||
|
||||
if len(lAuthor) > 1:
|
||||
|
||||
if n == (len(lAuthor) - 1):
|
||||
authors += " \& "
|
||||
elif n < (len(lAuthor) -1):
|
||||
authors += ", "
|
||||
|
||||
n = n + 1
|
||||
return authors
|
||||
|
||||
|
||||
authors = circle_people(e.persons['author'])
|
||||
if "editor" in e.persons.keys():
|
||||
editors = circle_people(e.persons['editor'])
|
||||
else:
|
||||
editors = ""
|
||||
|
||||
|
||||
year = e.fields['year']
|
||||
edition = ""
|
||||
if 'edition' in e.fields.keys():
|
||||
edition = e.fields['edition']
|
||||
edition = " {ed}. Ed.".format(ed = edition)
|
||||
else:
|
||||
edition = ""
|
||||
|
||||
if 'pages' in e.fields.keys():
|
||||
pages = e.fields['pages']
|
||||
else:
|
||||
pages = ""
|
||||
|
||||
if 'issbn' in e.fields.keys():
|
||||
issbn = e.fields['issbn']
|
||||
else:
|
||||
issbn = ""
|
||||
|
||||
if 'note' in e.fields.keys():
|
||||
note = e.fields['note']
|
||||
else:
|
||||
note = ""
|
||||
|
||||
|
||||
if 'publisher' in e.fields.keys():
|
||||
publisher = e.fields['publisher']
|
||||
if 'address' in e.fields.keys():
|
||||
location = e.fields['address']
|
||||
publisher = " {location}: {publisher}.".format(location = location, publisher = publisher)
|
||||
elif publisher:
|
||||
publisher = " {publisher}.".format(publisher = publisher)
|
||||
else:
|
||||
publisher = ""
|
||||
|
||||
|
||||
output = """<h2>{title}</h2><h3>{authors} ({pubYear})</h3>
|
||||
<p>{note}</p>
|
||||
<dl class="literature">
|
||||
<dt class="edition"></dt>
|
||||
<dd>{edition}</dd>
|
||||
<dt class="editors"></dt>
|
||||
<dd>{editors}</dd>
|
||||
<dt class="pages"></dt>
|
||||
<dd>{pages}</dd>
|
||||
<dt class="issbn"></dt>
|
||||
<dd>{issbn}</dd>
|
||||
<dt class="publisher"></dt>
|
||||
<dd>{publisher}</dd>
|
||||
</dl>""".format(eid = id, link = link, authors = authors, pubYear = year, title = e.fields['title'], edition = edition, publisher = publisher, editors = editors, pages = pages, issbn = issbn, note = note)
|
||||
return output
|
||||
|
||||
|
||||
|
||||
|
@ -83,6 +185,7 @@ class CitationPlugin(Plugin):
|
|||
self.env.jinja_env.globals['citation_entries'] = self.citation_entries
|
||||
self.env.jinja_env.globals['citation_entry'] = self.citation_entry
|
||||
self.env.jinja_env.globals['citation_short_output'] = self.citation_short_output
|
||||
self.env.jinja_env.globals['citation_full_output'] = self.citation_full_output
|
||||
self.env.jinja_env.filters['decode'] = decode_filter
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue