new-article (626B)
1 #!/bin/sh -e 2 3 cd ~/repos/riazj.com/articles 4 5 gitstat="$(git status -s . | grep "^??")" 6 article="${gitstat#* }" 7 8 text2html "$article" 9 grep -q '<meta name="description" content="">' "$article" && 10 echo "new-article: no article description" && exit 1 11 12 tidy -mq -wrap --keep-tabs yes --tidy-mark no "$article" 13 14 title="$(grep -im1 "<title>" "$article")" 15 title="${title#*>}"; title="${title% |*}" 16 article="${article%.html}" 17 18 sed -i "/<ul>/a\<li><time datetime=\"$(date +%F)\">$(date +'%Y %b %d')</time>\ 19 <a href=\"/articles/$article\">$title</a></li>" "../index.html" 20 21 git add -A; git commit -m "Write article about $*"; git push