2021-02-26 11:37:59 +00:00
#!/bin/bash
SOURCE_DIR = ~/blog_source
ASSETS_DIR = $SOURCE_DIR /assets
WEB_DIR = ~/public_html
rm -r $WEB_DIR /*
cp $SOURCE_DIR /posts/*.html $WEB_DIR /
mkdir -p $WEB_DIR /assets/jpeg
mkdir -p $WEB_DIR /assets/png
mkdir -p $WEB_DIR /assets/svg
mkdir -p $WEB_DIR /assets/css
2021-02-27 00:45:03 +00:00
cp $ASSETS_DIR /jpeg/* $WEB_DIR /assets/jpeg/
2021-02-26 11:37:59 +00:00
# cp $ASSETS_DIR/assets/png/* $WEB_DIR/assets/png/
cp $ASSETS_DIR /svg/* $WEB_DIR /assets/svg/
cp $ASSETS_DIR /css/* $WEB_DIR /assets/css/
cp $SOURCE_DIR /index.html $SOURCE_DIR /index.html.temp
LINE = ` grep -Fn 'id="posts"' $SOURCE_DIR /index.html | cut -d : -f 1`
LINE = $(( $LINE + 1 ))
for FILE in ` ls -tr $SOURCE_DIR /posts | grep -v /`
do
NAME = ${ FILE %.html }
SPACES = ` tr -s '_' ' ' <<< " $NAME " `
ENTRY = " posts/ ${ FILE } "
TIME_MODIFIED = ` stat -c %y ${ ENTRY } | grep -oE "\w{4}-\w{2}-\w{2} \w{2}:\w{2}:\w{2}" `
sed -i " $LINE i <a href=\"https://tilde.club/~chmod777/ ${ FILE } \"> ${ SPACES } </a><p>Last modified on: <time datetime=\" ${ TIME_MODIFIED } \"> ${ TIME_MODIFIED } UTC</time></p> " $SOURCE_DIR /index.html.temp
done
cp $SOURCE_DIR /index.html.temp $WEB_DIR /index.html
rm index.html.temp