diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-04-12 17:56:20 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-04-12 18:46:30 +0300 |
commit | 3a1f32c817f0b3f28afb9c87215a7502fe48864c (patch) | |
tree | f0d39eb5e19be1ebf6f3f53ceb83dfd2ae184e93 /subplot | |
parent | 924fc1add2de3edac4ad4b1097a3bbbb73d0ad50 (diff) | |
download | jt2-3a1f32c817f0b3f28afb9c87215a7502fe48864c.tar.gz |
feat: add "new-topic" command and "new --topic" option
This makes it easier to have "topic pages" in a journal, for
collecting entries related to a certain topic. The topic page uses
ikiwiki's !inline directive to collect pages linking to it.
Diffstat (limited to 'subplot')
-rw-r--r-- | subplot/jt.py | 7 | ||||
-rw-r--r-- | subplot/jt.yaml | 3 |
2 files changed, 10 insertions, 0 deletions
diff --git a/subplot/jt.py b/subplot/jt.py index 6ce75b0..d6023b3 100644 --- a/subplot/jt.py +++ b/subplot/jt.py @@ -135,6 +135,13 @@ def draft_contains_string(ctx, dirname=None, draftno=None, pattern=None): assert pattern in data +def draft_links_to_topic(ctx, dirname=None, draftno=None, topic=None): + logging.debug(f"checking draft {draftno} in {dirname} links to {topic!r}") + draft_contains_string( + ctx, dirname=dirname, draftno=draftno, pattern=f'\n[[!meta link="{topic}"]]\n' + ) + + def edit_draft(ctx, dirname=None, draftno=None, text=None): logging.debug(f"editing draft {draftno} in {dirname} to also contain {text!r}") draft = os.path.join(dirname, "drafts", f"{draftno}.md") diff --git a/subplot/jt.yaml b/subplot/jt.yaml index 65bf90e..a3d4f0f 100644 --- a/subplot/jt.yaml +++ b/subplot/jt.yaml @@ -43,6 +43,9 @@ - then: draft {draftno} in {dirname} contains "{pattern:text}" function: draft_contains_string +- then: draft {draftno} in {dirname} links to "{topic}" + function: draft_links_to_topic + - then: there are no journal entries in {dirname} function: journal_has_no_entries |