contentdb/app/templates/threads/view.html
2021-08-17 21:16:43 +01:00

92 lines
3.2 KiB
HTML

{% extends "base.html" %}
{% block title %}
{%- if thread.package -%}
{%- if thread.review -%}
{%- if thread.review.recommends -%}
{%- set rating = "👍" -%}
{%- else -%}
{%- set rating = "👎" -%}
{%- endif -%}
{%- endif -%}
{{ rating }} {{ _("%(title)s on %(package)s", title=thread.title, package=thread.package.title) }}
{%- else -%}
{{ thread.title }}
{%- endif -%}
{% endblock %}
{% block headextra %}
<meta name="og:title" content="{{ self.title() }}"/>
<meta name="og:description" content="{{ thread.get_description() }}"/>
<meta name="description" content="{{ thread.get_description() }}"/>
<meta name="og:url" content="{{ thread.getViewURL(absolute=True) }}"/>
<meta name="og:image" content="{{ thread.author.getProfilePicURL() }}"/>
{% endblock %}
{% block content %}
{% if current_user.is_authenticated %}
{% if current_user in thread.watchers %}
<form method="post" action="{{ thread.getUnsubscribeURL() }}" class="float-right">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<input type="submit" class="btn btn-primary" value="Unsubscribe" />
</form>
{% else %}
<form method="post" action="{{ thread.getSubscribeURL() }}" class="float-right">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<input type="submit" class="btn btn-primary" value="Subscribe" />
</form>
{% endif %}
{% if thread and thread.checkPerm(current_user, "DELETE_THREAD") %}
<a href="{{ url_for('threads.delete_thread', id=thread.id) }}" class="float-right mr-2 btn btn-danger">{{ _('Delete') }}</a>
{% endif %}
{% if thread and thread.checkPerm(current_user, "LOCK_THREAD") %}
{% if thread.locked %}
<form method="post" action="{{ url_for('threads.set_lock', id=thread.id, lock=0) }}" class="float-right mr-2">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<input type="submit" class="btn btn-secondary" value="{{ _('Unlock') }}" />
</form>
{% else %}
<form method="post" action="{{ url_for('threads.set_lock', id=thread.id, lock=1) }}" class="float-right mr-2">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<input type="submit" class="btn btn-secondary" value="{{ _('Lock') }}" />
</form>
{% endif %}
{% endif %}
{% endif %}
{% if current_user == thread.author and thread.review %}
<a class="btn btn-primary ml-1 float-right mr-2"
href="{{ thread.review.package.getURL("packages.review") }}">
<i class="fas fa-pen"></i>
{{ _("Edit Review") }}
</a>
{% endif %}
<h1>
{% if thread.review %}
{% if thread.review.recommends %}
<i class="fas fa-thumbs-up mr-2" style="color:#6f6;"></i>
{% else %}
<i class="fas fa-thumbs-down mr-2" style="color:#f66;"></i>
{% endif %}
{% endif %}
{% if thread.private %}&#x1f512; {% endif %}{{ thread.title }}
</h1>
{% if thread.package %}
<p>
Package: <a href="{{ thread.package.getURL("packages.view") }}">{{ thread.package.title }}</a>
</p>
{% endif %}
{% if thread.private %}
<i>
This thread is only visible to its creator, the package owner, and users of
Approver rank or above.
</i>
{% endif %}
{% from "macros/threads.html" import render_thread %}
{{ render_thread(thread, current_user) }}
{% endblock %}