From cb5d00ef91736f184461906e335e24ab5243db8e Mon Sep 17 00:00:00 2001 From: Akshay Date: Tue, 23 Feb 2021 12:20:20 +0530 Subject: modify script to generate site summary + art page --- art/moonshine.png | Bin 0 -> 20634 bytes art/onigiri.png | Bin 0 -> 5551 bytes art/please_do_not_feed_the_animals.png | Bin 0 -> 2435361 bytes art/the_observer.png | Bin 0 -> 17556 bytes generate.sh | 150 +++++++++++++++++++++++++++++---- post.esh | 4 +- 6 files changed, 134 insertions(+), 20 deletions(-) create mode 100644 art/moonshine.png create mode 100644 art/onigiri.png create mode 100644 art/please_do_not_feed_the_animals.png create mode 100644 art/the_observer.png diff --git a/art/moonshine.png b/art/moonshine.png new file mode 100644 index 0000000..aa8b145 Binary files /dev/null and b/art/moonshine.png differ diff --git a/art/onigiri.png b/art/onigiri.png new file mode 100644 index 0000000..a44dbe1 Binary files /dev/null and b/art/onigiri.png differ diff --git a/art/please_do_not_feed_the_animals.png b/art/please_do_not_feed_the_animals.png new file mode 100644 index 0000000..5ceea55 Binary files /dev/null and b/art/please_do_not_feed_the_animals.png differ diff --git a/art/the_observer.png b/art/the_observer.png new file mode 100644 index 0000000..67f1929 Binary files /dev/null and b/art/the_observer.png differ diff --git a/generate.sh b/generate.sh index b246d61..5c556a0 100755 --- a/generate.sh +++ b/generate.sh @@ -1,6 +1,11 @@ #! /usr/bin/env nix-shell #! nix-shell -i bash -p eva pandoc esh +INDEX_BLOG_LIMIT=2 +INDEX_BLOG_COUNT=0 +INDEX_ART_LIMIT=1 +INDEX_ART_COUNT=0 + title_wrapper() { # remove extension # snake to title case @@ -42,33 +47,89 @@ link_wrapper() { " } +more_links() { + # 1 - sub page + cat << EOF + More ⟶ +EOF +} + +recent_link() { + # 1 - sub page + cat << EOF + Recent $1 +EOF +} + +art_block() { + # 1 - filename + # 2 - title + # 3 - date + echo -ne " + + +
+ $3 +
+ + $2 + + + + + + + + + " +} + intro() { echo -ne " -
+
Hi. - " } -cat > ./docs/index.html << EOF +n_logo() { + cat << EOF +

n

+

nerdypepper's μsings

+EOF +} + +# setup dirs + +posts=$(ls -t ./posts) +rm -rf "./docs/posts/" +mkdir -p docs/posts + +art=$(ls -t ./art) +rm -rf "./docs/art/" +mkdir -p docs/art +cp -r ./art/* docs/art/ + + +cat << EOF | tee ./docs/posts/index.html ./docs/art/index.html ./docs/index.html > /dev/null - - + + @@ -79,20 +140,38 @@ cat > ./docs/index.html << EOF peppe.rs +EOF + +# index +echo +echo "[+] INDEX" +echo "$(n_logo)" >> ./docs/index.html + +cat << EOF | tee -a ./docs/posts/index.html ./docs/art/index.html > /dev/null -

n

-

nerdypepper's μsings

+ ⟵ Back EOF -echo -ne "$(intro)" >> ./docs/index.html +cat << EOF >> ./docs/index.html + +
+
+ $(intro) +
+ $(recent_link "Posts") +EOF # posts -posts=$(ls -t ./posts) -mkdir -p docs/posts -rm -rf "./docs/posts/" +echo -ne " +

Blog

+
+
+ " >> ./docs/posts/index.html +echo +echo "[+] POSTS" for f in $posts; do file="./posts/"$f id="${file##*/}" # ill name my posts just fine @@ -109,7 +188,12 @@ for f in $posts; do echo "[~] $post_title" post_date=$(date -r "$file" "+%d/%m — %Y") post_link=$(link_wrapper "${id%.*}" "$post_title" "$post_date" "$r_time" "$height") - echo -ne "$post_link" >> docs/index.html + echo -ne "$post_link" >> ./docs/posts/index.html + + if [[ $INDEX_BLOG_COUNT -lt $INDEX_BLOG_LIMIT ]]; then + echo -ne "$post_link" >> ./docs/index.html + fi + ((INDEX_BLOG_COUNT+=1)) id="${id%.*}" mkdir -p "docs/posts/$id" @@ -124,13 +208,43 @@ for f in $posts; do intro="$(intro)" done +echo "$(more_links posts)" >> ./docs/index.html +echo "$(recent_link Art)" >> ./docs/index.html + +# art +echo -ne " +

Art

+
+
+ " >> ./docs/art/index.html + +echo +echo "[+] ART" + +for f in $art; do + file="./art/"$f + id="${file##*/}" + art_title=$(title_wrapper "$id") + art_date=$(date -r "$file" "+%d/%m — %Y") + art_post=$(art_block "$f" "$art_title" "$art_date") + echo "[~] $art_title" + echo -ne "$art_post" >> docs/art/index.html + + if [[ $INDEX_ART_COUNT -lt $INDEX_ART_LIMIT ]]; then + echo -ne "$art_post" >> ./docs/index.html + ((INDEX_ART_COUNT+=1)) + fi +done + +echo "$(more_links art)" >> ./docs/index.html + # generate rss feeds echo "generating RSS feeds ..." esh \ -o "./docs/index.xml" \ "rss.esh" -cat >> ./docs/index.html << EOF +cat << EOF | tee -a ./docs/posts/index.html ./docs/art/index.html > /dev/null