diff --git a/.gitignore b/.gitignore index cade9e07..41183d2b 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ npm-debug.log* # Generated assets /assets +/assets-legacy server/views/master.pug server/views/legacy/master.pug server/views/setup.pug diff --git a/client/components/not-found.vue b/client/components/not-found.vue index 5a23892a..4ddf4f1f 100644 --- a/client/components/not-found.vue +++ b/client/components/not-found.vue @@ -2,7 +2,7 @@ v-app .notfound .notfound-content - img.animated.fadeIn(src='/_assets/svg/icon-delete-file.svg', alt='Not Found') + img.animated.fadeIn(src='/_assets-legacy/svg/icon-delete-file.svg', alt='Not Found') .headline {{$t('notfound.title')}} .subheading.mt-3 {{$t('notfound.subtitle')}} v-btn.mt-5(color='red lighten-4', href='/', large, outlined) diff --git a/client/components/unauthorized.vue b/client/components/unauthorized.vue index 59026d80..aa372c83 100644 --- a/client/components/unauthorized.vue +++ b/client/components/unauthorized.vue @@ -2,7 +2,7 @@ v-app .unauthorized .unauthorized-content - img.animated.fadeIn(src='/_assets/svg/icon-delete-shield.svg', alt='Unauthorized') + img.animated.fadeIn(src='/_assets-legacy/svg/icon-delete-shield.svg', alt='Unauthorized') .headline {{$t('unauthorized.title')}} .subtitle-1.mt-3 {{$t('unauthorized.action.' + action)}} v-btn.mt-5(href='/login', x-large) diff --git a/client/components/welcome.vue b/client/components/welcome.vue index 3e4f4af3..c182efdd 100644 --- a/client/components/welcome.vue +++ b/client/components/welcome.vue @@ -2,7 +2,7 @@ v-app .onboarding .onboarding-content - img.animated.fadeIn(src='/_assets/svg/logo-wikijs.svg', alt='Wiki.js') + img.animated.fadeIn(src='/_assets-legacy/svg/logo-wikijs.svg', alt='Wiki.js') .headline.animated.fadeInUp {{ $t('welcome.title') }} .subtitle-1.mt-3.animated.fadeInUp.wait-p1s {{ $t('welcome.subtitle') }} div diff --git a/dev/webpack/webpack.dev.js b/dev/webpack/webpack.dev.js index e769e052..ed570944 100644 --- a/dev/webpack/webpack.dev.js +++ b/dev/webpack/webpack.dev.js @@ -19,7 +19,7 @@ const babelDir = path.join(process.cwd(), '.webpack-cache/babel') process.noDeprecation = true -fs.emptyDirSync(path.join(process.cwd(), 'assets')) +fs.emptyDirSync(path.join(process.cwd(), 'assets-legacy')) module.exports = { mode: 'development', @@ -29,8 +29,8 @@ module.exports = { setup: ['./client/index-setup.js', 'webpack-hot-middleware/client'] }, output: { - path: path.join(process.cwd(), 'assets'), - publicPath: '/_assets/', + path: path.join(process.cwd(), 'assets-legacy'), + publicPath: '/_assets-legacy/', filename: 'js/[name].js', chunkFilename: 'js/[name].js', globalObject: 'this', diff --git a/dev/webpack/webpack.prod.js b/dev/webpack/webpack.prod.js index 0b170d7b..f7bc315b 100644 --- a/dev/webpack/webpack.prod.js +++ b/dev/webpack/webpack.prod.js @@ -24,7 +24,7 @@ const babelDir = path.join(process.cwd(), '.webpack-cache/babel') process.noDeprecation = true -fs.emptyDirSync(path.join(process.cwd(), 'assets')) +fs.emptyDirSync(path.join(process.cwd(), 'assets-legacy')) module.exports = { mode: 'production', @@ -34,8 +34,8 @@ module.exports = { setup: './client/index-setup.js' }, output: { - path: path.join(process.cwd(), 'assets'), - publicPath: '/_assets/', + path: path.join(process.cwd(), 'assets-legacy'), + publicPath: '/_assets-legacy/', filename: `js/[name].js?${now}`, chunkFilename: `js/[name].js?${now}`, globalObject: 'this', diff --git a/package.json b/package.json index 66b45616..9bb75bfb 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "start": "node server", "dev": "nodemon server", "legacy:dev": "node dev", - "legacy:build": "webpack --profile --config dev/webpack/webpack.prod.js", + "legacy:build": "NODE_OPTIONS=--openssl-legacy-provider webpack --profile --config dev/webpack/webpack.prod.js", "test": "eslint --format codeframe --ext .js,.vue . && pug-lint server/views && jest", "cypress:open": "cypress open" }, diff --git a/server/controllers/common.js b/server/controllers/common.js index 052c3757..709103ac 100644 --- a/server/controllers/common.js +++ b/server/controllers/common.js @@ -4,6 +4,7 @@ const pageHelper = require('../helpers/page') const _ = require('lodash') const CleanCSS = require('clean-css') const moment = require('moment') +const path = require('path') /* global WIKI */ @@ -35,24 +36,28 @@ router.get('/healthz', (req, res, next) => { /** * Administration */ -router.get(['/a', '/a/*'], (req, res, next) => { - if (!WIKI.auth.checkAccess(req.user, [ - 'manage:system', - 'write:users', - 'manage:users', - 'write:groups', - 'manage:groups', - 'manage:navigation', - 'manage:theme', - 'manage:api' - ])) { - _.set(res.locals, 'pageMeta.title', 'Unauthorized') - return res.status(403).render('unauthorized', { action: 'view' }) - } - - _.set(res.locals, 'pageMeta.title', 'Admin') - res.render('admin') +router.get(['/_admin', '/_admin/*'], (req, res, next) => { + res.sendFile(path.join(WIKI.ROOTPATH, 'assets/index.html')) }) +// router.get(['/_admin', '/_admin/*'], (req, res, next) => { +// if (!WIKI.auth.checkAccess(req.user, [ +// 'manage:system', +// 'write:users', +// 'manage:users', +// 'write:groups', +// 'manage:groups', +// 'manage:navigation', +// 'manage:theme', +// 'manage:api' +// ])) { +// _.set(res.locals, 'pageMeta.title', 'Unauthorized') +// return res.status(403).render('unauthorized', { action: 'view' }) +// } + +// _.set(res.locals, 'pageMeta.title', 'Admin') +// res.render('admin') + +// }) /** * Download Page / Version diff --git a/server/core/servers.js b/server/core/servers.js index 782a386b..2bc30ffa 100644 --- a/server/core/servers.js +++ b/server/core/servers.js @@ -134,7 +134,7 @@ module.exports = { ] }) await this.servers.graph.start() - this.servers.graph.applyMiddleware({ app: WIKI.app, cors: false }) + this.servers.graph.applyMiddleware({ app: WIKI.app, cors: false, path: '/_graphql' }) }, /** * Close all active connections diff --git a/server/master.js b/server/master.js index 6ea6778f..7c6fd342 100644 --- a/server/master.js +++ b/server/master.js @@ -53,14 +53,18 @@ module.exports = async () => { // ---------------------------------------- app.use(favicon(path.join(WIKI.ROOTPATH, 'assets', 'favicon.ico'))) - app.use('/_assets/svg/twemoji', async (req, res, next) => { + app.use('/_assets', express.static(path.join(WIKI.ROOTPATH, 'assets/_assets'), { + index: false, + maxAge: '7d' + })) + app.use('/_assets-legacy/svg/twemoji', async (req, res, next) => { try { WIKI.asar.serve('twemoji', req, res, next) } catch (err) { res.sendStatus(404) } }) - app.use('/_assets', express.static(path.join(WIKI.ROOTPATH, 'assets'), { + app.use('/_assets-legacy', express.static(path.join(WIKI.ROOTPATH, 'assets-legacy'), { index: false, maxAge: '7d' })) @@ -175,7 +179,7 @@ module.exports = async () => { }) app.use((err, req, res, next) => { - if (req.path === '/graphql') { + if (req.path === '/_graphql') { res.status(err.status || 500).json({ data: {}, errors: [{ diff --git a/ux/index.html b/ux/index.html index c03cd480..ac7a142b 100644 --- a/ux/index.html +++ b/ux/index.html @@ -69,6 +69,5 @@
-