mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-10 15:07:35 +01:00
Improve unified navigation further
This commit is contained in:
parent
545968a71f
commit
187202d363
@ -46,6 +46,16 @@ def get_package_tabs(user: User, package: Package):
|
|||||||
"title": "Maintainers",
|
"title": "Maintainers",
|
||||||
"url": package.getEditMaintainersURL()
|
"url": package.getEditMaintainersURL()
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "audit",
|
||||||
|
"title": "Audit Log",
|
||||||
|
"url": package.getURL("packages.audit")
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "share",
|
||||||
|
"title": "Share and Badges",
|
||||||
|
"url": package.getURL("packages.share")
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "remove",
|
"id": "remove",
|
||||||
"title": "Remove",
|
"title": "Remove",
|
||||||
|
@ -518,7 +518,8 @@ def audit(package):
|
|||||||
query = package.audit_log_entries.order_by(db.desc(AuditLogEntry.created_at))
|
query = package.audit_log_entries.order_by(db.desc(AuditLogEntry.created_at))
|
||||||
|
|
||||||
pagination = query.paginate(page, num, True)
|
pagination = query.paginate(page, num, True)
|
||||||
return render_template("admin/audit.html", log=pagination.items, pagination=pagination)
|
return render_template("packages/audit.html", log=pagination.items, pagination=pagination,
|
||||||
|
package=package, tabs=get_package_tabs(current_user, package), current_tab="audit")
|
||||||
|
|
||||||
|
|
||||||
class PackageAliasForm(FlaskForm):
|
class PackageAliasForm(FlaskForm):
|
||||||
@ -558,3 +559,11 @@ def alias_create_edit(package: Package, alias_id: int = None):
|
|||||||
return redirect(package.getAliasListURL())
|
return redirect(package.getAliasListURL())
|
||||||
|
|
||||||
return render_template("packages/alias_create_edit.html", package=package, form=form)
|
return render_template("packages/alias_create_edit.html", package=package, form=form)
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/packages/<author>/<name>/share/")
|
||||||
|
@login_required
|
||||||
|
@is_package_page
|
||||||
|
def share(package):
|
||||||
|
return render_template("packages/share.html", package=package,
|
||||||
|
tabs=get_package_tabs(current_user, package), current_tab="share")
|
||||||
|
@ -460,6 +460,9 @@ class Package(db.Model):
|
|||||||
else:
|
else:
|
||||||
return screenshot.url
|
return screenshot.url
|
||||||
|
|
||||||
|
def getURL(self, endpoint):
|
||||||
|
return url_for(endpoint, author=self.author.username, name=self.name)
|
||||||
|
|
||||||
def getDetailsURL(self, absolute=False):
|
def getDetailsURL(self, absolute=False):
|
||||||
if absolute:
|
if absolute:
|
||||||
from app.utils import abs_url_for
|
from app.utils import abs_url_for
|
||||||
@ -535,8 +538,8 @@ class Package(db.Model):
|
|||||||
return url_for("packages.remove_self_maintainers",
|
return url_for("packages.remove_self_maintainers",
|
||||||
author=self.author.username, name=self.name)
|
author=self.author.username, name=self.name)
|
||||||
|
|
||||||
def getReviewURL(self):
|
def getReviewURL(self, external=False):
|
||||||
return url_for('packages.review',
|
return url_for('packages.review', _external=external,
|
||||||
author=self.author.username, name=self.name)
|
author=self.author.username, name=self.name)
|
||||||
|
|
||||||
def getAuditLogURL(self):
|
def getAuditLogURL(self):
|
||||||
|
@ -1,14 +1,66 @@
|
|||||||
|
{% macro render_releases_edit(releases, package) %}
|
||||||
|
{% for rel in releases %}
|
||||||
|
<a class="list-group-item list-group-item-action" href="{{ rel.getEditURL() }}">
|
||||||
|
{{ rel.title }}
|
||||||
|
<span class="text-muted ml-1">
|
||||||
|
{% if rel.min_rel and rel.max_rel %}
|
||||||
|
[MT {{ rel.min_rel.name }}-{{ rel.max_rel.name }}]
|
||||||
|
{% elif rel.min_rel %}
|
||||||
|
[MT {{ rel.min_rel.name }}+]
|
||||||
|
{% elif rel.max_rel %}
|
||||||
|
[MT ≤{{ rel.max_rel.name }}]
|
||||||
|
{% endif %}
|
||||||
|
</span>
|
||||||
|
<br />
|
||||||
|
<small style="color:#999;">
|
||||||
|
{% if rel.commit_hash %}
|
||||||
|
[{{ rel.commit_hash | truncate(5, end='') }}]
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
created {{ rel.releaseDate | date }}.
|
||||||
|
</small>
|
||||||
|
</a>
|
||||||
|
{% endfor %}
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
|
||||||
|
{% macro render_releases_download(releases, package) %}
|
||||||
|
{% for rel in releases %}
|
||||||
|
{% if rel.approved or package.checkPerm(current_user, "MAKE_RELEASE") or rel.checkPerm(current_user, "APPROVE_RELEASE") %}
|
||||||
|
<a class="list-group-item list-group-item-action" href="{{ rel.getDownloadURL() }}">
|
||||||
|
{{ rel.title }}
|
||||||
|
<span class="text-muted ml-1">
|
||||||
|
{% if rel.min_rel and rel.max_rel %}
|
||||||
|
[MT {{ rel.min_rel.name }}-{{ rel.max_rel.name }}]
|
||||||
|
{% elif rel.min_rel %}
|
||||||
|
[MT {{ rel.min_rel.name }}+]
|
||||||
|
{% elif rel.max_rel %}
|
||||||
|
[MT ≤{{ rel.max_rel.name }}]
|
||||||
|
{% endif %}
|
||||||
|
</span>
|
||||||
|
<br />
|
||||||
|
<small style="color:#999;">
|
||||||
|
{% if rel.commit_hash %}
|
||||||
|
[{{ rel.commit_hash | truncate(5, end='') }}]
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
created {{ rel.releaseDate | date }}.
|
||||||
|
</small>
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
|
||||||
{% macro render_releases(releases, package, current_user) -%}
|
{% macro render_releases(releases, package, current_user) -%}
|
||||||
{% for rel in releases %}
|
{% for rel in releases %}
|
||||||
{% if rel.approved or package.checkPerm(current_user, "MAKE_RELEASE") or rel.checkPerm(current_user, "APPROVE_RELEASE") %}
|
{% if rel.approved or package.checkPerm(current_user, "MAKE_RELEASE") or rel.checkPerm(current_user, "APPROVE_RELEASE") %}
|
||||||
<li class="list-group-item">
|
<div class="list-group-item">
|
||||||
{% if package.checkPerm(current_user, "MAKE_RELEASE") or rel.checkPerm(current_user, "APPROVE_RELEASE") %}
|
|
||||||
<a class="btn btn-sm btn-primary float-right" href="{{ rel.getEditURL() }}">Edit
|
<a class="btn btn-sm btn-primary float-right" href="{{ rel.getEditURL() }}">Edit
|
||||||
{% if not rel.task_id and not rel.approved and rel.checkPerm(current_user, "APPROVE_RELEASE") %}
|
{% if not rel.task_id and not rel.approved and rel.checkPerm(current_user, "APPROVE_RELEASE") %}
|
||||||
/ Approve
|
/ Approve
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if not rel.approved %}<i>{% endif %}
|
{% if not rel.approved %}<i>{% endif %}
|
||||||
|
|
||||||
@ -16,7 +68,7 @@
|
|||||||
{{ rel.title }}
|
{{ rel.title }}
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<span style="color:#ddd;">
|
<span class="text-muted ml-1">
|
||||||
{% if rel.min_rel and rel.max_rel %}
|
{% if rel.min_rel and rel.max_rel %}
|
||||||
[MT {{ rel.min_rel.name }}-{{ rel.max_rel.name }}]
|
[MT {{ rel.min_rel.name }}-{{ rel.max_rel.name }}]
|
||||||
{% elif rel.min_rel %}
|
{% elif rel.min_rel %}
|
||||||
@ -42,10 +94,9 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if not rel.approved %}</i>{% endif %}
|
{% if not rel.approved %}</i>{% endif %}
|
||||||
|
</div>
|
||||||
</li>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<li class="list-group-item">No releases available.</li>
|
<div class="list-group-item">No releases available.</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
16
app/templates/packages/audit.html
Normal file
16
app/templates/packages/audit.html
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{% extends "packages/package_base.html" %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
Audit Log
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h2 class="mt-0">Audit Log</h2>
|
||||||
|
|
||||||
|
{% from "macros/pagination.html" import render_pagination %}
|
||||||
|
{% from "macros/audit_log.html" import render_audit_log %}
|
||||||
|
|
||||||
|
{{ render_pagination(pagination, url_set_query) }}
|
||||||
|
{{ render_audit_log(log, current_user) }}
|
||||||
|
{{ render_pagination(pagination, url_set_query) }}
|
||||||
|
{% endblock %}
|
@ -5,6 +5,8 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<h1>{{ self.title() }}</h1>
|
||||||
|
|
||||||
{% from "macros/forms.html" import render_field, render_submit_field, render_checkbox_field %}
|
{% from "macros/forms.html" import render_field, render_submit_field, render_checkbox_field %}
|
||||||
<form method="POST" action="">
|
<form method="POST" action="">
|
||||||
{{ form.hidden_tag() }}
|
{{ form.hidden_tag() }}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
{% if package.checkPerm(current_user, "MAKE_RELEASE") %}
|
||||||
<p class="float-right">
|
<p class="float-right">
|
||||||
{% if package.update_config %}
|
{% if package.update_config %}
|
||||||
<a class="btn btn-secondary" href="{{ package.getUpdateConfigURL() }}">
|
<a class="btn btn-secondary" href="{{ package.getUpdateConfigURL() }}">
|
||||||
@ -28,11 +29,16 @@
|
|||||||
Create
|
Create
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<h2 class="mt-0">{{ _("Releases") }}</h2>
|
<h2 class="mt-0">{{ _("Releases") }}</h2>
|
||||||
|
|
||||||
<ul class="list-group">
|
<div class="list-group">
|
||||||
{% from "macros/releases.html" import render_releases %}
|
{% from "macros/releases.html" import render_releases_edit, render_releases_download %}
|
||||||
{{ render_releases(package.releases, package, current_user) }}
|
{% if package.checkPerm(current_user, "MAKE_RELEASE") %}
|
||||||
</ul>
|
{{ render_releases_edit(package.releases, package) }}
|
||||||
|
{% else %}
|
||||||
|
{{ render_releases_download(package.releases, package) }}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
35
app/templates/packages/share.html
Normal file
35
app/templates/packages/share.html
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
{% extends "packages/package_base.html" %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
Share and Badges
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h2 class="mt-0">{{ self.title() }}</h2>
|
||||||
|
|
||||||
|
<h3>Links</h3>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Review link:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<pre><code>{{ package.getReviewURL(external=True) }}</code></pre>
|
||||||
|
|
||||||
|
<h3>Badges</h3>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
{{ package.makeShield("title") | markdown }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<pre><code>{{ package.makeShield("title") }}</code></pre>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
{{ package.makeShield("downloads") | markdown }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<pre><code>{{ package.makeShield("downloads") }}</code></pre>
|
||||||
|
</p>
|
||||||
|
{% endblock %}
|
@ -286,26 +286,6 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if package.checkPerm(current_user, "EDIT_PACKAGE") %}
|
|
||||||
<h2>Badges</h2>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
{{ package.makeShield("title") | markdown }}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<pre><code>{{ package.makeShield("title") }}</code></pre>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
{{ package.makeShield("downloads") | markdown }}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<pre><code>{{ package.makeShield("downloads") }}</code></pre>
|
|
||||||
</p>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<aside class="col-md-3 info-sidebar">
|
<aside class="col-md-3 info-sidebar">
|
||||||
@ -411,12 +391,8 @@
|
|||||||
<dd>{{ package.created_at | datetime }}</dd>
|
<dd>{{ package.created_at | datetime }}</dd>
|
||||||
<dt>Maintainers</dt>
|
<dt>Maintainers</dt>
|
||||||
<dd>
|
<dd>
|
||||||
{% if package.checkPerm(current_user, "EDIT_MAINTAINERS") %}
|
|
||||||
<a class="btn btn-primary btn-sm ml-1 float-right" href="{{ package.getEditMaintainersURL() }}"><i class="fas fa-pen"></i></a>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% for user in package.maintainers %}
|
{% for user in package.maintainers %}
|
||||||
<a class="badge badge-primary"
|
<a class="badge badge-secondary"
|
||||||
href="{{ url_for('users.profile', username=user.username) }}">
|
href="{{ url_for('users.profile', username=user.username) }}">
|
||||||
{{ user.display_name }}
|
{{ user.display_name }}
|
||||||
</a>
|
</a>
|
||||||
@ -425,7 +401,7 @@
|
|||||||
{% if current_user in package.maintainers and current_user != package.author %}
|
{% if current_user in package.maintainers and current_user != package.author %}
|
||||||
<form class="mt-2" method="post" action="{{ package.getRemoveSelfMaintainerURL() }}">
|
<form class="mt-2" method="post" action="{{ package.getRemoveSelfMaintainerURL() }}">
|
||||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
||||||
<input class="btn btn-sm btn-link p-0" type="submit" value="{{ _("Remove myself") }}" />
|
<input class="btn btn-sm btn-link p-0" type="submit" value="{{ _('Remove myself') }}" />
|
||||||
</form>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</dd>
|
</dd>
|
||||||
@ -448,12 +424,19 @@
|
|||||||
{% if package.checkPerm(current_user, "MAKE_RELEASE") %}
|
{% if package.checkPerm(current_user, "MAKE_RELEASE") %}
|
||||||
<a class="btn btn-primary btn-sm float-right" href="{{ package.getCreateReleaseURL() }}"><i class="fas fa-plus"></i></a>
|
<a class="btn btn-primary btn-sm float-right" href="{{ package.getCreateReleaseURL() }}"><i class="fas fa-plus"></i></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a href="{{ package.getReleaseListURL() }}">{{ _("Releases") }}</a>
|
{{ _("Releases") }}
|
||||||
</h3>
|
</h3>
|
||||||
<ul class="list-group">
|
<div class="list-group">
|
||||||
{% from "macros/releases.html" import render_releases %}
|
{% from "macros/releases.html" import render_releases, render_releases_download %}
|
||||||
|
{% if package.checkPerm(current_user, "MAKE_RELEASE") %}
|
||||||
{{ render_releases(releases, package, current_user) }}
|
{{ render_releases(releases, package, current_user) }}
|
||||||
</ul>
|
{% else %}
|
||||||
|
{{ render_releases_download(releases, package) }}
|
||||||
|
{% endif %}
|
||||||
|
<a class="list-group-item list-group-item-action text-center py-1 text-muted" href="{{ package.getReleaseListURL() }}">
|
||||||
|
More
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
<h3>
|
<h3>
|
||||||
{% if package.approved and package.checkPerm(current_user, "CREATE_THREAD") %}
|
{% if package.approved and package.checkPerm(current_user, "CREATE_THREAD") %}
|
||||||
|
Loading…
Reference in New Issue
Block a user