Initial commit.

This commit is contained in:
Homer S. 2022-01-20 07:02:55 +01:00
commit ebcc692408
4 changed files with 81 additions and 0 deletions

4
README.md Normal file
View File

@ -0,0 +1,4 @@
# lektor-citation
This is where a description of your plugin goes.
Provide usage instructions here.

36
lektor_citation.py Normal file
View File

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
import os
from pylatexenc.latex2text import LatexNodes2Text
from pybtex.database import parse_file
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.'
def __init__(self, env, id):
super().__init__(env, id)
config = self.get_config()
self.bibfile = config.get('Bibtex.file', []).strip()
self.bib_data = parse_file(os.path.join(env.root_path, 'assets', self.bibfile))
def citation_entries(self):
return self.bib_data.entries
def citation_entry(self, id):
return self.bib_data.entries[id]
def on_setup_env(self, **extra):
self.env.jinja_env.globals['citation_entries'] = self.citation_entries
self.env.jinja_env.globals['citation_entry'] = self.citation_entry

2
setup.cfg Normal file
View File

@ -0,0 +1,2 @@
[bdist_wheel]
universal=1

39
setup.py Normal file
View File

@ -0,0 +1,39 @@
import ast
import io
import re
from setuptools import setup, find_packages
with io.open('README.md', 'rt', encoding="utf8") as f:
readme = f.read()
_description_re = re.compile(r'description\s+=\s+(?P<description>.*)')
with open('lektor_citation.py', 'rb') as f:
description = str(ast.literal_eval(_description_re.search(
f.read().decode('utf-8')).group(1)))
setup(
author='Homer S',
author_email='homer77@ismus.net',
description=description,
keywords='Lektor plugin',
license='MIT',
long_description=readme,
long_description_content_type='text/markdown',
name='lektor-citation',
packages=find_packages(),
py_modules=['lektor_citation'],
# url='[link to your repository]',
version='0.1',
classifiers=[
'Framework :: Lektor',
'Environment :: Plugins',
],
entry_points={
'lektor.plugins': [
'citation = lektor_citation:CitationPlugin',
]
},
install_requires=['pybtex','pylatexenc']
)