Skip to content

Commit

Permalink
Add forum_url to API, change to forum.luanti.org
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenwardy committed Nov 3, 2024
1 parent dd2e73b commit a54104a
Show file tree
Hide file tree
Showing 20 changed files with 31 additions and 27 deletions.
2 changes: 1 addition & 1 deletion app/blueprints/users/claim.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'):
Expand Down
3 changes: 3 additions & 0 deletions app/flatpages/help/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<username>/<name>/` (Read)
* Redirects a JSON object with the keys documented by the PUT endpoint, below.
* Plus:
* `forum_url`: String or null.
* PUT `/api/packages/<author>/<name>/` (Update)
* Requires authentication.
* JSON object with any of these keys (all are optional, null to delete Nullables):
Expand Down
2 changes: 1 addition & 1 deletion app/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion app/models/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ def forums_url(self) -> typing.Optional[str]:
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)

Expand Down Expand Up @@ -679,6 +679,7 @@ def as_dict(self, base_url, version=None, lang="en", screenshots_dict=False):
"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,
Expand Down
4 changes: 2 additions & 2 deletions app/public/static/js/package_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions app/tasks/forumtasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions app/tasks/pkgtasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions app/templates/macros/topics.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
[{{ topic.type.text }}]
</td>
<td>
<a href="https://forum.minetest.net/viewtopic.php?t={{ topic.topic_id}}">{{ topic.title }}</a>
<a href="https://forum.luanti.org/viewtopic.php?t={{ topic.topic_id}}">{{ topic.title }}</a>
{% if topic.wip %}[{{ _("WIP") }}]{% endif %}
</td>
{% if show_author %}
Expand Down Expand Up @@ -42,7 +42,7 @@
{% macro render_topics(topics, current_user) -%}
<div class="list-group">
{% for topic in topics %}
<a class="list-group-item list-group-item-action" href="https://forum.minetest.net/viewtopic.php?t={{ topic.topic_id}}">
<a class="list-group-item list-group-item-action" href="https://forum.luanti.org/viewtopic.php?t={{ topic.topic_id}}">
<span class="float-end text-muted">
{{ topic.created_at | date }}
</span>
Expand Down
2 changes: 1 addition & 1 deletion app/templates/modnames/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h3>{{ _("Forum Topics") }}</h3>
{% for t in similar_topics %}
<li>
[{{ t.type.text }}]
<a href="https://forum.minetest.net/viewtopic.php?t={{ t.topic_id }}">
<a href="https://forum.luanti.org/viewtopic.php?t={{ t.topic_id }}">
{{ _("%(title)s by %(display_name)s", title=t.title, display_name=t.author.display_name) }}
</a>
{% if t.wip %}[{{ _("WIP") }}]{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion app/templates/packages/create_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ <h3>{{ _("Do you have a Git repository?") }}</h3>
{{ 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.")) }}
Expand Down
2 changes: 1 addition & 1 deletion app/templates/packages/similar.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h3 id="similar-forum-topics">{{ _("Similar Forum Topics") }}</h3>
{% for t in similar_topics %}
<li>
[{{ t.type.value }}]
<a href="https://forum.minetest.net/viewtopic.php?t={{ t.topic_id }}">
<a href="https://forum.luanti.org/viewtopic.php?t={{ t.topic_id }}">
{{ _("%(title)s by %(display_name)s", title=t.title, display_name=t.author.display_name) }}
</a>
{% if t.wip %}[{{ _("WIP") }}]{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions app/templates/users/account.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% endblock %}

{% block ruben_link %}
<a href="https://forum.minetest.net/ucp.php?i=pm&mode=compose&u=2051">rubenwardy</a>
<a href="https://forum.luanti.org/ucp.php?i=pm&mode=compose&u=2051">rubenwardy</a>
{% endblock %}

{% block pane %}
Expand Down Expand Up @@ -36,7 +36,7 @@ <h3 class="mt-5">{{ _("Linked Accounts") }}</h3>
<td>Forums</td>
<td>
{% if user.forums_username %}
<a href="https://forum.minetest.net/memberlist.php?mode=viewprofile&un={{ user.forums_username }}">
<a href="https://forum.luanti.org/memberlist.php?mode=viewprofile&un={{ user.forums_username }}">
{{ user.forums_username }}
</a>
{% else %}
Expand Down
2 changes: 1 addition & 1 deletion app/templates/users/change_set_password.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h1>{{ _("Set Password") }}</h1>
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.")) }}
<p>
{{ _("Note: protonmail is unsupported by ContentDB. <a href='https://forum.minetest.net/viewtopic.php?t=30709'>More info</a>.") }}
{{ _("Note: protonmail is unsupported by ContentDB. <a href='https://forum.luanti.org/viewtopic.php?t=30709'>More info</a>.") }}
</p>
{% endif %}

Expand Down
2 changes: 1 addition & 1 deletion app/templates/users/claim.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h2>{{ _("Do you have an account on the Luanti Forums?") }}</h2>
<a class="btn btn-primary me-3" href="{{ url_for('users.register') }}">
{{ _("<b>No</b>, I don't have one") }}
</a>
<a class="btn btn-secondary" href="https://forum.minetest.net/ucp.php?mode=register">
<a class="btn btn-secondary" href="https://forum.luanti.org/ucp.php?mode=register">
{{ _("Create forum account") }}
</a>
</p>
Expand Down
4 changes: 2 additions & 2 deletions app/templates/users/claim_forums.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ <h2>{{ _("Confirm Your Account") }}</h2>

<p>
{{ _("You'll need to have the GitHub field in your forum profile filled out.") }}
{{ _("Log into the forum and <a href='https://forum.minetest.net/ucp.php?i=173'>do that here</a>.") }}
{{ _("Log into the forum and <a href='https://forum.luanti.org/ucp.php?i=173'>do that here</a>.") }}
</p>

<input class="btn btn-primary" type="submit" value="{{ _('Next: log in with GitHub') }}">
Expand All @@ -68,7 +68,7 @@ <h2>{{ _("Confirm Your Account") }}</h2>
placeholder="{{ _('Forum username') }}" pattern="[a-zA-Z0-9._ -]+" title="{{ _('Only a-zA-Z0-9._ allowed') }}" required>

<p>
{{ _("Go to <a href='https://forum.minetest.net/ucp.php?i=profile&mode=signature'>User Control Panel &gt; Profile &gt; Edit signature</a>") }}
{{ _("Go to <a href='https://forum.luanti.org/ucp.php?i=profile&mode=signature'>User Control Panel &gt; Profile &gt; Edit signature</a>") }}
</p>

<p>
Expand Down
2 changes: 1 addition & 1 deletion app/templates/users/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ <h1 class="ms-3 my-0 {{ user.rank.name }}">
</span>

{% if user.forums_username %}
<a class="btn" href="https://forum.minetest.net/memberlist.php?mode=viewprofile&un={{ user.forums_username }}">
<a class="btn" href="https://forum.luanti.org/memberlist.php?mode=viewprofile&un={{ user.forums_username }}">
<i class="fas fa-comments"></i>
<span class="count">
{{ _("Forums") }}
Expand Down
2 changes: 1 addition & 1 deletion app/templates/users/profile_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h3>{{ _("Profile Picture") }}</h3>
<div class="row">
<div class="col-md-2">
{% if user.forums_username %}
<a href="https://forum.minetest.net/ucp.php?i=profile&mode=avatar">
<a href="https://forum.luanti.org/ucp.php?i=profile&mode=avatar">
{% elif user.email %}
<a href="https://en.gravatar.com/">
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion app/templates/users/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h2 class="card-header">{{ self.title() }}</h2>
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.")) }}
<p>
{{ _("Note: protonmail is unsupported by ContentDB. <a href='https://forum.minetest.net/viewtopic.php?t=30709'>More info</a>.") }}
{{ _("Note: protonmail is unsupported by ContentDB. <a href='https://forum.luanti.org/viewtopic.php?t=30709'>More info</a>.") }}
</p>

{{ render_field(form.password, hint=_("Must be at least 12 characters long.")) }}
Expand Down
2 changes: 1 addition & 1 deletion app/templates/users/settings_email.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h3>{{ _("Email Address") }}</h3>
{{ _("Your email will never be shared with a third-party.") }}
</p>
<p>
{{ _("Note: protonmail is unsupported by ContentDB. <a href='https://forum.minetest.net/viewtopic.php?t=30709'>More info</a>.") }}
{{ _("Note: protonmail is unsupported by ContentDB. <a href='https://forum.luanti.org/viewtopic.php?t=30709'>More info</a>.") }}
</p>

{% if user.email_verifications.filter_by(is_password_reset=False).count() > 0 %}
Expand Down
2 changes: 1 addition & 1 deletion app/utils/phpbbparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit a54104a

Please sign in to comment.