From 66fd50005fc201186c3ba889e9954095c549b4d1 Mon Sep 17 00:00:00 2001 From: ghost Date: Tue, 13 Feb 2024 00:49:34 +0200 Subject: [PATCH] implement transaction page --- src/Controller/MainController.php | 43 ++++++++++++++++++++ templates/default/layout.html.twig | 25 ++++++++++++ templates/default/main/index.html.twig | 23 +---------- templates/default/main/transaction.html.twig | 39 ++++++++++++++++++ 4 files changed, 108 insertions(+), 22 deletions(-) create mode 100644 templates/default/main/transaction.html.twig diff --git a/src/Controller/MainController.php b/src/Controller/MainController.php index 8e71543..597c060 100644 --- a/src/Controller/MainController.php +++ b/src/Controller/MainController.php @@ -41,4 +41,47 @@ class MainController extends AbstractController ] ); } + + #[Route( + '/{transaction}', + name: 'main_transaction', + requirements: + [ + 'transaction' => '^[A-f0-9]{64}$', + ], + methods: + [ + 'GET' + ] + )] + public function transaction( + ?Request $request + ): Response + { + $index = new \Kvazar\Index\Manticore(); + + $records = $index->get( + '', + [ + 'crc32transaction' => crc32( + $request->get('transaction') + ) + ] + ); + + if (empty($records)) + { + throw $this->createNotFoundException(); + } + + return $this->render( + 'default/main/transaction.html.twig', + [ + 'request' => $request, + 'record' => reset( + $records + ) + ] + ); + } } \ No newline at end of file diff --git a/templates/default/layout.html.twig b/templates/default/layout.html.twig index 7f3ae97..48ff2e1 100644 --- a/templates/default/layout.html.twig +++ b/templates/default/layout.html.twig @@ -8,5 +8,30 @@ {% block body %}{% endblock %} + diff --git a/templates/default/main/index.html.twig b/templates/default/main/index.html.twig index a5e4b62..800309d 100644 --- a/templates/default/main/index.html.twig +++ b/templates/default/main/index.html.twig @@ -21,7 +21,7 @@ {{ record.namespace }} - +
{{ record.key }}
@@ -59,25 +59,4 @@ } ) }}">{{ 'newer' | trans }}
-
-
- - {##} -
-
-
-
- {{ 'KVAZAR Webapp' | trans }} - {{ 'is content explorer for' | trans }} - {{ 'Kevacoin Blockchain' | trans }}. -
-
- {{ 'Sources distributed under the MIT License. Ownership of all content belongs to the authors.' | trans }} -
-
{% endblock %} \ No newline at end of file diff --git a/templates/default/main/transaction.html.twig b/templates/default/main/transaction.html.twig new file mode 100644 index 0000000..aee6346 --- /dev/null +++ b/templates/default/main/transaction.html.twig @@ -0,0 +1,39 @@ +{% extends 'default/layout.html.twig' %} +{% block body %} +
+
+ +
+ + {{ record.namespace }} + +
+ {# @TODO current namespace value +
+ {{ 'Observe Kevacoin Universe' | trans }} +
+ #} +
+
+
+
+
+
+
+
+ {{ record.key }} +
+
+ {{ record.value | nl2br }} +
+
+ {{ record.time | format_date }} {{ 'in' | trans }} {{ record.block }} +
+
+
+
+
+
+{% endblock %} \ No newline at end of file