instance identity config definitions
This commit is contained in:
parent
0e2a94bf34
commit
f57c24cf6d
3 changed files with 115 additions and 34 deletions
|
|
@ -40,7 +40,7 @@ import { useUserHighlightStore } from 'src/stores/user_highlight.js'
|
||||||
import VBodyScrollLock from 'src/directives/body_scroll_lock'
|
import VBodyScrollLock from 'src/directives/body_scroll_lock'
|
||||||
import {
|
import {
|
||||||
instanceDefaultConfig,
|
instanceDefaultConfig,
|
||||||
instanceIdentityDefault,
|
instanceIdentityDefaultDefinition,
|
||||||
} from 'src/modules/default_config_state.js'
|
} from 'src/modules/default_config_state.js'
|
||||||
|
|
||||||
let staticInitialResults = null
|
let staticInitialResults = null
|
||||||
|
|
@ -169,17 +169,20 @@ const setSettings = async ({ apiConfig, staticConfig, store }) => {
|
||||||
config = Object.assign({}, staticConfig, apiConfig)
|
config = Object.assign({}, staticConfig, apiConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
const copyInstanceOption = ({ source, destination }) => {
|
const copyInstanceOption = ({ source, definition = { required: true }, destination }) => {
|
||||||
if (typeof config[source] !== 'undefined') {
|
const value = config[source]
|
||||||
useInstanceStore().set({ path: destination, value: config[source] })
|
const { required, type } = definition
|
||||||
}
|
if (required && value == null) return
|
||||||
|
if (type != null && typeof value !== type) return
|
||||||
|
|
||||||
|
useInstanceStore().set({ path: destination, value })
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.keys(instanceIdentityDefault)
|
Object.entries(instanceIdentityDefaultDefinition)
|
||||||
.map((k) => ({ source: k, destination: `instanceIdentity.${k}` }))
|
.map(([source, definition]) => ({ source, definition, destination: `instanceIdentity.${source}` }))
|
||||||
.forEach(copyInstanceOption)
|
.forEach(copyInstanceOption)
|
||||||
Object.keys(instanceDefaultConfig)
|
Object.keys(instanceDefaultConfig)
|
||||||
.map((k) => ({ source: k, destination: `prefsStorage.${k}` }))
|
.map((source) => ({ source, destination: `prefsStorage.${source}` }))
|
||||||
.forEach(copyInstanceOption)
|
.forEach(copyInstanceOption)
|
||||||
|
|
||||||
useAuthFlowStore().setInitialStrategy(config.loginMethod)
|
useAuthFlowStore().setInitialStrategy(config.loginMethod)
|
||||||
|
|
|
||||||
|
|
@ -3,30 +3,112 @@ const browserLocale = (navigator.language || 'en').split('-')[0]
|
||||||
/// Instance config entries provided by static config or pleroma api
|
/// Instance config entries provided by static config or pleroma api
|
||||||
/// Put settings here only if it does not make sense for a normal user
|
/// Put settings here only if it does not make sense for a normal user
|
||||||
/// to override it.
|
/// to override it.
|
||||||
export const instanceIdentityDefault = {
|
export const instanceIdentityDefaultDefinition = {
|
||||||
theme: null,
|
style: {
|
||||||
palette: null,
|
description: 'Instance default style name',
|
||||||
style: null,
|
type: 'string',
|
||||||
themeChecksum: undefined,
|
required: false,
|
||||||
defaultAvatar: '/images/avi.png',
|
},
|
||||||
defaultBanner: '/images/banner.png',
|
palette: {
|
||||||
background: '/static/aurora_borealis.jpg',
|
description: 'Instance default palette name',
|
||||||
embeddedToS: true,
|
type: 'string',
|
||||||
logo: '/static/logo.svg',
|
required: false,
|
||||||
logoMargin: '.2em',
|
},
|
||||||
logoMask: true,
|
theme: {
|
||||||
logoLeft: false,
|
description: 'Instance default theme name',
|
||||||
redirectRootLogin: '/main/friends',
|
type: 'string',
|
||||||
redirectRootNoLogin: '/main/all',
|
required: false,
|
||||||
hideSitename: false,
|
},
|
||||||
nsfwCensorImage: null,
|
defaultAvatar: {
|
||||||
showFeaturesPanel: true,
|
description: "Default avatar image to use when user doesn't have one set",
|
||||||
showInstanceSpecificPanel: false,
|
type: 'string',
|
||||||
|
default: '/images/avi.png',
|
||||||
|
},
|
||||||
|
defaultBanner: {
|
||||||
|
description: "Default banner image to use when user doesn't have one set",
|
||||||
|
type: 'string',
|
||||||
|
default: '/images/banner.png',
|
||||||
|
},
|
||||||
|
background: {
|
||||||
|
description: 'Instance background/wallpaper',
|
||||||
|
type: 'string',
|
||||||
|
default: '/static/aurora_borealis.jpg',
|
||||||
|
},
|
||||||
|
embeddedToS: {
|
||||||
|
description: 'Whether to show Terms of Service title bar',
|
||||||
|
type: 'boolean',
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
logo: {
|
||||||
|
description: 'Instance logo',
|
||||||
|
type: 'string',
|
||||||
|
default: '/static/logo.svg',
|
||||||
|
},
|
||||||
|
logoMargin: {
|
||||||
|
description: 'Margin for logo (spacing above/below)',
|
||||||
|
type: 'string',
|
||||||
|
default: '.2em',
|
||||||
|
},
|
||||||
|
logoMask: {
|
||||||
|
description:
|
||||||
|
'Use logo as a mask (works well for monochrome/transparent logos)',
|
||||||
|
type: 'boolean',
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
logoLeft: {
|
||||||
|
description: 'Show logo on the left side of navbar',
|
||||||
|
type: 'boolean',
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
redirectRootLogin: {
|
||||||
|
description: 'Where to redirect user after login',
|
||||||
|
type: 'string',
|
||||||
|
default: '/main/friends',
|
||||||
|
},
|
||||||
|
redirectRootNoLogin: {
|
||||||
|
description: 'Where to redirect anonymous visitors',
|
||||||
|
type: 'string',
|
||||||
|
default: '/main/all',
|
||||||
|
},
|
||||||
|
hideSitename: {
|
||||||
|
description: 'Hide the instance name in navbar',
|
||||||
|
type: 'boolean',
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
nsfwCensorImage: {
|
||||||
|
description: 'Default NSFW censor image',
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
|
showFeaturesPanel: {
|
||||||
|
description: 'Show features panel to anonymous visitors',
|
||||||
|
type: 'boolean',
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
showInstanceSpecificPanel: {
|
||||||
|
description: 'Show instance-specific panel',
|
||||||
|
type: 'boolean',
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
|
||||||
// Html stuff
|
// Html stuff
|
||||||
instanceSpecificPanelContent: '',
|
instanceSpecificPanelContent: {
|
||||||
tos: '',
|
description: 'HTML of Instance-specific panel',
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
|
tos: {
|
||||||
|
description: 'HTML of Terms of Service panel',
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
export const instanceIdentityDefault = Object.fromEntries(
|
||||||
|
Object.entries(instanceIdentityDefaultDefinition).map(([k, v]) => [
|
||||||
|
k,
|
||||||
|
v.default == null ? null : v.default,
|
||||||
|
]),
|
||||||
|
)
|
||||||
|
|
||||||
/// This object contains setting entries that makes sense
|
/// This object contains setting entries that makes sense
|
||||||
/// at the user level. The defaults can also be overriden by
|
/// at the user level. The defaults can also be overriden by
|
||||||
|
|
|
||||||
|
|
@ -418,11 +418,7 @@ export const useInterfaceStore = defineStore('interface', {
|
||||||
palette: instancePaletteName,
|
palette: instancePaletteName,
|
||||||
} = useInstanceStore().instanceIdentity
|
} = useInstanceStore().instanceIdentity
|
||||||
|
|
||||||
let {
|
let { themesIndex, stylesIndex, palettesIndex } = useInstanceStore()
|
||||||
themesIndex,
|
|
||||||
stylesIndex,
|
|
||||||
palettesIndex,
|
|
||||||
} = useInstanceStore()
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
style: userStyleName,
|
style: userStyleName,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue