From 943f034f2bb2df772853a1de2e07d84a6c510c2a Mon Sep 17 00:00:00 2001 From: kaotisk Date: Mon, 10 Jun 2024 16:17:04 +0300 Subject: new lib: _ak_html --- lib/_ak_html | 290 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 290 insertions(+) create mode 100755 lib/_ak_html (limited to 'lib') diff --git a/lib/_ak_html b/lib/_ak_html new file mode 100755 index 0000000..bae5466 --- /dev/null +++ b/lib/_ak_html @@ -0,0 +1,290 @@ +#!/bin/bash +source $AK_LIBDIR/_ak_log + +_ak_generate_html_header(){ + printf '\n\n\n' + printf 'Arching Kaos Chain Data\n' + printf ' \n' + printf ' \n' + printf ' \n' + printf '\n' + printf '\n' +} + +_ak_generate_html_zblock(){ + if [ ! -z $1 ] && [ -n "$1" ] + then + arg="$1" + else + _ak_log_error "No argument given" + exit 1 + fi + # Iterate through each argument and parse data + if [ -f "$arg" ] + then + # Extract data from argument + zblock=$(cat $arg | jq -r '.zblock') + if [ ! -n "$zblock" ] + then + _ak_log_error "Empty zblock value" + exit 1 + fi + block=$(cat $arg | jq -r '.block') + if [ ! -n "$block" ] + then + _ak_log_error "Empty block value" + exit 1 + fi + timestamp=$(cat $arg | jq -r '.timestamp') + if [ ! -n "$timestamp" ] + then + _ak_log_error "Empty timestamp value" + exit 1 + fi + block_signature=$(cat $arg | jq -r '.block_signature') + if [ ! -n "$block_signature" ] + then + _ak_log_error "Empty block_signature value" + exit 1 + fi + detach=$(cat $arg | jq -r '.detach') + if [ ! -n "$detach" ] + then + _ak_log_error "Empty detach value" + exit 1 + fi + data=$(cat $arg | jq -r '.data') + if [ ! -n "$data" ] + then + _ak_log_error "Empty data value" + exit 1 + fi + module=$(cat $arg | jq -r '.module') + if [ ! -n "$module" ] + then + _ak_log_error "Empty module value" + exit 1 + fi + action=$(cat $arg | jq -r '.action') + if [ ! -n "$action" ] + then + _ak_log_error "Empty action value" + exit 1 + fi + gpg=$(cat $arg | jq -r '.gpg') + if [ ! -n "$gpg" ] + then + _ak_log_error "Empty gpg value" + exit 1 + fi + previous=$(cat $arg | jq -r '.previous') + if [ ! -n "$previous" ] + then + _ak_log_error "Empty previous value" + exit 1 + fi + datablock=$(cat $arg | jq -r ".$data") + if [ ! -n "$datablock" ] + then + _ak_log_error "Empty datablock value" + exit 1 + fi + + # Output data in HTML format + printf '

%s

\n' "$PROGRAM" + printf '

🔎 %szblock

\n' "$zblock" + if [ -f $AK_MODULESDIR/$module/main.sh ] && [ "$action" == "add" ] + then + ak -m $module -x $zblock > /dev/null 2>&1 + if [ $? -eq 0 ] + then + ak -m $module -x $zblock + fi + fi + printf '

ℹī¸ %s

\n' "$zblock" + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf '
\n' + printf '
đŸ“Ļ ZBLOCK
\n' + printf '
\n' + printf '
\n' + printf ' $zblock\n' + printf '
%s
' "$(_ak_ipfs_cat $zblock | jq)" + printf '
\n' + printf '
\n' + printf '
đŸ“Ļ BLOCK
\n' + printf '
\n' + printf '
\n' + printf ' %s\n' "$block" + printf '
%s
\n' "$(_ak_ipfs_cat $block | jq)" + printf '
\n' + printf '
\n' + printf '
🔏 BLOCK SIGNATURE
\n' + printf '
\n' + printf '
\n' + printf ' %s\n' "$block_signature" + printf '
%s
\n' "$(_ak_ipfs_cat $block_signature)" + printf '
\n' + printf '
\n' + printf '
⌚ TIMESTAMP
\n' + printf '
\n' + printf '

%s

\n' "$timestamp" + printf '
\n' + printf '
🔌 MODULE
\n' + printf '
\n' + printf '

%s

\n' "$module" + printf '
\n' + printf '
đŸĒ§ ACTION
\n' + printf '
\n' + printf '

%s

\n' "$action" + printf '
\n' + printf '
🔑 GPG
\n' + printf '
\n' + printf '
\n' + printf ' %s\n' "$gpg" + printf '
%s
\n' "$(_ak_ipfs_cat $gpg)" + printf '
\n' + printf '
\n' + printf '
đŸ“Ļ PREVIOUS
\n' + printf '
\n' + printf ' 🔗 %s\n' "$previous" "$previous" + printf '
\n' + printf '
đŸ“Ļ DATA
\n' + printf '
\n' + printf '
\n' + printf ' %s\n' "$data" + printf '
%s
\n' "$datablock" + printf '
\n' + printf '
\n' + printf '
🔏 DATA_SIGNATURE
\n' + printf '
\n' + printf '
\n' + printf ' %s\n' "$detach" + printf '
%s
\n' "$(_ak_ipfs_cat $detach)" + printf '
\n' + printf '
\n' + printf '
📄 ipfs
\n' + printf '
\n' + printf ' 🔗 %s\n' "$(echo $datablock | jq -r '.ipfs')" "$(echo $datablock | jq -r '.ipfs')" + printf '
\n' + printf '
🔏 detach
\n' + printf '
\n' + printf '
\n' + printf ' %s\n' "$(echo $datablock | jq -r '.detach')" + printf '
%s
\n' "$(_ak_ipfs_cat $(echo $datablock | jq -r '.detach'))" + printf '
\n' + printf '
\n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf ' \n' + printf '
\n' + printf '
📃 Rendered ZBLOCK
\n' + printf '
\n' + printf '
%s
\n' "$(cat $arg | jq)" + printf '
\n' + fi +} -- cgit v1.2.3