Browse Source

add scroll anchors to latest post

main 1.5.0
ghost 11 months ago
parent
commit
2fc1a34678
  1. 2
      .env
  2. 42
      src/Controller/RoomController.php
  3. 2
      src/Twig/AppExtension.php
  4. 2
      templates/default/module/rooms.html.twig
  5. 1
      templates/default/room/index.html.twig
  6. 4
      templates/default/room/index.rss.twig
  7. 2
      templates/default/room/list.html.twig

2
.env

@ -19,7 +19,7 @@ APP_ENV=dev @@ -19,7 +19,7 @@ APP_ENV=dev
APP_SECRET=EDIT_ME
###< symfony/framework-bundle ###
APP_VERSION=1.4.4
APP_VERSION=1.5.0
APP_NAME=KevaChat

42
src/Controller/RoomController.php

@ -26,7 +26,8 @@ class RoomController extends AbstractController @@ -26,7 +26,8 @@ class RoomController extends AbstractController
return $this->redirectToRoute(
'room_namespace',
[
'namespace' => $request->get('namespace') ? $request->get('namespace') : $this->getParameter('app.kevacoin.room.namespace.default')
'namespace' => $request->get('namespace') ? $request->get('namespace') : $this->getParameter('app.kevacoin.room.namespace.default'),
'_fragment' => 'latest'
]
);
}
@ -341,7 +342,8 @@ class RoomController extends AbstractController @@ -341,7 +342,8 @@ class RoomController extends AbstractController
[
'namespace' => $request->get('namespace'),
'message' => $request->get('message'),
'error' => $this->getParameter('app.maintenance')
'error' => $this->getParameter('app.maintenance'),
'_fragment' => 'latest'
]
);
}
@ -386,7 +388,8 @@ class RoomController extends AbstractController @@ -386,7 +388,8 @@ class RoomController extends AbstractController
[
'namespace' => $request->get('namespace'),
'message' => $request->get('message'),
'error' => $translator->trans('Namespace not found on this node!')
'error' => $translator->trans('Namespace not found on this node!'),
'_fragment' => 'latest'
]
);
}
@ -413,7 +416,8 @@ class RoomController extends AbstractController @@ -413,7 +416,8 @@ class RoomController extends AbstractController
[
'namespace' => $request->get('namespace'),
'message' => $request->get('message'),
'error' => $translator->trans('Namespace for read only!')
'error' => $translator->trans('Namespace for read only!'),
'_fragment' => 'latest'
]
);
}
@ -429,7 +433,8 @@ class RoomController extends AbstractController @@ -429,7 +433,8 @@ class RoomController extends AbstractController
'error' => sprintf(
$translator->trans('Access denied for host %s!'),
$request->getClientIp()
)
),
'_fragment' => 'latest'
]
);
}
@ -445,7 +450,8 @@ class RoomController extends AbstractController @@ -445,7 +450,8 @@ class RoomController extends AbstractController
'error' => sprintf(
$translator->trans('Access restricted for host %s!'),
$request->getClientIp()
)
),
'_fragment' => 'latest'
]
);
}
@ -458,7 +464,8 @@ class RoomController extends AbstractController @@ -458,7 +464,8 @@ class RoomController extends AbstractController
[
'namespace' => $request->get('namespace'),
'message' => $request->get('message'),
'error' => $translator->trans('Message length out of KevaCoin protocol limits')
'error' => $translator->trans('Message length out of KevaCoin protocol limits'),
'_fragment' => 'latest'
]
);
}
@ -474,7 +481,8 @@ class RoomController extends AbstractController @@ -474,7 +481,8 @@ class RoomController extends AbstractController
'error' => sprintf(
$translator->trans('Message does not match node requirements: %s'),
$this->getParameter('app.add.post.value.regex')
)
),
'_fragment' => 'latest'
]
);
}
@ -491,7 +499,8 @@ class RoomController extends AbstractController @@ -491,7 +499,8 @@ class RoomController extends AbstractController
'error' => sprintf(
$translator->trans('Please wait %s seconds before post new message!'),
(int) $this->getParameter('app.add.post.remote.ip.delay') - (time() - $delay)
)
),
'_fragment' => 'latest'
]
);
}
@ -507,7 +516,8 @@ class RoomController extends AbstractController @@ -507,7 +516,8 @@ class RoomController extends AbstractController
'error' => sprintf(
$translator->trans('Insufficient funds, wallet: %s'),
$this->getParameter('app.kevacoin.boost.address')
)
),
'_fragment' => 'latest'
]
);
}
@ -538,7 +548,8 @@ class RoomController extends AbstractController @@ -538,7 +548,8 @@ class RoomController extends AbstractController
[
'namespace' => $request->get('namespace'),
'error' => null,
'message' => null
'message' => null,
'_fragment' => 'latest'
]
);
}
@ -549,7 +560,8 @@ class RoomController extends AbstractController @@ -549,7 +560,8 @@ class RoomController extends AbstractController
[
'namespace' => $request->get('namespace'),
'message' => $request->get('message'),
'error' => $translator->trans('Internal error! Please feedback')
'error' => $translator->trans('Internal error! Please feedback'),
'_fragment' => 'latest'
]
);
}
@ -575,7 +587,8 @@ class RoomController extends AbstractController @@ -575,7 +587,8 @@ class RoomController extends AbstractController
[
'namespace' => $request->get('namespace'),
'message' => $request->get('message'),
'error' => $this->getParameter('app.maintenance')
'error' => $this->getParameter('app.maintenance'),
'_fragment' => 'latest'
]
);
}
@ -742,7 +755,8 @@ class RoomController extends AbstractController @@ -742,7 +755,8 @@ class RoomController extends AbstractController
[
'namespace' => $namespace['namespaceId'],
'error' => null,
'message' => null
'message' => null,
'_fragment' => 'latest'
]
);
}

2
src/Twig/AppExtension.php

@ -187,7 +187,7 @@ class AppExtension extends AbstractExtension @@ -187,7 +187,7 @@ class AppExtension extends AbstractExtension
{
return preg_replace(
'~(N[A-z0-9]{33})~i',
'[$1]($1)',
'[$1]($1#latest)',
$text
);
}

2
templates/default/module/rooms.html.twig

@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
{% if namespace == form.namespace.value %}
{{ namespace | keva_namespace_value }}
{% else %}
<a href="{{ path('room_namespace', { namespace : namespace }) }}">{{ namespace | keva_namespace_value }}</a>
<a href="{{ path('room_namespace', { namespace : namespace }) }}#latest">{{ namespace | keva_namespace_value }}</a>
{% endif %}
</h2>
<sup>

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

@ -49,6 +49,7 @@ @@ -49,6 +49,7 @@
{% block main_content %}
{% if tree %}
{{ recursive_post_tree(request.get('namespace'), tree) }}
<a name="latest"></a>
{% else %}
<ul>
<li>

4
templates/default/room/index.rss.twig

@ -1,9 +1,9 @@ @@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<atom:link href="{{ url('room_namespace', { namespace : request.get('namespace') }) }}" rel="self" type="application/rss+xml"></atom:link>
<atom:link href="{{ url('room_namespace', { namespace : request.get('namespace'), _fragment : 'latest' }) }}" rel="self" type="application/rss+xml"></atom:link>
<title>{{ request.get('namespace') | keva_namespace_value }} - {{ 'KevaChat' | trans }}</title>
<link>{{ url('room_namespace', { namespace : request.get('namespace') }) }}</link>
<link>{{ url('room_namespace', { namespace : request.get('namespace'), _fragment : 'latest' }) }}</link>
{% for post in feed %}
<item>
<title>#{{ post.id }}</title>

2
templates/default/room/list.html.twig

@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
<li>
<div>
<strong>
<a href="{{ path('room_namespace', { namespace : room.namespace }) }}">{{ room.namespace | keva_namespace_value }}</a>
<a href="{{ path('room_namespace', { namespace : room.namespace }) }}#latest">{{ room.namespace | keva_namespace_value }}</a>
</strong>
{{ room.total }}
<a href="{{ path('room_namespace', { namespace : room.namespace, feed : 'rss' }) }}" title="{{ 'RSS' | trans }}" target="_blank"><svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" fill="currentColor" viewBox="0 0 16 16">

Loading…
Cancel
Save