aboutsummaryrefslogtreecommitdiff
path: root/pages
diff options
context:
space:
mode:
authorTelérico Jones <[email protected]>2021-05-29 21:09:08 -0300
committerTelérico Jones <[email protected]>2021-05-29 21:09:08 -0300
commitcade848b78d7f06b69a195f5a543b23c25eedd14 (patch)
tree6f6b4f766a58ccd61452da7a32830f051a89003e /pages
downloadblog.sh-cade848b78d7f06b69a195f5a543b23c25eedd14.tar.bz2
blog.sh-cade848b78d7f06b69a195f5a543b23c25eedd14.zip
blog.sh project start
Diffstat (limited to 'pages')
-rwxr-xr-xpages/article.sh52
-rw-r--r--pages/contato.sh13
-rwxr-xr-xpages/home.sh25
3 files changed, 90 insertions, 0 deletions
diff --git a/pages/article.sh b/pages/article.sh
new file mode 100755
index 0000000..9832a76
--- /dev/null
+++ b/pages/article.sh
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+ARTICLE_TITLE=$(basename "$ARTICLE_FILE")
+
+# Pick all file content
+ARTICLE_FILE_CONTENT=$(cat "$ARTICLE_FILE")
+
+# The first 3 lines of the file are metadata information
+ARTICLE_METADATA=$(echo "$ARTICLE_FILE_CONTENT" | head -n 3)
+
+# Skip file metadata, first 3 lines
+ARTICLE_CONTENT=$(echo "$ARTICLE_FILE_CONTENT" | tail -n +3)
+
+# Tags are placed on the first line of the file, delimited by commas
+IFS=',' read -ra ARTICLE_TAGS <<< "$(echo "$ARTICLE_METADATA" | head -n 1)"
+
+ARTICLE_TIME=$(stat --format="Criado em: %w<br/>Última atualização: %z" "$ARTICLE_FILE")
+ARTICLE_BYTES=$(stat --format="%o bytes" "$ARTICLE_FILE")
+
+if [ $? -gt 0 ]; then
+ STATUS=404
+ cat <<ERR
+<p class="err-404">cat: $ARTICLE_FILE: Arquivo ou diretório inexistente</p>
+ERR
+ exit 0
+fi
+
+cat <<ARTICLE
+<article class="container">
+ <section>
+ <div class="post-header">
+ <h4 class="post-title">stat -c "%o %w %z" $ARTICLE_FILE</h4>
+ <small>$ARTICLE_BYTES</small> <br/>
+ <time>$ARTICLE_TIME</time> <br/>
+
+ <ul class="tags">
+ $(
+ for i in "${ARTICLE_TAGS[@]}"; do
+ echo "<li class="tag">$i</li>"
+ done
+ )
+ </ul>
+ </div>
+
+ <div class="post-content">
+ <p>
+ ${ARTICLE_CONTENT}
+ </p>
+ </div>
+ </section>
+</article>
+ARTICLE
diff --git a/pages/contato.sh b/pages/contato.sh
new file mode 100644
index 0000000..74d1ad4
--- /dev/null
+++ b/pages/contato.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+cat <<PAGE
+<style>
+ @media screen and (max-width: 600px) {
+ .contato-page {
+ text-align: center;
+ }
+ }
+</style>
+
+<article class="contato-page container">
+</article>
+PAGE
diff --git a/pages/home.sh b/pages/home.sh
new file mode 100755
index 0000000..ebb399d
--- /dev/null
+++ b/pages/home.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+print-all-articles () {
+ for i in $(find ./pages/articles -type f -name '*.txt'); do
+ ARTICLE_CONTENT=$(tail -n +3 $i)
+ cat <<POST
+<section class="post-preview">
+ <div class="post-header-preview">
+ <h5 class="post-title">stat -c "%w %z" $i</h5>
+ <time>$(stat --format="Criado em: %w<br/>Última atualização: %z" $i)</time>
+ </div>
+
+ <p>$(echo "$ARTICLE_CONTENT" | head -c 120)...</p>
+
+ <a href="/artigo/$(basename $i)">Ler artigo completo</a>
+</section>
+POST
+ done
+}
+
+cat <<PAGE
+<article class="home-feed container">
+ $(print-all-articles)
+</article>
+PAGE