X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;f=processor%2Fhelpers.sh;h=64d1123ce89e73ad080cd7a9b614d33266325178;hb=ff5b37d8bc4cfba8f1db69a279da887accaa0296;hp=2869a29a3d414db7066c71e17ff1439b0b7c6c92;hpb=221da1978401d0aa570bf02d141a5834bde8c1a7;p=redo-blog
diff --git a/processor/helpers.sh b/processor/helpers.sh
index 2869a29..64d1123 100644
--- a/processor/helpers.sh
+++ b/processor/helpers.sh
@@ -6,10 +6,32 @@ escape_html() {
}
read_and_escape_file() {
- in=`cat "$1"`
+ in=$(cat "$1")
escape_html "$in"
}
+get_uuid_from_meta_file() {
+ probable_uuid=$(cat "$1" | head -1)
+ if printf "$probable_uuid" | grep -Eq "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"; then
+ printf "$probable_uuid"
+ else
+ echo "Malformed UUID in meta file." >&2
+ exit 1
+ fi
+}
+
+get_creation_date_from_meta_file_seconds() {
+ cat "$1" | sed -n '2p' | cut -d'_' -f1
+}
+
+get_creation_date_from_meta_file_nanoseconds() {
+ cat "$1" | sed -n '2p'
+}
+
+get_lastmod_date_from_meta_file() {
+ cat "$1" | sed -n '4p'
+}
+
escape_url() {
out=`python3 -c 'import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1]))' "$1"`
printf "%s" "$out"