From 381bff129b70471e86e99a2d6b6a7e090f13287e Mon Sep 17 00:00:00 2001 From: Jefferson Julio Date: Sun, 30 May 2021 22:53:32 -0300 Subject: Better article parsing, support for article code parsing (add line numbers to code blocks) --- components/post-preview.sh | 6 +-- header.sh | 8 ++-- index.sh | 14 ++++--- nav.sh | 9 ++--- pages/article.sh | 2 +- pages/home.sh | 15 ++++++- static/key-press.mp3 | Bin 0 -> 2632 bytes static/manifest.json | 15 +++++++ static/navigator.js | 87 +++++++++++++++++++++++++++++++++++++++++ static/styles.css | 30 ++++++++++++-- utils/parse-article-content.sh | 62 +++++++++++++++++++++++++++++ utils/parse-article.sh | 4 +- 12 files changed, 226 insertions(+), 26 deletions(-) create mode 100644 static/key-press.mp3 create mode 100644 static/manifest.json create mode 100644 static/navigator.js create mode 100755 utils/parse-article-content.sh diff --git a/components/post-preview.sh b/components/post-preview.sh index dbbf663..2708060 100755 --- a/components/post-preview.sh +++ b/components/post-preview.sh @@ -1,13 +1,13 @@ #!/bin/bash -source $SCRIPT_DIR/utils/parse-article.sh +DO_NOT_PROCESS_HTML=true source $SCRIPT_DIR/utils/parse-article.sh cat <
-
$ stat -c "%w" \\
> $ARTICLE_FILE
+
$ stat -c "%w" \\
> $ARTICLE_FILE_SANITIZED
$ARTICLE_BYTES
- +
    $( diff --git a/header.sh b/header.sh index a95aa47..968ac84 100644 --- a/header.sh +++ b/header.sh @@ -21,18 +21,18 @@ cat <

    - $ ${HEADER_TITLE/;/$ }
    + $ ${HEADER_TITLE//;/$ }

    - $ ${HEADER_TITLE_MOBILE/;/$ }
    + $ ${HEADER_TITLE_MOBILE//;/$ }

    HEADER diff --git a/index.sh b/index.sh index 76d8c8d..58d8f8e 100755 --- a/index.sh +++ b/index.sh @@ -10,7 +10,7 @@ source ./config.sh RESPONSE_CONTENT_TYPE="text/html" STATUS=200 -HEADER_TITLE='cd programadores/;cd Jefferson\\ Julio/;source jefferson.sh' +HEADER_TITLE='cd programadores/;cd Jefferson\ Julio/;source jefferson.sh' HEADER_TITLE_MOBILE="$HEADER_TITLE" urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; } @@ -23,6 +23,10 @@ strip-html-tags () { echo "$1" | sed 's/<[^>]*>//g' } +sanitize-filename () { + echo "${1// /\\ }" +} + html () { cat < @@ -62,8 +66,8 @@ router () { ;; /$ARTICLES_PATH*.txt) ARTICLE_FILE=.$REQUEST_URI - HEADER_TITLE="ARTICLE_FILE=$ARTICLE_FILE source pages/article.sh" - HEADER_TITLE_MOBILE="export ARTICLE_FILE=$ARTICLE_FILE;source pages/article.sh" + HEADER_TITLE="ARTICLE_FILE=$(sanitize-filename "$ARTICLE_FILE");source pages/article.sh" + HEADER_TITLE_MOBILE="ARTICLE_FILE=$(sanitize-filename "$ARTICLE_FILE");source pages/article.sh" BODY=$(source ./pages/article.sh) ;; /json) @@ -78,8 +82,8 @@ JSON ;; *) STATUS=404 - HEADER_TITLE="REQUEST_FILE=.$REQUEST_URI source page.sh" - HEADER_TITLE_MOBILE="export REQUEST_FILE=.$REQUEST_URI;source page.sh" + HEADER_TITLE="REQUEST_FILE=.$(sanitize-filename "$REQUEST_URI");source page.sh" + HEADER_TITLE_MOBILE="$HEADER_TITLE" BODY="

    404: .$REQUEST_URI: Arquivo ou diretório inexistente

    " ;; esac diff --git a/nav.sh b/nav.sh index 2b0049d..256b1e8 100755 --- a/nav.sh +++ b/nav.sh @@ -8,13 +8,10 @@ cat <