From 2ee0921e1b9f5f59567e0b29ec19421307e84f54 Mon Sep 17 00:00:00 2001 From: Steph Enders Date: Mon, 11 Mar 2024 13:42:36 -0400 Subject: Add support for authoring gemtext posts Updating the build script to allow for posts to be .gmi files in addition .html files. I added a submodule to gmi2html so we can convert these on the fly and they'll write themselves to the build directory as the desired filename which then get hoisted into the www folder upon post creation - as normal! This should help with authoring more simple text posts that don't require complex markup like music stuff! This did require updating gmi2html to have more support for quote attribution however. So I should be mindful in the future of how that renders! --- .gitmodules | 3 +++ build.sh | 17 +++++++++++++++-- modules/gmi2html | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 .gitmodules create mode 160000 modules/gmi2html diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..517c99f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "modules/gmi2html"] + path = modules/gmi2html + url = git@senders.io:utils/gmi2html diff --git a/build.sh b/build.sh index 03be6f8..ab0559e 100755 --- a/build.sh +++ b/build.sh @@ -175,7 +175,7 @@ function add_to_rss() { local rss_data=$5 local pub_date=$(date -d "${post_date}" -R) sed -E -e "{ - s/[{]TITLE[}]/${post_title}/1; + s/[{]TITLE[}]/${post_title/\//\\/}/1; s,[{]LINK[}],${post_url},g; s/[{]PUBDATE[}]/${pub_date}/1; /CONTENT/ { @@ -201,7 +201,7 @@ echo "Building html" pinned_html=$(mktemp_file "pinned") rss_data=$(mktemp_file "rss_data") echo "Using pinned file: $pinned_html" -for post in posts/*.html; do +for post in posts/*.*; do echo "Processing $post" post_date=$(extract_metadata "post-date" $post) if [ -z "$post_date" ]; then @@ -220,6 +220,19 @@ for post in posts/*.html; do post_file=$(mktemp_file "post") content_file=$(mktemp_file "content") + # Check if gmi or HTML + extension="${post##*.}" + + if [ "${extension}" == "gmi" ]; then + echo "Converting gemtext 2 html" + gmihtml="$BUILD/$(basename ${post%.*}).html" + # todo - make gmi2html post as an article + echo "
" > $gmihtml + ./modules/gmi2html/gmi2html.sh <(sed "/^--.*$/d" $post) >> $gmihtml + echo "
" >> $gmihtml + post=$gmihtml # set post file to be the temporary HTML file + fi + echo "Copying $post data into $content_file" cp $post $content_file diff --git a/modules/gmi2html b/modules/gmi2html new file mode 160000 index 0000000..a6c2523 --- /dev/null +++ b/modules/gmi2html @@ -0,0 +1 @@ +Subproject commit a6c2523aed55f01ce8390272619cfee0db7cc3a5 -- cgit v1.2.3-54-g00ecf