Browse Source

implement identicons

main
ghost 11 months ago
parent
commit
96faf9464d
  1. 1
      composer.json
  2. 31
      src/Controller/RoomController.php
  3. 10
      templates/default/room/index.html.twig

1
composer.json

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
"php": ">=8.2",
"ext-ctype": "*",
"ext-iconv": "*",
"jdenticon/jdenticon": "^1.0",
"kevachat/kevacoin": "^1.0",
"symfony/console": "7.0.*",
"symfony/dotenv": "7.0.*",

31
src/Controller/RoomController.php

@ -58,6 +58,32 @@ class RoomController extends AbstractController @@ -58,6 +58,32 @@ class RoomController extends AbstractController
foreach ((array) $client->kevaFilter($request->get('namespace')) as $post)
{
// Set identicon if not anonymous user
if ($post['key'] === 'anonymous')
{
$icon = false;
}
else
{
$identicon = new \Jdenticon\Identicon();
$identicon->setValue(
$post['key']
);
$identicon->setSize(12);
$identicon->setStyle(
[
'backgroundColor' => 'rgba(255, 255, 255, 0)',
'padding' => 0
]
);
$icon = $identicon->getImageDataUri('webp');
}
// Skip values with meta keys
if (false !== stripos($post['key'], '_KEVA_'))
{
@ -69,7 +95,7 @@ class RoomController extends AbstractController @@ -69,7 +95,7 @@ class RoomController extends AbstractController
{
$feed[] =
[
'key' => $post['key'],
# 'key' => $post['key'],
'value' => $post['value'],
'height' => $post['height'],
# 'vout' => $post['vout'],
@ -80,7 +106,8 @@ class RoomController extends AbstractController @@ -80,7 +106,8 @@ class RoomController extends AbstractController
'timestamp' => $transaction['time'],
'confirmations' => $transaction['confirmations'],
],
'sort' => $transaction['time'] // sort order field
'icon' => $icon,
'sort' => $transaction['time'] // sort order field
];
}
}

10
templates/default/room/index.html.twig

@ -15,9 +15,13 @@ @@ -15,9 +15,13 @@
{% for post in feed %}
<li>
<a name="{{ post.txid }}"></a>
<strong>
@{{ post.key }}
</strong>
{% if post.icon %}
<img src="{{ post.icon }}" alt="icon" />
{% else %}
<strong>
@{{ 'anonymous' | trans }}
</strong>
{% endif %}
<a href="#{{ post.txid }}" title="{{ 'time:' | trans }} {{ post.transaction.time }} / {{ 'block:' | trans }} {{ post.height }}{# / {{ 'confirmations:' | trans }} {{ post.transaction.confirmations }}#}">
{{ post.transaction.timestamp | format_ago }}
</a>

Loading…
Cancel
Save