Skip to content

Commit

Permalink
feat: Migrate to wiki.gg [skip ci] (#2378)
Browse files Browse the repository at this point in the history
* feat: Migrate to wiki.gg

* refactor: Use replace instead

* chore: Update urls.json version
  • Loading branch information
JamieCallan117 committed Mar 21, 2024
1 parent 989243d commit ad6bc3b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright © Wynntils 2022-2023.
* Copyright © Wynntils 2022-2024.
* This file is released under LGPLv3. See LICENSE for full license details.
*/
package com.wynntils.models.activities.quests;
Expand Down Expand Up @@ -33,6 +33,7 @@

public final class QuestModel extends Model {
private static final String MINI_QUEST_PREFIX = "Mini-Quest - ";
private static final String WIKI_APOSTROPHE = "'";

private List<QuestInfo> quests = List.of();
private List<QuestInfo> miniQuests = List.of();
Expand Down Expand Up @@ -132,15 +133,18 @@ public void openQuestOnWiki(QuestInfo questInfo) {
String wikiName = "Quests#" + type + "ing_Posts";

Managers.Net.openLink(UrlId.LINK_WIKI_LOOKUP, Map.of("title", wikiName));
return;
} else {
ApiResponse apiResponse =
Managers.Net.callApi(UrlId.API_WIKI_QUEST_PAGE_QUERY, Map.of("name", questInfo.getName()));
apiResponse.handleJsonArray(json -> {
String pageTitle = json.get(0)
.getAsJsonObject()
.get("_pageTitle")
.getAsString()
.replace(WIKI_APOSTROPHE, "'");
Managers.Net.openLink(UrlId.LINK_WIKI_LOOKUP, Map.of("title", pageTitle));
});
}

ApiResponse apiResponse =
Managers.Net.callApi(UrlId.API_WIKI_QUEST_PAGE_QUERY, Map.of("name", questInfo.getName()));
apiResponse.handleJsonArray(json -> {
String pageTitle = json.get(0).getAsJsonObject().get("_pageTitle").getAsString();
Managers.Net.openLink(UrlId.LINK_WIKI_LOOKUP, Map.of("title", pageTitle));
});
}

public Optional<QuestInfo> getQuestInfoFromName(String name) {
Expand Down
8 changes: 4 additions & 4 deletions common/src/main/resources/assets/wynntils/urls.json
@@ -1,6 +1,6 @@
[
{
"version": 10
"version": 11
},
{
"id": "apiAthenaAuthPublicKey",
Expand Down Expand Up @@ -61,15 +61,15 @@
],
"encoding": "wiki",
"id": "apiWikiDiscoveryQuery",
"url": "https://wynncraft.gamepedia.com/api.php?action=parse&format=json&prop=wikitext&section=0&redirects=true&page=%{name}"
"url": "https://wynncraft.wiki.gg/api.php?action=parse&format=json&prop=wikitext&section=0&page=%{name}"
},
{
"arguments": [
"name"
],
"encoding": "cargo",
"id": "apiWikiQuestPageQuery",
"url": "https://wynncraft.fandom.com/index.php?title=Special:CargoExport&format=json&tables=Quests&fields=Quests._pageTitle&where=Quests.name=%{name}"
"url": "https://wynncraft.wiki.gg/index.php?title=Special:CargoExport&tables=Quests&&fields=Quests._pageTitle&where=Quests.name+%3D+%{name}&order+by=&limit=2000&format=json"
},
{
"id": "dataAthenaGuildList",
Expand Down Expand Up @@ -222,7 +222,7 @@
],
"encoding": "wiki",
"id": "linkWikiLookup",
"url": "https://wynncraft.fandom.com/wiki/%{title}"
"url": "https://wynncraft.wiki.gg/wiki/%{title}"
},
{
"arguments": [
Expand Down

0 comments on commit ad6bc3b

Please sign in to comment.