--- /dev/null
+#!/bin/sh
+
+# Pull in dependencies.
+. ./helpers.sh
+src_file=$(get_source_file "$1")
+uuid_file="${1%.feed_snippet}.uuid"
+redo-ifchange "$uuid_file"
+intermediate_file="${src_file%.*}.intermediate"
+redo-ifchange "$intermediate_file"
+
+# Get variables, write entry.
+html_file=`escape_url "${src_file%.*}.html"`
+lastmod=`stat -c%y "$src_file"`
+lastmod_rfc3339=`date -u "+%Y-%m-%dT%TZ" -d "$lastmod"`
+published=`stat -c%y "$uuid_file"`
+published_rfc3339=`date -u "+%Y-%m-%dT%TZ" -d "${published}"`
+title=`read_and_escape_file "$intermediate_file" | head -1`
+uuid=`read_and_escape_file "$uuid_file" | head -1`
+body=`read_and_escape_file "$intermediate_file" | sed 1d`
+printf "<entry>\n"
+printf "<title type=\"html\">%s</title>\n" "$title"
+printf "<id>urn:uuid:%s</id>\n" "$uuid"
+printf "<updated>%s</updated>\n" "$lastmod_rfc3339"
+printf "<published>%s</published>\n" "$published_rfc3339"
+printf "<link href=\"%s%s\" />\n" "$(get_basepath)" "${html_file#\./}"
+printf "<content type=\"html\">\n%s\n</content>\n" "$body"
+printf "</entry>\n"
--- /dev/null
+#!/bin/sh
+
+# Pull in dependencies.
+. ./helpers.sh
+src_file=$(get_source_file "$1")
+intermediate_file="${src_file%.*}.intermediate"
+redo-ifchange "$intermediate_file"
+html_file="${src_file%.*}.html"
+redo-ifchange "$html_file"
+
+# Get variables, write entry.
+title_html=`cat "$intermediate_file" | head -1`
+html_file_escaped=`escape_url "${html_file#\./}"`
+printf "<li><a href=\"%s\" />%s</a></li>\n" "$html_file_escaped" "$title_html"
#!/bin/sh
-build_entry () {
- file="${1}"
- uuidfile="${2}"
- published="${3}"
- intermediate_file="${file%.*}.intermediate"
- htmlfile=`escape_url "${file%.*}.html"`
- redo-ifchange "$uuid_file"
- redo-ifchange "$intermediate_file"
- lastmod=`stat -c%y "$file"`
- lastmod_rfc3339=`date -u "+%Y-%m-%dT%TZ" -d "$lastmod"`
- title=`read_and_escape_file "$intermediate_file" | head -1`
- uuid=`read_and_escape_file "$uuid_file" | head -1`
- body=`read_and_escape_file "$intermediate_file" | sed 1d`
- published_rfc3339=`date -u "+%Y-%m-%dT%TZ" -d "${published}"`
- printf "<entry>\n"
- printf "<title type=\"html\">%s</title>\n" "$title"
- printf "<id>urn:uuid:%s</id>\n" "$uuid"
- printf "<updated>%s</updated>\n" "$lastmod_rfc3339"
- printf "<published>%s</published>\n" "$published_rfc3339"
- printf "<link href=\"%s%s\" />\n" "$basepath" "${htmlfile#\./}"
- printf "<content type=\"html\">\n%s\n</content>\n" "$body"
- printf "</entry>"
-}
-
# Pull in global dependencies.
. ./helpers.sh
-url_file=url.meta
author_file=author.meta
uuid_file=uuid.meta
title_file=title.meta
# Build some variables. XML-escape even file contents that should not contain
# dangerous characters, just to avoid any XML trouble.
-base_url=`cat "$url_file" | head -1`
-url_protocol=`echo $base_url | cut -d ':' -f 1`
-url_basepath=`echo $base_url | cut -d '/' -f 3-`
-url_basepath_escaped=`escape_url "$url_basepath"`
-basepath="$url_protocol""://""$url_basepath_escaped"
+srcdir=`pwd`
+basepath=$(get_basepath)
title=`read_and_escape_file "$title_file" | head -1`
author=`read_and_escape_file "$author_file" | head -1`
uuid=`read_and_escape_file "$uuid_file" | head -1`
redo-ifchange "$uuid_file"
published=`stat -c%y "${uuid_file}"`
published_unix=$(date -u "+%s%N" -d "${published}")
- entry=$(build_entry "${file}" "${uuid_file}" "${published}")
- echo "${entry}" > ./feed_snippets/${published_unix}
+ snippet_file="${file%.*}.feed_snippet"
+ redo-ifchange "$snippet_file"
+ ln -s "$srcdir/$snippet_file" "./feed_snippets/${published_unix}"
fi
done
#!/bin/sh
-escape_html()
-{
-out=`python3 -c 'import sys, html; print(html.escape(sys.argv[1]))' "$1"`
-printf "%s" "$out"
+escape_html() {
+ out=`python3 -c 'import sys, html; print(html.escape(sys.argv[1]))' "$1"`
+ printf "%s" "$out"
}
-read_and_escape_file()
-{
-in=`cat "$1"`
-escape_html "$in"
+read_and_escape_file() {
+ in=`cat "$1"`
+ escape_html "$in"
}
-escape_url()
-{
-out=`python3 -c 'import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1]))' "$1"`
-printf "%s" "$out"
+escape_url() {
+ out=`python3 -c 'import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1]))' "$1"`
+ printf "%s" "$out"
+}
+
+get_basepath() {
+ url_file=url.meta
+ redo-ifchange "$url_file"
+ base_url=`cat "$url_file" | head -1`
+ url_protocol=`echo $base_url | cut -d ':' -f 1`
+ url_basepath=`echo $base_url | cut -d '/' -f 3-`
+ url_basepath_escaped=`escape_url "$url_basepath"`
+ basepath="$url_protocol""://""$url_basepath_escaped"
+ echo "$basepath"
+}
+
+get_source_file() {
+ md_file="${1%.*}.md"
+ rst_file="${1%.*}.rst"
+ if [ -f "$rst_file" ]; then
+ src_file="$rst_file"
+ elif [ -f "$md_file" ]; then
+ src_file="$md_file"
+ else
+ exit 1
+ fi
+ redo-ifchange "$src_file"
+ printf "$src_file"
}
# Pull in global dependencies.
. ./helpers.sh
+srcdir=`pwd`
title_file=title.meta
redo-ifchange "$title_file"
redo-ifchange "$uuid_file"
published=`stat -c%y "${uuid_file}"`
published_unix=$(date -u "+%s%N" -d "${published}")
- intermediate_file="${file%.*}.intermediate"
- html_file="${file%.*}.html"
- redo-ifchange "$intermediate_file"
- redo-ifchange "$html_file"
- title_html=`cat "$intermediate_file" | head -1`
- html_file_escaped=`escape_url "${html_file#\./}"`
- printf "<li><a href=\"%s\" />%s</a></li>\n" "$html_file_escaped" "$title_html" > ./index_snippets/${published_unix}
+ snippet_file="${file%.*}.index_snippet"
+ redo-ifchange "$snippet_file"
+ ln -s "$srcdir/$snippet_file" "./index_snippets/${published_unix}"
fi
done