mirror of
https://github.com/requarks/wiki.git
synced 2026-08-26 13:17:10 -05:00
feat: page duplicate + code styling fixes
This commit is contained in:
@@ -12,7 +12,7 @@ export default {
|
||||
fdCache: {},
|
||||
async serve (pkgName, req, res, next) {
|
||||
const packages = {
|
||||
'twemoji': path.join(WIKI.ROOTPATH, `assets/svg/twemoji.asar`)
|
||||
twemoji: path.join(WIKI.ROOTPATH, 'assets/svg/twemoji.asar')
|
||||
}
|
||||
const file = this.readFilesystemSync(packages[pkgName])
|
||||
const { filesystem, fd } = file
|
||||
@@ -74,7 +74,7 @@ export default {
|
||||
filesystem.headerSize = header.headerSize
|
||||
this.fdCache[archive] = {
|
||||
fd,
|
||||
filesystem: filesystem
|
||||
filesystem
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+21
-18
@@ -31,13 +31,15 @@ export default {
|
||||
|
||||
// Fetch DB Config
|
||||
|
||||
this.config = (!isEmpty(process.env.DATABASE_URL)) ? process.env.DATABASE_URL : {
|
||||
host: WIKI.config.db.host.toString(),
|
||||
user: WIKI.config.db.user.toString(),
|
||||
password: WIKI.config.db.pass.toString(),
|
||||
database: WIKI.config.db.db.toString(),
|
||||
port: WIKI.config.db.port
|
||||
}
|
||||
this.config = (!isEmpty(process.env.DATABASE_URL))
|
||||
? process.env.DATABASE_URL
|
||||
: {
|
||||
host: WIKI.config.db.host.toString(),
|
||||
user: WIKI.config.db.user.toString(),
|
||||
password: WIKI.config.db.pass.toString(),
|
||||
database: WIKI.config.db.db.toString(),
|
||||
port: WIKI.config.db.port
|
||||
}
|
||||
|
||||
// Handle SSL Options
|
||||
|
||||
@@ -88,16 +90,17 @@ export default {
|
||||
connection: this.config,
|
||||
searchPath: [WIKI.config.db.schema],
|
||||
pool: {
|
||||
...workerMode ? { min: 0, max: 1 } : WIKI.config.pool,
|
||||
async afterCreate(conn, done) {
|
||||
// -> Set Connection App Name
|
||||
if (workerMode) {
|
||||
await conn.query(`set application_name = 'Wiki.js - ${WIKI.INSTANCE_ID}'`)
|
||||
} else {
|
||||
await conn.query(`set application_name = 'Wiki.js - ${WIKI.INSTANCE_ID}:MAIN'`)
|
||||
}
|
||||
done()
|
||||
}
|
||||
...workerMode ? { min: 0, max: 1 } : WIKI.config.pool
|
||||
// FIXME: Throws DeprecatingWarning because Knex encapsulates this into a promisify...
|
||||
// async afterCreate (conn, done) {
|
||||
// // -> Set Connection App Name
|
||||
// if (workerMode) {
|
||||
// await conn.query(`set application_name = 'Wiki.js - ${WIKI.INSTANCE_ID}'`)
|
||||
// } else {
|
||||
// await conn.query(`set application_name = 'Wiki.js - ${WIKI.INSTANCE_ID}:MAIN'`)
|
||||
// }
|
||||
// done()
|
||||
// }
|
||||
},
|
||||
debug: WIKI.IS_DEBUG
|
||||
})
|
||||
@@ -170,7 +173,7 @@ export default {
|
||||
WIKI.configSvc.subscribeToEvents()
|
||||
WIKI.db.pages.subscribeToEvents()
|
||||
|
||||
WIKI.logger.info(`PG PubSub Listener initialized successfully: [ OK ]`)
|
||||
WIKI.logger.info('PG PubSub Listener initialized successfully: [ OK ]')
|
||||
},
|
||||
/**
|
||||
* Unsubscribe from database LISTEN / NOTIFY
|
||||
|
||||
@@ -106,9 +106,9 @@ export default {
|
||||
throw new Error('ERR_FORBIDDEN')
|
||||
}
|
||||
|
||||
const results = args.states?.length > 0 ?
|
||||
await WIKI.db.knex('jobHistory').whereIn('state', args.states.map(s => s.toLowerCase())).orderBy('startedAt', 'desc') :
|
||||
await WIKI.db.knex('jobHistory').orderBy('startedAt', 'desc')
|
||||
const results = args.states?.length > 0
|
||||
? await WIKI.db.knex('jobHistory').whereIn('state', args.states.map(s => s.toLowerCase())).orderBy('startedAt', 'desc')
|
||||
: await WIKI.db.knex('jobHistory').orderBy('startedAt', 'desc')
|
||||
return results.map(r => ({
|
||||
...r,
|
||||
state: r.state.toUpperCase()
|
||||
|
||||
+9
-3
@@ -1,5 +1,5 @@
|
||||
// ===========================================
|
||||
// Wiki.js | Server
|
||||
// Wiki.js Server
|
||||
// Licensed under AGPLv3
|
||||
// ===========================================
|
||||
|
||||
@@ -14,8 +14,8 @@ import logger from './core/logger.mjs'
|
||||
|
||||
const nanoid = customAlphabet('1234567890abcdef', 10)
|
||||
|
||||
if (!semver.satisfies(process.version, '>=18')) {
|
||||
console.error('ERROR: Node.js 18.x or later required!')
|
||||
if (!semver.satisfies(process.version, '>=20')) {
|
||||
console.error('ERROR: Node.js 20.x or later required!')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
@@ -41,6 +41,12 @@ const WIKI = {
|
||||
}
|
||||
global.WIKI = WIKI
|
||||
|
||||
if (WIKI.IS_DEBUG) {
|
||||
process.on('warning', (warning) => {
|
||||
console.log(warning.stack)
|
||||
})
|
||||
}
|
||||
|
||||
await WIKI.configSvc.init()
|
||||
|
||||
// ----------------------------------------
|
||||
|
||||
+20
-20
@@ -36,8 +36,8 @@
|
||||
"node": ">=18.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@apollo/server": "4.11.0",
|
||||
"@azure/storage-blob": "12.25.0",
|
||||
"@apollo/server": "4.11.2",
|
||||
"@azure/storage-blob": "12.26.0",
|
||||
"@exlinc/keycloak-passport": "1.0.2",
|
||||
"@graphql-tools/schema": "10.0.7",
|
||||
"@graphql-tools/utils": "10.5.5",
|
||||
@@ -51,7 +51,7 @@
|
||||
"@vue-email/compiler": "0.8.14",
|
||||
"acme": "3.0.3",
|
||||
"akismet-api": "6.0.0",
|
||||
"aws-sdk": "2.1691.0",
|
||||
"aws-sdk": "2.1692.0",
|
||||
"bcryptjs": "2.4.3",
|
||||
"chalk": "5.3.0",
|
||||
"cheerio": "1.0.0",
|
||||
@@ -59,7 +59,7 @@
|
||||
"chromium-pickle-js": "0.2.0",
|
||||
"clean-css": "5.3.3",
|
||||
"command-exists": "1.2.9",
|
||||
"compression": "1.7.4",
|
||||
"compression": "1.7.5",
|
||||
"connect-session-knex": "5.0.0",
|
||||
"cookie-parser": "1.4.7",
|
||||
"cors": "2.8.5",
|
||||
@@ -69,11 +69,11 @@
|
||||
"dependency-graph": "1.0.0",
|
||||
"diff": "7.0.0",
|
||||
"diff2html": "3.4.48",
|
||||
"dompurify": "3.1.7",
|
||||
"dompurify": "3.2.2",
|
||||
"dotize": "0.3.0",
|
||||
"emoji-regex": "10.4.0",
|
||||
"eventemitter2": "6.4.9",
|
||||
"express": "4.21.1",
|
||||
"express": "4.21.2",
|
||||
"express-brute": "1.0.1",
|
||||
"express-session": "1.18.1",
|
||||
"file-type": "19.6.0",
|
||||
@@ -82,7 +82,7 @@
|
||||
"getos": "3.2.1",
|
||||
"graphql": "16.9.0",
|
||||
"graphql-list-fields": "2.0.4",
|
||||
"graphql-rate-limit-directive": "2.0.5",
|
||||
"graphql-rate-limit-directive": "2.0.6",
|
||||
"graphql-tools": "9.0.2",
|
||||
"graphql-upload": "17.0.0",
|
||||
"gray-matter": "4.0.3",
|
||||
@@ -102,7 +102,7 @@
|
||||
"luxon": "3.5.0",
|
||||
"markdown-it": "14.1.0",
|
||||
"markdown-it-abbr": "2.0.0",
|
||||
"markdown-it-attrs": "4.2.0",
|
||||
"markdown-it-attrs": "4.3.0",
|
||||
"markdown-it-decorate": "1.2.2",
|
||||
"markdown-it-emoji": "3.0.0",
|
||||
"markdown-it-expand-tabs": "1.0.13",
|
||||
@@ -118,10 +118,10 @@
|
||||
"mime-types": "2.1.35",
|
||||
"ms": "2.1.3",
|
||||
"multer": "1.4.5-lts.1",
|
||||
"nanoid": "5.0.7",
|
||||
"nanoid": "5.0.9",
|
||||
"node-2fa": "2.0.3",
|
||||
"node-cache": "5.1.2",
|
||||
"nodemailer": "6.9.15",
|
||||
"nodemailer": "6.9.16",
|
||||
"objection": "3.1.5",
|
||||
"octokit": "4.0.2",
|
||||
"passport": "0.7.0",
|
||||
@@ -144,15 +144,15 @@
|
||||
"passport-slack-oauth2": "1.2.0",
|
||||
"passport-twitch-strategy": "2.2.0",
|
||||
"pem-jwk": "2.0.0",
|
||||
"pg": "8.13.0",
|
||||
"pg": "8.13.1",
|
||||
"pg-hstore": "2.3.4",
|
||||
"pg-pubsub": "0.8.1",
|
||||
"pg-query-stream": "4.7.0",
|
||||
"pg-query-stream": "4.7.1",
|
||||
"pg-tsquery": "8.4.2",
|
||||
"poolifier": "4.3.0",
|
||||
"poolifier": "4.4.5",
|
||||
"prom-client": "15.1.3",
|
||||
"punycode": "2.3.1",
|
||||
"puppeteer-core": "23.6.0",
|
||||
"puppeteer-core": "23.10.1",
|
||||
"qr-image": "3.2.0",
|
||||
"remove-markdown": "0.5.5",
|
||||
"safe-regex": "2.1.1",
|
||||
@@ -162,25 +162,25 @@
|
||||
"serve-favicon": "2.5.0",
|
||||
"sharp": "0.33.5",
|
||||
"simple-git": "3.27.0",
|
||||
"socket.io": "4.8.0",
|
||||
"socket.io": "4.8.1",
|
||||
"striptags": "3.2.0",
|
||||
"tar-fs": "3.0.6",
|
||||
"turndown": "7.2.0",
|
||||
"twemoji": "14.0.2",
|
||||
"ufo": "1.5.4",
|
||||
"uslug": "1.0.4",
|
||||
"uuid": "10.0.0",
|
||||
"uuid": "11.0.3",
|
||||
"validate.js": "0.13.1",
|
||||
"vue": "3.5.12",
|
||||
"vue": "3.5.13",
|
||||
"xss": "1.0.15",
|
||||
"yargs": "17.7.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "9.13.0",
|
||||
"eslint": "9.16.0",
|
||||
"eslint-plugin-import": "2.31.0",
|
||||
"eslint-plugin-node": "11.1.0",
|
||||
"eslint-plugin-promise": "7.1.0",
|
||||
"neostandard": "0.11.6",
|
||||
"eslint-plugin-promise": "7.2.1",
|
||||
"neostandard": "0.11.9",
|
||||
"nodemon": "3.1.7"
|
||||
},
|
||||
"overrides": {
|
||||
|
||||
Generated
+901
-592
File diff suppressed because it is too large
Load Diff
@@ -229,8 +229,8 @@ function duplicatePage () {
|
||||
itemTitle: pageStore.title,
|
||||
itemFileName: pageStore.path
|
||||
}
|
||||
}).onOk(() => {
|
||||
// TODO: change route to new location
|
||||
}).onOk((newPageOpts) => {
|
||||
pageStore.pageDuplicate({ sourecePageId: pageStore.id, path: newPageOpts.path, title: newPageOpts.title })
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -380,6 +380,48 @@ export const usePageStore = defineStore('page', {
|
||||
mode: 'edit'
|
||||
})
|
||||
},
|
||||
/**
|
||||
* PAGE - DUPLICATE
|
||||
*/
|
||||
async pageDuplicate ({ sourecePageId, title, path }) {
|
||||
try {
|
||||
const resp = await APOLLO_CLIENT.query({
|
||||
query: gql`
|
||||
query loadPageSource (
|
||||
$id: UUID!
|
||||
) {
|
||||
pageById(
|
||||
id: $id
|
||||
) {
|
||||
id
|
||||
content
|
||||
contentType
|
||||
description
|
||||
editor
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
id: sourecePageId ?? pageStore.id
|
||||
},
|
||||
fetchPolicy: 'network-only'
|
||||
})
|
||||
const pageData = cloneDeep(resp?.data?.pageById ?? {})
|
||||
if (!pageData?.id) {
|
||||
throw new Error('ERR_PAGE_NOT_FOUND')
|
||||
}
|
||||
this.pageCreate({
|
||||
editor: pageData.editor,
|
||||
title,
|
||||
path,
|
||||
content: pageData.content,
|
||||
description: pageData.description
|
||||
})
|
||||
} catch (err) {
|
||||
console.warn(err)
|
||||
throw err
|
||||
}
|
||||
},
|
||||
/**
|
||||
* PAGE - EDIT
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user