blob: 289823b1c51aa850f7808ae4c0570e83b81bfedb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
#!/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>"
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
|