contentdb/app/templates/packages/view.html
2022-02-01 21:22:28 +00:00

553 lines
19 KiB
HTML

{% set query=package.name %}
{% set release = package.getDownloadRelease() %}
{% extends "base.html" %}
{% block title %}
{{ package.title }}
{% endblock %}
{% block headextra %}
<meta name="og:title" content="{{ package.title }}"/>
<meta name="og:description" content="{{ package.short_desc }}"/>
<meta name="description" content="{{ package.short_desc }}"/>
<meta name="og:url" content="{{ package.getURL("packages.view", absolute=True) }}"/>
{% if package.getMainScreenshotURL() %}
<meta name="og:image" content="{{ package.getMainScreenshotURL(absolute=True) }}"/>
{% endif %}
{% endblock %}
{% block scriptextra %}
<script src="/static/video_embed.js"></script>
{% endblock %}
{% macro render_license(license) %}
{% if license.url %}
<a href="{{ license.url }}">{{ license.name }}</a>
{% else %}
{{ license.name }}
{% endif %}
{% endmacro %}
{% block download_btn %}
{% if release %}
<a class="btn btn-block btn-download" rel="nofollow" download="{{ release.getDownloadFileName() }}"
href="{{ package.getURL('packages.download') }}">
<div>
{{ _("Download") }}
</div>
{% if release and (release.min_rel or release.max_rel) %}
<small class="count display-block">
{% if release.min_rel and release.max_rel %}
{{ _("Minetest %(min)s - %(max)s", min=release.min_rel.name, max=release.max_rel.name) }}
{% elif release.min_rel %}
{{ _("For Minetest %(min)s and above", min=release.min_rel.name) }}
{% elif release.max_rel %}
{{ _("Minetest %(max)s and below", max=release.max_rel.name) }}
{% endif %}
</small>
{% endif %}
</a>
{% if package.type == package.type.MOD %}
{% set installing_url = "https://wiki.minetest.net/Installing_Mods" %}
{% elif package.type == package.type.GAME %}
{% set installing_url = "https://wiki.minetest.net/Games#Installing_games" %}
{% elif package.type == package.type.TXP %}
{% set installing_url = "https://wiki.minetest.net/Installing_Texture_Packs" %}
{% else %}
{{ 0 / 0 }}
{% endif %}
<p class="text-center mt-1 mb-4">
<a href="{{ installing_url }}">
<small>
<i class="fas fa-question-circle mr-1"></i>
{{ _("How do I install this?") }}
</small>
</a>
</p>
{% else %}
<i>
{{ _("No downloads available") }}
</i>
{% endif %}
{% endblock %}
{% block container %}
{% if not package.license.is_foss and not package.media_license.is_foss and package.type != package.type.TXP %}
{% set package_warning=_("Non-free code and media") %}
{% elif not package.license.is_foss and package.type != package.type.TXP %}
{% set package_warning=_("Non-free code") %}
{% elif not package.media_license.is_foss %}
{% set package_warning=_("Non-free media") %}
{% endif %}
<main>
{% set cover_image = package.cover_image.url or package.getMainScreenshotURL() %}
<header class="jumbotron pb-3"
style="background: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.7)), url('{{ cover_image }}');
background-size: cover;
background-repeat: no-repeat;
background-position: center;">
<div class="container">
<div class="btn-group float-right mb-4">
{% if package.checkPerm(current_user, "EDIT_PACKAGE") %}
<a class="btn btn-primary" href="{{ package.getURL('packages.create_edit') }}">
<i class="fas fa-pen mr-1"></i>
{{ _("Edit") }}
</a>
{% endif %}
{% if package.checkPerm(current_user, "MAKE_RELEASE") %}
<a class="btn btn-primary" href="{{ package.getURL('packages.create_release') }}">
<i class="fas fa-plus mr-1"></i>
{{ _("Release") }}
</a>
{% endif %}
{% if package.checkPerm(current_user, "DELETE_PACKAGE") or package.checkPerm(current_user, "UNAPPROVE_PACKAGE") %}
<a class="btn btn-danger" href="{{ package.getURL('packages.remove') }}">
<i class="fas fa-trash mr-1"></i>
{{ _("Remove") }}
</a>
{% endif %}
</div>
<h1 class="display-3">
{{ package.title }}
</h1>
<p class="lead">
{{ package.short_desc }}
</p>
<p>
{% if package.dev_state.name == "LOOKING_FOR_MAINTAINER" or package.dev_state.name == "DEPRECATED" %}
<span class="badge badge-warning" title="{{ package.dev_state.get_desc() }}">
<i class="fas fa-exclamation-circle" style="margin-right: 0.3em;"></i>
{{ package.dev_state.value }}
</span>
{% endif %}
{% if package_warning %}
<a class="badge badge-danger" href="/help/non_free/">
<i class="fas fa-exclamation-circle" style="margin-right: 0.3em;"></i>
{{ package_warning }}
</a>
{% endif %}
{% for warning in package.content_warnings %}
<a class="badge badge-warning" rel="nofollow" href="/help/content_flags/"
title="{{ warning.description }}">
<i class="fas fa-exclamation-circle" style="margin-right: 0.3em;"></i>
{{ warning.title }}
</a>
{% endfor %}
{% if package.dev_state.name == "WIP" %}
<span class="badge badge-info" title="{{ package.dev_state.get_desc() }}">
<i class="fas fa-tools" style="margin-right: 0.3em;"></i>
{{ _("Work in Progress") }}
</span>
{% endif %}
{% for t in package.tags %}
<a class="badge badge-primary" rel="nofollow"
title="{{ t.description or '' }}"
href="{{ url_for('packages.list_all', tag=t.name) }}">
{{ t.title }}
</a>
{% endfor %}
</p>
<div class="info-row row" style="margin-top: 2rem;">
<div class="btn-group-horizontal col">
<a class="btn" href="{{ url_for('users.profile', username=package.author.username) }}" title="{{ _("Author") }}">
<img src="{{ package.author.getProfilePicURL() }}" style="max-height: 1em; filter: none">
<span class="count">
{{ package.author.display_name }}
</span>
</a>
{% if release %}
<a class="btn" rel="nofollow" href="{{ package.getURL("packages.download") }}" title="{{ _("Downloads") }}"
download="{{ release.getDownloadFileName() }}">
<i class="fas fa-download"></i>
<span class="count">{{ package.downloads }}</span>
</a>
{% endif %}
<a class="btn" href="{{ url_for('threads.list_all', pid=package.id) }}" title="{{ _("Threads") }}">
<i class="fas fa-comment-alt"></i>
<span class="count">{{ threads | length }}</span>
</a>
<a class="btn" href="#reviews" title="{{ _("Reviews") }}">
<i class="fas fa-star-half-alt"></i>
<span class="count">
+{{ package.reviews | selectattr("recommends") | list | length }}
/
-{{ package.reviews | rejectattr("recommends") | list | length }}
</span>
</a>
{% if package.website %}
<a class="btn" href="{{ package.website }}">
<i class="fas fa-globe-europe"></i>
<span class="count">{{ _("Website") }}</span>
</a>
{% endif %}
{% if package.repo %}
<a class="btn" href="{{ package.repo }}">
<i class="fas fa-code"></i>
<span class="count">{{ _("Source") }}</span>
</a>
{% endif %}
{% if package.forums %}
<a class="btn" href="https://forum.minetest.net/viewtopic.php?t={{ package.forums }}">
<i class="fas fa-comments"></i>
<span class="count">{{ _("Forums") }}</span>
</a>
{% endif %}
{% if package.issueTracker %}
<a class="btn" href="{{ package.issueTracker }}">
<i class="fas fa-bug"></i>
<span class="count">{{ _("Issue Tracker") }}</span>
</a>
{% endif %}
</div>
</div>
</div>
</header>
{% if not package.approved %}
<section class="my-4 pb-3" style="border-bottom: 1px solid rgba(0,0,0,0.5);">
<div class="container">
{% from "macros/package_approval.html" import render_banners %}
{{ render_banners(package, current_user, topic_error, topic_error_lvl, conflicting_modnames) }}
{% if review_thread and review_thread.checkPerm(current_user, "SEE_THREAD") %}
<h2>{% if review_thread.private %}&#x1f512;{% endif %} {{ review_thread.title }}</h2>
{% if review_thread.private %}
<p><i>
{{ _("This thread is only visible to the package owner and users of Approver rank or above.") }}
</i></p>
{% endif %}
{% from "macros/threads.html" import render_thread %}
{{ render_thread(review_thread, current_user) }}
{% endif %}
</div>
</section>
{% endif %}
<div class="container d-block d-md-none">
{{ self.download_btn() }}
</div>
<section class="container mt-4">
<div class="row">
<div class="col-md-9" style="padding-right: 45px;">
{% set screenshots = package.screenshots.all() %}
{% if package.checkPerm(current_user, "ADD_SCREENSHOTS") %}
<a href="{{ package.getURL('packages.screenshots') }}" class="btn btn-primary float-right">
<i class="fas fa-images mr-1"></i>
{{ _("Edit") }}
</a>
{% endif %}
{% if screenshots or package.checkPerm(current_user, "ADD_SCREENSHOTS") or package.video_url %}
<ul class="gallery">
{% if package.video_url %}
<li>
<a href="{{ package.video_url }}" class="video-embed">
<i class="fas fa-play"></i>
<div class="label">
<i class="fas fa-external-link-square-alt"></i>
</div>
</a>
</li>
{% endif %}
{% if screenshots or package.checkPerm(current_user, "ADD_SCREENSHOTS") %}
{% for ss in screenshots %}
{% if ss.approved or package.checkPerm(current_user, "ADD_SCREENSHOTS") %}
<li>
<a href="{{ ss.url }}" class="gallery-image">
<img src="{{ ss.getThumbnailURL() }}" alt="{{ ss.title }}" />
{% if not ss.approved %}
<span class="badge bg-dark badge-tr">{{ _("Awaiting review") }}</span>
{% endif %}
</a>
</li>
{% endif %}
{% else %}
<li>
<a href="{{ package.getURL('packages.create_screenshot') }}">
<i class="fas fa-plus screenshot-add"></i>
</a>
</li>
{% endfor %}
{% endif %}
</ul>
{% endif %}
{% if package.desc %}
<article class="markdown panel mb-5">
{{ package.desc | markdown }}
</article>
{% endif %}
<h2 id="reviews" class="mt-0">{{ _("Reviews") }}</h2>
{% from "macros/reviews.html" import render_reviews, render_review_form, render_review_preview with context %}
{% if current_user.is_authenticated %}
{% if has_review %}
<p>
<a class="btn btn-primary" href="{{ package.getURL("packages.review") }}">
{{ _("Edit Review") }}
</a>
</p>
{% elif current_user in package.maintainers %}
<p>
{{ _("You can't review your own package.") }}
</p>
{% else %}
{{ render_review_preview(package) }}
{% endif %}
{% else %}
{{ render_review_preview(package) }}
{% endif %}
{% if current_user.is_authenticated and current_user.rank.atLeast(current_user.rank.ADMIN) %}
<a href="{{ package.getURL('packages.review_votes') }}" class="btn btn-secondary">{{ _("Review Votes") }}</a>
{% endif %}
{{ render_reviews(package.reviews, current_user) }}
{% if packages_uses %}
<h2>{{ _("Used By") }}</h2>
{% from "macros/packagegridtile.html" import render_pkggrid %}
{{ render_pkggrid(packages_uses) }}
{% endif %}
{% if package.type == package.type.GAME %}
<h2>{{ _("Content") }}</h2>
<a href="{{ package.getURL('packages.game_hub') }}" class="btn btn-lg btn-primary">
{{ _("View content for game") }}
</a>
{% endif %}
</div>
<aside class="col-md-3 info-sidebar">
<div class="d-none d-md-block">
{{ self.download_btn() }}
</div>
{% if package.checkPerm(current_user, "MAKE_RELEASE") and package.update_config and package.update_config.outdated_at %}
{% set config = package.update_config %}
<div class="alert alert-warning">
<p class="mt-0 my-1">
<b>{{ _("Package may be outdated") }}</b>
</p>
<p class="mt-0 my-1">
{{ config.get_message() }}
</p>
<p class="mt-0 my-1" style="font-size: 80%; opacity: 85%;">
<i class="fas fa-lock mr-1"></i>
{{ _("Only visible to the author and Editors.") }}
</p>
<div class="btn-group btn-group-sm my-0">
<a class="btn btn-warning" href="{{ config.get_create_release_url() }}">
<i class="fas fa-plus mr-1"></i>
{{ _("Release") }}
</a>
<a class="btn btn-warning" href="{{ package.getURL("packages.update_config") }}">
<i class="fas fa-cog mr-1"></i>
{{ _("Update settings") }}
</a>
</div>
</div>
{% endif %}
{% if package_warning %}
<p class="alert alert-danger">
<a href="/help/non_free/" class="float-right">Info</a>
<b>{{ _("Warning") }}:</b> {{ package_warning }}
</p>
{% endif %}
{% if package.author.donate_url %}
<div class="alert alert-secondary mb-4">
<p>{{ _("Like this package? Help support its development by making a donation", display_name=package.author.display_name) }}</p>
<a class="btn btn-block btn-primary" href="{{ package.author.donate_url }}" rel="nofollow">
<i class="fas fa-heart mr-2"></i>
{{ _("Donate now") }}
</a>
</div>
{% endif %}
{% if package.type == package.type.GAME %}
<a href="{{ package.getURL('packages.game_hub') }}" class="btn btn-lg btn-block mb-4 btn-primary">
{{ _("View content for game") }}
</a>
{% endif %}
{% if package.type != package.type.TXP %}
<h3>{{ _("Dependencies") }}</h3>
<dl>
<dt>{{ _("Required") }}</dt>
<dd>
{% for dep in package.getSortedHardDependencies() %}
{%- if dep.package %}
<a class="badge badge-primary"
href="{{ dep.package.getURL("packages.view") }}">
{{ _("%(title)s by %(display_name)s",
title=dep.package.title, display_name=dep.package.author.display_name) }}
</a>
{% elif dep.meta_package %}
<a class="badge badge-primary"
href="{{ url_for('metapackages.view', name=dep.meta_package.name) }}">
{{ dep.meta_package.name }}
</a>
{% else %}
{{ "Expected package or meta_package in dep!" | throw }}
{% endif %}
{% else %}
{{ _("No required dependencies") }}
{% endfor %}
</dd>
{% set optional_deps=package.getSortedOptionalDependencies() %}
{% if optional_deps %}
<dt>{{ _("Optional") }}</dt>
<dd>
{% for dep in optional_deps %}
{%- if dep.package %}
<a class="badge badge-secondary"
href="{{ dep.package.getURL("packages.view") }}">
{{ _("%(title)s by %(display_name)s",
title=dep.package.title, display_name=dep.package.author.display_name) }}
{% elif dep.meta_package %}
<a class="badge badge-secondary"
href="{{ url_for('metapackages.view', name=dep.meta_package.name) }}">
{{ dep.meta_package.name }}
{% else %}
{{ "Expected package or meta_package in dep!" | throw }}
{% endif %}</a>
{% endfor %}
</dd>
{% endif %}
</dl>
{% endif %}
{% if package.type == package.type.MOD %}
<h3>{{ _("Supported Games") }}</h3>
{% for support in package.getSortedSupportedGames() %}
<a class="badge badge-primary"
href="{{ support.game.getURL('packages.view') }}">
{{ _("%(title)s by %(display_name)s",
title=support.game.title, display_name=support.game.author.display_name) }}
</a>
{% else %}
{{ _("No specifc game is required") }}
{% endfor %}
{% endif %}
<h3>
{{ _("Information") }}
</h3>
<dl>
<dt>{{ _("Type") }}</dt>
<dd>{{ package.type.text }}</dd>
<dt>{{ _("Technical Name") }}</dt>
<dd>{{ package.name }}</dd>
<dt>{{ _("License") }}</dt>
<dd>
{% if package.license == package.media_license %}
{{ render_license(package.license) }}
{% elif package.type == package.type.TXP %}
{{ render_license(package.media_license) }}
{% else %}
{{ _("%(code_license)s for code,<br>%(media_license)s for media.",
code_license=render_license(package.license), media_license=render_license(package.media_license)) }}
{% endif %}
</dd>
<dt>{{ _("Maintenance State") }}</dt>
{% if package.dev_state %}
<dd title="{{ package.dev_state.get_desc() }}">{{ package.dev_state.value }}</dd>
{% else %}
<dd><i>{{ _("Unknown") }}</i></dd>
{% endif %}
<dt>{{ _("Added") }}</dt>
<dd>{{ package.created_at | datetime }}</dd>
<dt>{{ _("Maintainers") }}</dt>
<dd>
{% for user in package.maintainers %}
<a class="badge badge-secondary"
href="{{ url_for('users.profile', username=user.username) }}">
{{ user.display_name }}
</a>
{% endfor %}
{% if current_user in package.maintainers and current_user != package.author %}
<form class="mt-2" method="post" action="{{ package.getURL("packages.remove_self_maintainers") }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<input class="btn btn-sm btn-link p-0" type="submit" value="{{ _('Remove myself') }}" />
</form>
{% endif %}
</dd>
{% if package.provides %}
<dt>{{ _("Provides") }}</dt>
<dd>{% for meta in package.provides %}
<a class="badge badge-secondary"
href="{{ url_for('metapackages.view', name=meta.name) }}">{{ meta.name }}</a>
{% endfor %}</dd>
{% endif %}
</dl>
<h3>
{% if package.checkPerm(current_user, "MAKE_RELEASE") %}
<a class="btn btn-primary btn-sm float-right" href="{{ package.getURL("packages.create_release") }}"><i class="fas fa-plus"></i></a>
{% endif %}
{{ _("Releases") }}
</h3>
<div class="list-group">
{% from "macros/releases.html" import render_releases, render_releases_download %}
{% if package.checkPerm(current_user, "MAKE_RELEASE") %}
{{ render_releases(releases, package, current_user) }}
{% else %}
{{ render_releases_download(releases, package, current_user) }}
{% endif %}
<a class="list-group-item list-group-item-action text-center py-1 text-muted" href="{{ package.getURL("packages.list_releases") }}">
{{ _("More") }}
</a>
</div>
<h3>
{% if package.approved and package.checkPerm(current_user, "CREATE_THREAD") %}
<div class="btn-group float-right">
<a class="btn btn-primary btn-sm mx-1" href="{{ url_for('threads.new', pid=package.id) }}"><i class="fas fa-plus"></i></a>
</div>
{% endif %}
{{ _("Threads") }}
</h3>
<div class="list-group">
{% from "macros/threads.html" import render_compact_threadlist %}
{{ render_compact_threadlist(threads) }}
</div>
<p class="mt-3">
{% if package.approved and current_user != package.author %}
<a href="{{ url_for('report.report', url=url_current()) }}">
<i class="fas fa-flag mr-1"></i>
{{ _("Report") }}
</a>
{% endif %}
{% if package.checkPerm(current_user, "EDIT_PACKAGE") or package.checkPerm(current_user, "APPROVE_NEW") %}
{% if package.approved and current_user != package.author %}
|
{% endif %}
<a href="{{ package.getURL('packages.audit') }}">
{{ _("See audit log") }}
</a>
{% endif %}
</p>
</aside>
</div>
</section>
</main>
{% endblock %}