summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2015-10-03 10:34:06 +0300
committerLars Wirzenius <liw@liw.fi>2015-10-03 10:34:06 +0300
commit6b00e6cc829602cec7e6b6b73f94febd28bfa9a3 (patch)
treee5a3eaa479c6092fffa0e2367f14e5318a463572
parente8d1f422888d1ea4d703b446cf732331d0fff116 (diff)
downloadjt-6b00e6cc829602cec7e6b6b73f94febd28bfa9a3.tar.gz
Move template texts into files
-rw-r--r--jtlib/app.py5
-rw-r--r--jtlib/plugins/new_person_plugin.py7
-rw-r--r--jtlib/plugins/new_plugin.py10
-rw-r--r--jtlib/plugins/new_topic_plugin.py9
-rw-r--r--jtlib/templates/new-note.tmpl5
-rw-r--r--jtlib/templates/new_person.tmpl3
-rw-r--r--jtlib/templates/new_topic.tmpl3
7 files changed, 19 insertions, 23 deletions
diff --git a/jtlib/app.py b/jtlib/app.py
index a560c26..8e0303a 100644
--- a/jtlib/app.py
+++ b/jtlib/app.py
@@ -93,3 +93,8 @@ class JournalTool(cliapp.Application):
return args[0], pathname
elif len(args) > 1:
raise cliapp.AppException('Must give at most one draft number')
+
+ def read_template(self, basename):
+ filename = os.path.join(self.app_directory(), 'templates', basename)
+ with open(filename) as f:
+ return f.read()
diff --git a/jtlib/plugins/new_person_plugin.py b/jtlib/plugins/new_person_plugin.py
index 43db172..050e97a 100644
--- a/jtlib/plugins/new_person_plugin.py
+++ b/jtlib/plugins/new_person_plugin.py
@@ -53,12 +53,7 @@ class NewPersonCommand(cliapp.Plugin):
if os.path.exists(pathname):
raise cliapp.AppException('File %s already exists' % pathname)
- template = '''\
-[[!meta title="%(name)s"]]
-
-[[!inline archive=yes pages="link(.)"]]
-'''
-
+ template = self.app.read_template('new_person.tmpl')
with open(pathname, 'w') as f:
f.write(
template %
diff --git a/jtlib/plugins/new_plugin.py b/jtlib/plugins/new_plugin.py
index b10b4a1..8134fa5 100644
--- a/jtlib/plugins/new_plugin.py
+++ b/jtlib/plugins/new_plugin.py
@@ -25,14 +25,6 @@ import jtlib
class NewCommand(cliapp.Plugin):
- _default_new_note_template = '''\
-[[!meta title="%(title)s"]]
-[[!tag ]]
-[[!meta date="%(date)s"]]
-%(topiclink)s
-
-'''
-
def enable(self):
self.app.add_subcommand('new', self.run, arg_synopsis='TITLE')
@@ -79,4 +71,4 @@ class NewCommand(cliapp.Plugin):
with open(filename) as f:
return f.read()
else:
- return self._default_new_note_template
+ return self.app.read_template('new-note.tmpl')
diff --git a/jtlib/plugins/new_topic_plugin.py b/jtlib/plugins/new_topic_plugin.py
index 09fcbd5..4f44f2b 100644
--- a/jtlib/plugins/new_topic_plugin.py
+++ b/jtlib/plugins/new_topic_plugin.py
@@ -49,13 +49,6 @@ class NewTopicCommand(cliapp.Plugin):
if not os.path.exists(dirname):
os.makedirs(dirname)
- template = '''\
-[[!meta title="%(title)s"]]
-
-
-
-[[!inline pages="link(.)" archive=yes reverse=yes trail=yes]]
-'''
-
+ template = self.app.read_template('new_topic.tmpl')
with open(pathname, 'w') as f:
f.write(template % {'title': title})
diff --git a/jtlib/templates/new-note.tmpl b/jtlib/templates/new-note.tmpl
new file mode 100644
index 0000000..0db1798
--- /dev/null
+++ b/jtlib/templates/new-note.tmpl
@@ -0,0 +1,5 @@
+[[!meta title="%(title)s"]]
+[[!tag ]]
+[[!meta date="%(date)s"]]
+%(topiclink)s
+
diff --git a/jtlib/templates/new_person.tmpl b/jtlib/templates/new_person.tmpl
new file mode 100644
index 0000000..86d5162
--- /dev/null
+++ b/jtlib/templates/new_person.tmpl
@@ -0,0 +1,3 @@
+[[!meta title="%(name)s"]]
+
+[[!inline archive=yes pages="link(.)"]]
diff --git a/jtlib/templates/new_topic.tmpl b/jtlib/templates/new_topic.tmpl
new file mode 100644
index 0000000..5321b7f
--- /dev/null
+++ b/jtlib/templates/new_topic.tmpl
@@ -0,0 +1,3 @@
+[[!meta title="%(title)s"]]
+
+[[!inline pages="link(.)" archive=yes reverse=yes trail=yes]]