feat: theming resolvers + config fixes
This commit is contained in:
@@ -24,21 +24,21 @@ defaults:
|
||||
db: 0
|
||||
password: null
|
||||
# DB defaults
|
||||
auth:
|
||||
public: false
|
||||
strategies:
|
||||
local:
|
||||
isEnabled: true
|
||||
allowSelfRegister: false
|
||||
logging:
|
||||
telemetry: false
|
||||
loggers:
|
||||
console:
|
||||
enabled: true
|
||||
site:
|
||||
lang: en
|
||||
rtl: false
|
||||
title: Wiki.js
|
||||
defaultEditor: 'markdown'
|
||||
graphEndpoint: 'https://graph.requarks.io'
|
||||
lang:
|
||||
code: en
|
||||
autoUpdate: true
|
||||
namespaces: []
|
||||
namespacing: false
|
||||
public: false
|
||||
telemetry:
|
||||
clientId: ''
|
||||
isEnabled: false
|
||||
title: Wiki.js
|
||||
theming:
|
||||
theme: 'default'
|
||||
darkMode: false
|
||||
# System defaults
|
||||
setup: false
|
||||
cors:
|
||||
|
||||
@@ -41,10 +41,11 @@ module.exports = {
|
||||
|
||||
// Load enable strategies
|
||||
const enabledStrategies = await WIKI.db.authentication.getEnabledStrategies()
|
||||
console.info(enabledStrategies)
|
||||
for (let idx in enabledStrategies) {
|
||||
const stg = enabledStrategies[idx]
|
||||
const strategy = require(`../modules/authentication/${stg.key}`)
|
||||
stg.config.callbackURL = `${WIKI.config.site.host}/login/${stg.key}/callback`
|
||||
stg.config.callbackURL = `${WIKI.config.host}/login/${stg.key}/callback` // TODO: config.host
|
||||
strategy.init(passport, stg.config)
|
||||
|
||||
fs.readFile(path.join(WIKI.ROOTPATH, `assets/svg/auth-icon-${strategy.key}.svg`), 'utf8').then(iconData => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const _ = require('lodash')
|
||||
// const _ = require('lodash')
|
||||
const winston = require('winston')
|
||||
|
||||
/* global WIKI */
|
||||
@@ -16,11 +16,17 @@ module.exports = {
|
||||
)
|
||||
})
|
||||
|
||||
_.forOwn(_.omitBy(WIKI.config.logging.loggers, s => s.enabled === false), (loggerConfig, loggerKey) => {
|
||||
let loggerModule = require(`../modules/logging/${loggerKey}`)
|
||||
loggerModule.init(logger, loggerConfig)
|
||||
this.loggers[logger.key] = loggerModule
|
||||
})
|
||||
// Init Console (default)
|
||||
|
||||
let loggerConsoleModule = require(`../modules/logging/console`)
|
||||
loggerConsoleModule.init(logger)
|
||||
this.loggers['console'] = loggerConsoleModule
|
||||
|
||||
// _.forOwn(_.omitBy(WIKI.config.logging.loggers, s => s.enabled === false), (loggerConfig, loggerKey) => {
|
||||
// let loggerModule = require(`../modules/logging/${loggerKey}`)
|
||||
// loggerModule.init(logger, loggerConfig)
|
||||
// this.loggers[logger.key] = loggerModule
|
||||
// })
|
||||
|
||||
return logger
|
||||
}
|
||||
|
||||
42
server/graph/resolvers/theming.js
Normal file
42
server/graph/resolvers/theming.js
Normal file
@@ -0,0 +1,42 @@
|
||||
const graphHelper = require('../../helpers/graph')
|
||||
|
||||
/* global WIKI */
|
||||
|
||||
module.exports = {
|
||||
Query: {
|
||||
async theming() { return {} }
|
||||
},
|
||||
Mutation: {
|
||||
async theming() { return {} }
|
||||
},
|
||||
ThemingQuery: {
|
||||
async themes(obj, args, context, info) {
|
||||
return [{ // TODO
|
||||
key: 'default',
|
||||
title: 'Default',
|
||||
author: 'requarks.io'
|
||||
}]
|
||||
},
|
||||
async config(obj, args, context, info) {
|
||||
return {
|
||||
theme: WIKI.config.theming.theme,
|
||||
darkMode: WIKI.config.theming.darkMode
|
||||
}
|
||||
}
|
||||
},
|
||||
ThemingMutation: {
|
||||
async setConfig(obj, args, context, info) {
|
||||
try {
|
||||
WIKI.config.theming.theme = args.theme
|
||||
WIKI.config.theming.darkMode = args.darkMode
|
||||
await WIKI.configSvc.saveToDb(['theming'])
|
||||
|
||||
return {
|
||||
responseResult: graphHelper.generateSuccess('Theme config updated')
|
||||
}
|
||||
} catch (err) {
|
||||
return graphHelper.generateError(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
46
server/graph/schemas/theming.graphql
Normal file
46
server/graph/schemas/theming.graphql
Normal file
@@ -0,0 +1,46 @@
|
||||
# ===============================================
|
||||
# THEMES
|
||||
# ===============================================
|
||||
|
||||
extend type Query {
|
||||
theming: ThemingQuery
|
||||
}
|
||||
|
||||
extend type Mutation {
|
||||
theming: ThemingMutation
|
||||
}
|
||||
|
||||
# -----------------------------------------------
|
||||
# QUERIES
|
||||
# -----------------------------------------------
|
||||
|
||||
type ThemingQuery {
|
||||
themes: [ThemingTheme]
|
||||
config: ThemingConfig
|
||||
}
|
||||
|
||||
# -----------------------------------------------
|
||||
# MUTATIONS
|
||||
# -----------------------------------------------
|
||||
|
||||
type ThemingMutation {
|
||||
setConfig(
|
||||
theme: String!
|
||||
darkMode: Boolean!
|
||||
): DefaultResponse
|
||||
}
|
||||
|
||||
# -----------------------------------------------
|
||||
# TYPES
|
||||
# -----------------------------------------------
|
||||
|
||||
type ThemingConfig {
|
||||
theme: String
|
||||
darkMode: Boolean
|
||||
}
|
||||
|
||||
type ThemingTheme {
|
||||
key: String
|
||||
title: String
|
||||
author: String
|
||||
}
|
||||
@@ -111,7 +111,7 @@ module.exports = async () => {
|
||||
app.locals.basedir = WIKI.ROOTPATH
|
||||
app.locals._ = require('lodash')
|
||||
app.locals.moment = require('moment')
|
||||
app.locals.moment.locale(WIKI.config.site.lang)
|
||||
app.locals.moment.locale(WIKI.config.lang.code)
|
||||
app.locals.config = WIKI.config
|
||||
|
||||
// ----------------------------------------
|
||||
|
||||
@@ -284,6 +284,8 @@ module.exports = () => {
|
||||
_.set(WIKI.config, 'sessionSecret', (await crypto.randomBytesAsync(32)).toString('hex'))
|
||||
_.set(WIKI.config, 'telemetry.isEnabled', req.body.telemetry === 'true')
|
||||
_.set(WIKI.config, 'telemetry.clientId', WIKI.telemetry.cid)
|
||||
_.set(WIKI.config, 'theming.theme', 'default')
|
||||
_.set(WIKI.config, 'theming.darkMode', false)
|
||||
_.set(WIKI.config, 'title', req.body.title)
|
||||
|
||||
// Save config to DB
|
||||
@@ -295,6 +297,7 @@ module.exports = () => {
|
||||
'public',
|
||||
'sessionSecret',
|
||||
'telemetry',
|
||||
'theming',
|
||||
'title'
|
||||
])
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ html
|
||||
meta(name='theme-color', content='#333333')
|
||||
meta(name='msapplication-TileColor', content='#333333')
|
||||
meta(name='msapplication-TileImage', content='/favicons/ms-icon-144x144.png')
|
||||
title= config.site.title
|
||||
title= config.title
|
||||
|
||||
//- Favicon
|
||||
each favsize in [57, 60, 72, 76, 114, 120, 144, 152, 180]
|
||||
@@ -19,7 +19,7 @@ html
|
||||
|
||||
//- Site Lang
|
||||
script.
|
||||
var siteConfig = !{JSON.stringify(config.site)}
|
||||
var siteConfig = !{JSON.stringify({ title: config.title, theme: config.theming.theme, darkMode: config.theming.darkMode, lang: config.lang.code })}
|
||||
|
||||
//- CSS
|
||||
link(type='text/css', rel='stylesheet', href='https://fonts.googleapis.com/icon?family=Roboto:400,500,700|Source+Code+Pro:400,700|Material+Icons')
|
||||
|
||||
Reference in New Issue
Block a user