templates: Translate pkgbase.html and partials

+ Include the `is_maintainer` context key.
+ Use `is_maintainer` in more locations.

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-07-14 14:08:14 -07:00
parent 1e1c0c3fe5
commit 2d3d03e01e
5 changed files with 155 additions and 75 deletions

View file

@ -14,18 +14,23 @@
<input type="hidden" name="ID" value="{{ pkgbase_id }}"/>
</div>
<p>
Git commit identifiers referencing commits in the AUR package
repository and URLs are converted to links automatically.
<a href="https://daringfireball.net/projects/markdown/syntax">
Markdown syntax
</a>
is partially supported.
{{
"Git commit identifiers referencing commits in the AUR package"
" repository and URLs are converted to links automatically."
| tr
}}
{{
"%sMarkdown Syntax%s is partially supported."
| tr
| format('<a href="https://daringfireball.net/projects/markdown/syntax">', '</a>')
| safe
}}
</p>
<p>
<textarea id="id_comment" name="comment" cols="80" rows="10"></textarea>
</p>
<p>
<input type="submit" value="Add Comment"/>
<input type="submit" value="{{ 'Add Comment' | tr }}"/>
</p>
</fieldset>
</form>
@ -34,22 +39,35 @@
<div class="comments package-comments">
<div class="comments-header">
<h3>
<span class="text">Latest Comments</span>
<span class="text">{{ "Latest Comments" | tr }}</span>
<span class="arrow"></span>
</h3>
</div>
{% for comment in comments %}
<h4 id="comment-{{ comment.ID }}" class="comment-header">
{% set commentTimestamp = comment.CommentTS | dt | as_timezone(timezone) %}
<a href="/account/{{ comment.User.Username }}" title="View account information for {{ comment.User.Username }}">{{ comment.User.Username }}</a>
commented on <a href="#comment-{{ comment.ID }}" class="date">{{ "%s" | tr | format(commentTimestamp.strftime("%Y-%m-%d %H:%M")) }}</a>
{% if request.user.is_authenticated() and pkgbase.Maintainer.Username == request.user.Username %}
{% set commented_at = comment.CommentTS | dt | as_timezone(timezone) %}
{% set view_account_info = 'View account information for %s' | tr | format(comment.User.Username) %}
{{
"%s commented on %s" | tr | format(
'<a href="/account/%s" title="%s">%s</a>' | format(
comment.User.Username,
view_account_info,
comment.User.Username
),
'<a href="#comment-%s" class="date">%s</a>' | format(
comment.ID,
commented_at.strftime("%Y-%m-%d %H:%M")
)
)
| safe
}}
{% if is_maintainer %}
<form class="delete-comment-form" method="post" action="/pkgbase/{{ pkgname }}/">
<fieldset style="display:inline;">
<input type="hidden" name="action" value="do_DeleteComment" />
<input type="hidden" name="comment_id" value="{{ comment.ID }}"/>
<input type="hidden" name="return_to" value="/pkgbase/{{ pkgname }}/"/>
<input type="image" class="delete-comment" src="/images/x.min.svg" width="11" height="11" alt="Delete comment" title="Delete comment" name="submit" value="1" />
<input type="image" class="delete-comment" src="/images/x.min.svg" width="11" height="11" alt="{{ 'Delete comment' | tr }}" title="{{ 'Delete comment' | tr }}" name="submit" value="1" />
</fieldset>
</form>
<a href="/pkgbase/{{ pkgname }}/edit-comment/?comment_id={{ comment.ID }}" class="edit-comment" title="Edit comment"><img src="/images/pencil.min.svg" alt="Edit comment" width="11" height="11"></a>
@ -60,13 +78,13 @@
<input type="hidden" name="comment_id" value="{{ comment.ID }}"/>
<input type="hidden" name="package_base" value="{{ pkgbase_id }}"/>
<input type="hidden" name="return_to" value="/pkgbase/{{ pkgname }}/"/>
<input type="image" class="pin-comment" src="/images/pin.min.svg" width="11" height="11" alt="Pin comment" title="Pin comment" name="submit" value="1"/>
<input type="image" class="pin-comment" src="/images/pin.min.svg" width="11" height="11" alt="{{ 'Pin comment' | tr }}" title="{{ 'Pin comment' | tr }}" name="submit" value="1"/>
</fieldset>
</form>
</h4>
<div id="comment-{{ comment.ID }}-content" class="article-content">
<div>
<p>{{ comment.Comments }}</p>
<p>{{ comment.RenderedComment | safe }}</p>
</div>
</div>
{% endfor %}