Added links to cite methods. (Issue #1)

This commit is contained in:
Homer S. 2022-01-27 21:48:23 +01:00
parent ed616698a8
commit af095b8d32
1 changed files with 19 additions and 6 deletions

View File

@ -15,6 +15,8 @@ class CitationPlugin(Plugin):
config = self.get_config() config = self.get_config()
self.bibfile = config.get('Bibtex.file', []).strip() self.bibfile = config.get('Bibtex.file', []).strip()
self.default_prio = config.get('default.priority', []).strip()
self.default_link = config.get('default.link', []).strip()
self.bib_data = parse_file(os.path.join(env.root_path, 'assets', self.bibfile)) self.bib_data = parse_file(os.path.join(env.root_path, 'assets', self.bibfile))
@ -223,18 +225,29 @@ class CitationPlugin(Plugin):
""".format(eid = id, link = link, authors = authors, pubYear = year, title = title, edition = edition, publisher = publisher, editors = editors, pages = pages, issbn = issbn, note = note) """.format(eid = id, link = link, authors = authors, pubYear = year, title = title, edition = edition, publisher = publisher, editors = editors, pages = pages, issbn = issbn, note = note)
return output return output
def citation_full_cite(self,id,link=""): def citation_base_cite(self,id,link="",output=""):
e = self.citation_entry(id) e = self.citation_entry(id)
if len(link) > 1:
link = link
elif self.default_prio == "url":
link = self.get_url(e)
if len(link) < 2:
link = self.default_link
else:
link = self.default_link
authors = self.get_authors_short(e) authors = self.get_authors_short(e)
year = self.get_pubYear(e) year = self.get_pubYear(e)
output = """<a href=\"{link}#{id}\" class=\"litref\">({authors}, {pubYear})</a>""".format(link = link, id = id, authors = authors, pubYear = year) output = output.format(link = link, id = id, authors = authors, pubYear = year)
return output
def citation_full_cite(self,id,link=""):
output = self.citation_base_cite(id,link="",output="""<a href=\"{link}#{id}\" class=\"litref\">({authors}, {pubYear})</a>""")
return output return output
def citation_full_citeNP(self,id,link=""): def citation_full_citeNP(self,id,link=""):
e = self.citation_entry(id) output = self.citation_base_cite(id,link="",output="""<a href=\"{link}#{id}\" class=\"litref\">{authors} ({pubYear})</a>""")
authors = self.get_authors_short(e)
year = self.get_pubYear(e)
output = """<a href=\"{link}#{id}\" class=\"litref\">{authors} ({pubYear})</a>""".format(link = link, id = id, authors = authors, pubYear = year)
return output return output
def on_setup_env(self, **extra): def on_setup_env(self, **extra):