From a54104aa82d421001052a71c7f24505f096ac4f1 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Sun, 3 Nov 2024 14:20:14 +0000 Subject: [PATCH] Add forum_url to API, change to forum.luanti.org --- app/blueprints/users/claim.py | 2 +- app/flatpages/help/api.md | 3 +++ app/models/__init__.py | 2 +- app/models/packages.py | 3 ++- app/public/static/js/package_edit.js | 4 ++-- app/tasks/forumtasks.py | 8 ++++---- app/tasks/pkgtasks.py | 4 ++-- app/templates/macros/topics.html | 4 ++-- app/templates/modnames/view.html | 2 +- app/templates/packages/create_edit.html | 2 +- app/templates/packages/similar.html | 2 +- app/templates/users/account.html | 4 ++-- app/templates/users/change_set_password.html | 2 +- app/templates/users/claim.html | 2 +- app/templates/users/claim_forums.html | 4 ++-- app/templates/users/profile.html | 2 +- app/templates/users/profile_edit.html | 2 +- app/templates/users/register.html | 2 +- app/templates/users/settings_email.html | 2 +- app/utils/phpbbparser.py | 2 +- 20 files changed, 31 insertions(+), 27 deletions(-) diff --git a/app/blueprints/users/claim.py b/app/blueprints/users/claim.py index 328bd8cc..c456cb9f 100644 --- a/app/blueprints/users/claim.py +++ b/app/blueprints/users/claim.py @@ -77,7 +77,7 @@ def claim_forums(): # Get signature try: - profile = get_profile("https://forum.minetest.net", username) + profile = get_profile("https://forum.luanti.org", username) sig = profile.signature if profile else None except IOError as e: if hasattr(e, 'message'): diff --git a/app/flatpages/help/api.md b/app/flatpages/help/api.md index 1aad0730..865e5355 100644 --- a/app/flatpages/help/api.md +++ b/app/flatpages/help/api.md @@ -78,6 +78,9 @@ curl -X DELETE https://content.luanti.org/api/delete-token/ \ * GET `/api/packages/` (List) * See [Package Queries](#package-queries) * GET `/api/packages///` (Read) + * Redirects a JSON object with the keys documented by the PUT endpoint, below. + * Plus: + * `forum_url`: String or null. * PUT `/api/packages///` (Update) * Requires authentication. * JSON object with any of these keys (all are optional, null to delete Nullables): diff --git a/app/models/__init__.py b/app/models/__init__.py index d4bca51a..b4219472 100644 --- a/app/models/__init__.py +++ b/app/models/__init__.py @@ -158,7 +158,7 @@ class ForumTopic(db.Model): @property def url(self): - return "https://forum.minetest.net/viewtopic.php?t=" + str(self.topic_id) + return "https://forum.luanti.org/viewtopic.php?t=" + str(self.topic_id) def get_repo_url(self): if self.link is None: diff --git a/app/models/packages.py b/app/models/packages.py index 271acf04..d9863eba 100644 --- a/app/models/packages.py +++ b/app/models/packages.py @@ -457,7 +457,7 @@ class Package(db.Model): if self.forums is None: return None - return "https://forum.minetest.net/viewtopic.php?t=" + str(self.forums) + return "https://forum.luanti.org/viewtopic.php?t=" + str(self.forums) enable_game_support_detection = db.Column(db.Boolean, nullable=False, default=True) @@ -679,6 +679,7 @@ class Package(db.Model): "website": self.website, "issue_tracker": self.issueTracker, "forums": self.forums, + "forum_url": self.forums_url, "video_url": self.video_url, "video_thumbnail_url": self.get_video_thumbnail_url(True), "donate_url": self.donate_url_actual, diff --git a/app/public/static/js/package_edit.js b/app/public/static/js/package_edit.js index fac8f678..793748ac 100644 --- a/app/public/static/js/package_edit.js +++ b/app/public/static/js/package_edit.js @@ -26,7 +26,7 @@ window.addEventListener("load", () => { try { const pasteData = e.clipboardData.getData('text'); const url = new URL(pasteData); - if (url.hostname === "forum.minetest.net") { + if (url.hostname === "forum.luanti.org") { forumsField.value = url.searchParams.get("t"); e.preventDefault(); } @@ -37,7 +37,7 @@ window.addEventListener("load", () => { const openForums = document.getElementById("forums-button"); openForums.addEventListener("click", () => { - window.open("https://forum.minetest.net/viewtopic.php?t=" + forumsField.value, "_blank"); + window.open("https://forum.luanti.org/viewtopic.php?t=" + forumsField.value, "_blank"); }); function setupHints(id, hints) { diff --git a/app/tasks/forumtasks.py b/app/tasks/forumtasks.py index 6b2f49b9..87cd8dc3 100644 --- a/app/tasks/forumtasks.py +++ b/app/tasks/forumtasks.py @@ -57,7 +57,7 @@ def _get_or_create_user(forums_username: str, cache: Optional[dict] = None) -> O def check_forum_account(forums_username, force_replace_pic=False): print("### Checking " + forums_username, file=sys.stderr) try: - profile = get_profile("https://forum.minetest.net", forums_username) + profile = get_profile("https://forum.luanti.org", forums_username) except OSError as e: print(e, file=sys.stderr) return @@ -88,13 +88,13 @@ def check_forum_account(forums_username, force_replace_pic=False): db.session.commit() if pic: - pic = urljoin("https://forum.minetest.net/", pic) + pic = urljoin("https://forum.luanti.org/", pic) print(f"####### Picture: {pic}", file=sys.stderr) print(f"####### User pp {user.profile_pic}", file=sys.stderr) pic_needs_replacing = user.profile_pic is None or user.profile_pic == "" or \ - user.profile_pic.startswith("https://forum.minetest.net") or force_replace_pic - if pic_needs_replacing and pic.startswith("https://forum.minetest.net"): + user.profile_pic.startswith("https://forum.luanti.org") or force_replace_pic + if pic_needs_replacing and pic.startswith("https://forum.luanti.org"): print(f"####### Queueing", file=sys.stderr) set_profile_picture_from_url.delay(user.username, pic) diff --git a/app/tasks/pkgtasks.py b/app/tasks/pkgtasks.py index d3f79d82..726d393e 100644 --- a/app/tasks/pkgtasks.py +++ b/app/tasks/pkgtasks.py @@ -45,7 +45,7 @@ def update_package_scores(): def desc_contains(desc: str, search_str: str): - if search_str.startswith("https://forum.minetest.net/viewtopic.php?%t="): + if search_str.startswith("https://forum.luanti.org/viewtopic.php?%t="): reg = re.compile(search_str.replace(".", "\\.").replace("/", "\\/").replace("?", "\\?").replace("%", ".*")) return reg.search(desc) else: @@ -58,7 +58,7 @@ def notify_about_git_forum_links(): .filter(Package.repo.is_not(None), Package.state == PackageState.APPROVED).all()] for pair in db.session.query(Package, Package.forums) \ .filter(Package.forums.is_not(None), Package.state == PackageState.APPROVED).all(): - package_links.append((pair[0], f"https://forum.minetest.net/viewtopic.php?%t={pair[1]}")) + package_links.append((pair[0], f"https://forum.luanti.org/viewtopic.php?%t={pair[1]}")) clauses = [and_(Package.id != pair[0].id, Package.desc.ilike(f"%{pair[1]}%")) for pair in package_links] packages = Package.query.filter(Package.desc != "", Package.desc.is_not(None), Package.state == PackageState.APPROVED, or_(*clauses)).all() diff --git a/app/templates/macros/topics.html b/app/templates/macros/topics.html index 31edf17e..52132004 100644 --- a/app/templates/macros/topics.html +++ b/app/templates/macros/topics.html @@ -14,7 +14,7 @@ [{{ topic.type.text }}] - {{ topic.title }} + {{ topic.title }} {% if topic.wip %}[{{ _("WIP") }}]{% endif %} {% if show_author %} @@ -42,7 +42,7 @@ {% macro render_topics(topics, current_user) -%}
{% for topic in topics %} - + {{ topic.created_at | date }} diff --git a/app/templates/modnames/view.html b/app/templates/modnames/view.html index 79709c15..a48b8ddc 100644 --- a/app/templates/modnames/view.html +++ b/app/templates/modnames/view.html @@ -23,7 +23,7 @@ {% for t in similar_topics %}
  • [{{ t.type.text }}] - + {{ _("%(title)s by %(display_name)s", title=t.title, display_name=t.author.display_name) }} {% if t.wip %}[{{ _("WIP") }}]{% endif %} diff --git a/app/templates/packages/create_edit.html b/app/templates/packages/create_edit.html index 4a50e824..41cb7969 100644 --- a/app/templates/packages/create_edit.html +++ b/app/templates/packages/create_edit.html @@ -137,7 +137,7 @@ {{ render_field(form.issueTracker, class_="pkg_meta", hint=_("Where should users report issues?")) }} {{ render_field_prefix_button(form.forums, class_="pkg_meta", pattern="[0-9]+", - prefix="forum.minetest.net/viewtopic.php?t=", + prefix="forum.luanti.org/viewtopic.php?t=", placeholder=_("Paste a forum topic URL"), has_view=True) }} {{ render_field(form.video_url, class_="pkg_meta", hint=_("YouTube videos will be shown in an embed.")) }} diff --git a/app/templates/packages/similar.html b/app/templates/packages/similar.html index 00811dfe..f38f2b20 100644 --- a/app/templates/packages/similar.html +++ b/app/templates/packages/similar.html @@ -34,7 +34,7 @@ {% for t in similar_topics %}
  • [{{ t.type.value }}] - + {{ _("%(title)s by %(display_name)s", title=t.title, display_name=t.author.display_name) }} {% if t.wip %}[{{ _("WIP") }}]{% endif %} diff --git a/app/templates/users/account.html b/app/templates/users/account.html index d67482cc..a6e9ec34 100644 --- a/app/templates/users/account.html +++ b/app/templates/users/account.html @@ -5,7 +5,7 @@ {% endblock %} {% block ruben_link %} - rubenwardy + rubenwardy {% endblock %} {% block pane %} @@ -36,7 +36,7 @@ Forums {% if user.forums_username %} - + {{ user.forums_username }} {% else %} diff --git a/app/templates/users/change_set_password.html b/app/templates/users/change_set_password.html index 1766e325..13d77375 100644 --- a/app/templates/users/change_set_password.html +++ b/app/templates/users/change_set_password.html @@ -16,7 +16,7 @@ hint=_("Your email is needed to recover your account if you forget your password and to send (configurable) notifications. ") + _("Your email will never be shared with a third-party.")) }}

    - {{ _("Note: protonmail is unsupported by ContentDB. More info.") }} + {{ _("Note: protonmail is unsupported by ContentDB. More info.") }}

    {% endif %} diff --git a/app/templates/users/claim.html b/app/templates/users/claim.html index c8ba1d87..9f91dd59 100644 --- a/app/templates/users/claim.html +++ b/app/templates/users/claim.html @@ -20,7 +20,7 @@ {{ _("No, I don't have one") }} - + {{ _("Create forum account") }}

    diff --git a/app/templates/users/claim_forums.html b/app/templates/users/claim_forums.html index bf389d09..ab818f54 100644 --- a/app/templates/users/claim_forums.html +++ b/app/templates/users/claim_forums.html @@ -41,7 +41,7 @@ Create Account from Forums User

    {{ _("You'll need to have the GitHub field in your forum profile filled out.") }} - {{ _("Log into the forum and do that here.") }} + {{ _("Log into the forum and do that here.") }}

    @@ -68,7 +68,7 @@ Create Account from Forums User placeholder="{{ _('Forum username') }}" pattern="[a-zA-Z0-9._ -]+" title="{{ _('Only a-zA-Z0-9._ allowed') }}" required>

    - {{ _("Go to User Control Panel > Profile > Edit signature") }} + {{ _("Go to User Control Panel > Profile > Edit signature") }}

    diff --git a/app/templates/users/profile.html b/app/templates/users/profile.html index 9ee61f8e..cb250d17 100644 --- a/app/templates/users/profile.html +++ b/app/templates/users/profile.html @@ -71,7 +71,7 @@ {% if user.forums_username %} - + {{ _("Forums") }} diff --git a/app/templates/users/profile_edit.html b/app/templates/users/profile_edit.html index 953923c3..5a056943 100644 --- a/app/templates/users/profile_edit.html +++ b/app/templates/users/profile_edit.html @@ -11,7 +11,7 @@

    {% if user.forums_username %} - + {% elif user.email %} {% endif %} diff --git a/app/templates/users/register.html b/app/templates/users/register.html index a87d8d35..960ea69e 100644 --- a/app/templates/users/register.html +++ b/app/templates/users/register.html @@ -24,7 +24,7 @@ hint=_("Your email is needed to recover your account if you forget your password and to send (configurable) notifications. ") + _("Your email will never be shared with a third-party.")) }}

    - {{ _("Note: protonmail is unsupported by ContentDB. More info.") }} + {{ _("Note: protonmail is unsupported by ContentDB. More info.") }}

    {{ render_field(form.password, hint=_("Must be at least 12 characters long.")) }} diff --git a/app/templates/users/settings_email.html b/app/templates/users/settings_email.html index 9f3ac59a..95a4f2f8 100644 --- a/app/templates/users/settings_email.html +++ b/app/templates/users/settings_email.html @@ -24,7 +24,7 @@ {{ _("Your email will never be shared with a third-party.") }}

    - {{ _("Note: protonmail is unsupported by ContentDB. More info.") }} + {{ _("Note: protonmail is unsupported by ContentDB. More info.") }}

    {% if user.email_verifications.filter_by(is_password_reset=False).count() > 0 %} diff --git a/app/utils/phpbbparser.py b/app/utils/phpbbparser.py index f8139b11..395b49d3 100644 --- a/app/utils/phpbbparser.py +++ b/app/utils/phpbbparser.py @@ -124,7 +124,7 @@ def parse_forum_list_page(id, page, out, extra=None): start = page*num_per_page+1 print(" - Fetching page {} (topics {}-{})".format(page, start, start+num_per_page), file=sys.stderr) - url = "https://forum.minetest.net/viewforum.php?f=" + str(id) + "&start=" + str(start) + url = "https://forum.luanti.org/viewforum.php?f=" + str(id) + "&start=" + str(start) r = urllib.request.urlopen(url).read().decode("utf-8") soup = BeautifulSoup(r, "html.parser")