mirror of
https://github.com/minetest/contentdb.git
synced 2024-11-10 01:23:48 +01:00
Add translation url field to package form and API
This commit is contained in:
parent
9fd182c4fd
commit
ab57b6aa2c
@ -804,6 +804,11 @@ def json_schema():
|
||||
"type": ["string", "null"],
|
||||
"format": "uri"
|
||||
},
|
||||
"translation_url": {
|
||||
"description": "URL to send users interested in translating your package",
|
||||
"type": ["string", "null"],
|
||||
"format": "uri"
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -270,6 +270,7 @@ class PackageForm(FlaskForm):
|
||||
forums = IntegerField(lazy_gettext("Forum Topic ID"), [Optional(), NumberRange(0, 999999)])
|
||||
video_url = StringField(lazy_gettext("Video URL"), [Optional(), URL()], filters=[lambda x: x or None])
|
||||
donate_url = StringField(lazy_gettext("Donate URL"), [Optional(), URL()], filters=[lambda x: x or None])
|
||||
translation_url = StringField(lazy_gettext("Translation URL"), [Optional(), URL()], filters=[lambda x: x or None])
|
||||
|
||||
submit = SubmitField(lazy_gettext("Save"))
|
||||
|
||||
@ -323,6 +324,7 @@ def handle_create_edit(package: typing.Optional[Package], form: PackageForm, aut
|
||||
"forums": form.forums.data,
|
||||
"video_url": form.video_url.data,
|
||||
"donate_url": form.donate_url.data,
|
||||
"translation_url": form.translation_url.data,
|
||||
})
|
||||
|
||||
if wasNew:
|
||||
|
@ -101,6 +101,7 @@ curl -X DELETE https://content.minetest.net/api/delete-token/ \
|
||||
* `forums`: forum topic ID.
|
||||
* `video_url`: URL to a video.
|
||||
* `donate_url`: URL to a donation page.
|
||||
* `translation_url`: URL to send users interested in translating your package.
|
||||
* `game_support`: Array of game support information objects. Not currently documented, as subject to change.
|
||||
* GET `/api/packages/<author>/<name>/hypertext/`
|
||||
* Converts the long description to [Minetest Markup Language](https://github.com/minetest/minetest/blob/master/doc/lua_api.md#markup-language)
|
||||
|
@ -76,6 +76,7 @@ It should be a JSON dictionary with one or more of the following optional keys:
|
||||
* `forums`: forum topic ID.
|
||||
* `video_url`: URL to a video.
|
||||
* `donate_url`: URL to a donation page.
|
||||
* `translation_url`: URL to send users interested in translating your package.
|
||||
|
||||
Use `null` or `[]` to unset fields where relevant.
|
||||
|
||||
|
@ -66,6 +66,7 @@ ALLOWED_FIELDS = {
|
||||
"forums": int,
|
||||
"video_url": str,
|
||||
"donate_url": str,
|
||||
"translation_url": str,
|
||||
}
|
||||
|
||||
ALIASES = {
|
||||
@ -125,7 +126,7 @@ def do_edit_package(user: User, package: Package, was_new: bool, was_web: bool,
|
||||
|
||||
validate(data)
|
||||
|
||||
for field in ["short_desc", "desc", "website", "issueTracker", "repo", "video_url", "donate_url"]:
|
||||
for field in ["short_desc", "desc", "website", "issueTracker", "repo", "video_url", "donate_url", "translation_url"]:
|
||||
if field in data and has_blocked_domains(data[field], user.username,
|
||||
f"{field} of {package.get_id()}"):
|
||||
raise LogicError(403, lazy_gettext("Linking to blocked sites is not allowed"))
|
||||
@ -148,7 +149,7 @@ def do_edit_package(user: User, package: Package, was_new: bool, was_web: bool,
|
||||
raise LogicError(403, "Never gonna give you up / Never gonna let you down / Never gonna run around and desert you")
|
||||
|
||||
for key in ["name", "title", "short_desc", "desc", "type", "dev_state", "license", "media_license",
|
||||
"repo", "website", "issueTracker", "forums", "video_url", "donate_url"]:
|
||||
"repo", "website", "issueTracker", "forums", "video_url", "donate_url", "translation_url"]:
|
||||
if key in data:
|
||||
setattr(package, key, data[key])
|
||||
|
||||
|
@ -586,6 +586,7 @@ class Package(db.Model):
|
||||
"forums": self.forums,
|
||||
"video_url": self.video_url,
|
||||
"donate_url": self.donate_url_actual,
|
||||
"translation_url": self.translation_url,
|
||||
|
||||
"tags": sorted([x.name for x in self.tags]),
|
||||
"content_warnings": sorted([x.name for x in self.content_warnings]),
|
||||
|
@ -119,6 +119,7 @@
|
||||
has_view=True) }}
|
||||
{{ render_field(form.video_url, class_="pkg_meta", hint=_("YouTube videos will be shown in an embed.")) }}
|
||||
{{ render_field(form.donate_url, class_="pkg_meta", hint=_("If blank, the author's donation URL will be used instead.")) }}
|
||||
{{ render_field(form.translation_url, class_="pkg_meta", hint=_("How can users translate your package? ie: weblate URL or a help page")) }}
|
||||
</fieldset>
|
||||
|
||||
<div class="pkg_meta mt-5">{{ render_submit_field(form.submit) }}</div>
|
||||
|
@ -224,6 +224,12 @@
|
||||
<span class="count">{{ _("Issue Tracker") }}</span>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if package.translation_url %}
|
||||
<a class="btn" href="{{ package.translation_url }}">
|
||||
<i class="fas fa-language"></i>
|
||||
<span class="count">{{ _("Translate") }}</span>
|
||||
</a>
|
||||
{% endif %}
|
||||
<a class="btn" href="{{ package.get_url('packages.statistics') }}">
|
||||
<i class="fas fa-chart-line"></i>
|
||||
<span class="count">{{ _("Statistics") }}</span>
|
||||
|
Loading…
Reference in New Issue
Block a user