Browse Source

implement post quotes

main
ghost 12 months ago
parent
commit
3a500a1554
  1. 33
      src/Controller/ModuleController.php
  2. 7
      src/Controller/RoomController.php
  3. 6
      templates/default/module/room.html.twig
  4. 7
      templates/default/room/index.html.twig

33
src/Controller/ModuleController.php

@ -120,12 +120,43 @@ class ModuleController extends AbstractController @@ -120,12 +120,43 @@ class ModuleController extends AbstractController
}
}
// Format quoted message
if (preg_match('/^[A-z0-9]{64}$/', $request->get('txid')))
{
$message = str_replace(
[
sprintf(
'@%s',
$request->get('txid')
)
],
false,
$request->get('message')
);
$message = trim(
$message
);
$message = sprintf(
'@%s%s%s',
$request->get('txid'),
PHP_EOL,
$request->get('message')
);
}
else
{
$message = $request->get('message');
}
return $this->render(
'default/module/post.html.twig',
[
'enabled' => in_array($request->get('namespace'), $public),
'namespace' => $request->get('namespace'),
'message' => $request->get('message'),
'message' => $message,
'user' => $request->get('user'),
'ip' => $request->getClientIp()
]

7
src/Controller/RoomController.php

@ -29,11 +29,16 @@ class RoomController extends AbstractController @@ -29,11 +29,16 @@ class RoomController extends AbstractController
}
#[Route(
'/room/{namespace}',
'/room/{namespace}/{txid}',
name: 'room_namespace',
requirements:
[
'namespace' => '^[A-z0-9]{34}$',
'txid' => '^[A-z0-9]{64}$',
],
defaults:
[
'txid' => null,
],
methods:
[

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

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<form name="room" action="{{ path('room_index') }}" method="get">
<form name="room" action="{{ path('room_namespace', { namespace : room.namespace }) }}" method="get">
<input type="text" name="namespace" value="{{ room.namespace }}" placeholder="{{ 'join room by kevacoin namespace...' | trans }}" />
</form>
{% if list %}
@ -6,10 +6,10 @@ @@ -6,10 +6,10 @@
{% for namespace, name in list %}
{% if i %}&bull;{% endif %}
<h2>
{% if room.namespace == namespace %}
{% if namespace == room.namespace %}
{{ name }}
{% else %}
<a href="{{ namespace }}">{{ name }}</a>
<a href="{{ path('room_namespace', { namespace : namespace }) }}">{{ name }}</a>
{% endif %}
</h2>
{% set i = i + 1 %}

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

@ -23,9 +23,10 @@ @@ -23,9 +23,10 @@
@{{ 'anonymous' | trans }}
</strong>
{% endif %}
<a href="#{{ post.txid }}" title="{{ 'time:' | trans }} {{ post.transaction.time }} / {{ 'confirmations:' | trans }} {{ post.transaction.confirmations }}">
{{ post.transaction.timestamp | format_ago }}
</a>
&bull;
<a href="#{{ post.txid }}" title="{{ 'time:' | trans }} {{ post.transaction.time }} / {{ 'confirmations:' | trans }} {{ post.transaction.confirmations }}">{{ post.transaction.timestamp | format_ago }}</a>
&bull;
<a href="{{ path('room_namespace', { namespace : request.get('namespace'), txid : post.txid }) }}#{{ post.txid }}">{{ 'quote' | trans }}</a>
<p>
{{ post.value }}
</p>

Loading…
Cancel
Save