aboutsummaryrefslogtreecommitdiff
path: root/index.sh
diff options
context:
space:
mode:
authorJefferson Julio <[email protected]>2021-05-30 22:53:32 -0300
committerJefferson Julio <[email protected]>2021-05-30 22:53:32 -0300
commit381bff129b70471e86e99a2d6b6a7e090f13287e (patch)
tree35d383b4ec622efd8fbbd49a72c44a5561a04f92 /index.sh
parente9c35a9eff9e0881df7d6a6e8d17b70ac37ad0fe (diff)
downloadblog.sh-381bff129b70471e86e99a2d6b6a7e090f13287e.tar.bz2
blog.sh-381bff129b70471e86e99a2d6b6a7e090f13287e.zip
Better article parsing, support for article code parsing (add line numbers to code blocks)
Diffstat (limited to 'index.sh')
-rwxr-xr-xindex.sh14
1 files changed, 9 insertions, 5 deletions
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 <<HTML
<html lang="pt-br">
@@ -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="<p class='err-404'>404: .$REQUEST_URI: Arquivo ou diretório inexistente</p>"
;;
esac