From 1c0efac2b6be7d9e5e7bbddd237fef72eef49bd5 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Mon, 10 Jun 2024 16:35:33 +0300 Subject: Refactoring --- lib/_ak_zblock | 238 +++------------------------------------------------------ lib/_ak_zchain | 4 +- 2 files changed, 11 insertions(+), 231 deletions(-) (limited to 'lib') diff --git a/lib/_ak_zblock b/lib/_ak_zblock index 8a83479..ae95159 100755 --- a/lib/_ak_zblock +++ b/lib/_ak_zblock @@ -386,242 +386,22 @@ _ak_zblock_gen_html(){ arg="$(mktemp)" _ak_zblock_show "$1" | jq > $arg - ( \ - # Create HTML document - echo "" - echo "" - echo "" - echo " Arching Kaos Chain Data" - echo ' ' - echo ' ' - echo ' ' - echo "" - echo "" - - # Iterate through each argument and parse data - if [ -f "$arg" ] - then - # Extract data from argument - zblock=$(cat $arg | jq -r '.zblock') - block=$(cat $arg | jq -r '.block') - timestamp=$(cat $arg | jq -r '.timestamp') - block_signature=$(cat $arg | jq -r '.block_signature') - detach=$(cat $arg | jq -r '.detach') - data=$(cat $arg | jq -r '.data') - module=$(cat $arg | jq -r '.module') - action=$(cat $arg | jq -r '.action') - gpg=$(cat $arg | jq -r '.gpg') - previous=$(cat $arg | jq -r '.previous') - datablock=$(cat $arg | jq -r ".$data") - - # Output data in HTML format - echo "

$PROGRAM

" - echo "

🔎 $zblock

" - if [ "$module" == "news" ] && [ "$action" == "add" ] - then - ak-news -x $zblock - fi - echo "

ℹī¸ $zblock

" - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo "
" - echo "
đŸ“Ļ ZBLOCK
" - echo "
" - echo "
" - echo " $zblock" - echo "
$(_ak_ipfs_cat $zblock | jq)
" - echo "
" - echo "
" - echo "
đŸ“Ļ BLOCK
" - echo "
" - echo "
" - echo " $block" - echo "
$(_ak_ipfs_cat $block | jq)
" - echo "
" - echo "
" - echo "
🔏 BLOCK SIGNATURE
" - echo "
" - echo "
" - echo " $block_signature" - echo "
$(_ak_ipfs_cat $block_signature)
" - echo "
" - echo "
" - echo "
⌚ TIMESTAMP
" - echo "
" - echo "

$timestamp

" - echo "
" - echo "
🔌 MODULE
" - echo "
" - echo "

$module

" - echo "
" - echo "
đŸĒ§ ACTION
" - echo "
" - echo "

$action

" - echo "
" - echo "
🔑 GPG
" - echo "
" - echo "
" - echo " $gpg" - echo "
$(_ak_ipfs_cat $gpg)
" - echo "
" - echo "
" - echo "
đŸ“Ļ PREVIOUS
" - echo "
" - echo ' 🔗 '$previous'' - echo "
" - echo "
đŸ“Ļ DATA
" - echo "
" - echo "
" - echo " $data" - echo "
$datablock
" - echo "
" - echo "
" - echo "
🔏 DATA_SIGNATURE
" - echo "
" - echo "
" - echo " $detach" - echo "
$(_ak_ipfs_cat $detach)
" - echo "
" - echo "
" - echo "
📄 ipfs
" - echo "
" - echo ' '🔗 $(echo $datablock | jq -r '.ipfs')'' - echo "
" - echo "
🔏 detach
" - echo "
" - echo "
" - echo " $(echo $datablock | jq -r '.detach')" - echo "
$(_ak_ipfs_cat $(echo $datablock | jq -r '.detach'))
" - echo "
" - echo "
" - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo " " - echo "
" - echo "
📃 Rendered ZBLOCK
" - echo "
" - echo "
$(cat $arg | jq)
" - echo "
" - fi + _ak_generate_html_header > zblock-$1.html + _ak_generate_html_zblock $arg >> zblock-$1.html + time_ended=$(date -u +%s.%N) se=$(echo $time_ended | cut -d '.' -f 1) nse=$(echo $time_ended | cut -d '.' -f 2) - echo "
" - echo -n " \n' "$(( 1$nse - $nss ))" >> zblock-$1.html else - echo "$(( $nse - $(echo -n $nss|sed 's/^0*//') )) seconds" + printf '%s seconds' "$(( $nse - $(echo -n $nss|sed 's/^0*//') ))" >> zblock-$1.html fi - - echo "" - echo "" ) > zblock-$1.html + printf '' >> zblock-$1.html + printf '' >> zblock-$1.html rm $arg } diff --git a/lib/_ak_zchain b/lib/_ak_zchain index 2573524..8ba431d 100755 --- a/lib/_ak_zchain +++ b/lib/_ak_zchain @@ -2,7 +2,7 @@ source $AK_LIBDIR/_ak_ipfs source $AK_LIBDIR/_ak_log -_ak_zchain_reset (){ +_ak_zchain_reset(){ echo "Reseting ZLATEST to ZGENESIS" cp $ZGENESIS $ZLATEST if [ $? != 0 ]; then exit 1; fi @@ -39,7 +39,7 @@ _ak_zchain_reset (){ exit 0 } -_ak_zchain_rebase (){ +_ak_zchain_rebase(){ if [ ! -n "$1" ]; then exit 1; fi ZTARGET="$1" echo "Reseting ZLATEST to ZTARGET" -- cgit v1.2.3