diff --git a/new-post.sh b/new-post.sh index ba7c047..0ca49e5 100755 --- a/new-post.sh +++ b/new-post.sh @@ -1,8 +1,35 @@ -nvim -c '39' -c 'norm yypk14w' sitemap/index.html -nvim -c '3' -c 'norm yypk10w' blog/index.html -nvim -c '3' -c 'norm yypk10w' blog/linux/index.html -nvim -c '3' -c 'norm yypk10w' blog/software/index.html -nvim -c '3' -c 'norm yypk10w' blog/technology/index.html -nvim -c '3' -c 'norm yypk10w' blog/design/index.html -nvim -c '3' -c 'norm yypk10w' blog/guides/index.html -nvim -c '3' -c 'norm yypk10w' blog/other/index.html +#!/bin/sh + +# Script for new posts + +FILE=/tmp/sufyaan-website-post$(date +%d).md + +echo '- [ ] Linux\n- [ ] Software\n- [ ] Technology\n- [ ] Design\n- [ ] Guides\n- [ ] Literary\n- [ ] Other' > $FILE +nvim $FILE +CATSTR="$(grep 'X' $FILE | cut -d' ' -f3 | tr -d \\n | sed 's/[A-Z]/ \&\& &/g')" +CATFIN="$(echo $CATSTR | cut --complement -d' ' -f1 | sed 's/\(Linux\|Software\|Technology\|Design\|Guides\|Literary\|Other\)/&<\/strong><\/a>/g' | sed 's/\/blog\/\(Linux\|Software\|Technology\|Design\|Guides\|Literary\|Other\)/\L&/g' | sed 's/\//\\\//g' | sed 's/\&\&/\\\&\\\&/g')" +POSTED=$(date +'%d %B %Y') +read -p "Enter post title: " TITLE +read -p "Enter post relative URL: " URL +read -p "Enter reading time: " READ +read -p "Enter previous post: " PREVPOST +EMAIL=$(echo $TITLE | sed 's/ /%20/g') + +cd ~/docs/sys/gits/sufyaan-website +mkdir -p $URL +cp template.html $URL/index.html + +# Replacing placeholders with values in new post +sed -i "s/POST TITLE/$TITLE/g" $URL/index.html +sed -i "s/POST DATE/$POSTED/g" $URL/index.html +sed -i "s/READING/$READ/g" $URL/index.html +sed -i "s/MAILSUBJECT/$EMAIL/g" $URL/index.html +sed -i "s/URL/$URL/g" $URL/index.html +sed -i "s/PREVIOUSPOST/$PREVPOST/g" $URL/index.html +sed -i "s/POSTCATEGORIES/$CATFIN/g" $URL/index.html +ORIGINALFOOTER="First Post<\/a> <\/svg><\/p>" +NEWFOOTER="Next Post<\/a> <\/mask><\/svg><\/p>" +sed -i "s/$ORIGINALFOOTER/$NEWFOOTER/g" $PREVPOST/index.html + +# Removing temporary file +rm $FILE diff --git a/template.html b/template.html new file mode 100644 index 0000000..a29b27f --- /dev/null +++ b/template.html @@ -0,0 +1,33 @@ + + + + (POST) POST TITLE + + + + + + + +
+ _______ _     _ _______ __   __ _______ _______ __   _
+ |______ |     | |______   \_/   |_____| |_____| | \  |
+ ______| |_____| |          |    |     | |     | |  \_|
+	  
+
+ +

sf.cu > Blog > POST TITLE

+

POST TITLE

+

Posted on: POST DATE

+

Reading time: READING min +

Category: POSTCATEGORIES

+ +

>>> Reply To Me

+

>>> Download PDF

+

Previous Post - First Post

+
+ +