Format package page

This commit is contained in:
rubenwardy 2018-12-21 15:58:43 +00:00
parent 9da6b45cc3
commit c97eefc7b2
6 changed files with 267 additions and 244 deletions

@ -53,6 +53,8 @@
.packagegridinfo h3 { .packagegridinfo h3 {
color: white; color: white;
font-size: 120%;
font-weight: bold;
} }
.packagegridinfo p { .packagegridinfo p {

@ -114,7 +114,7 @@
</main> </main>
{% endblock %} {% endblock %}
<footer class="container"> <footer class="container footer-copyright my-5 page-footer font-small text-center">
ContentDB &copy; 2018 to <a href="https://rubenwardy.com/">rubenwardy</a> | ContentDB &copy; 2018 to <a href="https://rubenwardy.com/">rubenwardy</a> |
<a href="https://github.com/minetest/contentdb">GitHub</a> | <a href="https://github.com/minetest/contentdb">GitHub</a> |
<a href="{{ url_for('flatpage', path='help') }}">Help</a> | <a href="{{ url_for('flatpage', path='help') }}">Help</a> |

@ -5,31 +5,16 @@ Welcome
{% endblock %} {% endblock %}
{% block container %} {% block container %}
<!-- <div class="jumbotron">
<h1 class="display-3">Hello, world!</h1>
<p class="lead">This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.</p>
<hr class="my-4">
<p>It uses utility classes for typography and spacing to space content out within the larger container.</p>
<p class="lead">
<a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a>
</p>
</div> -->
<header class="jumbotron"> <header class="jumbotron">
<div class="container"> <div class="container">
<h1 class="display-3">Content DB</h1> <h1 class="display-3">{{ config.USER_APP_NAME }}</h1>
<p> <p class="lead">
Minetest's official content repository. Minetest's official content repository.
Browse {{ count }} packages, Browse {{ count }} packages,
the majority of which are available under a free the majority of which are available under a free
and open source license. and open source license.
</p> </p>
<!-- <form method="get" action="/packages/">
<input type="text" name="q" value="{{ query or ''}}" />
<input type="submit" value="Search" />
</form> -->
</div> </div>
</header> </header>

@ -25,12 +25,24 @@
{% endif %} {% endif %}
{% endmacro %} {% endmacro %}
{% macro render_threadlist(threads) -%} {% macro render_threadlist(threads, list_group=False) -%}
<ul> {% if not list_group %}<ul>{% endif %}
<li {% if list_group %}class="list-group-item"{% endif %}>
{% for t in threads %} {% for t in threads %}
<li>{% if t.private %}&#x1f512; {% endif %}<a href="{{ url_for('thread_page', id=t.id) }}">{{ t.title }}</a> by {{ t.author.display_name }}</li> {% if list_group %}
<a href="{{ url_for('thread_page', id=t.id) }}">
{% if t.private %}&#x1f512; {% endif %}
{{ t.title }}
by {{ t.author.display_name }}
</a>
{% else %} {% else %}
<li><i>No threads found</i></li> {% if t.private %}&#x1f512; {% endif %}
<a href="{{ url_for('thread_page', id=t.id) }}">{{ t.title }}</a>
by {{ t.author.display_name }}
{% endif %}
{% else %}
<i>No threads found</i>
{% endfor %} {% endfor %}
</li>
</ul> </ul>
{% endmacro %} {% endmacro %}

@ -4,7 +4,7 @@
{{ package.title }} {{ package.title }}
{% endblock %} {% endblock %}
{% block content %} {% block container %}
{% if not package.approved %} {% if not package.approved %}
<div class="box box_grey alert alert-warning"> <div class="box box_grey alert alert-warning">
<span class="icon_message"></span> <span class="icon_message"></span>
@ -80,35 +80,65 @@
{% endif %} {% endif %}
{% endif %} {% endif %}
<h1>{{ package.title }} by {{ package.author.display_name }}</h1> <header class="jumbotron mb-0">
<div class="container">
<h1 class="display-3">{{ package.title }} by {{ package.author.display_name }}</h1>
<ul class="screenshot_list"> <p class="lead">
{% for ss in package.screenshots %} {{ package.shortDesc }}
{% if ss.approved or package.checkPerm(current_user, "ADD_SCREENSHOTS") %} </p>
<li> </div>
<a href="{% if package.checkPerm(current_user, 'ADD_SCREENSHOTS') %}{{ ss.getEditURL() }}{% else %}{{ ss.url }}{% endif %}"> </header>
<img src="{{ ss.getThumbnailURL() }}" alt="{{ ss.title }}" />
</a> <main class="container">
</li> <div class="row mt-1 mb-4 ">
<div class="col">
{% if package.getDownloadRelease() %}
<a class="btn btn-success" href="{{ package.getDownloadURL() }}" class="btn_green">Download</a>
{% else %}
No download available.
{% endif %} {% endif %}
{% endfor %} </div>
</ul> <div class="btn-group-horizontal col-md-auto">
{% if package.repo %}<a class="btn btn-primary" href="{{ package.repo }}">View Source</a>{% endif %}
{% if package.forums %}<a class="btn btn-primary" href="https://forum.minetest.net/viewtopic.php?t={{ package.forums }}">Forums</a>{% endif %}
{% if package.issueTracker %}<a class="btn btn-primary" href="{{ package.issueTracker }}">Issue Tracker</a>{% endif %}
{% if package.website %}<a class="btn btn-primary" href="{{ package.website }}">Website</a>{% endif %}
{% if package.checkPerm(current_user, "EDIT_PACKAGE") %}
<a class="btn btn-primary" href="{{ package.getNewScreenshotURL() }}">Add screenshot</a>
{% endif %}
{# {% if current_user.is_authenticated %}
<a class="btn btn-primary" href="{{ package.getCreateEditRequestURL() }}">Suggest Changes</a>
{% endif %} #}
{% if package.checkPerm(current_user, "MAKE_RELEASE") %}
<a class="btn btn-primary" href="{{ package.getCreateReleaseURL() }}">Create Release</a>
{% endif %}
{% if package.checkPerm(current_user, "DELETE_PACKAGE") %}
<a class="btn btn-danger" href="{{ package.getDeleteURL() }}">Delete</a>
{% endif %}
</div>
</div>
<aside class="asideright box box_grey"> <aside class="float-right">
<h3>Details</h3> <div class="card" style="width: 18rem;">
<div class="card-header">
Details
{% if package.checkPerm(current_user, "EDIT_PACKAGE") %}
<a class="btn btn-sm btn-xs btn-primary float-right" href="{{ package.getEditURL() }}">Edit</a>
{% endif %}
<div class="box-body"> </div>
<div class="card-body">
{% if not package.license.is_foss and not package.media_license.is_foss and package.type != package.type.TXP %} {% if not package.license.is_foss and not package.media_license.is_foss and package.type != package.type.TXP %}
<div class="box box_grey alert alert-error" style="margin-top: 0;"> {% set package_warning="Non-free code and media." %}
<b>Warning:</b> Non-free code and media.
</div>
{% elif not package.license.is_foss and package.type != package.type.TXP %} {% elif not package.license.is_foss and package.type != package.type.TXP %}
<div class="box box_grey alert alert-error" style="margin-top: 0;"> {% set package_warning="Non-free code." %}
<b>Warning:</b> Non-free code.
</div>
{% elif not package.media_license.is_foss %} {% elif not package.media_license.is_foss %}
<div class="box box_grey alert alert-error" style="margin-top: 0;"> {% set package_warning="Non-free media." %}
<b>Warning:</b> Non-free media. {% endif %}
{% if package_warning %}
<div class="alert alert-danger">
<b>Warning:</b> {{ package_warning }}
</div> </div>
{% endif %} {% endif %}
<table> <table>
@ -156,87 +186,43 @@
<td>Added</td> <td>Added</td>
<td>{{ package.created_at | datetime }}</td> <td>{{ package.created_at | datetime }}</td>
</tr> </tr>
<tr>
<td>Tags</td>
<td>
{% for t in package.tags %}
<span class="badge badge-primary">{{ t.title }}</span>
{% else %}
<i>No tags.</i>
{% endfor %}
</td>
</table> </table>
</div>
<ul class="btnset linedbuttonset">
{% if package.getDownloadRelease() %}<li><a href="{{ package.getDownloadURL() }}" class="btn_green">Download</a></li>{% endif %}
{% if package.repo %}<li><a href="{{ package.repo }}">View Source</a></li>{% endif %}
{% if package.forums %}<li><a href="https://forum.minetest.net/viewtopic.php?t={{ package.forums }}">Forums</a></li>{% endif %}
{% if package.issueTracker %}<li><a href="{{ package.issueTracker }}">Issue Tracker</a></li>{% endif %}
{% if package.website %}<li><a href="{{ package.website }}">Website</a></li>{% endif %}
{% if package.checkPerm(current_user, "EDIT_PACKAGE") %}
<li><a href="{{ package.getEditURL() }}">Edit</a></li>
<li><a href="{{ package.getNewScreenshotURL() }}">Add screenshot</a></li>
{% endif %}
{# {% if current_user.is_authenticated %}
<li><a href="{{ package.getCreateEditRequestURL() }}">Suggest Changes</a></li>
{% endif %} #}
{% if package.checkPerm(current_user, "MAKE_RELEASE") %}
<li><a href="{{ package.getCreateReleaseURL() }}">Create Release</a></li>
{% endif %}
{% if package.approved and package.checkPerm(current_user, "CREATE_THREAD") %}
<li><a href="{{ url_for('new_thread_page', pid=package.id) }}">Open Thread</a></li>
{% endif %}
{% if package.checkPerm(current_user, "DELETE_PACKAGE") %}
<li><a href="{{ package.getDeleteURL() }}">Delete</a></li>
{% endif %}
</ul>
</div> </div>
</aside> </aside>
<p class="package-short-large">{{ package.shortDesc }}</p> <ul class="screenshot_list">
{% for ss in package.screenshots %}
{% if ss.approved or package.checkPerm(current_user, "ADD_SCREENSHOTS") %}
<li>
<a href="{% if package.checkPerm(current_user, 'ADD_SCREENSHOTS') %}{{ ss.getEditURL() }}{% else %}{{ ss.url }}{% endif %}">
<img src="{{ ss.getThumbnailURL() }}" alt="{{ ss.title }}" />
</a>
</li>
{% endif %}
{% endfor %}
</ul>
{{ package.desc | markdown }} {{ package.desc | markdown }}
<h3>Releases</h3> <div style="clear: both;"></div>
<ul> <div class="row my-4">
{% for rel in releases %} <div class="col-sm-4">
{% if rel.approved or package.checkPerm(current_user, "MAKE_RELEASE") or package.checkPerm(current_user, "APPROVE_RELEASE") %} <div class="card">
<li> <div class="card-header">Dependencies</div>
{% if not rel.approved %}<i>{% endif %} <ul class="list-group list-group-flush">
<a href="{{ rel.getDownloadURL() }}">{{ rel.title }}</a>{% if rel.commit_hash %}
[{{ rel.commit_hash | truncate(5, end='') }}]{% endif %},
created {{ rel.releaseDate | datetime }}.
{% if rel.task_id %}
<a href="{{ url_for('check_task', id=rel.task_id, r=package.getDetailsURL()) }}">Importing...</a>
{% elif not rel.approved %}
Waiting for approval.
{% endif %}
{% if package.checkPerm(current_user, "MAKE_RELEASE") or package.checkPerm(current_user, "APPROVE_RELEASE") %}
<a href="{{ rel.getEditURL() }}">Edit
{% if not rel.task_id and not rel.approved and package.checkPerm(current_user, "APPROVE_RELEASE") %}
/ Approve
{% endif %}
</a>
{% endif %}
{% if not rel.approved %}</i>{% endif %}
</li>
{% endif %}
{% else %}
<li>No releases available.</li>
{% endfor %}
</ul>
<h3>Tags</h3>
<ul>
{% for t in package.tags %}
<li>{{ t.title }}</li>
{% else %}
<li>No tags.</li>
{% endfor %}
</ul>
<!-- <table class="table-topalign">
<tr>
<td> -->
<h3>Dependencies</h3>
<ul>
{% for dep in package.dependencies %} {% for dep in package.dependencies %}
<li> <li class="list-group-item">
{%- if dep.package %} {%- if dep.package %}
<a href="{{ dep.package.getDetailsURL() }}">{{ dep.package.title }}</a> by {{ dep.package.author.display_name }} <a href="{{ dep.package.getDetailsURL() }}">{{ dep.package.title }}</a> by {{ dep.package.author.display_name }}
{% elif dep.meta_package %} {% elif dep.meta_package %}
@ -249,27 +235,76 @@
{% endif %} {% endif %}
</li> </li>
{% else %} {% else %}
<li><i>No dependencies</i></li> <li class="list-group-item"><i>No dependencies</i></li>
{% endfor %} {% endfor %}
</ul> </ul>
<!-- </td> </div>
<td> </div>
<h3>Required by</h3>
<ul>
{% for p in package.dependents %}
<li><a href="{{ p.getDetailsURL() }}">{{ p.title }}</a> by {{ p.author.display_name }}</li> <div class="col-sm-4">
{% else %} <div class="card">
{% if not package.softdependents %} <div class="card-header">
<li>No dependents.</li> Releases
{% if package.checkPerm(current_user, "MAKE_RELEASE") %}
<a class="btn btn-xs btn-primary float-right"
href="{{ package.getCreateReleaseURL() }}">+</a>
{% endif %} {% endif %}
{% endfor %} </div>
{% for p in package.softdependents %} <ul class="list-group list-group-flush">
<li><a href="{{ p.getDetailsURL() }}">{{ p.title }}</a> by {{ p.author.display_name }} [optional]</li> {% for rel in releases %}
{% if rel.approved or package.checkPerm(current_user, "MAKE_RELEASE") or package.checkPerm(current_user, "APPROVE_RELEASE") %}
<li class="list-group-item list-group-item-action" href="{{ rel.getDownloadURL() }}">
{% if not rel.approved %}<i>{% endif %}
{{ rel.title }}{% if rel.commit_hash %}
[{{ rel.commit_hash | truncate(5, end='') }}]{% endif %},
<small>created {{ rel.releaseDate | datetime }}.</small>
{% if rel.task_id %}
<a href="{{ url_for('check_task', id=rel.task_id, r=package.getDetailsURL()) }}">Importing...</a>
{% elif not rel.approved %}
Waiting for approval.
{% endif %}
{% if not rel.approved %}</i>{% endif %}
{% if package.checkPerm(current_user, "MAKE_RELEASE") or package.checkPerm(current_user, "APPROVE_RELEASE") %}
<a class="btn btn-sm btn-primary float-right" href="{{ rel.getEditURL() }}">Edit
{% if not rel.task_id and not rel.approved and package.checkPerm(current_user, "APPROVE_RELEASE") %}
/ Approve
{% endif %}
</a>
{% endif %}
</li>
{% endif %}
{% else %}
<li class="list-group-item">No releases available.</li>
{% endfor %} {% endfor %}
</ul> </ul>
</td> </div>
</tr> </div>
</table> -->
<div class="col-sm-4">
<div class="card">
<div class="card-header">
Threads
{% if package.approved and package.checkPerm(current_user, "CREATE_THREAD") %}
<a class="btn btn-xs btn-primary float-right"
href="{{ url_for('new_thread_page', pid=package.id) }}">
+
</a>
{% endif %}
</div>
<ul class="list-group list-group-flush">
{% from "macros/threads.html" import render_threadlist %}
{{ render_threadlist(threads, list_group=True) }}
</ul>
</div>
</div>
</div>
{# {#
{% if current_user.is_authenticated or requests %} {% if current_user.is_authenticated or requests %}
@ -290,12 +325,10 @@
#} #}
{% if alternatives %} {% if alternatives %}
<h3>Alternatives</h3> <h3>Related</h3>
<ul>
{% for p in alternatives %} {% from "macros/packagegridtile.html" import render_pkggrid %}
<li><a href="{{ p.getDetailsURL() }}">{{ p.title }} by {{ p.author.display_name }}</a></li> {{ render_pkggrid(alternatives) }}
{% endfor %}
</ul>
{% endif %} {% endif %}
{% if similar_topics %} {% if similar_topics %}
@ -321,15 +354,5 @@
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %} {% endif %}
</main>
{% if threads %}
<h3>Threads</h3>
{% if package.approved and package.checkPerm(current_user, "CREATE_THREAD") %}
<p><a href="{{ url_for('new_thread_page', pid=package.id) }}">Open Thread</a></p>
{% endif %}
{% from "macros/threads.html" import render_threadlist %}
{{ render_threadlist(threads) }}
{% endif %}
{% endblock %} {% endblock %}

@ -153,9 +153,10 @@ def package_page(package):
alternatives = Package.query \ alternatives = Package.query \
.filter_by(name=package.name, type=PackageType.MOD, soft_deleted=False) \ .filter_by(name=package.name, type=PackageType.MOD, soft_deleted=False) \
.filter(Package.id != package.id) \ .filter(Package.id != package.id) \
.order_by(db.asc(Package.title)) \ .order_by(db.desc(Package.score)) \
.all() .all()
show_similar_topics = current_user == package.author or \ show_similar_topics = current_user == package.author or \
package.checkPerm(current_user, Permission.APPROVE_NEW) package.checkPerm(current_user, Permission.APPROVE_NEW)