pyratelog

personal blog
git clone git://git.pyratebeard.net/pyratelog.git
Log | Files | Refs | README

commit 6edcf02544d2c68d0820bf87237149c0da9a83ce
parent 91bfbe9f45e5b9b027cbf6955f96e098883f2f64
Author: pyratebeard <root@pyratebeard.net>
Date:   Thu, 17 Nov 2022 22:06:02 +0000

Merge branch 'main' into as_a_matter_of_course

Diffstat:
MMakefile | 30+++++++++++++++---------------
Rpost_template.html -> entry_template.html | 0
Mpyratelog.sh | 2+-
Mscripts/draft | 12++++++------
Mscripts/preview | 18+++++++++---------
Mscripts/publish | 14+++++++-------
6 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/Makefile b/Makefile @@ -4,29 +4,29 @@ RND := "" # If the first argument is "draft" ifeq (draft,$(firstword $(MAKECMDGOALS))) # use the rest as arguments for "draft" - DRAFT_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) + ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) # ...and turn them into do-nothing targets - $(eval $(DRAFT_ARGS):;@:) + $(eval $(ARGS):;@:) else ifeq (preview,$(firstword $(MAKECMDGOALS))) - VIEW_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) - $(eval $(VIEW_ARGS):;@:) + ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) + $(eval $(ARGS):;@:) else ifeq (publish,$(firstword $(MAKECMDGOALS))) - PUB_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) - $(eval $(PUB_ARGS):;@:) + ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) + $(eval $(ARGS):;@:) endif endif endif -ifeq ($(DRAFT_ARGS), ) - DRAFT_ARGS := $(shell git branch --show-current) +ifeq ($(ARGS), ) + ARGS := $(shell git branch --show-current) endif -ifeq ($(VIEW_ARGS), ) - VIEW_ARGS := $(shell git branch --show-current) +ifeq ($(ARGS), ) + ARGS := $(shell git branch --show-current) endif -ifeq ($(PUB_ARGS), ) - PUB_ARGS := $(shell git branch --show-current) +ifeq ($(ARGS), ) + ARGS := $(shell git branch --show-current) endif prog: # ... @@ -35,10 +35,10 @@ prog: # ... .PHONY: draft preview publish draft : prog - scripts/draft $(DRAFT_ARGS) $(RND) + scripts/draft $(ARGS) $(RND) preview : prog - scripts/preview $(VIEW_ARGS) + scripts/preview $(ARGS) publish : prog - scripts/publish $(PUB_ARGS) + scripts/publish $(ARGS) $(RND) diff --git a/post_template.html b/entry_template.html diff --git a/pyratelog.sh b/pyratelog.sh @@ -47,7 +47,7 @@ for md in ${find_md} ; do # for new files we turn the markdown into html # using a template file pandoc -s \ - --template=./post_template.html \ + --template=./entry_template.html \ --metadata title="${input_title}" \ -f markdown \ -t html \ diff --git a/scripts/draft b/scripts/draft @@ -5,9 +5,9 @@ TITLE=$1 RND=$2 if [ "$RND" = "mov" ] || [ "$RND" = "lit" ] ; then - POST="entry/rnd.${RND}.rec:_${TITLE}.md" + ENTRY="entry/rnd.${RND}.rec:_${TITLE}.md" else - POST="entry/${TITLE}.md" + ENTRY="entry/${TITLE}.md" fi # checkout the correct branch @@ -21,13 +21,13 @@ else fi # if post file does not exist yet touch it -[ -f "${POST}" ] || touch "${POST}" +[ -f "${ENTRY}" ] || touch "${ENTRY}" # open post file in favourite editor -vim "${POST}" +vim "${ENTRY}" # when vim closes add and commit the changes # if there are any -git status | grep "${POST}" || exit 0 -git add "${POST}" +git status | grep "${ENTRY}" || exit 0 +git add "${ENTRY}" git commit -S -m "${TITLE}" diff --git a/scripts/preview b/scripts/preview @@ -1,23 +1,23 @@ #!/bin/bash -# use arg as title and set post file path +# use arg as title and set entry file path TITLE=$1 -POST="entry/${TITLE}.md" +ENTRY="entry/${TITLE}.md" # create a tmp dir mkdir demo -# copy post file, post_template and css +# copy entry file, entry_template and css # to temp dir -cp ${POST} demo/index.md -cp post_template.html style.css demo/ +cp ${ENTRY} demo/index.md +cp entry_template.html style.css demo/ -# small change to post_template for stylesheet -sed -i 's%\.\./%%' demo/post_template.html +# small change to entry_template for stylesheet +sed -i 's%\.\./%%' demo/entry_template.html # generate html file pandoc -s \ - --template=demo/post_template.html \ + --template=demo/entry_template.html \ --metadata title="demolog" \ -f markdown \ -t html \ @@ -28,7 +28,7 @@ pandoc -s \ busybox httpd -f -h ./demo -p 8080 & busypid=$! -# open demo post file in browser +# open demo entry file in browser xdg-open http://localhost:8080 # wait until ready to stop web server diff --git a/scripts/publish b/scripts/publish @@ -1,16 +1,16 @@ #!/bin/sh -# use arg as title and set post file path +# use arg as title and set entry file path # set published file path with date TITLE=$1 RND=$2 if [ "$RND" = "mov" ] || [ "$RND" = "lit" ] ; then - POST="entry/rnd.${RND}.rec:_${TITLE}.md" + ENTRY="entry/rnd.${RND}.rec:_${TITLE}.md" PUBLISH="entry/$(date +%Y%m%d)-rnd.${RND}.rec:_${TITLE}.md" LINK="https://log.pyratebeard.net/entry/$(date +%Y%m%d)-rnd.${RND}.rec:_${TITLE}.html" else - POST="entry/${TITLE}.md" + ENTRY="entry/${TITLE}.md" PUBLISH="entry/$(date +%Y%m%d)-${TITLE}.md" LINK="https://log.pyratebeard.net/entry/$(date +%Y%m%d)-${TITLE}.html" fi @@ -27,13 +27,13 @@ else exit 1 fi -# rename post to set date -git mv "${POST}" "${PUBLISH}" +# rename entry to set date +git mv "${ENTRY}" "${PUBLISH}" # commit the rename as published git commit -S -m "publish ${TITLE}" -# checkout main branch and merge published post +# checkout main branch and merge published entry git checkout main if [ "$RND" = "mov" ] || [ "$RND" = "lit" ] ; then git merge rnd.${RND}.rec @@ -41,7 +41,7 @@ else git merge "${TITLE}" fi -# push new post +# push new entry git push #cat <<log | $TOOT post || curl -d "log toot failed" https://pager.pyratebeard.net/logtoot