summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2014-11-22 20:10:25 +0200
committerLars Wirzenius <liw@liw.fi>2014-11-22 20:10:25 +0200
commitc8d40b889cd8f4d5c92c42f51ed555c38591dffe (patch)
treea8212be8ffb18d8cf0451273dbe81c98084d85d9
parent39055e208b1fcb6fc3e5c975f4b529fe6c051c67 (diff)
downloadjt-c8d40b889cd8f4d5c92c42f51ed555c38591dffe.tar.gz
Add test for and implement using topic pages
-rwxr-xr-xjt17
-rw-r--r--yarns/030-topics.yarn9
2 files changed, 24 insertions, 2 deletions
diff --git a/jt b/jt
index 6ce9ffc..22f05a6 100755
--- a/jt
+++ b/jt
@@ -36,6 +36,8 @@ template = '''\
[[!tag ]]
[[!meta date="%(date)s"]]
+%(topiclink)s
+
'''
@@ -115,10 +117,12 @@ class NewCommand(Command):
raise cliapp.AppException('Usage: journal-note new TITLE')
self._app.settings.require('source')
+ topic = self._app.settings['topic']
values = {
'title': args[0],
- 'date': time.strftime('%Y-%m-%d %H:%M')
+ 'date': time.strftime('%Y-%m-%d %H:%M'),
+ 'topiclink': self._get_topic_link(topic),
}
drafts_dir = DraftsDirectory(self._app.drafts_dir())
@@ -126,6 +130,12 @@ class NewCommand(Command):
draft_id = drafts_dir.create_draft(template % values)
self._app.edit_file(drafts_dir.get_draft_pathname(draft_id))
+ def _get_topic_link(self, topic):
+ if topic:
+ return 'Part of [[%s]]' % topic
+ else:
+ return ''
+
class ListCommand(Command):
@@ -329,6 +339,11 @@ class JournalTool(cliapp.Application):
'push finished articles with git?')
self.settings.string(
+ ['topic'],
+ 'new entry belongs to TOPIC',
+ metavar='TOPIC')
+
+ self.settings.string(
['pretend-time'],
'pretend that the time is NOW (form: YYYY-MM-DD HH:MM:DD form)',
metavar='NOW')
diff --git a/yarns/030-topics.yarn b/yarns/030-topics.yarn
index 4595604..e931ae3 100644
--- a/yarns/030-topics.yarn
+++ b/yarns/030-topics.yarn
@@ -4,7 +4,14 @@ Using Topics
A topic is implemented as a wiki page to which journal entries link.
First we create a topic page:
- SCENARIO create topic page
+ SCENARIO create and use topic page
GIVEN an empty journal in SRC
WHEN I run jt new-topic research/2014/dishwasher Dishwasher
THEN file SRC/research/2014/dishwasher.mdwn matches title="Dishwasher"
+
+After this, we can create a new journal entry that belongs to the
+topic.
+
+ GIVEN the time is 2014-11-20 20:04:08
+ WHEN I run jt new --topic=research/2014/dishwasher TITLE
+ THEN file SRC/drafts/0.mdwn matches research/2014/dishwasher