From 4bf2c17e3f647ebf004b2a1ca5e6eb682e4ad966 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 20 Nov 2022 10:22:00 +0000 Subject: add --draft switch --- README.md | 2 +- gemtexter | 5 ++++- lib/generate.source.sh | 13 +++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 663fab4..df001ae 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ You can also have a look at `$BASE_CONTENT_DIR/meta/gemfeed`. There is a metafil ## Drafting a blog post before publishing it -If you don't want to publish your article yet (e.g. don't advertise it on the Gemfeed and Atom feed yet), you can draft your article in `./gemtext/gemfeed/DRAFT-article-title-dash-separated.gmi`. Gemtexter will still generate all output formats of the draft, but your site visitors won't be aware of it. Once you want to publish your draft just rename `DRAFT` with the publishing date `YYYY-MM-DD` and from there everything works normally. +If you don't want to publish your article yet (e.g. don't advertise it on the Gemfeed and Atom feed yet), you can draft your article in `./gemtext/gemfeed/DRAFT-article-title-dash-separated.gmi` and when invoke `./gemtexter --draft` to generate the outputs. Once you want to publish your draft just rename `DRAFT` with the publishing date `YYYY-MM-DD` and from there everything works normally. ## Ready to be published diff --git a/gemtexter b/gemtexter index 2e41d88..71fe298 100755 --- a/gemtexter +++ b/gemtexter @@ -4,7 +4,7 @@ # by Paul Buetow 2021, 2022 declare -r ARG="$1"; shift -declare -r CONTENT_FILTER="$1"; shift +declare CONTENT_FILTER="$1"; shift declare -r VERSION=1.2.0 declare -r VERSION_DESCR=develop @@ -131,6 +131,9 @@ main () { --version) echo "This is gemtexter version $VERSION $VERSION_DESCR" ;; + --draft) + generate::draft html md + ;; --publish) $0 --generate $0 --git diff --git a/lib/generate.source.sh b/lib/generate.source.sh index 5392163..9a9e90b 100644 --- a/lib/generate.source.sh +++ b/lib/generate.source.sh @@ -185,3 +185,16 @@ generate::fromgmi () { done log INFO "You may want to commit all changes to version control!" } + +# Only generate draft posts +generate::draft () { + if [ ! -z "$CONTENT_FILTER" ]; then + log ERROR "ERROR, you can't set a content filter manually in draft mode" + exit 2 + fi + CONTENT_FILTER=DRAFT- + generate::fromgmi $@ + + log INFO 'For HTML preview, open in your browser:' + find $CONTENT_BASE_DIR/html -name DRAFT-\*.html +} -- cgit v1.2.3