diff options
Diffstat (limited to 'build.sh')
-rwxr-xr-x | build.sh | 137 |
1 files changed, 100 insertions, 37 deletions
@@ -46,15 +46,7 @@ for i in *.md; do convert "../con/contact.md" "../tmp/con-contact-tmp-file.html" - cat ../con/header.html \ - ../tmp/"$filename".html \ - ../tmp/con-contact-tmp-file.html \ - ../con/footer.html \ - > ../web/"$filename".html - - cat "$i" \ - ../con/contact.md \ - > ../web/"$filename".md + echo "[build] skipping index file for later..." else @@ -74,6 +66,10 @@ done echo "[build] writing articles..." cd ./articles/ +declare -A articlearr +declare -a workingarr +declare -a thebestarr + for i in *.md; do echo "[build] converting: $i" @@ -94,10 +90,7 @@ for i in *.md; do cp "$i" ../../web/articles/"$filename"/index.md - export WEBMETA_TITLE="" export WEBMETA_DATE="" - export WEBMETA_AUTH="" - export WEBMETA_SUMMARY="" if [ -e "$filename".meta ]; then echo "[build] running script: $filename.meta" @@ -111,57 +104,127 @@ for i in *.md; do # please note that you have to actually check if this data is correct # and you should not just import random `.meta` files as they can arbitrarily # execute code on your system and are directly injected into the HTML. + # + # NOTE: + # I do not expect to have multiple articles written on the same day + # as I am a lazy fuck. The generator below does not expect multiple + # articles to have the exact same date. + # If I were you, I would maybe add hours and minutes to the timestamps + # and maybe change this script accordingly. fi - + if [ "$WEBMETA_DATE" == "" ]; then - export WEBMETA_DATE="2001-09-11*REDACTED!*" - fi - if [ "$WEBMETA_AUTH" == "" ]; then - export WEBMETA_AUTH="Anonymous" - fi - if [ "$WEBMETA_SUMMARY" == "" ]; then - export WEBMETA_SUMMARY="redacted" + export WEBMETA_DATE="2001-09-11*" fi - if [ "$WEBMETA_TITLE" == "" ]; then - export WEBMETA_TITLE="$filename" + + articlearr["$filename"]="$WEBMETA_DATE" + + fi + +done + +echo "[build] sorting articles..." + +workingarr=($( sort -nr < <(printf '%s\n' "${articlearr[@]}") )) + +for date in "${workingarr[@]}"; do + for key in "${!articlearr[@]}"; do + if [ "${articlearr[$key]}" == "$date" ]; then + thebestarr+=("$key") fi + done +done + +for i in "${thebestarr[@]}"; do + + export WEBMETA_TITLE="" + export WEBMETA_DATE="" + export WEBMETA_AUTH="" + export WEBMETA_SUMMARY="" + if [ -e "$i".meta ]; then + echo "[build] re-running script: $i.meta" + source ./"$i".meta + # see above + fi - touch ../../tmp/articles/gen-articles-tmp-list.html - tee -a ../../tmp/articles/gen-articles-tmp-list.html > /dev/null << EOF + if [ "$WEBMETA_DATE" == "" ]; then + export WEBMETA_DATE="2001-09-11*" + fi + if [ "$WEBMETA_AUTH" == "" ]; then + export WEBMETA_AUTH="Anonymous" + fi + if [ "$WEBMETA_SUMMARY" == "" ]; then + export WEBMETA_SUMMARY="redacted" + fi + if [ "$WEBMETA_TITLE" == "" ]; then + export WEBMETA_TITLE="$i" + fi + + if [ "$i" == "${thebestarr[0]}" ]; then + tee ../../tmp/articles/gen-first-article-tmp.html > /dev/null << EOF + <h2>Latest Post:</h2> + <article> + <a href="/articles/$i"><h3>$WEBMETA_TITLE</h3></a> + <h6><code>$WEBMETA_DATE</code> by $WEBMETA_AUTH</h6> + <p>$WEBMETA_SUMMARY</p> + </article> + <a href="/articles/"><h5>See more Articles →</h5></a> +EOF + tee ../../tmp/articles/gen-first-article-tmp.md > /dev/null << EOF + +## Latest Post: + +## [$WEBMETA_TITLE](/articles/$i) +###### \`$WEBMETA_DATE\` by $WEBMETA_AUTH +$WEBMETA_SUMMARY +EOF + fi + + touch ../../tmp/articles/gen-articles-tmp-list.html + tee -a ../../tmp/articles/gen-articles-tmp-list.html > /dev/null << EOF <article> - <a href="$filename"><h2>$WEBMETA_TITLE</h2></a> + <a href="$i"><h2>$WEBMETA_TITLE</h2></a> <h6><code>$WEBMETA_DATE</code> by $WEBMETA_AUTH</h6> <p>$WEBMETA_SUMMARY</p> </article> EOF - touch ../../tmp/articles/gen-articles-tmp-list.md - tee -a ../../tmp/articles/gen-articles-tmp-list.md > /dev/null << EOF + touch ../../tmp/articles/gen-articles-tmp-list.md + tee -a ../../tmp/articles/gen-articles-tmp-list.md > /dev/null << EOF -## [$WEBMETA_TITLE]($filename) +## [$WEBMETA_TITLE]($i) ###### \`$WEBMETA_DATE\` by $WEBMETA_AUTH $WEBMETA_SUMMARY EOF - touch ../../tmp/articles/gen-articles-tmp-rss.xml - tee -a ../../tmp/articles/gen-articles-tmp-rss.xml > /dev/null << EOF + touch ../../tmp/articles/gen-articles-tmp-rss.xml + tee -a ../../tmp/articles/gen-articles-tmp-rss.xml > /dev/null <<EOF <item> <title>$WEBMETA_TITLE</title> - <pubDate>$(date -d "${WEBMETA_DATE:0:10}" +"%a, %d %b %Y %H:%M:%S +0000" )</pubDate> - <author>$WEBMETA_AUTHOR</author> + <pubDate>$(date -d "${WEBMETA_DATE:0:10}" +"%a, %d %b %Y %H:%M:%S +0000")</pubDate> + <author>$WEBMETA_AUTH</author> <description>$WEBMETA_SUMMARY</description> - <link>/$filename</link> - <guid>/$filename</guid> + <link>/$i</link> + <guid>/$i</guid> </item> EOF - fi - done +echo "[build] generating feed..." cd ../.. -echo "[build] generating feed..." +cat ./con/header.html \ + ./tmp/index.html \ + ./tmp/articles/gen-first-article-tmp.html \ + ./tmp/con-contact-tmp-file.html \ + ./con/footer.html \ + > ./web/index.html + +cat ./src/index.md \ + ./tmp/articles/gen-first-article-tmp.md \ + ./con/contact.md \ + > ./web/index.md cat ./con/header.html \ ./tmp/articles/index.html \ |