Browse Source

implement identicons

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

1
composer.json

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

29
src/Controller/RoomController.php

@ -58,6 +58,32 @@ class RoomController extends AbstractController
foreach ((array) $client->kevaFilter($request->get('namespace')) as $post) 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 // Skip values with meta keys
if (false !== stripos($post['key'], '_KEVA_')) if (false !== stripos($post['key'], '_KEVA_'))
{ {
@ -69,7 +95,7 @@ class RoomController extends AbstractController
{ {
$feed[] = $feed[] =
[ [
'key' => $post['key'], # 'key' => $post['key'],
'value' => $post['value'], 'value' => $post['value'],
'height' => $post['height'], 'height' => $post['height'],
# 'vout' => $post['vout'], # 'vout' => $post['vout'],
@ -80,6 +106,7 @@ class RoomController extends AbstractController
'timestamp' => $transaction['time'], 'timestamp' => $transaction['time'],
'confirmations' => $transaction['confirmations'], 'confirmations' => $transaction['confirmations'],
], ],
'icon' => $icon,
'sort' => $transaction['time'] // sort order field 'sort' => $transaction['time'] // sort order field
]; ];
} }

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

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

Loading…
Cancel
Save