mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-19 04:28:31 +02:00
parent
6c98c7cdfc
commit
09d652899a
4 changed files with 58 additions and 0 deletions
9
tests/external_plugins_src/README.md
Normal file
9
tests/external_plugins_src/README.md
Normal file
|
@ -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.
|
14
tests/external_plugins_src/jrnl/contrib/exporter/rot13.py
Normal file
14
tests/external_plugins_src/jrnl/contrib/exporter/rot13.py
Normal file
|
@ -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")
|
35
tests/external_plugins_src/setup.py
Normal file
35
tests/external_plugins_src/setup.py
Normal file
|
@ -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
|
||||||
|
)
|
Loading…
Add table
Reference in a new issue