blockchain_view.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. const { div, h2, h3, p, section, button, form, a, input, span, pre, table, tr, td, strong } = require("../server/node_modules/hyperaxe");
  2. const { template, i18n } = require("../views/main_views");
  3. const moment = require("../server/node_modules/moment");
  4. const FILTER_LABELS = {
  5. votes: i18n.typeVotes, vote: i18n.typeVote, recent: i18n.recent, all: i18n.all,
  6. mine: i18n.mine, tombstone: i18n.typeTombstone, logs: i18n.typeLog || 'LOGS', pixelia: i18n.typePixelia,
  7. curriculum: i18n.typeCurriculum, document: i18n.typeDocument, bookmark: i18n.typeBookmark,
  8. feed: i18n.typeFeed, event: i18n.typeEvent, task: i18n.typeTask, report: i18n.typeReport,
  9. image: i18n.typeImage, audio: i18n.typeAudio, video: i18n.typeVideo, post: i18n.typePost,
  10. forum: i18n.typeForum, about: i18n.typeAbout, contact: i18n.typeContact, pub: i18n.typePub,
  11. transfer: i18n.typeTransfer, market: i18n.typeMarket, job: i18n.typeJob, tribe: i18n.typeTribe,
  12. project: i18n.typeProject, banking: i18n.typeBanking, bankWallet: i18n.typeBankWallet, bankClaim: i18n.typeBankClaim,
  13. aiExchange: i18n.typeAiExchange, parliament: i18n.typeParliament, courts: i18n.typeCourts,
  14. map: i18n.typeMap, shop: i18n.typeShop, shopProduct: i18n.typeShopProduct || 'Shop Product',
  15. pad: i18n.typePad || 'PAD', chat: i18n.typeChat || 'CHAT', gameScore: i18n.typeGameScore || 'GAME SCORE',
  16. calendar: i18n.typeCalendar || 'CALENDAR', torrent: i18n.typeTorrent
  17. };
  18. const BASE_FILTERS = ['recent', 'all', 'mine', 'tombstone', 'logs'];
  19. const CAT_BLOCK1 = ['votes', 'event', 'task', 'report', 'calendar', 'parliament', 'courts'];
  20. const CAT_BLOCK2 = ['pub', 'tribe', 'about', 'contact', 'curriculum', 'vote', 'aiExchange'];
  21. const CAT_BLOCK3 = ['banking', 'job', 'market', 'project', 'transfer', 'feed', 'post', 'pixelia', 'shop', 'gameScore'];
  22. const CAT_BLOCK4 = ['forum', 'pad', 'chat', 'bookmark', 'image', 'video', 'audio', 'document', 'map', 'torrent'];
  23. const SEARCH_FIELDS = ['author','id','from','to'];
  24. const hiddenSearchInputs = (search) =>
  25. SEARCH_FIELDS.map(k => {
  26. const v = String(search?.[k] ?? '').trim();
  27. return v ? input({ type: 'hidden', name: k, value: v }) : null;
  28. }).filter(Boolean);
  29. const toDatetimeLocal = (s) => {
  30. const raw = String(s || '').trim();
  31. if (!raw) return '';
  32. const ts = new Date(raw).getTime();
  33. if (!Number.isFinite(ts)) return '';
  34. return moment(ts).format('YYYY-MM-DDTHH:mm');
  35. };
  36. const toQueryString = (filter, search = {}) => {
  37. const parts = [];
  38. const f = String(filter || '').trim();
  39. if (f) parts.push(`filter=${encodeURIComponent(f)}`);
  40. for (const k of SEARCH_FIELDS) {
  41. const v = String(search?.[k] ?? '').trim();
  42. if (v) parts.push(`${encodeURIComponent(k)}=${encodeURIComponent(v)}`);
  43. }
  44. return parts.length ? `?${parts.join('&')}` : '';
  45. };
  46. const filterBlocks = (blocks, filter, userId) => {
  47. if (filter === 'recent') return blocks.filter(b => Date.now() - b.ts < 24*60*60*1000);
  48. if (filter === 'mine') return blocks.filter(b => b.author === userId);
  49. if (filter === 'all') return blocks;
  50. if (filter === 'banking') return blocks.filter(b => b.type === 'bankWallet' || b.type === 'bankClaim');
  51. if (filter === 'parliament') {
  52. const pset = new Set(['parliamentTerm','parliamentProposal','parliamentLaw','parliamentCandidature','parliamentRevocation']);
  53. return blocks.filter(b => pset.has(b.type));
  54. }
  55. if (filter === 'courts') {
  56. const cset = new Set(['courtsCase','courtsEvidence','courtsAnswer','courtsVerdict','courtsSettlement','courtsSettlementProposal','courtsSettlementAccepted','courtsNomination','courtsNominationVote']);
  57. return blocks.filter(b => cset.has(b.type));
  58. }
  59. if (filter === 'shop') return blocks.filter(b => b.type === 'shop' || b.type === 'shopProduct');
  60. if (filter === 'logs') return blocks.filter(b => b.type === 'log' && b.author === userId);
  61. return blocks.filter(b => b.type === filter);
  62. };
  63. const generateFilterButtons = (filters, currentFilter, action, search = {}) =>
  64. div({ class: 'mode-buttons-cols' },
  65. filters.map(mode =>
  66. form({ method: 'GET', action },
  67. input({ type: 'hidden', name: 'filter', value: mode }),
  68. ...hiddenSearchInputs(search),
  69. button({
  70. type: 'submit',
  71. class: currentFilter === mode ? 'filter-btn active' : 'filter-btn'
  72. }, (FILTER_LABELS[mode]||mode).toUpperCase())
  73. )
  74. )
  75. );
  76. const getViewDetailsAction = (type, block) => {
  77. if (block && block.content && typeof block.content.encryptedPayload === 'string') return null;
  78. switch (type) {
  79. case 'votes': return `/votes/${encodeURIComponent(block.id)}`;
  80. case 'transfer': return `/transfers/${encodeURIComponent(block.id)}`;
  81. case 'pixelia': return `/pixelia`;
  82. case 'tribe': return `/tribe/${encodeURIComponent(block.id)}`;
  83. case 'curriculum': return `/inhabitant/${encodeURIComponent(block.author)}`;
  84. case 'image': return `/images/${encodeURIComponent(block.id)}`;
  85. case 'audio': return `/audios/${encodeURIComponent(block.id)}`;
  86. case 'video': return `/videos/${encodeURIComponent(block.id)}`;
  87. case 'forum': return `/forum/${encodeURIComponent(block.content?.key||block.id)}`;
  88. case 'document': return `/documents/${encodeURIComponent(block.id)}`;
  89. case 'bookmark': return `/bookmarks/${encodeURIComponent(block.id)}`;
  90. case 'event': return `/events/${encodeURIComponent(block.id)}`;
  91. case 'task': return `/tasks/${encodeURIComponent(block.id)}`;
  92. case 'about': return `/author/${encodeURIComponent(block.author)}`;
  93. case 'post': return `/thread/${encodeURIComponent(block.id)}#${encodeURIComponent(block.id)}`;
  94. case 'vote': return `/thread/${encodeURIComponent(block.content.vote.link)}#${encodeURIComponent(block.content.vote.link)}`;
  95. case 'contact': return `/inhabitants`;
  96. case 'pub': return `/invites`;
  97. case 'market': return `/market/${encodeURIComponent(block.id)}`;
  98. case 'job': return `/jobs/${encodeURIComponent(block.id)}`;
  99. case 'project': return `/projects/${encodeURIComponent(block.id)}`;
  100. case 'report': return `/reports/${encodeURIComponent(block.id)}`;
  101. case 'calendar': return `/calendars/${encodeURIComponent(block.id)}`;
  102. case 'bankWallet': return `/wallet`;
  103. case 'bankClaim': return `/banking${block.content?.epochId ? `/epoch/${encodeURIComponent(block.content.epochId)}` : ''}`;
  104. case 'parliamentTerm': return `/parliament`;
  105. case 'parliamentProposal': return `/parliament`;
  106. case 'parliamentLaw': return `/parliament`;
  107. case 'parliamentCandidature': return `/parliament`;
  108. case 'parliamentRevocation': return `/parliament`;
  109. case 'courtsCase': return `/courts`;
  110. case 'courtsEvidence': return `/courts`;
  111. case 'courtsAnswer': return `/courts`;
  112. case 'courtsVerdict': return `/courts`;
  113. case 'courtsSettlement': return `/courts`;
  114. case 'courtsSettlementProposal': return `/courts`;
  115. case 'courtsSettlementAccepted': return `/courts`;
  116. case 'courtsNomination': return `/courts`;
  117. case 'courtsNominationVote': return `/courts`;
  118. case 'map': return `/maps/${encodeURIComponent(block.id)}`;
  119. case 'torrent': return `/torrents/${encodeURIComponent(block.id)}`;
  120. case 'mapMarker': return block.content?.mapId ? `/maps/${encodeURIComponent(block.content.mapId)}` : `/maps`;
  121. case 'shop': return `/shops/${encodeURIComponent(block.id)}`;
  122. case 'shopProduct': return `/shops/product/${encodeURIComponent(block.id)}`;
  123. case 'pad': return `/pads/${encodeURIComponent(block.id)}`;
  124. case 'chat': return `/chats/${encodeURIComponent(block.id)}`;
  125. case 'gameScore': return `/games?filter=scoring`;
  126. case 'log': return `/logs/view/${encodeURIComponent(block.id)}`;
  127. case 'calendarDate':
  128. case 'calendarNote': return block.content?.calendarId ? `/calendars/${encodeURIComponent(block.content.calendarId)}` : `/calendars`;
  129. case 'padEntry': return block.content?.padId ? `/pads/${encodeURIComponent(block.content.padId)}` : `/pads`;
  130. case 'chatMessage': return block.content?.roomId ? `/chats/${encodeURIComponent(block.content.roomId)}` : `/chats`;
  131. default: return null;
  132. }
  133. };
  134. const TYPE_COLORS = {
  135. post:'#3498db', vote:'#9b59b6', votes:'#9b59b6', about:'#1abc9c', contact:'#16a085',
  136. pub:'#2ecc71', tribe:'#e67e22', event:'#e74c3c', task:'#f39c12', report:'#c0392b',
  137. image:'#2980b9', audio:'#8e44ad', video:'#d35400', document:'#27ae60', bookmark:'#f1c40f',
  138. forum:'#1abc9c', feed:'#95a5a6', transfer:'#e74c3c', market:'#e67e22', job:'#3498db',
  139. project:'#2ecc71', banking:'#f39c12', bankWallet:'#f39c12', bankClaim:'#f39c12',
  140. pixelia:'#9b59b6', curriculum:'#1abc9c', aiExchange:'#3498db', tombstone:'#7f8c8d',
  141. parliamentTerm:'#8e44ad', parliamentProposal:'#8e44ad', parliamentLaw:'#8e44ad',
  142. parliamentCandidature:'#8e44ad', parliamentRevocation:'#8e44ad',
  143. courtsCase:'#c0392b', courtsEvidence:'#c0392b', courtsAnswer:'#c0392b',
  144. courtsVerdict:'#c0392b', courtsSettlement:'#c0392b', courtsNomination:'#c0392b',
  145. map:'#27ae60', mapMarker:'#27ae60',
  146. shop:'#e67e22', shopProduct:'#e67e22',
  147. pad:'#2ecc71', chat:'#3498db', gameScore:'#f39c12',
  148. calendar:'#e74c3c'
  149. };
  150. const renderBlockDiagram = (blocks, qs) => {
  151. const last2 = blocks.slice(0, 2);
  152. if (!last2.length) return null;
  153. return div({ class: 'block-diagram-section' },
  154. h3({ class: 'block-diagram-title' }, i18n.blockchainLatestDatagram || 'Latest Datagram'),
  155. ...last2.map(block => {
  156. const ts = moment(block.ts).format('YYYY-MM-DD HH:mm:ss');
  157. const typeLabel = (FILTER_LABELS[block.type] || block.type).toUpperCase();
  158. const color = TYPE_COLORS[block.type] || '#95a5a6';
  159. const shortId = block.id.length > 20 ? block.id.slice(0, 10) + '…' + block.id.slice(-8) : block.id;
  160. const shortAuthor = block.author.length > 20 ? block.author.slice(0, 10) + '…' + block.author.slice(-8) : block.author;
  161. const contentKeys = Object.keys(block.content || {}).filter(k => k !== 'type').join(', ');
  162. const flags = [
  163. block.isTombstoned ? 'TOMBSTONED' : null,
  164. block.isReplaced ? 'REPLACED' : null,
  165. block.content?.replaces ? 'EDIT' : null
  166. ].filter(Boolean).join(' | ') || '—';
  167. const datagramQs = qs ? `${qs}&view=datagram` : '?view=datagram';
  168. const typeClass = `bd-type-${String(block.type || 'unknown').replace(/[^a-zA-Z0-9_-]/g, '-')}`;
  169. return a({ href: `/blockexplorer/block/${encodeURIComponent(block.id)}${datagramQs}`, class: 'block-diagram-link' },
  170. div({ class: `block-diagram ${typeClass}` },
  171. div({ class: 'block-diagram-ruler' },
  172. span('0'), span('4'), span('8'), span('16'), span('24'), span('31')
  173. ),
  174. div({ class: 'block-diagram-grid' },
  175. div({ class: 'block-diagram-cell bd-seq' },
  176. span({ class: 'bd-label' }, 'SEQ:'),
  177. span({ class: 'bd-value' }, String(block.content?.sequence || '—'))
  178. ),
  179. div({ class: 'block-diagram-cell bd-type' },
  180. span({ class: 'bd-label' }, 'TYPE:'),
  181. span({ class: 'bd-value' }, typeLabel)
  182. ),
  183. div({ class: 'block-diagram-cell bd-ts' },
  184. span({ class: 'bd-label' }, 'TIMESTAMP:'),
  185. span({ class: 'bd-value' }, ts)
  186. ),
  187. div({ class: 'block-diagram-cell bd-id' },
  188. span({ class: 'bd-label' }, 'BLOCK ID:'),
  189. span({ class: 'bd-value' }, shortId)
  190. ),
  191. div({ class: 'block-diagram-cell bd-author' },
  192. span({ class: 'bd-label' }, 'AUTHOR:'),
  193. span({ class: 'bd-value' }, shortAuthor)
  194. ),
  195. div({ class: 'block-diagram-cell bd-flags' },
  196. span({ class: 'bd-label' }, 'FLAGS:'),
  197. span({ class: 'bd-value' }, flags)
  198. ),
  199. div({ class: 'block-diagram-cell bd-ctype' },
  200. span({ class: 'bd-label' }, 'CONTENT.TYPE:'),
  201. span({ class: 'bd-value' }, block.content?.type || '—')
  202. ),
  203. div({ class: 'block-diagram-cell bd-data' },
  204. span({ class: 'bd-label' }, 'CONTENT:'),
  205. span({ class: 'bd-value' }, contentKeys || '—')
  206. )
  207. )
  208. )
  209. );
  210. })
  211. );
  212. };
  213. const renderSingleBlockView = (block, filter = 'recent', userId, search = {}, viewMode = 'block', restricted = false) => {
  214. if (!block) {
  215. return template(
  216. i18n.blockchain,
  217. section(
  218. div({ class: 'tags-header' },
  219. h2(i18n.blockchain),
  220. p(i18n.blockchainDescription)
  221. ),
  222. p(i18n.blockchainNoBlocks || 'No blocks')
  223. )
  224. );
  225. }
  226. const qs = toQueryString(filter, search);
  227. const isDatagram = viewMode === 'datagram';
  228. const blockContent = restricted
  229. ? div(
  230. div({ class: 'block-single' },
  231. div({ class: 'block-row block-row--meta' },
  232. span({ class: 'blockchain-card-label' }, `${i18n.blockchainBlockID}:`),
  233. span({ class: 'blockchain-card-value' }, block.id)
  234. ),
  235. div({ class: 'block-row block-row--meta' },
  236. span({ class: 'blockchain-card-label' }, `${i18n.blockchainBlockTimestamp}:`),
  237. span({ class: 'blockchain-card-value' }, moment(block.ts).format('YYYY-MM-DDTHH:mm:ss.SSSZ')),
  238. span({ class: 'blockchain-card-label' }, `${i18n.blockchainBlockType}:`),
  239. span({ class: 'blockchain-card-value' }, (FILTER_LABELS[block.type]||block.type).toUpperCase())
  240. )
  241. ),
  242. div({ class: 'block-row block-row--content' },
  243. p({ class: 'access-denied-msg' }, i18n.blockAccessRestricted)
  244. )
  245. )
  246. : isDatagram
  247. ? renderBlockDiagram([block], qs)
  248. : div(
  249. div({ class: 'block-single' },
  250. div({ class: 'block-row block-row--meta' },
  251. span({ class: 'blockchain-card-label' }, `${i18n.blockchainBlockID}:`),
  252. span({ class: 'blockchain-card-value' }, block.id)
  253. ),
  254. div({ class: 'block-row block-row--meta' },
  255. span({ class: 'blockchain-card-label' }, `${i18n.blockchainBlockTimestamp}:`),
  256. span({ class: 'blockchain-card-value' }, moment(block.ts).format('YYYY-MM-DDTHH:mm:ss.SSSZ')),
  257. span({ class: 'blockchain-card-label' }, `${i18n.blockchainBlockType}:`),
  258. span({ class: 'blockchain-card-value' }, (FILTER_LABELS[block.type]||block.type).toUpperCase())
  259. ),
  260. div({ class: 'block-row block-row--meta block-row--meta-spaced' },
  261. a({ href:`/author/${encodeURIComponent(block.author)}`, class:'block-author user-link' }, block.author)
  262. )
  263. ),
  264. div({ class:'block-row block-row--content' },
  265. div({ class:'block-content-preview' },
  266. block.content && typeof block.content.encryptedPayload === 'string'
  267. ? div({ class: 'encrypted-payload-box' },
  268. p({ class: 'encrypted-label' }, `[${i18n.bxEncrypted || 'ENCRYPTED'}]`),
  269. p({ class: 'encrypted-hex-label' }, i18n.bxEncryptedHexLabel || 'Ciphertext (preview)'),
  270. pre({ class: 'json-content' }, String(block.content.encryptedPayload).slice(0, 128) + (String(block.content.encryptedPayload).length > 128 ? '…' : ''))
  271. )
  272. : pre({ class:'json-content' }, JSON.stringify(block.content,null,2))
  273. )
  274. )
  275. );
  276. return template(
  277. i18n.blockchain,
  278. section(
  279. div({ class: 'tags-header' },
  280. h2(i18n.blockchain),
  281. p(i18n.blockchainDescription)
  282. ),
  283. div({ class: 'mode-buttons-row' },
  284. div({ class: 'filter-column' },
  285. generateFilterButtons(BASE_FILTERS, filter, '/blockexplorer', search)
  286. ),
  287. div({ class: 'filter-column' },
  288. generateFilterButtons(CAT_BLOCK1, filter, '/blockexplorer', search),
  289. generateFilterButtons(CAT_BLOCK2, filter, '/blockexplorer', search)
  290. ),
  291. div({ class: 'filter-column' },
  292. generateFilterButtons(CAT_BLOCK3, filter, '/blockexplorer', search),
  293. generateFilterButtons(CAT_BLOCK4, filter, '/blockexplorer', search)
  294. )
  295. ),
  296. blockContent,
  297. div({ class:'block-row block-row--back' },
  298. form({ method:'GET', action:'/blockexplorer' },
  299. input({ type: 'hidden', name: 'filter', value: filter }),
  300. ...hiddenSearchInputs(search),
  301. button({ type:'submit', class:'filter-btn' }, `← ${i18n.blockchainBack}`)
  302. ),
  303. !block.isTombstoned && !block.isReplaced && getViewDetailsAction(block.type, block) ?
  304. form({ method:'GET', action:getViewDetailsAction(block.type, block) },
  305. button({ type:'submit', class:'filter-btn' }, i18n.visitContent)
  306. )
  307. : (block.isTombstoned || block.isReplaced) ?
  308. div({ class: 'deleted-label' },
  309. i18n.blockchainContentDeleted || "This content has been deleted."
  310. )
  311. : null
  312. )
  313. )
  314. );
  315. };
  316. const renderBlockchainView = (blocks, filter, userId, search = {}) => {
  317. const s = search || {};
  318. const authorVal = String(s.author || '');
  319. const idVal = String(s.id || '');
  320. const fromVal = toDatetimeLocal(s.from);
  321. const toVal = toDatetimeLocal(s.to);
  322. const shown = filterBlocks(blocks, filter, userId);
  323. const qs = toQueryString(filter, s);
  324. return template(
  325. i18n.blockchain,
  326. section(
  327. div({ class:'tags-header' },
  328. h2(i18n.blockchain),
  329. p(i18n.blockchainDescription)
  330. ),
  331. div({ class:'mode-buttons-row' },
  332. div({ class: 'filter-column' },
  333. generateFilterButtons(BASE_FILTERS, filter, '/blockexplorer', s)
  334. ),
  335. div({ class: 'filter-column' },
  336. generateFilterButtons(CAT_BLOCK1, filter, '/blockexplorer', s),
  337. generateFilterButtons(CAT_BLOCK2, filter, '/blockexplorer', s)
  338. ),
  339. div({ class: 'filter-column' },
  340. generateFilterButtons(CAT_BLOCK3, filter, '/blockexplorer', s),
  341. generateFilterButtons(CAT_BLOCK4, filter, '/blockexplorer', s)
  342. )
  343. ),
  344. div({ class: 'blockexplorer-search' },
  345. form({ method: 'GET', action: '/blockexplorer', class: 'blockexplorer-search-form' },
  346. input({ type: 'hidden', name: 'filter', value: filter }),
  347. div({ class: 'blockexplorer-search-row' },
  348. div({ class: 'blockexplorer-search-pair' },
  349. input({ type: 'text', name: 'id', value: idVal, placeholder: i18n.blockchainBlockID, class: 'blockexplorer-search-input' }),
  350. input({ type: 'text', name: 'author', value: authorVal, placeholder: i18n.courtsJudgeIdPh, class: 'blockexplorer-search-input' })
  351. ),
  352. div({ class: 'blockexplorer-search-dates' },
  353. input({ type: 'datetime-local', name: 'from', value: fromVal, class: 'blockexplorer-search-input' }),
  354. input({ type: 'datetime-local', name: 'to', value: toVal, class: 'blockexplorer-search-input' })
  355. ),
  356. div({ class: 'blockexplorer-search-actions' },
  357. button({ type: 'submit', class: 'filter-box__button' }, i18n.searchSubmit)
  358. )
  359. )
  360. )
  361. ),
  362. renderBlockDiagram(shown, qs),
  363. h2({ class: 'block-diagram-title' }, 'Blockchain Blocks'),
  364. shown.length === 0
  365. ? div(p(i18n.blockchainNoBlocks))
  366. : shown
  367. .sort((a,b)=>{
  368. const ta = a.type==='market'&&a.content.updatedAt
  369. ? new Date(a.content.updatedAt).getTime()
  370. : a.ts;
  371. const tb = b.type==='market'&&b.content.updatedAt
  372. ? new Date(b.content.updatedAt).getTime()
  373. : b.ts;
  374. return tb - ta;
  375. })
  376. .map(block=>
  377. div({ class:'block' },
  378. div({ class:'block-buttons' },
  379. block.restricted ? null : a({ href:`/blockexplorer/block/${encodeURIComponent(block.id)}${qs}`, class:'btn-singleview', title:i18n.blockchainDetails }, '⦿'),
  380. block.restricted ? null : a({ href:`/blockexplorer/block/${encodeURIComponent(block.id)}${qs}&view=datagram`, class:'btn-singleview btn-datagram', title:i18n.blockchainDatagram || 'Datagram' }, '⊞'),
  381. !block.isTombstoned && !block.isReplaced && getViewDetailsAction(block.type, block) ?
  382. form({ method:'GET', action:getViewDetailsAction(block.type, block) },
  383. button({ type:'submit', class:'filter-btn' }, i18n.visitContent)
  384. )
  385. : (block.isTombstoned || block.isReplaced) ?
  386. div({ class: 'deleted-label' },
  387. i18n.blockchainContentDeleted || "This content has been deleted."
  388. )
  389. : null
  390. ),
  391. div({ class:'block-row block-row--meta' },
  392. table({ class:'block-info-table' },
  393. tr(td({ class:'card-label' }, i18n.blockchainBlockTimestamp), td({ class:'card-value' }, moment(block.ts).format('YYYY-MM-DDTHH:mm:ss.SSSZ'))),
  394. tr(td({ class:'card-label' }, i18n.blockchainBlockID), td({ class:'card-value' }, block.id)),
  395. tr(td({ class:'card-label' }, i18n.blockchainBlockType), td({ class:'card-value' }, (FILTER_LABELS[block.type]||block.type).toUpperCase())),
  396. tr(td({ class:'card-label' }, i18n.blockchainBlockAuthor), td({ class:'card-value' }, a({ href:`/author/${encodeURIComponent(block.author)}`, class:'block-author user-link' }, block.author)))
  397. )
  398. )
  399. )
  400. )
  401. )
  402. );
  403. };
  404. module.exports = { renderBlockchainView, renderSingleBlockView };