mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-23 14:32:25 +01:00
Add helpful page for game support
This commit is contained in:
parent
d6887d7b46
commit
7f00b77db3
@ -17,7 +17,7 @@
|
|||||||
from flask import Blueprint
|
from flask import Blueprint
|
||||||
from flask_babel import gettext
|
from flask_babel import gettext
|
||||||
|
|
||||||
from app.models import User, Package, Permission
|
from app.models import User, Package, Permission, PackageType
|
||||||
|
|
||||||
bp = Blueprint("packages", __name__)
|
bp = Blueprint("packages", __name__)
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ def get_package_tabs(user: User, package: Package):
|
|||||||
if package is None or not package.checkPerm(user, Permission.EDIT_PACKAGE):
|
if package is None or not package.checkPerm(user, Permission.EDIT_PACKAGE):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
return [
|
retval = [
|
||||||
{
|
{
|
||||||
"id": "edit",
|
"id": "edit",
|
||||||
"title": gettext("Edit Details"),
|
"title": gettext("Edit Details"),
|
||||||
@ -64,5 +64,14 @@ def get_package_tabs(user: User, package: Package):
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if package.type == PackageType.MOD:
|
||||||
|
retval.insert(1, {
|
||||||
|
"id": "game_support",
|
||||||
|
"title": gettext("Supported Games"),
|
||||||
|
"url": package.getURL("packages.game_support")
|
||||||
|
})
|
||||||
|
|
||||||
|
return retval
|
||||||
|
|
||||||
|
|
||||||
from . import packages, screenshots, releases, reviews, game_hub
|
from . import packages, screenshots, releases, reviews, game_hub
|
||||||
|
@ -624,3 +624,18 @@ def similar(package):
|
|||||||
|
|
||||||
return render_template("packages/similar.html", package=package,
|
return render_template("packages/similar.html", package=package,
|
||||||
packages_modnames=packages_modnames, similar_topics=similar_topics)
|
packages_modnames=packages_modnames, similar_topics=similar_topics)
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/packages/<author>/<name>/support/")
|
||||||
|
@login_required
|
||||||
|
@is_package_page
|
||||||
|
def game_support(package):
|
||||||
|
if package.type != PackageType.MOD:
|
||||||
|
abort(404)
|
||||||
|
|
||||||
|
if not (package.checkPerm(current_user, Permission.EDIT_PACKAGE) or
|
||||||
|
package.checkPerm(current_user, Permission.APPROVE_NEW)):
|
||||||
|
abort(403)
|
||||||
|
|
||||||
|
return render_template("packages/game_support.html", package=package,
|
||||||
|
tabs=get_package_tabs(current_user, package), current_tab="game_support")
|
||||||
|
@ -19,6 +19,7 @@ toc: False
|
|||||||
* [Git Update Detection](update_config)
|
* [Git Update Detection](update_config)
|
||||||
* [Creating Releases using Webhooks](release_webhooks)
|
* [Creating Releases using Webhooks](release_webhooks)
|
||||||
* [Package Configuration and Releases Guide](package_config)
|
* [Package Configuration and Releases Guide](package_config)
|
||||||
|
* [Supported Games](game_support)
|
||||||
|
|
||||||
## Help for Specific User Ranks
|
## Help for Specific User Ranks
|
||||||
|
|
||||||
|
37
app/flatpages/help/game_support.md
Normal file
37
app/flatpages/help/game_support.md
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
title: Supported Games
|
||||||
|
|
||||||
|
<p class="alert alert-warning">
|
||||||
|
This feature is experimental
|
||||||
|
</p>
|
||||||
|
|
||||||
|
## Why?
|
||||||
|
|
||||||
|
The supported/compatible games feature allows mods to specify the games that they work with, which improves
|
||||||
|
user experience.
|
||||||
|
|
||||||
|
|
||||||
|
## Support sources
|
||||||
|
|
||||||
|
### mod.conf
|
||||||
|
|
||||||
|
You can use `supported_games` to specify games that your mod is compatible with.
|
||||||
|
|
||||||
|
You can use `unsupported_games` to specify games that your mod doesn't work with, which is useful for overriding
|
||||||
|
ContentDB's automatic detection.
|
||||||
|
|
||||||
|
Both of these are comma-separated lists of game technical ids. Any `_game` suffixes are ignored, just like in Minetest.
|
||||||
|
|
||||||
|
supported_games = minetest_game, repixture
|
||||||
|
unsupported_games = lordofthetest, nodecore, whynot
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
ContentDB will analyse hard dependencies and work out which games a mod supports.
|
||||||
|
|
||||||
|
This uses a recursive algorithm that works out whether a dependency can be installed independently, or if it requires
|
||||||
|
a certain game.
|
||||||
|
|
||||||
|
|
||||||
|
## Combining all the sources
|
||||||
|
|
||||||
|
mod.conf will override anything ContentDB detects.
|
@ -506,8 +506,12 @@ class Package(db.Model):
|
|||||||
def getSortedOptionalDependencies(self):
|
def getSortedOptionalDependencies(self):
|
||||||
return self.getSortedDependencies(False)
|
return self.getSortedDependencies(False)
|
||||||
|
|
||||||
def getSortedSupportedGames(self):
|
def getSortedSupportedGames(self, include_unsupported=False):
|
||||||
supported = self.supported_games.filter_by(supports=True).all()
|
query = self.supported_games
|
||||||
|
if not include_unsupported:
|
||||||
|
query = query.filter_by(supports=True)
|
||||||
|
|
||||||
|
supported = query.all()
|
||||||
supported.sort(key=lambda x: -(x.game.score + 100000*x.confidence))
|
supported.sort(key=lambda x: -(x.game.score + 100000*x.confidence))
|
||||||
return supported
|
return supported
|
||||||
|
|
||||||
|
64
app/templates/packages/game_support.html
Normal file
64
app/templates/packages/game_support.html
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
{% extends "packages/package_base.html" %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
{{ _("Supported Games") }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h2 class="mt-0">{{ self.title() }}</h2>
|
||||||
|
|
||||||
|
<p class="alert alert-info">
|
||||||
|
<a class="float-right btn btn-sm" href="{{ url_for('flatpage', path='help/game_support') }}">
|
||||||
|
{{ _("Read more") }}
|
||||||
|
</a>
|
||||||
|
{{ _("Support is determined based on dependencies and fields in mod.conf") }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="list-group">
|
||||||
|
<div class="list-group-item">
|
||||||
|
<div class="row">
|
||||||
|
<span class="col-5">
|
||||||
|
{{ _("Package") }}
|
||||||
|
</span>
|
||||||
|
<span class="col-5">
|
||||||
|
{{ _("Source") }}
|
||||||
|
</span>
|
||||||
|
<span class="col-2 text-right">
|
||||||
|
{{ _("Supported?") }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% for support in package.getSortedSupportedGames(True) %}
|
||||||
|
<a class="list-group-item list-group-item-action"
|
||||||
|
href="{{ support.game.getURL('packages.view') }}">
|
||||||
|
<div class="row">
|
||||||
|
<span class="col-5">
|
||||||
|
{{ _("%(title)s by %(display_name)s",
|
||||||
|
title=support.game.title, display_name=support.game.author.display_name) }}
|
||||||
|
</span>
|
||||||
|
<span class="col-5">
|
||||||
|
{% if support.confidence == 1 %}
|
||||||
|
{{ _("Detected from dependencies") }}
|
||||||
|
{% elif support.confidence == 10 %}
|
||||||
|
{{ _("mod.conf") }}
|
||||||
|
{% else %}
|
||||||
|
{{ support.confidence }}
|
||||||
|
{% endif %}
|
||||||
|
</span>
|
||||||
|
<span class="col-2 text-right">
|
||||||
|
{% if support.supports %}
|
||||||
|
<span class="badge badge-success">Yes</span>
|
||||||
|
{% else %}
|
||||||
|
<span class="badge badge-danger">No</span>
|
||||||
|
{% endif %}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
{% else %}
|
||||||
|
<div class="list-group-item text-muted">
|
||||||
|
{{ _("No specific game is required") }}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
@ -433,7 +433,14 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if package.type == package.type.MOD %}
|
{% if package.type == package.type.MOD %}
|
||||||
<h3>{{ _("Compatible Games") }}</h3>
|
<h3>
|
||||||
|
{% if package.checkPerm(current_user, "EDIT_PACKAGE") %}
|
||||||
|
<a href="{{ package.getURL('packages.game_support') }}" class="btn btn-secondary btn-sm float-right">
|
||||||
|
<i class="fas fa-pen"></i>
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
{{ _("Compatible Games") }}
|
||||||
|
</h3>
|
||||||
<div style="max-height: 300px; overflow: hidden auto;">
|
<div style="max-height: 300px; overflow: hidden auto;">
|
||||||
{% for support in package.getSortedSupportedGames() %}
|
{% for support in package.getSortedSupportedGames() %}
|
||||||
<a class="badge badge-secondary"
|
<a class="badge badge-secondary"
|
||||||
|
Loading…
Reference in New Issue
Block a user