From 4eed9a1ddd5fec1f69552e6e31266c34bbe5a64e Mon Sep 17 00:00:00 2001 From: "wjak56@gmail.com" Date: Wed, 26 Aug 2015 03:27:03 -0400 Subject: [PATCH] Ability to add and clear tags through environment variables --- api.rkt | 9 +++++---- tagadd.rkt | 14 ++++++++++++++ tagadd.sh | 5 +++++ tagclear.sh | 4 ++++ 4 files changed, 28 insertions(+), 4 deletions(-) create mode 100755 tagadd.rkt create mode 100755 tagadd.sh create mode 100755 tagclear.sh diff --git a/api.rkt b/api.rkt index 1aaab57..4037559 100644 --- a/api.rkt +++ b/api.rkt @@ -402,7 +402,7 @@ (define (get-current-tag post) (hash-ref current-tags (format "~a_tags" - (regexp-replace* #px"\\|\\." post "_")) + (regexp-replace* #px"\\/|\\." post "_")) #f)) @@ -450,8 +450,8 @@ (let* ([post-status (car post-file)] [post (cadr post-file)] [categories (get-categories post)] - [tags (check-tags post current-tags)]) - (displayln tags) + [tags (check-tags post)]) + (displayln current-tags) (match (git-href post #f) @@ -490,4 +490,5 @@ password username xstring - in-blog?) + in-blog? + add-tag-env) diff --git a/tagadd.rkt b/tagadd.rkt new file mode 100755 index 0000000..dfc2f4f --- /dev/null +++ b/tagadd.rkt @@ -0,0 +1,14 @@ +#! /usr/bin/racket +#lang racket + +(require "api.rkt") + +(define argv + (current-command-line-arguments)) + +(displayln + (add-tag-env + (vector-ref argv 0) + (vector-ref argv 1))) + +(displayln (environment-variables-names (current-environment-variables))) diff --git a/tagadd.sh b/tagadd.sh new file mode 100755 index 0000000..0d3c6c6 --- /dev/null +++ b/tagadd.sh @@ -0,0 +1,5 @@ +#! /usr/bin/bash + +# add a tag to the environment +name="$(echo "$(realpath --relative-to=/home/wes/myblog ${1})" | sed "s/[\:\.\/\\ \n]/_/g")_tags" +export "$name"="${!name}:#${2}" diff --git a/tagclear.sh b/tagclear.sh new file mode 100755 index 0000000..101eef7 --- /dev/null +++ b/tagclear.sh @@ -0,0 +1,4 @@ +#! /usr/bin/bash + +name="$(echo "$(realpath --relative-to=/home/wes/myblog ${1})" | sed "s/[\:\.\/\\ \n]/_/g")_tags" +unset "$name"