[download]

local/bin/bloge

   1 #!/bin/bash
   2 #         ░███████
   3 #       ░███████       D O T F I L E S
   4 #       ░███████       B L O G E
   5 #    ░█████████████
   6 #       ░███████
   7 #       ░███████       LGPL <http://www.gnu.org/licenses/>
   8 #       ░██  ░██
   9 #       ░██  ░██   (C) 2018-2020 Alexey Gagin <http://www.lexa.by/dotfiles/>
  10 
  11 cd ~/Lexa.by/bloge || exit
  12 
  13 post=$(mktemp -u).md
  14 news=$(date +%Y)/news.txt
  15 
  16 [[ $1 == -l || $1 == --list ]] &&
  17 awk -F / '{ print NR ". #" $2 " " substr($3, 1, 70) }' $news &&
  18 exit
  19 
  20 [[ $1 ]] &&
  21 sed 's/\\n/\n/g; '$1'q; d' $news |
  22 pandoc -f html -o $post ||
  23 date +'%F %H:%M//' > $post
  24 
  25 cp $post $post.orig
  26 ${EDITOR:-vim} $post
  27 diff $post* && exit
  28 
  29 meta=$(sed 1q $post)
  30 body=$(sed 1d $post | pandoc -t html)
  31 body=$(sed 'y/“‘’”/«„“»/' <<< "$body")
  32 body=${body//$'\n'/\\\\n}
  33 
  34 sed -i "${1:-$}a\\$meta$body" $news
  35 [[ $1 ]] && sed -i $1d $news
  36 
  37 ./build.php