mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-18 20:18:32 +02:00
remove template exporter
This commit is contained in:
parent
e25869e9bc
commit
3795159767
3 changed files with 0 additions and 68 deletions
|
@ -9,8 +9,6 @@ import jrnl.contrib.importer
|
|||
import jrnl.plugins.exporter
|
||||
import jrnl.plugins.importer
|
||||
|
||||
from .template_exporter import __all__ as template_exporters
|
||||
|
||||
__exporters_builtin = list(
|
||||
pkgutil.iter_modules(
|
||||
jrnl.plugins.exporter.__path__, jrnl.plugins.exporter.__name__ + "."
|
||||
|
@ -43,9 +41,6 @@ __exporter_types_contrib = {
|
|||
for plugin in __exporters_contrib
|
||||
for name in importlib.import_module(plugin.name).Exporter.names
|
||||
}
|
||||
__exporter_types_template = {
|
||||
name: plugin for plugin in template_exporters for name in plugin.names
|
||||
}
|
||||
|
||||
|
||||
__importer_types_builtin = {
|
||||
|
@ -62,7 +57,6 @@ __importer_types_contrib = {
|
|||
__exporter_types = {
|
||||
**__exporter_types_builtin,
|
||||
**__exporter_types_contrib,
|
||||
**__exporter_types_template,
|
||||
}
|
||||
__importer_types = {**__importer_types_builtin, **__importer_types_contrib}
|
||||
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
# Copyright (C) 2012-2021 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
from glob import glob
|
||||
import os
|
||||
|
||||
from jrnl.plugins.template import Template
|
||||
from jrnl.plugins.exporter.text_exporter import Exporter as TextExporter
|
||||
|
||||
|
||||
class GenericTemplateExporter(TextExporter):
|
||||
"""This Exporter can convert entries and journals into text files."""
|
||||
|
||||
@classmethod
|
||||
def export_entry(cls, entry):
|
||||
"""Returns a string representation of a single entry."""
|
||||
vars = {"entry": entry, "tags": entry.tags}
|
||||
return cls.template.render_block("entry", **vars)
|
||||
|
||||
@classmethod
|
||||
def export_journal(cls, journal):
|
||||
"""Returns a string representation of an entire journal."""
|
||||
vars = {"journal": journal, "entries": journal.entries, "tags": journal.tags}
|
||||
return cls.template.render_block("journal", **vars)
|
||||
|
||||
|
||||
def __exporter_from_file(template_file):
|
||||
"""Create a template class from a file"""
|
||||
name = os.path.basename(template_file).replace(".template", "")
|
||||
template = Template.from_file(template_file)
|
||||
return type(
|
||||
str(f"{name.title()}TemplateExporter"),
|
||||
(GenericTemplateExporter,),
|
||||
{"names": [name], "extension": template.extension, "template": template},
|
||||
)
|
||||
|
||||
|
||||
__all__ = []
|
||||
|
||||
# Factory pattern to create Exporter classes for all available templates
|
||||
for template_file in glob("jrnl/templates/*.template"):
|
||||
__all__.append(__exporter_from_file(template_file))
|
|
@ -1,18 +0,0 @@
|
|||
---
|
||||
extension: txt
|
||||
---
|
||||
|
||||
{% block journal %}
|
||||
{% for entry in entries %}
|
||||
{% include entry %}
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block entry %}
|
||||
{{ entry.title }}
|
||||
{{ "-" * len(entry.title) }}
|
||||
|
||||
{{ entry.body }}
|
||||
|
||||
{% endblock %}
|
Loading…
Add table
Reference in a new issue