From c32279f814da799b1f09709fe332d626455f19e5 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sat, 22 Dec 2018 19:21:56 -0200 Subject: Add script to scaffold new pastebin skeleton. --- Makefile | 5 +++++ pastebin-template.org | 3 --- pastebin/new.sh | 23 +++++++++++++++++++++++ pastebin/skeleton.org | 5 +++++ pastebin/template.org | 3 +++ 5 files changed, 36 insertions(+), 3 deletions(-) delete mode 100644 pastebin-template.org create mode 100755 pastebin/new.sh create mode 100644 pastebin/skeleton.org create mode 100644 pastebin/template.org diff --git a/Makefile b/Makefile index c64c4c8..9b9cc69 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,11 @@ publish: rsync --verbose --copy-links --progress --stats --update --recursive result/ root@euandre.org:/home/user-data/www/default .PHONY: publish +## Create a new pastebin file from the template. +pastebin: + @./pastebin/new.sh +.PHONY: pastebin + # Taken from https://gist.github.com/klmr/575726c7e05d8780505a # Inspired by diff --git a/pastebin-template.org b/pastebin-template.org deleted file mode 100644 index 3856724..0000000 --- a/pastebin-template.org +++ /dev/null @@ -1,3 +0,0 @@ -#+BIND: org-html-postamble-format (("en" "

%T

"))) -#+HTML_HEAD: -#+HTML_HEAD: diff --git a/pastebin/new.sh b/pastebin/new.sh new file mode 100755 index 0000000..b792e33 --- /dev/null +++ b/pastebin/new.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -eo pipefail +cd "$(dirname ${BASH_SOURCE[0]})" + +OUTDIR="../site/pastebin" + +# Taken from: +# https://stackoverflow.com/a/49035906 +slugify () { + echo "$1" | iconv -t ascii//TRANSLIT | sed -r s/[~\^]+//g | sed -r s/[^a-zA-Z0-9]+/-/g | sed -r s/^-+\|-+$//g | tr A-Z a-z +} + +if [[ -z "$1" ]]; then + printf "Type the pastebin title: " + read title +else + title="$1" +fi + +slug=$(slugify "$title") + +export title +cat skeleton.org | envsubst > "$OUTDIR/$slug.org" diff --git a/pastebin/skeleton.org b/pastebin/skeleton.org new file mode 100644 index 0000000..8349906 --- /dev/null +++ b/pastebin/skeleton.org @@ -0,0 +1,5 @@ +#+SETUPFILE: ../../pastebin/template.org +#+TITLE: $title +#+BEGIN_SRC FIXME -n +FIXME +#+END_SRC diff --git a/pastebin/template.org b/pastebin/template.org new file mode 100644 index 0000000..3856724 --- /dev/null +++ b/pastebin/template.org @@ -0,0 +1,3 @@ +#+BIND: org-html-postamble-format (("en" "

%T

"))) +#+HTML_HEAD: +#+HTML_HEAD: -- cgit v1.2.3