add scroll anchors to latest post

This commit is contained in:
ghost 2023-12-10 11:08:27 +02:00
parent eace77d32d
commit 2fc1a34678
7 changed files with 35 additions and 20 deletions

2
.env
View File

@ -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

View File

@ -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
[
'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
[
'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
[
'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
'error' => sprintf(
$translator->trans('Access denied for host %s!'),
$request->getClientIp()
)
),
'_fragment' => 'latest'
]
);
}
@ -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
[
'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
'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
'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
'error' => sprintf(
$translator->trans('Insufficient funds, wallet: %s'),
$this->getParameter('app.kevacoin.boost.address')
)
),
'_fragment' => 'latest'
]
);
}
@ -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
[
'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
[
'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
[
'namespace' => $namespace['namespaceId'],
'error' => null,
'message' => null
'message' => null,
'_fragment' => 'latest'
]
);
}

View File

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

View File

@ -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>

View File

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

View File

@ -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>

View File

@ -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">