diff --git a/tests/external_plugins_src/README.md b/tests/external_plugins_src/README.md new file mode 100644 index 00000000..a6674f4e --- /dev/null +++ b/tests/external_plugins_src/README.md @@ -0,0 +1,9 @@ +# Rot13 Custom Exporter for Jrnl + +This is a custom exporter to demostrate how to write customer exporters for +[jrnl](https://github.com/jrnl-org/jrnl). It is also used by *jrnl* in its +tests to ensure the feature works as expected. + +This plugin applies a [Caeser +cipher](https://en.wikipedia.org/wiki/Caesar_cipher) (specifically the +[ROT13](https://en.wikipedia.org/wiki/ROT13)) to output text. diff --git a/tests/external_plugins_src/jrnl/contrib/exporter/rot13.py b/tests/external_plugins_src/jrnl/contrib/exporter/rot13.py new file mode 100644 index 00000000..508a8f42 --- /dev/null +++ b/tests/external_plugins_src/jrnl/contrib/exporter/rot13.py @@ -0,0 +1,14 @@ +import codecs + +from jrnl.plugins.base import BaseExporter + +__version__ = "1.0.0" + +class Exporter(BaseExporter): + names = ["rot13"] + extension = "txt" + version = __version__ + + @classmethod + def export_entry(cls, entry): + return codecs.encode(str(entry), "rot_13") diff --git a/tests/external_plugins_src/jrnl/contrib/importer/.gitkeep b/tests/external_plugins_src/jrnl/contrib/importer/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tests/external_plugins_src/setup.py b/tests/external_plugins_src/setup.py new file mode 100644 index 00000000..820b5022 --- /dev/null +++ b/tests/external_plugins_src/setup.py @@ -0,0 +1,35 @@ +import os +import re + +try: + from setuptools import setup +except ImportError: + from distutils.core import setup + +base_dir = os.path.dirname(os.path.abspath(__file__)) + + +def get_version(filename="jrnl/contrib/exporter/rot13.py"): + with open(os.path.join(base_dir, filename), encoding="utf-8") as initfile: + for line in initfile.readlines(): + m = re.match("__version__ *= *['\"](.*)['\"]", line) + if m: + return m.group(1) + + +setup( + name="jrnl-demo-plugins", + version=get_version(), + description="Demonstration custom plugins for jrnl", + long_description="\n\n".join([open(os.path.join(base_dir, "README.md")).read()]), + long_description_content_type="text/markdown", + author="W. Minchin", + author_email="w_minchin@hotmail.com", + url="https://github.com/jrnl-org/jrnl/tree/develop/tests/external_plugins_src", + packages=["jrnl", "jrnl.contrib", "jrnl.contrib.exporter", "jrnl.contrib.importer"], + include_package_data=True, + install_requires=[ + "jrnl", + ], + zip_safe=False, # use wheels instead +)