Allow using custom source URLs #421

Open
Oneric wants to merge 1 commit from Oneric/akkoma-fe:custom-source into develop
3 changed files with 15 additions and 4 deletions

View file

@ -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'])
}

View file

@ -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
Review

done with URL.parse() which won't throw exceptions itself, and since i wasn’t sure if a null might lead to exceptions later it gets stubbed out for an invalid config

done with `URL.parse()` which won't throw exceptions itself, and since i wasn’t sure if a `null` might lead to exceptions later it gets stubbed out for an invalid config
return joinURL(this.frontendCommitUrl, this.frontendVersion)
},
backendVersionLink () {
return pleromaBeCommitUrl + extractCommit(this.backendVersion)
return joinURL(this.backendCommitUrl, extractCommit(this.backendVersion))
}
}
}

View file

@ -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: [],