From e31fd72048b68daa4dcac1319da0e28cc49c88b7 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Sun, 10 Mar 2024 05:44:05 +0200 Subject: ak2html -> ak-zblock-gen-html --- README | 2 +- bin/ak-zblock-gen-html | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++ bin/ak2html | 80 -------------------------------------------------- 3 files changed, 81 insertions(+), 81 deletions(-) create mode 100755 bin/ak-zblock-gen-html delete mode 100755 bin/ak2html diff --git a/README b/README index 67d0e71..d59dd35 100644 --- a/README +++ b/README @@ -263,7 +263,7 @@ ak-zblock-cache # Caches a whole zblock as it would be done by ak-enter ak-zblock-manipulator # TODO ak-zblock-show # Shows a specified ZBLOCK ak-pack_z_block # Creates and publishes a ZBLOCK (used by modules) -ak2html # Generates a HTML file for a given zblock +ak-zblock-gen-html # Generates a HTML file for a given zblock Zchain tools ------------ diff --git a/bin/ak-zblock-gen-html b/bin/ak-zblock-gen-html new file mode 100755 index 0000000..5c9a8ea --- /dev/null +++ b/bin/ak-zblock-gen-html @@ -0,0 +1,80 @@ +#!/bin/bash + +# Check if there are enough arguments +if [ $# -lt 1 ] +then + echo "Error: Not enough arguments provided" + echo "Give a zblock's IPFS CID v0 as an argument" + exit 1 +fi + +if [ -n "$1" ] +then + TEST="$(echo -n "$1" | grep -v '^Qm[A-Za-z0-9]\{44\}$')" + if [ -n "$TEST" ] + then + echo not ok + exit 1 + fi +fi + +ak-enter -l 1 "$1" | jq '.[]' > tempz +arg="tempz" + +( \ +# Create HTML document +echo "" +echo "" +echo "" +echo " Arching Kaos Chain Data" +echo ' ' +echo ' ' +echo "" +echo "" + +# Iterate through each argument and parse data +# for arg in "$@" +if [ -f "$arg" ] +then +#do + # 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 "

ZBLOCK: $zblock

" + echo "

BLOCK SIGNATURE: $block_signature

" + echo "
$(ak-ipfs-cat $zblock | jq)
" + echo "

BLOCK: $block

" + echo "
$(ak-ipfs-cat $block | jq)
" + echo "

TIMESTAMP: $timestamp

" + echo "

DETACH: $detach

" + echo "
$(ak-ipfs-cat $detach)
" + echo "

MODULE: $module

" + echo "

ACTION: $action

" + echo "

GPG: $gpg

" + echo "
$(ak-ipfs-cat $gpg)
" + echo "

PREVIOUS: $previous

" + echo "

DATA: $data

" + echo "
$datablock
" + echo "

ipfs: $(echo $datablock | jq -r '.ipfs')

" + echo "

detach: $(echo $datablock | jq -r '.detach')

" + echo "
$(ak-ipfs-cat $(echo $datablock | jq -r '.detach'))
" + echo "

Rendered ZBLOCK

" + echo "
$(cat $arg | jq)
" +fi +#done + +echo "" +echo "" ) > zblock-$1.html + +rm tempz diff --git a/bin/ak2html b/bin/ak2html deleted file mode 100755 index 5c9a8ea..0000000 --- a/bin/ak2html +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash - -# Check if there are enough arguments -if [ $# -lt 1 ] -then - echo "Error: Not enough arguments provided" - echo "Give a zblock's IPFS CID v0 as an argument" - exit 1 -fi - -if [ -n "$1" ] -then - TEST="$(echo -n "$1" | grep -v '^Qm[A-Za-z0-9]\{44\}$')" - if [ -n "$TEST" ] - then - echo not ok - exit 1 - fi -fi - -ak-enter -l 1 "$1" | jq '.[]' > tempz -arg="tempz" - -( \ -# Create HTML document -echo "" -echo "" -echo "" -echo " Arching Kaos Chain Data" -echo ' ' -echo ' ' -echo "" -echo "" - -# Iterate through each argument and parse data -# for arg in "$@" -if [ -f "$arg" ] -then -#do - # 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 "

ZBLOCK: $zblock

" - echo "

BLOCK SIGNATURE: $block_signature

" - echo "
$(ak-ipfs-cat $zblock | jq)
" - echo "

BLOCK: $block

" - echo "
$(ak-ipfs-cat $block | jq)
" - echo "

TIMESTAMP: $timestamp

" - echo "

DETACH: $detach

" - echo "
$(ak-ipfs-cat $detach)
" - echo "

MODULE: $module

" - echo "

ACTION: $action

" - echo "

GPG: $gpg

" - echo "
$(ak-ipfs-cat $gpg)
" - echo "

PREVIOUS: $previous

" - echo "

DATA: $data

" - echo "
$datablock
" - echo "

ipfs: $(echo $datablock | jq -r '.ipfs')

" - echo "

detach: $(echo $datablock | jq -r '.detach')

" - echo "
$(ak-ipfs-cat $(echo $datablock | jq -r '.detach'))
" - echo "

Rendered ZBLOCK

" - echo "
$(cat $arg | jq)
" -fi -#done - -echo "" -echo "" ) > zblock-$1.html - -rm tempz -- cgit v1.2.3