feat: edit shortcuts
This commit is contained in:
@@ -67,6 +67,14 @@ defaults:
|
||||
audience: 'urn:wiki.js'
|
||||
tokenExpiration: '30m'
|
||||
tokenRenewal: '14d'
|
||||
editShortcuts:
|
||||
editFab: true
|
||||
editMenuBar: false
|
||||
editMenuBtn: true
|
||||
editMenuExternalBtn: true
|
||||
editMenuExternalName: 'GitHub'
|
||||
editMenuExternalIcon: 'mdi-github'
|
||||
editMenuExternalUrl: 'https://github.com/org/repo/blob/main/{filename}'
|
||||
features:
|
||||
featurePageRatings: true
|
||||
featurePageComments: true
|
||||
|
@@ -542,13 +542,18 @@ router.get('/*', async (req, res, next) => {
|
||||
})
|
||||
}
|
||||
|
||||
// -> Page Filename (for edit on external repo button)
|
||||
let pageFilename = WIKI.config.lang.namespacing ? `${pageArgs.locale}/${page.path}` : page.path
|
||||
pageFilename += page.contentType === 'markdown' ? '.md' : '.html'
|
||||
|
||||
// -> Render view
|
||||
res.render('page', {
|
||||
page,
|
||||
sidebar,
|
||||
injectCode,
|
||||
comments: commentTmpl,
|
||||
effectivePermissions
|
||||
effectivePermissions,
|
||||
pageFilename
|
||||
})
|
||||
}
|
||||
} else if (pageArgs.path === 'home') {
|
||||
|
@@ -20,6 +20,7 @@ module.exports = {
|
||||
logoUrl: WIKI.config.logoUrl,
|
||||
pageExtensions: WIKI.config.pageExtensions.join(', '),
|
||||
...WIKI.config.seo,
|
||||
...WIKI.config.editShortcuts,
|
||||
...WIKI.config.features,
|
||||
...WIKI.config.security,
|
||||
authAutoLogin: WIKI.config.auth.autoLogin,
|
||||
@@ -84,6 +85,16 @@ module.exports = {
|
||||
tokenRenewal: _.get(args, 'authJwtRenewablePeriod', WIKI.config.auth.tokenRenewal)
|
||||
}
|
||||
|
||||
WIKI.config.editShortcuts = {
|
||||
editFab: _.get(args, 'editFab', WIKI.config.editShortcuts.editFab),
|
||||
editMenuBar: _.get(args, 'editMenuBar', WIKI.config.editShortcuts.editMenuBar),
|
||||
editMenuBtn: _.get(args, 'editMenuBtn', WIKI.config.editShortcuts.editMenuBtn),
|
||||
editMenuExternalBtn: _.get(args, 'editMenuExternalBtn', WIKI.config.editShortcuts.editMenuExternalBtn),
|
||||
editMenuExternalName: _.get(args, 'editMenuExternalName', WIKI.config.editShortcuts.editMenuExternalName),
|
||||
editMenuExternalIcon: _.get(args, 'editMenuExternalIcon', WIKI.config.editShortcuts.editMenuExternalIcon),
|
||||
editMenuExternalUrl: _.get(args, 'editMenuExternalUrl', WIKI.config.editShortcuts.editMenuExternalUrl)
|
||||
}
|
||||
|
||||
WIKI.config.features = {
|
||||
featurePageRatings: _.get(args, 'featurePageRatings', WIKI.config.features.featurePageRatings),
|
||||
featurePageComments: _.get(args, 'featurePageComments', WIKI.config.features.featurePageComments),
|
||||
@@ -109,7 +120,7 @@ module.exports = {
|
||||
forceDownload: _.get(args, 'uploadForceDownload', WIKI.config.uploads.forceDownload)
|
||||
}
|
||||
|
||||
await WIKI.configSvc.saveToDb(['host', 'title', 'company', 'contentLicense', 'seo', 'logoUrl', 'pageExtensions', 'auth', 'features', 'security', 'uploads'])
|
||||
await WIKI.configSvc.saveToDb(['host', 'title', 'company', 'contentLicense', 'seo', 'logoUrl', 'pageExtensions', 'auth', 'editShortcuts', 'features', 'security', 'uploads'])
|
||||
|
||||
if (WIKI.config.security.securityTrustProxy) {
|
||||
WIKI.app.enable('trust proxy')
|
||||
|
@@ -41,6 +41,13 @@ type SiteMutation {
|
||||
authJwtAudience: String
|
||||
authJwtExpiration: String
|
||||
authJwtRenewablePeriod: String
|
||||
editFab: Boolean
|
||||
editMenuBar: Boolean
|
||||
editMenuBtn: Boolean
|
||||
editMenuExternalBtn: Boolean
|
||||
editMenuExternalName: String
|
||||
editMenuExternalIcon: String
|
||||
editMenuExternalUrl: String
|
||||
featurePageRatings: Boolean
|
||||
featurePageComments: Boolean
|
||||
featurePersonalWikis: Boolean
|
||||
@@ -83,6 +90,13 @@ type SiteConfig {
|
||||
authJwtAudience: String
|
||||
authJwtExpiration: String
|
||||
authJwtRenewablePeriod: String
|
||||
editFab: Boolean
|
||||
editMenuBar: Boolean
|
||||
editMenuBtn: Boolean
|
||||
editMenuExternalBtn: Boolean
|
||||
editMenuExternalName: String
|
||||
editMenuExternalIcon: String
|
||||
editMenuExternalUrl: String
|
||||
featurePageRatings: Boolean
|
||||
featurePageComments: Boolean
|
||||
featurePersonalWikis: Boolean
|
||||
|
@@ -148,6 +148,7 @@ module.exports = class Page extends Model {
|
||||
isPublished: 'boolean',
|
||||
publishEndDate: 'string',
|
||||
publishStartDate: 'string',
|
||||
contentType: 'string',
|
||||
render: 'string',
|
||||
tags: [
|
||||
{
|
||||
@@ -787,7 +788,7 @@ module.exports = class Page extends Model {
|
||||
* @returns {Promise} Promise with no value
|
||||
*/
|
||||
static async deletePage(opts) {
|
||||
const page = await WIKI.models.pages.getPageFromDb(_.has(opts, 'id') ? opts.id : opts);
|
||||
const page = await WIKI.models.pages.getPageFromDb(_.has(opts, 'id') ? opts.id : opts)
|
||||
if (!page) {
|
||||
throw new WIKI.Error.PageNotFound()
|
||||
}
|
||||
@@ -1067,6 +1068,7 @@ module.exports = class Page extends Model {
|
||||
isPublished: page.isPublished === 1 || page.isPublished === true,
|
||||
publishEndDate: page.publishEndDate,
|
||||
publishStartDate: page.publishStartDate,
|
||||
contentType: page.contentType,
|
||||
render: page.render,
|
||||
tags: page.tags.map(t => _.pick(t, ['tag', 'title'])),
|
||||
title: page.title,
|
||||
|
@@ -29,6 +29,8 @@ block body
|
||||
comments-enabled=config.features.featurePageComments
|
||||
effective-permissions=Buffer.from(JSON.stringify(effectivePermissions)).toString('base64')
|
||||
comments-external=comments.codeTemplate
|
||||
edit-shortcuts=Buffer.from(JSON.stringify(config.editShortcuts)).toString('base64')
|
||||
filename=pageFilename
|
||||
)
|
||||
template(slot='contents')
|
||||
div!= page.render
|
||||
|
Reference in New Issue
Block a user