summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-10-26 23:22:49 +0100
committerLars Wirzenius <liw@liw.fi>2013-10-26 23:22:49 +0100
commit97755806efc52658a8eef434f3510fcc9e75d0b7 (patch)
tree9dc8332faa57506fa45059c52936e919bacf3eb8
parent60b2da934adff81d1a76417294f98a5f11ed83b9 (diff)
downloadjt-97755806efc52658a8eef434f3510fcc9e75d0b7.tar.gz
Add new-person subcommand
-rwxr-xr-xjt36
1 files changed, 36 insertions, 0 deletions
diff --git a/jt b/jt
index a60b34e..0df63bd 100755
--- a/jt
+++ b/jt
@@ -223,4 +223,40 @@ class JournalTool(cliapp.Application):
['git', 'push', 'origin', 'HEAD'],
cwd=self.settings['source'])
+ def cmd_new_person(self, args):
+ '''Create a page to list all notes referring to a person.
+
+ This is probably only useful to Lars's personal journal.
+
+ '''
+
+ if len(args) != 1:
+ raise cliapp.AppException(
+ 'Need the name of a person (in Last, First form)')
+
+ def normalise(name):
+ s = name.lower()
+ s = ' '.join(s.split(','))
+ s = '.'.join(s.split())
+ return s
+
+ name = args[0]
+ basename = normalise(name)
+ pathname = os.path.join(
+ self.settings['source'], 'people', basename + '.mdwn')
+
+ if os.path.exists(pathname):
+ raise cliapp.AppException('File %s already exists' % pathname)
+
+ with open(pathname, 'w') as f:
+ f.write('''\
+[[!meta title="%(name)s"]]
+
+[[!inline archive=yes pages="link(people/%(basename)s)"]]
+''' %
+ {
+ 'name': name,
+ 'basename': basename,
+ })
+
JournalTool().run()