From a1646480fb7d7ffe9e81de2b0884e09e79adc686 Mon Sep 17 00:00:00 2001 From: blueb Date: Tue, 22 Aug 2023 01:04:27 -0400 Subject: [PATCH] move servers into config.json for page.js --- src/config.json | 3 ++- src/front/cobalt.css | 3 +-- src/modules/config.js | 1 + src/modules/pageRender/page.js | 35 +++++++++++----------------------- 4 files changed, 15 insertions(+), 27 deletions(-) diff --git a/src/config.json b/src/config.json index 6337654f..fc001b73 100644 --- a/src/config.json +++ b/src/config.json @@ -69,5 +69,6 @@ "copy": ["-c:a", "copy"], "audio": ["-ar", "48000", "-ac", "2", "-b:a", "320k"], "m4a": ["-movflags", "frag_keyframe+empty_moov"] - } + }, + "otherServers": ["default", "https://co.wuk.sh", "https://api.c0ba.lt", "https://wukko.wolfdo.gg", "https://api.co.749.city", "https://cobalt-api.fluffy.tools", "https://capi.oak.li"] } diff --git a/src/front/cobalt.css b/src/front/cobalt.css index fdae5962..ee6f2e7d 100644 --- a/src/front/cobalt.css +++ b/src/front/cobalt.css @@ -1213,5 +1213,4 @@ button:active, border-bottom-left-radius: 5px 6px!important; border-bottom-right-radius: 5px 6px!important; border-top-right-radius: 0px; -} - +} \ No newline at end of file diff --git a/src/modules/config.js b/src/modules/config.js index 5268b8dd..0f068213 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -15,5 +15,6 @@ export const donations = config.donations, ffmpegArgs = config.ffmpegArgs, supportedAudio = config.supportedAudio, + otherServers = config.otherServers, celebrations = config.celebrations, links = config.links diff --git a/src/modules/pageRender/page.js b/src/modules/pageRender/page.js index e0d942f6..4094cfec 100644 --- a/src/modules/pageRender/page.js +++ b/src/modules/pageRender/page.js @@ -1,5 +1,5 @@ import { checkbox, collapsibleList, explanation, footerButtons, multiPagePopup, popup, popupWithBottomButtons, sep, settingsCategory, switcher, socialLink, urgentNotice, keyboardShortcuts } from "./elements.js"; -import { services as s, authorInfo, version, repo, donations, supportedAudio } from "../config.js"; +import { services as s, authorInfo, version, repo, donations, supportedAudio, otherServers } from "../config.js"; import { getCommitInfo } from "../sub/currentCommit.js"; import loc from "../../localization/manager.js"; import emoji from "../emoji.js"; @@ -7,6 +7,8 @@ import changelogManager from "../changelog/changelogManager.js"; let com = getCommitInfo(); +let defaultApiURL = process.env.apiURL ? process.env.apiURL.slice(0, -1) : ''; + let enabledServices = Object.keys(s).filter((p) => { if (s[p].enabled) return true; }).sort().map((p) => { @@ -28,7 +30,13 @@ for (let i in donations["crypto"]) { extr = ' top-margin' } -let defaultApiURL = process.env.apiURL ? process.env.apiURL.slice(0, -1) : ''; +let servers = otherServers.map((p) => { + if (p === "default") { + return { "action": defaultApiURL, "text": defaultApiURL.replace("https://","") } + } else { + return { "action": p, "text": p.replace("https://","") } + } +}) export default function(obj) { const t = (str, replace) => { return loc(obj.lang, str, replace) }; @@ -461,28 +469,7 @@ export default function(obj) { name: "serverPicker", explanation: t(['SettingsServerPickerDescription'])+defaultApiURL.replace("https://","")+".", vertical: true, - items: [{ - action: defaultApiURL, - text: defaultApiURL.replace("https://","") - }, { - action: "https://co.wuk.sh", - text: "co.wuk.sh" - }, { - action: "https://api.c0ba.lt", - text: "api.c0ba.lt" - }, { - action: "https://wukko.wolfdo.gg", - text: "wukko.wolfdo.gg" - }, { - action: "https://api.co.749.city", - text: "api.co.749.city" - }, { - action: "https://cobalt-api.fluffy.tools", - text: "cobalt-api.fluffy.tools" - }, { - action: "https://capi.oak.li", - text: "capi.oak.li" - }] + items: servers }) }) }],