aboutsummaryrefslogtreecommitdiff
path: root/bin/ak-news
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-03-27 09:37:57 +0200
committerkaotisk <kaotisk@arching-kaos.org>2024-03-27 09:37:57 +0200
commita4fed5715cc9e47def717ef6f21a5aed34455b32 (patch)
treeee1f7ab07d8f2a6975667e8c3e7f4750b8f79519 /bin/ak-news
parent465d5db06e56dc21072a8ff01258f6815d340b00 (diff)
downloadarching-kaos-tools-a4fed5715cc9e47def717ef6f21a5aed34455b32.tar.gz
arching-kaos-tools-a4fed5715cc9e47def717ef6f21a5aed34455b32.tar.bz2
arching-kaos-tools-a4fed5715cc9e47def717ef6f21a5aed34455b32.zip
News module aware renderer
Diffstat (limited to 'bin/ak-news')
-rwxr-xr-xbin/ak-news60
1 files changed, 60 insertions, 0 deletions
diff --git a/bin/ak-news b/bin/ak-news
index 4c42a5d..3f8b94a 100755
--- a/bin/ak-news
+++ b/bin/ak-news
@@ -176,6 +176,7 @@ _ak_modules_news_usage(){
echo " -c, --create Vim is going to pop up, you will write and save your"
echo " newsletter and it's going to be saved"
echo " -s, --specs Print specs of data block"
+ echo " -x, --html <zblock> Returns an appropriate html element from a NEWS zblock"
exit 0
}
@@ -203,6 +204,64 @@ _ak_modules_news_read(){
rm temp
}
+_ak_modules_news_html(){
+ ak-enter -l 1 $1 > temp
+ if [ $? -ne 0 ]
+ then
+ logit "ERROR" "Failed to retrieve zblock $1"
+ exit 22
+ fi
+ module="`cat temp | jq -r '.[].module'`"
+ action="`cat temp | jq -r '.[].action'`"
+ data="`cat temp | jq -r '.[].data'`"
+ linkToText="`cat temp | jq -r ".[].$data.ipfs"`"
+ zfilename="`cat temp | jq -r ".[].$data.filename"`"
+ ztitle="`cat temp | jq -r ".[].$data.title"`"
+ zdatetime="`cat temp | jq -r ".[].$data.datetime"`"
+
+ if [ "$module" == "news" ] && [ "$action" == "add" ]
+ then
+ echo "<table>"
+ echo " <tr>"
+ echo " <td>"
+ echo " <pre>⌚ Date/Time</pre>"
+ echo " </td>"
+ echo " <td>"
+ echo " <pre>$zdatetime</pre>"
+ echo " </td>"
+ echo " </tr>"
+ echo " <tr>"
+ echo " <td>"
+ echo " <pre> ✍️ Title</pre>"
+ echo " </td>"
+ echo " <td>"
+ echo " <pre>$ztitle</pre>"
+ echo " </td>"
+ echo " </tr>"
+ echo " <tr>"
+ echo " <td>"
+ echo " <pre>📄 Filename</pre>"
+ echo " </td>"
+ echo " <td>"
+ echo " <pre>$zfilename</pre>"
+ echo " </td>"
+ echo " </tr>"
+ echo " <tr>"
+ echo " <td>"
+ echo " <pre>📄 Content</pre>"
+ echo " </td>"
+ echo " <td>"
+ echo " <pre>$(_ak_ipfs_cat $linkToText)</pre>"
+ echo " </td>"
+ echo " </tr>"
+ echo '</table>'
+ else
+ logit "ERROR" "Not a news block."
+ exit 1
+ fi
+ rm temp
+}
+
_ak_modules_news_specs(){
datetime_mask=$(printf '^[0-9]\{8\}_[0-9]\{6\}$' | xxd -p)
ipfs_mask=$(printf '^Qm[a-zA-Z0-9]\{44\}$' | xxd -p)
@@ -226,6 +285,7 @@ if [ ! -z $1 ]; then
-c | --create) _ak_modules_news_create; exit;;
-r | --read) _ak_modules_news_read $2; exit;;
-s | --specs) _ak_modules_news_specs $2; exit;;
+ -x | --html) _ak_modules_news_html $2; exit;;
* ) _ak_modules_news_usage;;
esac
else _ak_modules_news_usage