diff options
Diffstat (limited to 'bin/ak-zblock-gen-html')
-rwxr-xr-x | bin/ak-zblock-gen-html | 203 |
1 files changed, 178 insertions, 25 deletions
diff --git a/bin/ak-zblock-gen-html b/bin/ak-zblock-gen-html index 5c9a8ea..0ad01ad 100755 --- a/bin/ak-zblock-gen-html +++ b/bin/ak-zblock-gen-html @@ -1,5 +1,9 @@ #!/bin/bash +PROGRAM="$(basename $0)" +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 @@ -18,8 +22,8 @@ then fi fi -ak-enter -l 1 "$1" | jq '.[]' > tempz -arg="tempz" +arg="$(mktemp)" +ak-enter -l 1 "$1" | jq '.[]' > $arg ( \ # Create HTML document @@ -29,14 +33,50 @@ 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 -# for arg in "$@" if [ -f "$arg" ] then -#do # Extract data from argument zblock=$(cat $arg | jq -r '.zblock') block=$(cat $arg | jq -r '.block') @@ -51,30 +91,143 @@ then datablock=$(cat $arg | jq -r ".$data") # Output data in HTML format - echo " <h1>ZBLOCK: $zblock</h1>" - echo " <p>BLOCK SIGNATURE: $block_signature</p>" - echo " <pre>$(ak-ipfs-cat $zblock | jq)</pre>" - echo " <h2>BLOCK: $block</h2>" - echo " <pre>$(ak-ipfs-cat $block | jq)</pre>" - echo " <p>TIMESTAMP: $timestamp</p>" - echo " <p>DETACH: $detach</p>" - echo " <pre>$(ak-ipfs-cat $detach)</pre>" - echo " <p>MODULE: $module</p>" - echo " <p>ACTION: $action</p>" - echo " <p>GPG: $gpg</p>" - echo " <pre>$(ak-ipfs-cat $gpg)</pre>" - echo " <p>PREVIOUS: $previous</p>" - echo " <h3>DATA: $data</h3>" - echo " <pre>$datablock</pre>" - echo " <p>ipfs: $(echo $datablock | jq -r '.ipfs')</p>" - echo " <p>detach: $(echo $datablock | jq -r '.detach')</p>" - echo " <pre>$(ak-ipfs-cat $(echo $datablock | jq -r '.detach'))</pre>" - echo " <h2>Rendered ZBLOCK</h2>" + echo " <h1>$PROGRAM</h1>" + 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 -#done +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 tempz +rm $arg |