From 42ba77ebf46dc35147d2f6fb138431ed7a6f9047 Mon Sep 17 00:00:00 2001 From: Oneric Date: Sat, 28 Sep 2024 18:33:30 +0200 Subject: [PATCH] Allow using custom source URLs --- src/boot/after_store.js | 6 ++++++ src/components/settings_modal/tabs/version_tab.js | 11 +++++++---- src/modules/instance.js | 2 ++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/boot/after_store.js b/src/boot/after_store.js index d45584c0..d27d4fb8 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -183,6 +183,12 @@ const setSettings = async ({ apiConfig, staticConfig, store }) => { copyInstanceOption('renderMisskeyMarkdown') copyInstanceOption('sidebarRight') + if (config.backendCommitUrl) + copyInstanceOption('backendCommitUrl') + + if (config.frontendCommitUrl) + copyInstanceOption('frontendCommitUrl') + return store.dispatch('setTheme', config['theme']) } diff --git a/src/components/settings_modal/tabs/version_tab.js b/src/components/settings_modal/tabs/version_tab.js index d69b131d..97791a3a 100644 --- a/src/components/settings_modal/tabs/version_tab.js +++ b/src/components/settings_modal/tabs/version_tab.js @@ -1,22 +1,25 @@ import { extractCommit } from 'src/services/version/version.service' -const pleromaFeCommitUrl = 'https://akkoma.dev/AkkomaGang/pleroma-fe/commit/' -const pleromaBeCommitUrl = 'https://akkoma.dev/AkkomaGang/akkoma/commit/' +function joinURL(base, subpath) { + return URL.parse(subpath, base)?.href || "invalid base URL" +} const VersionTab = { data () { const instance = this.$store.state.instance return { + backendCommitUrl: instance.backendCommitUrl, backendVersion: instance.backendVersion, + frontendCommitUrl: instance.frontendCommitUrl, frontendVersion: instance.frontendVersion } }, computed: { frontendVersionLink () { - return pleromaFeCommitUrl + this.frontendVersion + return joinURL(this.frontendCommitUrl, this.frontendVersion) }, backendVersionLink () { - return pleromaBeCommitUrl + extractCommit(this.backendVersion) + return joinURL(this.backendCommitUrl, extractCommit(this.backendVersion)) } } } diff --git a/src/modules/instance.js b/src/modules/instance.js index 0c856352..c60e1918 100644 --- a/src/modules/instance.js +++ b/src/modules/instance.js @@ -73,6 +73,8 @@ const defaultState = { conversationOtherRepliesButton: 'below', conversationTreeFadeAncestors: false, maxDepthInThread: 6, + backendCommitUrl: 'https://akkoma.dev/AkkomaGang/akkoma/commit/', + frontendCommitUrl: 'https://akkoma.dev/AkkomaGang/pleroma-fe/commit/', // Nasty stuff customEmoji: [], -- 2.43.0