mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
feat(fastapi): add comment actions to /account/{username}/comments
With this change, we've decoupled some partials shared between `/pkgbase/{name}` and `/account/{username}/comments`. The comment actions template now resolves its package base via the `comment` instance instead of requiring `pkgbase`. We've also modified the existing package comment routes to support execution from any location using the `next` parameter. This allows us to reuse code from package comments for account comments actions. Moved the majority of comment editing javascript to its own .js file. Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
adb6252f85
commit
691b7b9091
12 changed files with 276 additions and 182 deletions
|
@ -18,35 +18,50 @@
|
|||
</div>
|
||||
|
||||
{% for comment in comments %}
|
||||
{% set commented_at = comment.CommentTS | dt | as_timezone(timezone) %}
|
||||
<h4 id="comment-{{ comment.ID }}" class="comment-header">
|
||||
{{
|
||||
"Commented on package %s%s%s on %s%s%s" | tr
|
||||
| format(
|
||||
'<a href="/pkgbase/{{ comment.PackageBase.Name }}">',
|
||||
comment.PackageBase.Name,
|
||||
"</a>",
|
||||
'<a href="/account/%s/comments#comment-%s">' | format(
|
||||
username,
|
||||
comment.ID
|
||||
),
|
||||
commented_at.strftime("%Y-%m-%d %H:%M"),
|
||||
"</a>"
|
||||
) | safe
|
||||
}}
|
||||
</h4>
|
||||
<div id="comment-{{ comment.ID }}-content" class="article-content">
|
||||
<div>
|
||||
{% if comment.RenderedComment %}
|
||||
{{ comment.RenderedComment | safe }}
|
||||
{% else %}
|
||||
{{ comment.Comments }}
|
||||
{% set header_cls = "comment-header" %}
|
||||
{% if comment.Deleter %}
|
||||
{% set header_cls = "%s %s" | format(header_cls, "comment-deleted") %}
|
||||
{% endif %}
|
||||
|
||||
{% if not comment.Deleter or request.user.has_credential("CRED_COMMENT_VIEW_DELETED", approved=[comment.Deleter]) %}
|
||||
|
||||
{% set commented_at = comment.CommentTS | dt | as_timezone(timezone) %}
|
||||
<h4 id="comment-{{ comment.ID }}" class="{{ header_cls }}">
|
||||
{{
|
||||
"Commented on package %s%s%s on %s%s%s" | tr
|
||||
| format(
|
||||
'<a href="/pkgbase/%s">' | format(comment.PackageBase.Name),
|
||||
comment.PackageBase.Name,
|
||||
"</a>",
|
||||
'<a href="/account/%s/comments#comment-%s">' | format(
|
||||
username,
|
||||
comment.ID
|
||||
),
|
||||
commented_at.strftime("%Y-%m-%d %H:%M"),
|
||||
"</a>"
|
||||
) | safe
|
||||
}}
|
||||
{% if comment.Editor %}
|
||||
{% set edited_on = comment.EditedTS | dt | as_timezone(timezone) %}
|
||||
<span class="edited">
|
||||
({{ "edited on %s by %s" | tr
|
||||
| format(edited_on.strftime('%Y-%m-%d %H:%M'),
|
||||
'<a href="/account/%s">%s</a>' | format(
|
||||
comment.Editor.Username, comment.Editor.Username))
|
||||
| safe
|
||||
}})
|
||||
</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% include "partials/comment_actions.html" %}
|
||||
</h4>
|
||||
|
||||
{% include "partials/comment_content.html" %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue