diff --git a/blog.html b/blog.html index 4ca453e..f54cf4e 100644 --- a/blog.html +++ b/blog.html @@ -35,10 +35,12 @@ Home

Blog

-

Introduction

Hello, welcome to my blog! My name is Hugo. I am a 22 year old Software +

Introduction

+Sat 08 Feb 2020 09:30:06 AM CET

Hello, welcome to my blog! My name is Hugo. I am a 22 year old Software Engineering student from the Netherlands. Software development is a huge part of my life, I write a lot of (weird) programs to scratch my own itch and most software I create is open_source by default. I also run a one-man company that -provides some IT services on the side. ... Continue reading


- - +provides some IT services on the side. ... Continue reading

+
+
+ diff --git a/feed.xml b/feed.xml new file mode 100644 index 0000000..31e54a1 --- /dev/null +++ b/feed.xml @@ -0,0 +1,23 @@ + + + + Hugot Blog + https://hugot.nl/blog.html + Hugo's personal blog + en-us + Sat 08 Feb 2020 09:58:35 AM CET + Sat 08 Feb 2020 09:58:35 AM CET + http://blogs.law.harvard.edu/tech/rss + Hugo's Custom Bash Script + social@hugot.nl + infra@hugot.nl + Introduction + Hello, welcome to my blog! My name is Hugo. I am a 22 year old Software +Engineering student from the Netherlands. Software development is a huge part +of my life, I write a lot of (weird) programs to scratch my own itch and most +software I create is open_source by default. I also run a one-man company that +provides some IT services on the side. + Sat 08 Feb 2020 09:30:06 AM CET + ./posts/introduction/index.html#MjM3MzUyOTAwNSA5MDYK + + diff --git a/generate-blog.bash b/generate-blog.bash index 1256632..b648619 100755 --- a/generate-blog.bash +++ b/generate-blog.bash @@ -5,7 +5,7 @@ # page. # Check if required executables can be found -if ! type readlink dirname html2text mv; then +if ! type readlink dirname html2text mv cat cksum base64; then echo 'One or more required executables are not present. Generation cancelled' >&2 exit 1 fi @@ -31,9 +31,7 @@ html-to-text() { html2text -nobs -style compact "$@" } -blog_html="$here/blog.html" - -{ +print-blog-html-top() { echo ' Blog @@ -71,32 +69,121 @@ blog_html="$here/blog.html" Home

Blog

' - while read -r post_html; do - # Convert the post's html to text to make it easier to use the blog's text - text="$(html-to-text "$post_html" | escape-html)" || exit $? +} - # The title should be on the 2nd line of text, right after the link to the - # homepage. This is a bit inflexible but it will do for now. - title="$(tail -n +2 <<<"$text" | head -n 1 | tr -d '*')" || exit $? +print-blog-html-bottom() { + echo ' + ' +} - # Use the first 5 lines after the title as post excerpt. - excerpt="$(tail -n +3 <<<"$text" | head -n 5)" || exit $? +# Note: pubDate and lastBuildDate are both set to the current time. +print-blog-rss-top() { + cat < + + + Hugot Blog + https://hugot.nl/blog.html + Hugo's personal blog + en-us + $(date) + $(date) + http://blogs.law.harvard.edu/tech/rss + Hugo's Custom Bash Script + social@hugot.nl + infra@hugot.nl +EOF +} - # Escape the post html file name to safely use it in the generated html. - href="$(escape-html <<<"$post_html")" || exit $? +print-blog-rss-bottom() { + echo ' +' +} - printf '

%s

%s ... Continue reading


\n' \ - "$href" \ - "$title" \ - "$excerpt" \ - "$href" - done < "$posts_file" +el() { + format_string="$1" + shift - echo ' -' + printf "<$format_string>" "$@" +} + +el-close() { + echo "" +} + +el-enclose() { + element_name="$1" + shift + + echo "<$element_name>" "$@" "" +} + +site_url="https://hugot.nl" + +blog_html="$here/blog.html" +new_html="$blog_html.new" + +blog_rss="$here/feed.xml" +new_rss="$blog_rss.new" + +print-blog-html-top > "$new_html" +print-blog-rss-top > "$new_rss" + +while read -r post_html; do + # Convert the post's html to text to make it easier to use the blog's text + text="$(html-to-text "$post_html" | escape-html)" || exit $? + + # The title should be on the 2nd line of text, right after the link to the + # homepage. This is a bit inflexible but it will do for now. + title="$(tail -n +2 <<<"$text" | head -n 1 | tr -d '*')" || exit $? + + # Use the first 5 lines after the title as post excerpt. + excerpt="$(tail -n +3 <<<"$text" | head -n 5)" || exit $? + + # Escape the post html file name to safely use it in the generated html. + href="$(escape-html <<<"$post_html")" || exit $? + + post_dir="$(dirname "$post_html")" || exit $? + pubdate_file="$post_dir/publish_date.txt" + + # Determine a publishing date for the post + if [[ -f "$pubdate_file" ]]; then + read -r pubdate < "$pubdate_file" + else + pubdate="$(date)" + echo "$pubdate" > "$pubdate_file" + fi + + { + el div + + el 'a href="%s"' "$href" + printf '

%s

' "$title" + el-close a + + printf '%s' "$pubdate" + + el 'p style="margin-top: 0.5em;"' + printf '%s ... Continue reading' "$excerpt" "$href" + el-close p + + el-close div + + el hr + } >> "$new_html" + + { + el-enclose title "$title" + el-enclose description "$excerpt" + el-enclose pubDate "$pubdate" + el-enclose guid "${href}#$(base64 <(cksum <<<"$text"))" + } >> "$new_rss" +done < "$posts_file" -} > "$blog_html.new" +print-blog-html-bottom >> "$new_html" +print-blog-rss-bottom >> "$new_rss" -mv -v "$blog_html.new" "$blog_html" || exit $? +mv -v "$new_html" "$blog_html" || exit $? +mv -v "$new_rss" "$blog_rss" || exit $? echo 'SUCCESS!' diff --git a/index.html b/index.html index 070ca22..566c320 100644 --- a/index.html +++ b/index.html @@ -39,5 +39,11 @@ Hello and welcome to my personal homepage! I'll add some info about myself to this page soon. In the mean time, maybe take a look at my blog

+ +
+          testing pre
+
+          jallaballa
+        
diff --git a/posts/introduction/publish_date.txt b/posts/introduction/publish_date.txt new file mode 100644 index 0000000..b4739dd --- /dev/null +++ b/posts/introduction/publish_date.txt @@ -0,0 +1 @@ +Sat 08 Feb 2020 09:30:06 AM CET