aboutsummaryrefslogtreecommitdiff
path: root/scripts/pastebin.sh
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2022-01-04 15:42:33 -0300
committerEuAndreh <eu@euandre.org>2022-01-04 15:42:33 -0300
commit0900f817a0a88eb8b209265e464aa1153ab4e76b (patch)
treee5387e6d689e6112f1271ec5093049538e0adf29 /scripts/pastebin.sh
parentscripts/todo: Remove script, which became the "td" project (diff)
downloaddotfiles-0900f817a0a88eb8b209265e464aa1153ab4e76b.tar.gz
dotfiles-0900f817a0a88eb8b209265e464aa1153ab4e76b.tar.xz
scripts/{post,pastebin}.sh: Remove scripts, which moved to the "website" project
Diffstat (limited to '')
-rwxr-xr-xscripts/pastebin.sh84
1 files changed, 0 insertions, 84 deletions
diff --git a/scripts/pastebin.sh b/scripts/pastebin.sh
deleted file mode 100755
index d306f878..00000000
--- a/scripts/pastebin.sh
+++ /dev/null
@@ -1,84 +0,0 @@
-#!/bin/sh
-set -eu
-
-usage() {
- cat <<EOF
-Missing argument <$1>.
-
-Usage:
- pastebin.sh <FULL_TITLE> [-|FILE]
-
- Reads contents from [FILE], from stdin if '-' is given, and opens the
- editor on the content.
-
- Arguments:
- FULL_TITLE Full title of the pastebin
-
-Examples:
- pastebin.sh 'My example pastebin title'
- pastebin.sh 'My example pastebin title' - < file
- cat file | pastebin.sh 'My example pastebin title' -
-EOF
-}
-
-FULL_TITLE="${1:-}"
-[ -z "$FULL_TITLE" ] && {
- usage 'FULL_TITLE'
- exit 2
-}
-
-# Derived from:
-# https://stackoverflow.com/questions/4009281/how-can-i-generate-url-slugs-in-perl/4009519#4009519
-slugify() {
- echo "$1" | \
- tr '[:upper:]' '[:lower:]' | \
- perl -ne 'tr/\000-\177//cd;
- s/[^\w\s-]//g;
- s/^\s+|\s+$//g;
- s/[-\s]+/-/g;
- print;'
-}
-
-SLUG_TITLE="$(slugify "$FULL_TITLE")"
-PASTE_DATE="$(date -I)"
-OUT="_pastebins/$PASTE_DATE-$SLUG_TITLE.md"
-if [ -n "${2:-}" ]; then
- shift
- CONTENT=$(cat "$@")
-else
- CONTENT='FIXME'
-fi
-
-cd ~/dev/libre/website > /dev/null
-
-[ -f "$OUT" ] && {
- echo "Pastebin named $OUT already exists."
- exit 1
-}
-
-cat <<EOF | vipe | sponge > "$OUT"
----
-
-title: ${FULL_TITLE}
-
-date: ${PASTE_DATE}
-
-layout: post
-
-lang: en
-
-ref: $SLUG_TITLE
-
----
-
-\`\`\`FIXME
-$CONTENT
-\`\`\`
-EOF
-
-git reset .
-git add "$OUT"
-git commit -m "$0: Auto-add $OUT"
-make publish
-open "https://euandre.org/pastebin/$(echo "$PASTE_DATE" | tr '-' '/')/$SLUG_TITLE.html"
-cd - > /dev/null