pyratelog

personal blog
git clone git://git.pyratebeard.net/pyratelog.git
Log | Files | Refs | README

commit 78af07bffe4e201df4bc61b4125a4c7b9cdebd1d
parent d875516e3a23de6d9348e3be93514850ec3bb783
Author: pyratebeard <root@pyratebeard.net>
Date:   Sat, 23 Jan 2021 15:08:45 +0000

updates for script location. add busybox Sat 23 Jan 15:08:45 GMT 2021 check and output as unix time

Diffstat:
Mpyratelog.sh | 25+++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/pyratelog.sh b/pyratelog.sh @@ -1,14 +1,20 @@ #!/bin/bash function initialise() { - cd /blog - find_md=$(find content/ -type f -name "*.md") + find_md=$(find entry/ -type f -name "*.md" | sort) for md in ${find_md} ; do input=$(echo ${md} | cut -f2 -d '/' | cut -f1 -d '.') + input_date=$(echo ${input} | cut -f1 -d '-' ) - input_date=$(date -d ${input_date} -D "%Y%m%d" +%Y\ %m\ %d) + ls -l /bin/date | grep busybox >/dev/null && \ + # busybox `date` works differently + index_date=$(date -d ${input_date} -D "%Y%m%d" +%s) || \ + index_date=$(date -d ${input_date} +%s) + input_title=$(echo ${input} | cut -f2 -d '-' | sed 's/_/\ /g') - input_link="<li><a class="index" href='content/${input}.html'>${input_date} - ${input_title}</a></li>" + index_title=$(echo ${input_title}) + + input_link="<li><a class='index' href='entry/${input}.html'><b>${index_date}</b> ${index_title}</a></li>" grep ${input} index.html >/dev/null && return @@ -17,18 +23,17 @@ function initialise() { --metadata title="${input_title}" \ -f markdown \ -t html \ - -o content/${input}.html \ - content/${input}.md + -o entry/${input}.html \ + entry/${input}.md - sed "/<ul>/a ${input_link}" index.html > index.html.bak + sed "/<ul class='index'>/a ${input_link}" index.html > index.html.bak cat index.html.bak >index.html - rm -f content/${input}.md index.html.bak + rm -f index.html.bak done } while : ; do - #[ -f /blog/content/*.md ] && initialise || sleep 30 - ls /blog/content/*.md >/dev/null 2>&1 && initialise || sleep 30 + ls ./entry/*.md >/dev/null 2>&1 && initialise || sleep 30 done