diff options
Diffstat (limited to 'bin/ak-zblock-gen-html')
-rwxr-xr-x | bin/ak-zblock-gen-html | 239 |
1 files changed, 0 insertions, 239 deletions
diff --git a/bin/ak-zblock-gen-html b/bin/ak-zblock-gen-html deleted file mode 100755 index d125d82..0000000 --- a/bin/ak-zblock-gen-html +++ /dev/null @@ -1,239 +0,0 @@ -#!/bin/bash -PROGRAM="$(basename $0)" -source $AK_LIBDIR/_ak_ipfs - -time_started=$(date -u +%s.%N) -ss=$(echo $time_started | cut -d '.' -f 1) -nss=$(echo $time_started | cut -d '.' -f 2) -# 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 - -arg="$(mktemp)" -ak-enter -l 1 "$1" | jq '.[]' > $arg - -( \ -# Create HTML document -echo "<!DOCTYPE html>" -echo "<html>" -echo "<head>" -echo " <title>Arching Kaos Chain Data</title>" -echo ' <meta charset="UTF-8">' -echo ' <meta name="viewport" content="width=device-width, initial-scale=1">' -echo ' <style> - body { - background-color: #000; - color: lightgreen; - padding: 2%; - width: auto; - font-family: monospace; - font-size: 1rem; - } - h1, h2, h3, h4 { - text-align: left; - } - pre { - text-align: initial; - background-color: #090909; - border: 1px dashed #444; - font-size: 1rem; - padding: 1vh 1vw; - margin: 0; - } - a, p, summary { - background: #061624; - border: 1px solid #827c7c; - padding: 1vh 1vw; - margin: 0; - color: lightgreen; - font-style: normal; - text-decoration: none; - } - details { - /*! padding: 1vh 1vw; */ - border: 1px dotted; - background-color: #1d4055; - } - footer { - text-align: center; - } - </style>' -echo "</head>" -echo "<body>" - -# 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 " <h1>$PROGRAM</h1>" - echo " <h2>đ $zblock</h2>" - if [ "$module" == "news" ] && [ "$action" == "add" ] - then - ak-news -x $zblock - fi - echo " <h2>âšī¸ $zblock</h2>" - echo " <table>" - echo " <tr>" - echo " <td>" - echo " <pre>đĻ ZBLOCK</pre>" - echo " </td>" - echo " <td>" - echo " <details>" - echo " <summary>$zblock</summary>" - echo " <pre>$(_ak_ipfs_cat $zblock | jq)</pre>" - echo " </details>" - echo " </td>" - echo " </tr>" - echo " <tr>" - echo " <td>" - echo " <pre>đĻ BLOCK</pre>" - echo " </td>" - echo " <td>" - echo " <details>" - echo " <summary>$block</summary>" - echo " <pre>$(_ak_ipfs_cat $block | jq)</pre>" - echo " </details>" - echo " </td>" - echo " </tr>" - echo " <tr>" - echo " <td>" - echo " <pre>đ BLOCK SIGNATURE</pre>" - echo " </td>" - echo " <td>" - echo " <details>" - echo " <summary>$block_signature</summary>" - echo " <pre>$(_ak_ipfs_cat $block_signature)</pre>" - echo " </details>" - echo " </td>" - echo " </tr>" - echo " <tr>" - echo " <td>" - echo " <pre>â TIMESTAMP</pre>" - echo " </td>" - echo " <td>" - echo " <p>$timestamp</p>" - echo " </td>" - echo " </tr>" - echo " <tr>" - echo " <td>" - echo " <pre>đ MODULE</pre>" - echo " </td>" - echo " <td>" - echo " <p>$module</p>" - echo " </td>" - echo " </tr>" - echo " <tr>" - echo " <td>" - echo " <pre>đĒ§ ACTION</pre>" - echo " </td>" - echo " <td>" - echo " <p>$action</p>" - echo " </td>" - echo " </tr>" - echo " <tr>" - echo " <td>" - echo " <pre>đ GPG</pre>" - echo " </td>" - echo " <td>" - echo " <details>" - echo " <summary>$gpg</summary>" - echo " <pre>$(_ak_ipfs_cat $gpg)</pre>" - echo " </details>" - echo " </td>" - echo " </tr>" - echo " <tr>" - echo " <td>" - echo " <pre>đĻ PREVIOUS</pre>" - echo " </td>" - echo " <td>" - echo ' <a target="_blank" href="http://z.kaotisk-hund.com/files/zblocks-as-html/zblock-'$previous'.html">đ '$previous'</a>' - echo " </td>" - echo " </tr>" - echo " <tr>" - echo " <td>" - echo " <pre>đĻ DATA</pre>" - echo " </td>" - echo " <td>" - echo " <details>" - echo " <summary>$data</summary>" - echo " <pre>$datablock</pre>" - echo " </details>" - echo " </td>" - echo " </tr>" - echo " <tr>" - echo " <td>" - echo " <pre>đ DATA_SIGNATURE</pre>" - echo " </td>" - echo " <td>" - echo " <details>" - echo " <summary>$detach</summary>" - echo " <pre>$(_ak_ipfs_cat $detach)</pre>" - echo " </details>" - echo " </td>" - echo " </tr>" - echo " <tr>" - echo " <td>" - echo " <pre>đ ipfs</pre>" - echo " </td>" - echo " <td>" - echo ' <a target="_blank" href="http://gw.ipfs.z.kaotisk-hund.com/ipfs/'$(echo $datablock | jq -r '.ipfs')'">'đ $(echo $datablock | jq -r '.ipfs')'</a>' - echo " </td>" - echo " </tr>" - echo " <tr>" - echo " <td>" - echo " <pre>đ detach</pre>" - echo " </td>" - echo " <td>" - echo " <details>" - echo " <summary>$(echo $datablock | jq -r '.detach')</summary>" - echo " <pre>$(_ak_ipfs_cat $(echo $datablock | jq -r '.detach'))</pre>" - echo " </details>" - echo " </td>" - echo " </tr>" - echo " </table>" - echo " <pre>đ Rendered ZBLOCK</pre>" - echo " <pre>$(cat $arg | jq)</pre>" -fi -time_ended=$(date -u +%s.%N) -se=$(echo $time_ended | cut -d '.' -f 1) -nse=$(echo $time_ended | cut -d '.' -f 2) -echo " <hr>" -echo -n " <footer>Generated by $PROGRAM on $(datehuman) in $(( $se - $ss ))." -if [ $nse -lt $nss ] -then - echo "$(( 1$nse - $nss )) seconds</footer>" -else - echo "$(( $nse - $(echo -n $nss|sed 's/^0*//') )) seconds</footer>" -fi - -echo "</body>" -echo "</html>" ) > zblock-$1.html - -rm $arg |