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
} }
} }
// 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( return $this->render(
'default/module/post.html.twig', 'default/module/post.html.twig',
[ [
'enabled' => in_array($request->get('namespace'), $public), 'enabled' => in_array($request->get('namespace'), $public),
'namespace' => $request->get('namespace'), 'namespace' => $request->get('namespace'),
'message' => $request->get('message'), 'message' => $message,
'user' => $request->get('user'), 'user' => $request->get('user'),
'ip' => $request->getClientIp() 'ip' => $request->getClientIp()
] ]

7
src/Controller/RoomController.php

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

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

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

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

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

Loading…
Cancel
Save