kloeckner.com.ar

a backup of my entire webpage
Index Commits Files Refs README LICENSE
commit 45eb084b422ece18e50885a110bcaa372d796ffb
parent fc218a7f4fd71eaa29a73b5f78aac396200383f4
Author: mjkloeckner <martin.cachari@gmail.com>
Date:   Sat, 15 Oct 2022 22:13:37 -0300

General dir structure reorganization, scripts folder introduced

This commits adds a new folder, `scripts` which includes all the
scripts that are used to generate the content of the webpage

Also the build_page.sh script was having a fault in which the article
date was not set properly causing article-date.js to malfunction

Diffstat:
Darticle-title-with-icon.html | 6------
Mblog.html | 2+-
Mblog/dwm-config/dwm-config.html | 2+-
Mblog/nerdearla-2022/nerdearla-2022.html | 2+-
Mblog/sav/sav.html | 2+-
Mblog/vim-config/vim-config.html | 4++--
Dbuild.sh | 13-------------
Dbuild_page.sh | 139-------------------------------------------------------------------------------
Rblog_index.shtml -> common/blog_index.shtml | 0
Rlatest_uploads.shtml -> common/latest_uploads.shtml | 0
Mindex.html | 2+-
Rjs/article-date.js -> scripts/article-date.js | 0
Ascripts/article-title-with-icon.html | 6++++++
Ascripts/build.sh | 15+++++++++++++++
Ascripts/build_page.sh | 140+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ascripts/deploy_local.sh | 11+++++++++++
Rrss_feed_top.xml -> scripts/rss_feed_top.xml | 0
Rsort_blog_index.py -> scripts/sort_blog_index.py | 0
Ascripts/sync.sh | 105+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ascripts/template.html | 31+++++++++++++++++++++++++++++++
Dsync.sh | 111-------------------------------------------------------------------------------
Dtemplate.html | 31-------------------------------
22 files changed, 315 insertions(+), 307 deletions(-)
diff --git a/article-title-with-icon.html b/article-title-with-icon.html
@@ -1,6 +0,0 @@
-<div id="article-title-with-icon">
-    <div id="article-icon">
-        <img src="$logo-src$" title="$logo-title$" alt="$logo-alt$">
-    </div>
-    <h1 id="article-title">$article-title$</h1>
-</div>
diff --git a/blog.html b/blog.html
@@ -22,7 +22,7 @@
             <link rel='stylesheet' type='text/css' href="/css/article_style.css">
             <h1 id="index-title">Blog</h1>
             <ul id=blog_entries>
-                <!--#include virtual="/blog_index.shtml" -->
+                <!--#include virtual="/common/blog_index.shtml" -->
             </ul>
             <div style="margin-top: 1em; padding-bottom: .75em; text-align: center; text-decoration: none;">
                 <a href="/rss.xml" id="rss"><img style="width: 1.5em; padding: 0;" src="/common/rss_logo.png" alt="rss logo"></a>
diff --git a/blog/dwm-config/dwm-config.html b/blog/dwm-config/dwm-config.html
@@ -181,7 +181,7 @@ clear you should google how to use diff and patch to modify a file.</p>
 <li><a href="https://man7.org/linux/man-pages/man1/patch.1.html">patch man page</a></li>
 </ul>
 
-            <script type="text/javascript" src="/js/article-date.js"></script>
+            <script type="text/javascript" src="/scripts/article-date.js"></script>
             <!--#include virtual="/common/end_of_article.shtml" -->
         </article>
 
diff --git a/blog/nerdearla-2022/nerdearla-2022.html b/blog/nerdearla-2022/nerdearla-2022.html
@@ -47,7 +47,7 @@
 <pre><code class="language-console">$ ./build.sh nerdearla-2022.md
 </code></pre>
 
-            <script type="text/javascript" src="/js/article-date.js"></script>
+            <script type="text/javascript" src="/scripts/article-date.js"></script>
             <!--#include virtual="/common/end_of_article.shtml" -->
         </article>
 
diff --git a/blog/sav/sav.html b/blog/sav/sav.html
@@ -42,7 +42,7 @@
 <li>heap sort</li>
 </ul>
 
-            <script type="text/javascript" src="/js/article-date.js"></script>
+            <script type="text/javascript" src="/scripts/article-date.js"></script>
             <!--#include virtual="/common/end_of_article.shtml" -->
         </article>
 
diff --git a/blog/vim-config/vim-config.html b/blog/vim-config/vim-config.html
@@ -21,7 +21,7 @@
             <link rel='stylesheet' type='text/css' href="/css/article_style.css">
 
 
-<div id="article-title-with-icon">        <div id="article-icon"> <img src="vim_logo.png" title="Vim logo" alt="Vim logo">        </div> <h1 id="article-title">The keyboard driven text editor</h1> </div>
+<div id="article-title-with-icon">        <div id="article-icon"> <img src="vim_logo.png" title="Vim logo" alt="Vim logo">        </div> <h1 id="article-title">The keyboard driven text editor</h1></div><p class="article-date">04-Mar-2021</p>
 
 <p>If we think for a moment about software we are going to realize that the
 core of every program it&#8217;s just plain text, literally just words in a
@@ -56,7 +56,7 @@ binding to comment a line or auto close brackets, parenthesis, etc, this
 features you can enable them by installing <em>plugins</em> which I
 will cover leter.</p>
 
-            <script type="text/javascript" src="/js/article-date.js"></script>
+            <script type="text/javascript" src="/scripts/article-date.js"></script>
             <!--#include virtual="/common/end_of_article.shtml" -->
         </article>
 
diff --git a/build.sh b/build.sh
@@ -1,13 +0,0 @@
-#!/bin/sh
-
-# Builds a page for all the folders contained in md.
-# Copies entire folder to blog folder, generates an html file
-# converting the markdown file *named the same as the subfolder*,
-# then removes the md file conbtained in the dest folder.
-
-# TODO: leave markdown file to generate a description for the rss feed
-for i in $(ls md); do
-    cp -r md/$i ./blog &> /dev/null;
-    ./build_page.sh -i md/$i/$i.md -t template.html -d ./blog/$i;
-    # rm -r ./blog/$i/$i.md;
-done
diff --git a/build_page.sh b/build_page.sh
@@ -1,139 +0,0 @@
-#!/bin/sh
-
-# The most bloated, non-mantainable, non-readable static site generator
-# by: Martin Kloeckner - https://kloeckner.com.ar
-# Dependencies: sed, grep, lowdown.
-
-# Template: the converted html text is placed on a copy of the template
-# containing $body$ on it, $body$ then gets deleted.
-# Also the template should contain an $article-title$, $article-date$ and
-# $pagetitle$
-
-# The article title is considered to be the first h1 header found
-# in the markdown file
-
-# TODO: ...
-apply_syntax_highlight() {
-    commands=("make" "cat" "grep" "sed")
-    ul_commands=("sudo")
-
-    # Requires GNU grep
-    grep -zoP '<code.*>(.|\n)*?<\/code>' $1
-    for i in ${commands[@]}; do
-        echo $i
-    done
-    for i in ${ul_commands[@]}; do
-        echo $i
-    done
-}
-
-div_article_title_w_logo() {
-    # convert:
-    #     <p><img src="vim_logo.png" alt="Vim logo" class="article-icon" title="Vim logo" /></p>
-    #     <h1>The keyboard driven text editor</h1>
-
-    # into:
-    #     <div id="article-title-with-icon">
-    #         <div id="article-icon">
-    #             <img src="/blog/vim-config/vim_logo.png" title="Vim logo" alt="Vim logo">
-    #         </div>
-    #         <h1 id="article-title">The keyboard driven text editor</h1>
-    #     </div>
-    logo_src=$(echo $1 | grep -zoP '(?<=src=\")(.*?)(?=\")' | tr -d '\0')
-    logo_alt=$(echo $1 | grep -zoP '(?<=alt=\")(.*?)(?=\")' | tr -d '\0')
-    logo_title=$(echo $1 | grep -zoP '(?<=title=\")(.*?)(?=\")' | tr -d '\0')
-    h1_title=$(echo $2 | grep -zoP '(?<=<h1 id=article-title>)(.*?)(?=</h1>)' | tr -d '\0')
-}
-
-usage() {
-    echo "usage: $0 -i <input_file> -t <template_file>"
-}
-
-missing_operand() {
-    echo "$0: missing operands"
-    usage
-}
-
-check_opt() {
-    local opt OPTIND
-    while getopts ":i:t:d:" opt; do
-        case $opt in
-            i) input="$OPTARG";;
-            t) templ="$OPTARG";;
-            d) dest_dir="$OPTARG";;
-            \?) printf "%s\n\n" "error: flag not found" && usage && exit 1;;
-        esac
-    done
-
-    [ $OPTIND -eq 1 ] && missing_operand && exit 2
-    shift "$((OPTIND-1))"
-
-    [ -z "$input" ] || [ ! -e "$input" ] && echo "error: no input file" && exit 1
-    [ -z "$templ" ] || [ ! -e "$templ" ] && echo "error: no template fshellile" && exit 1
-    [ -z "$dest_dir" ] && dest_dir="."
-}
-
-check_opt $@
-
-title=$(cat $input | head -n 3 | grep -oP '(?<=% title: \")(.*?)(?=\")')
-date=$(cat $input | head -n 3 | grep -oP '(?<=% date: \")(.*?)(?=\")')
-pagetitle="Martin Klöckner's Webpage"
-lang="en"
-generator="Shell script"
-template="$templ"
-filename="$(basename $input | sed 's/\.[^.]*$//')"
-
-echo "file: $input"
-echo "filename: $filename"
-echo "title: $title"
-echo "date: $date"
-echo "dest dir: $dest_dir"
-echo "template: $template"
-
-# generate body (skips lines starting with `%`, they're considered metadata)
-sed '/^% /d' $input | lowdown --html-no-head-ids --html-no-escapehtml --html-no-owasp > body.html
-
-# puts ids to <h1> tag and adds paragraph next to it with the article-date
-sed -i -e 's/<h1>/<h1 id=article-title>/g' \
-    -e "s/<\/h1>/<\/h1><p class=\"article-date\">"$date"<\/p>/" body.html
-
-# indent: sed + `-e 's/^/\t\t\t/'`
-# (applying indent makes final html more pleasant to view, but causes code
-#     block to not be displayed properly)
-
-sed -e "s/\$article-title\\$/$title/" -e "s/\$article-date\\$/$date/" \
-    -e "s/\$pagetitle\\$/$pagetitle/" -e '/\$body\$/r./body.html' \
-    -e "s/\$lang\\$/$lang/" -e "s/\$generator\\$/$generator/" \
-    -e '/\$body\$/d' $template > "$dest_dir"/"$filename".html
-
-logo_line=$(grep -zoP '<img.*?("article-icon").*?>' "$dest_dir"/"$filename".html | tr -d '\0')
-title_line=$(grep -P '<h1.*?(article-title).*?>' "$dest_dir"/"$filename".html | tr -d '\0')
-
-insert_div_article_title_w_logo() {
-    logo_line="$1"
-    title_line="$2"
-
-    echo "logo_line: $logo_line"
-    echo "title_line: $title_line"
-
-    div_article_title_w_logo "$logo_line" "$title_line"
-
-    sed -i -e "s^$title_line^<div id=\"article-title-with-icon\">\
-        <div id=\"article-icon\"> <img src=\"$logo_src\" title=\"$logo_title\" alt=\"$logo_alt\">\
-        <\/div> <h1 id=\"article-title\">$h1_title<\/h1> <\/div>^" "$dest_dir"/"$filename".html
-
-    sed -i -E '/(^<p>).*?(article-icon).*?<\/p>/d' "$dest_dir"/"$filename".html
-}
-
-[ ! -z "$logo_line" ] && insert_div_article_title_w_logo "$logo_line" "$title_line"
-
-rm body.html &> /dev/null
-
-# ./syntax-highlight "$dest_dir"/"$filename".html > sh.html
-
-# cp -rf sh.html "$dest_dir"/"$filename".html
-
-echo "==> "$dest_dir"/"$filename".html generated succesfully"
-echo ""
-
-# apply_syntax_highlight "$filename.html"
diff --git a/blog_index.shtml b/common/blog_index.shtml
diff --git a/latest_uploads.shtml b/common/latest_uploads.shtml
diff --git a/index.html b/index.html
@@ -42,7 +42,7 @@
             </div>
 
             <ul id=blog_entries>
-                <!--#include virtual="/latest_uploads.shtml" -->
+                <!--#include virtual="/common/latest_uploads.shtml" -->
             </ul>
 
             <p>See more <a href="/blog">blog entries</a></p>
diff --git a/js/article-date.js b/scripts/article-date.js
diff --git a/scripts/article-title-with-icon.html b/scripts/article-title-with-icon.html
@@ -0,0 +1,6 @@
+<div id="article-title-with-icon">
+    <div id="article-icon">
+        <img src="$logo-src$" title="$logo-title$" alt="$logo-alt$">
+    </div>
+    <h1 id="article-title">$article-title$</h1><p class="article-date">$article-date$</p>
+</div>
diff --git a/scripts/build.sh b/scripts/build.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Builds a page for all the folders contained in md.
+# Copies entire folder to blog folder, generates an html file
+# converting the markdown file *named the same as the subfolder*,
+# then removes the md file conbtained in the dest folder.
+
+# TODO: leave markdown file to generate a description for the rss feed
+
+root_folder="/home/mk/soydev/webp/kloeckner.com.ar"
+
+for i in $(ls /home/mk/soydev/webp/kloeckner.com.ar/md); do
+    cp -r "$root_folder"/md/$i "$root_folder"/blog &>/dev/null;
+    "$root_folder"/scripts/build_page.sh -i "$root_folder"/md/$i/$i.md -t "$root_folder"/scripts/template.html -d "$root_folder"/blog/$i;
+done
diff --git a/scripts/build_page.sh b/scripts/build_page.sh
@@ -0,0 +1,140 @@
+#!/bin/sh
+
+# The most bloated, non-mantainable, non-readable static site generator
+# by: Martin Kloeckner - https://kloeckner.com.ar
+# Dependencies: sed, grep, lowdown.
+
+# Template: the converted html text is placed on a copy of the template
+# containing $body$ on it, $body$ then gets deleted.
+# Also the template should contain an $article-title$, $article-date$ and
+# $pagetitle$
+
+# The article title is considered to be the first h1 header found
+# in the markdown file
+
+# TODO: ...
+apply_syntax_highlight() {
+    commands=("make" "cat" "grep" "sed")
+    ul_commands=("sudo")
+
+    # Requires GNU grep
+    grep -zoP '<code.*>(.|\n)*?<\/code>' $1
+    for i in ${commands[@]}; do
+        echo $i
+    done
+    for i in ${ul_commands[@]}; do
+        echo $i
+    done
+}
+
+div_article_title_w_logo() {
+    # convert:
+    #     <p><img src="vim_logo.png" alt="Vim logo" class="article-icon" title="Vim logo" /></p>
+    #     <h1>The keyboard driven text editor</h1>
+
+    # into:
+    #     <div id="article-title-with-icon">
+    #         <div id="article-icon">
+    #             <img src="/blog/vim-config/vim_logo.png" title="Vim logo" alt="Vim logo">
+    #         </div>
+    #         <h1 id="article-title">The keyboard driven text editor</h1>
+    #     </div>
+    logo_src=$(echo $1 | grep -zoP '(?<=src=\")(.*?)(?=\")' | tr -d '\0')
+    logo_alt=$(echo $1 | grep -zoP '(?<=alt=\")(.*?)(?=\")' | tr -d '\0')
+    logo_title=$(echo $1 | grep -zoP '(?<=title=\")(.*?)(?=\")' | tr -d '\0')
+    h1_title=$(echo $2 | grep -zoP '(?<=<h1 id=article-title>)(.*?)(?=</h1>)' | tr -d '\0')
+}
+
+usage() {
+    echo "usage: $0 -i <input_file> -t <template_file>"
+}
+
+missing_operand() {
+    echo "$0: missing operands"
+    usage
+}
+
+check_opt() {
+    local opt OPTIND
+    while getopts ":i:t:d:" opt; do
+        case $opt in
+            i) input="$OPTARG";;
+            t) templ="$OPTARG";;
+            d) dest_dir="$OPTARG";;
+            \?) printf "%s\n\n" "error: flag not found" && usage && exit 1;;
+        esac
+    done
+
+    [ $OPTIND -eq 1 ] && missing_operand && exit 2
+    shift "$((OPTIND-1))"
+
+    [ -z "$input" ] || [ ! -e "$input" ] && echo "error: no input file" && exit 1
+    [ -z "$templ" ] || [ ! -e "$templ" ] && echo "error: no template fshellile" && exit 1
+    [ -z "$dest_dir" ] && dest_dir="."
+}
+
+check_opt $@
+
+title=$(cat $input | head -n 3 | grep -oP '(?<=% title: \")(.*?)(?=\")')
+date=$(cat $input | head -n 3 | grep -oP '(?<=% date: \")(.*?)(?=\")')
+pagetitle="Martin Klöckner's Webpage"
+lang="en"
+generator="Shell script"
+template="$templ"
+filename="$(basename $input | sed 's/\.[^.]*$//')"
+
+echo "file: $input"
+echo "filename: $filename"
+echo "title: $title"
+echo "date: $date"
+echo "dest dir: $dest_dir"
+echo "template: $template"
+
+# generate body (skips lines starting with `%`, they're considered metadata)
+sed '/^% /d' $input | lowdown --html-no-head-ids --html-no-escapehtml --html-no-owasp > body.html
+
+# puts ids to <h1> tag and adds paragraph next to it with the article-date
+sed -i -e 's/<h1>/<h1 id=article-title>/g' \
+    -e "s/<\/h1>/<\/h1><p class=\"article-date\">"$date"<\/p>/" body.html
+
+# indent: sed + `-e 's/^/\t\t\t/'`
+# (applying indent makes final html more pleasant to view, but causes code
+#     block to not be displayed properly)
+
+sed -e "s/\$article-title\\$/$title/" -e "s/\$article-date\\$/$date/" \
+    -e "s/\$pagetitle\\$/$pagetitle/" -e '/\$body\$/r./body.html' \
+    -e "s/\$lang\\$/$lang/" -e "s/\$generator\\$/$generator/" \
+    -e '/\$body\$/d' $template > "$dest_dir"/"$filename".html
+
+logo_line=$(grep -zoP '<img.*?("article-icon").*?>' "$dest_dir"/"$filename".html | tr -d '\0')
+title_line=$(grep -P '<h1.*?(article-title).*?>' "$dest_dir"/"$filename".html | tr -d '\0')
+
+insert_div_article_title_w_logo() {
+    logo_line="$1"
+    title_line="$2"
+
+    echo "logo_line: $logo_line"
+    echo "title_line: $title_line"
+
+    div_article_title_w_logo "$logo_line" "$title_line"
+
+    sed -i -e "s^$title_line^<div id=\"article-title-with-icon\">\
+        <div id=\"article-icon\"> <img src=\"$logo_src\" title=\"$logo_title\" alt=\"$logo_alt\">\
+        <\/div> <h1 id=\"article-title\">$h1_title<\/h1><\/div><p class=\"article-date\">$date</p>^"\
+        "$dest_dir"/"$filename".html
+
+    sed -i -E '/(^<p>).*?(article-icon).*?<\/p>/d' "$dest_dir"/"$filename".html
+}
+
+[ ! -z "$logo_line" ] && insert_div_article_title_w_logo "$logo_line" "$title_line"
+
+rm body.html &> /dev/null
+
+# ./syntax-highlight "$dest_dir"/"$filename".html > sh.html
+
+# cp -rf sh.html "$dest_dir"/"$filename".html
+
+echo "==> "$dest_dir"/"$filename".html generated succesfully"
+echo ""
+
+# apply_syntax_highlight "$filename.html"
diff --git a/scripts/deploy_local.sh b/scripts/deploy_local.sh
@@ -0,0 +1,11 @@
+root_folder="/home/mk/soydev/webp/kloeckner.com.ar"
+
+set -xe
+
+rm -rf /var/www/html &>/dev/null
+
+cp -rf "$root_folder" /var/www/html
+
+rm /var/www/html/{rss_feed_top.xml,README.md} &> /dev/null
+
+systemctl restart nginx
diff --git a/rss_feed_top.xml b/scripts/rss_feed_top.xml
diff --git a/sort_blog_index.py b/scripts/sort_blog_index.py
diff --git a/scripts/sync.sh b/scripts/sync.sh
@@ -0,0 +1,105 @@
+#!/bin/sh
+
+root_folder="/home/mk/soydev/webp/kloeckner.com.ar"
+blog_folder="blog"
+blog_index_file="common/blog_index.shtml"
+latest_uploads_file="common/latest_uploads.shtml"
+rss_feed_file=$root_folder/"rss.xml"   # RSS feed file
+blog_folders=$("$root_folder"/scripts/sort_blog_index.py "$blog_folder")
+
+# set -xe
+
+generate_blog_index() {
+    rm $root_folder/$blog_index_file 2> /dev/null
+    touch $root_folder/$blog_index_file
+
+    # for i in $(eval $root_folder/scritps/sort_blog_index.py $root_folder/$blog_folder); do
+    for i in ${blog_folders[@]}; do
+        article_date=$(cat $i | grep -oP '(?<=<meta name="article-date" content=")(.*?)(?=")')
+        article_title=$(cat $i | grep -oP '(?<=<meta name="article-title" content=")(.*?)(?=")')
+        file_name=$(echo "$i" | grep -oE '[^/]*$' | cut -d '.' -f 1)
+
+        printf "<li><time>%s</time> <a href=\"/$blog_folder/$file_name/$file_name.html\">%s</a></li>\n" \
+            "${article_date}" "${article_title}" >> $root_folder/$blog_index_file
+    done
+}
+
+generate_latest_uploads() {
+    rm $root_folder/$latest_uploads_file &> /dev/null
+
+    tail -n 5 $root_folder/$blog_index_file > $root_folder/$latest_uploads_file
+}
+
+generate_rss_feed() {
+    rm $rss_feed_file &> /dev/null
+
+    cp "$root_folder"/scripts/rss_feed_top.xml $rss_feed_file
+    printf "<lastBuildDate>%s</lastBuildDate>\n" "$(date)" >> $rss_feed_file
+
+    for i in ${blog_folders[@]}; do
+        article_date=$(cat $i | grep -oP '(?<=<meta name="article-date" content=")(.*?)(?=")')
+        article_title=$(cat $i | grep -oP '(?<=<meta name="article-title" content=")(.*?)(?=")')
+        file_name=$(echo "$i" | grep -oE '[^/]*$' | cut -d '.' -f 1)
+
+        article_description="$(md2html $root_folder/md/$file_name/$file_name.md |\
+            sed -E -e 's/ \(last\ update//g' -e 's/\{[^\}]*\}//g'\
+                   -e 's/<code>|<\/code>//g' -e 's/<em>|<\/em>//g')"
+
+        # Create RSS feed item
+        echo "<item>" >> $rss_feed_file
+        echo "<title>$article_title</title>" >> $rss_feed_file
+        echo "<link>https://kloeckner.com.ar/blog/$file_name/$file_name.html</link>" >> $rss_feed_file
+        echo "<description>
+                <htmlData>
+                    <![CDATA[<html>$article_description</html>]]>
+                </htmlData>
+            </description>" >> $rss_feed_file
+        echo "<pubDate>$article_date</pubDate>" >> $rss_feed_file
+        echo "$article_date"
+        echo "</item>" >> $rss_feed_file
+        echo "" >> $rss_feed_file
+    done
+
+    # Close the RSS feed file
+    echo "" >> $rss_feed_file
+    echo "</channel>" >> $rss_feed_file
+    echo "</rss>" >> $rss_feed_file
+}
+
+check_rss_feed_last_build() {
+    [ ! -e $rss_feed_file ] && echo "+ Regenerating rss feed" && generate_rss_feed && return
+    for i in $(ls $root_folder/$blog_folder); do
+        # if exists and it's a directory
+        if [ -d $root_folder/$blog_folder/$i ]; then
+            last_modified=$(stat $root_folder/$blog_folder/$i/$i.html --format "%Y")
+            rss_file_date=$(stat $rss_feed_file --format "%Y")
+
+            if [ $last_modified -gt $rss_file_date ]
+            then
+                echo "==> $i.html is newer than $rss_feed_file"
+                echo "+ Regenerating rss feed"
+                generate_rss_feed
+                break
+            fi
+        fi
+    done
+}
+
+[ ! -d $root_folder ] && echo "error: root_folder: $root_folder not found" && exit 1
+
+echo "* root_folder: $root_folder"
+echo "* blog_folder: $blog_folder"
+echo "* blog_index_file: $blog_index_file"
+echo "* latest_uploads_file: $latest_uploads_file"
+echo "* rss_feed_file: $rss_feed_file"
+echo ""
+echo "+ generate_blog_index"
+generate_blog_index
+
+echo "+ generate_latest_uploads"
+generate_latest_uploads
+
+case "$1" in
+    --force-rss) echo "+ generate_rss_feed"; generate_rss_feed;;
+    *) echo "==> Checking if rss feed needs to be rebuild"; check_rss_feed_last_build;;
+esac
diff --git a/scripts/template.html b/scripts/template.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html lang="$lang$">
+    <head>
+        <meta charset="utf-8">
+        <meta name="generator" content="$generator$">
+        <meta name="viewport" content="width=device-width, initial-scale=1.0">
+
+        <meta name="article-author" content="$article-author$">
+        <meta name="article-date" content="$article-date$">
+        <meta name="article-title" content="$article-title$">
+
+        <title>$article-title$ | $pagetitle$</title>
+        <link rel='stylesheet' type='text/css' href="/css/style.css">
+        <link rel="icon" href="/favicon.png">
+    </head>
+
+    <body>
+        <!--#include virtual="/common/header.shtml" -->
+
+        <article>
+            <link rel='stylesheet' type='text/css' href="/css/article_style.css">
+
+            $body$
+
+            <script type="text/javascript" src="/scripts/article-date.js"></script>
+            <!--#include virtual="/common/end_of_article.shtml" -->
+        </article>
+
+        <!--#include virtual="/common/footer.shtml" -->
+    </body>
+</html>
diff --git a/sync.sh b/sync.sh
@@ -1,111 +0,0 @@
-#!/bin/sh
-
-root_folder="/home/mk/soydev/webp/kloeckner.com.ar"
-blog_folder="blog"
-blog_index_file="blog_index.shtml"
-latest_uploads_file="latest_uploads.shtml"
-rss_feed_file=$root_folder/"rss.xml"   # RSS feed file
-
-generate_blog_index() {
-    rm $root_folder/$blog_index_file 2> /dev/null
-    touch $root_folder/$blog_index_file
-
-    for i in $(./sort_blog_index.py /home/mk/soydev/webp/tmp/html/blog/); do
-        article_date=$(cat $i | grep -oP '(?<=<meta name="article-date" content=")(.*?)(?=")')
-        article_title=$(cat $i | grep -oP '(?<=<meta name="article-title" content=")(.*?)(?=")')
-
-        file_name=$(echo "$i" | grep -oE '[^/]*$' | cut -d '.' -f 1)
-
-        printf "<li><time>%s</time> <a href=\"/$blog_folder/$file_name/$file_name.html\">%s</a></li>\n" "${article_date}" "${article_title}" >> $root_folder/$blog_index_file
-    done
-}
-
-generate_latest_uploads() {
-    rm $root_folder/$latest_uploads_file &> /dev/null
-
-    tail -n 5 $root_folder/$blog_index_file > $root_folder/$latest_uploads_file
-}
-
-generate_rss_feed() {
-    rm $rss_feed_file 2> /dev/null
-
-    cp rss_feed_top.xml $rss_feed_file
-    printf "<lastBuildDate>%s</lastBuildDate>\n" "$(date)" >> $rss_feed_file
-
-    for i in $(./sort_blog_index.py /home/mk/soydev/webp/tmp/html/blog/); do
-        article_date=$(cat $i | grep -oP '(?<=<meta name="article-date" content=")(.*?)(?=")')
-        article_title=$(cat $i | grep -oP '(?<=<meta name="article-title" content=")(.*?)(?=")')
-        file_name=$(echo "$i" | grep -oE '[^/]*$' | cut -d '.' -f 1)
-
-        article_description="$(md2html $root_folder/md/$file_name/$file_name.md | sed -E -e 's/ \(last\ update//g' -e 's/\{[^\}]*\}//g' -e 's/<code>|<\/code>//g' -e 's/<em>|<\/em>//g')"
-        rm $root_folder/$blog_folder/$file_name/$file_name.md
-
-        # Create RSS feed item
-        echo "<item>" >> $rss_feed_file
-        echo "<title>$article_title</title>" >> $rss_feed_file
-        echo "<link>https://kloeckner.com.ar/blog/$file_name/$file_name.html</link>" >> $rss_feed_file
-        echo "<description>
-                <htmlData>
-                    <![CDATA[<html>$article_description</html>]]>
-                </htmlData>
-            </description>" >> $rss_feed_file
-        echo "<pubDate>$article_date</pubDate>" >> $rss_feed_file
-        echo "$article_date"
-        echo "</item>" >> $rss_feed_file
-        echo "" >> $rss_feed_file
-    done
-
-    # Close the RSS feed file
-    echo "" >> $rss_feed_file
-    echo "</channel>" >> $rss_feed_file
-    echo "</rss>" >> $rss_feed_file
-}
-
-check_rss_feed_last_build() {
-    for i in $(ls $root_folder/$blog_folder); do
-        # if exists and it's a directory
-        if [ -d $root_folder/$blog_folder/$i ]; then
-            last_modified=$(stat $root_folder/$blog_folder/$i/$i.html --format "%Y")
-            rss_file_date=$(stat $rss_feed_file --format "%Y")
-
-            if [ $last_modified -gt $rss_file_date ]
-            then
-                echo "==> $i.html is newer than $rss_feed_file"
-                echo "+ Regenerating rss feed"
-                generate_rss_feed
-                break
-            fi
-        fi
-    done
-}
-
-[ ! -d $root_folder ] && echo "error: root_folder: $root_folder not found" && exit 1
-
-echo "* root_folder: $root_folder"
-echo "* blog_folder: $blog_folder"
-echo "* blog_index_file: $blog_index_file"
-echo "* latest_uploads_file: $latest_uploads_file"
-echo "* rss_feed_file: $rss_feed_file"
-echo ""
-echo "+ generate_blog_index"
-generate_blog_index
-
-echo "+ generate_latest_uploads"
-generate_latest_uploads
-
-case "$1" in
-    --force-rss) echo "+ generate_rss_feed"; generate_rss_feed;;
-    *) echo "==> Checking if rss feed needs to be rebuild"; check_rss_feed_last_build;;
-esac
-
-set -xe
-
-chown mk:mk $root_folder/$latest_uploads_file
-
-rm -rf /var/www/html 2>/dev/null
-
-cp -rf $root_folder /var/www/html
-
-rm /var/www/html/{rss_feed_top.xml,README.md}
-
-systemctl restart nginx
diff --git a/template.html b/template.html
@@ -1,31 +0,0 @@
-<!DOCTYPE html>
-<html lang="$lang$">
-    <head>
-        <meta charset="utf-8">
-        <meta name="generator" content="$generator$">
-        <meta name="viewport" content="width=device-width, initial-scale=1.0">
-
-        <meta name="article-author" content="$article-author$">
-        <meta name="article-date" content="$article-date$">
-        <meta name="article-title" content="$article-title$">
-
-        <title>$article-title$ | $pagetitle$</title>
-        <link rel='stylesheet' type='text/css' href="/css/style.css">
-        <link rel="icon" href="/favicon.png">
-    </head>
-
-    <body>
-        <!--#include virtual="/common/header.shtml" -->
-
-        <article>
-            <link rel='stylesheet' type='text/css' href="/css/article_style.css">
-
-            $body$
-
-            <script type="text/javascript" src="/js/article-date.js"></script>
-            <!--#include virtual="/common/end_of_article.shtml" -->
-        </article>
-
-        <!--#include virtual="/common/footer.shtml" -->
-    </body>
-</html>