fix: Switch converted to Object Literal (#940)
* updating a switch into object literal and fixed a couple linter errors * added a comment about weird formatting * style: use lodash get * fix: pass eslint + puglint + jest
This commit is contained in:
committed by
Nicolas Giard
parent
2142b5f674
commit
0f9ddf1e5d
@@ -42,7 +42,8 @@
|
|||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
value: {
|
value: {
|
||||||
type: Object
|
type: Object,
|
||||||
|
default: () => ({})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
|||||||
@@ -186,7 +186,6 @@
|
|||||||
v-subheader.pl-0 Regular Expressions
|
v-subheader.pl-0 Regular Expressions
|
||||||
span Expressions that are deemed unsafe or could result in exponential time processing will be rejected upon saving.
|
span Expressions that are deemed unsafe or could result in exponential time processing will be rejected upon saving.
|
||||||
|
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -196,7 +195,8 @@ import nanoid from 'nanoid/non-secure/generate'
|
|||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
value: {
|
value: {
|
||||||
type: Object
|
type: Object,
|
||||||
|
default: () => ({})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
|||||||
@@ -57,7 +57,8 @@ import unassignUserMutation from 'gql/admin/groups/groups-mutation-unassign.gql'
|
|||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
value: {
|
value: {
|
||||||
type: Object
|
type: Object,
|
||||||
|
default: () => ({})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
import 'grapesjs/dist/css/grapes.min.css'
|
import 'grapesjs/dist/css/grapes.min.css'
|
||||||
import grapesjs from 'grapesjs'
|
import grapesjs from 'grapesjs'
|
||||||
|
|
||||||
let editor
|
let editor // eslint-disable-line no-unused-vars
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mounted() {
|
mounted() {
|
||||||
@@ -31,7 +31,7 @@ export default {
|
|||||||
}, {
|
}, {
|
||||||
id: 'text',
|
id: 'text',
|
||||||
label: 'Text',
|
label: 'Text',
|
||||||
content: '<div data-gjs-type="text">Insert your text here</div>',
|
content: '<div data-gjs-type="text">Insert your text here</div>'
|
||||||
}, {
|
}, {
|
||||||
id: 'image',
|
id: 'image',
|
||||||
label: 'Image',
|
label: 'Image',
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export default {
|
|||||||
],
|
],
|
||||||
backendOptions: [
|
backendOptions: [
|
||||||
{
|
{
|
||||||
expirationTime: 1000*60*60*24 // 24h
|
expirationTime: 1000 * 60 * 60 * 24 // 24h
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
loadPath: '{{lng}}/{{ns}}',
|
loadPath: '{{lng}}/{{ns}}',
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import { make } from 'vuex-pathify'
|
import { make } from 'vuex-pathify'
|
||||||
|
|
||||||
/* global siteConfig */
|
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
info: {
|
info: {
|
||||||
currentVersion: 'n/a',
|
currentVersion: 'n/a',
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import page from './page'
|
|||||||
import site from './site'
|
import site from './site'
|
||||||
import user from './user'
|
import user from './user'
|
||||||
|
|
||||||
|
/* global WIKI */
|
||||||
|
|
||||||
Vue.use(Vuex)
|
Vue.use(Vuex)
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
|
|||||||
11
package.json
11
package.json
@@ -236,6 +236,7 @@
|
|||||||
"i18next-localstorage-backend": "3.0.0",
|
"i18next-localstorage-backend": "3.0.0",
|
||||||
"i18next-xhr-backend": "3.0.1",
|
"i18next-xhr-backend": "3.0.1",
|
||||||
"ignore-loader": "0.1.2",
|
"ignore-loader": "0.1.2",
|
||||||
|
"jest": "24.8.0",
|
||||||
"js-cookie": "2.2.0",
|
"js-cookie": "2.2.0",
|
||||||
"mini-css-extract-plugin": "0.8.0",
|
"mini-css-extract-plugin": "0.8.0",
|
||||||
"moment-duration-format": "2.3.2",
|
"moment-duration-format": "2.3.2",
|
||||||
@@ -343,9 +344,15 @@
|
|||||||
"requireSpaceAfterCodeOperator": true,
|
"requireSpaceAfterCodeOperator": true,
|
||||||
"requireStrictEqualityOperators": true,
|
"requireStrictEqualityOperators": true,
|
||||||
"validateAttributeQuoteMarks": "'",
|
"validateAttributeQuoteMarks": "'",
|
||||||
"validateAttributeSeparator": ", ",
|
"validateAttributeSeparator": { "separator": ", ", "multiLineSeparator": "\n " },
|
||||||
"validateDivTags": true,
|
"validateDivTags": true,
|
||||||
"validateIndentation": 2
|
"validateIndentation": 2,
|
||||||
|
"excludeFiles": [
|
||||||
|
"node_modules/**",
|
||||||
|
"server/views/master.pug",
|
||||||
|
"server/views/setup.pug",
|
||||||
|
"server/views/legacy/master.pug"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"collective": {
|
"collective": {
|
||||||
"type": "opencollective",
|
"type": "opencollective",
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ const bruteforce = new ExpressBrute(new BruteKnex({
|
|||||||
knex: WIKI.models.knex
|
knex: WIKI.models.knex
|
||||||
}), {
|
}), {
|
||||||
freeRetries: 5,
|
freeRetries: 5,
|
||||||
minWait: 5*60*1000, // 5 minutes
|
minWait: 5 * 60 * 1000, // 5 minutes
|
||||||
maxWait: 60*60*1000, // 1 hour
|
maxWait: 60 * 60 * 1000, // 1 hour
|
||||||
failCallback: (req, res, next) => {
|
failCallback: (req, res, next) => {
|
||||||
res.status(401).send('Too many failed attempts. Try again later.')
|
res.status(401).send('Too many failed attempts. Try again later.')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
/* global WIKI */
|
||||||
|
|
||||||
exports.up = knex => {
|
exports.up = knex => {
|
||||||
const dbCompat = {
|
const dbCompat = {
|
||||||
blobLength: (WIKI.config.db.type === `mysql` || WIKI.config.db.type === `mariadb`)
|
blobLength: (WIKI.config.db.type === `mysql` || WIKI.config.db.type === `mariadb`)
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
/* global WIKI */
|
||||||
|
|
||||||
exports.up = knex => {
|
exports.up = knex => {
|
||||||
const dbCompat = {
|
const dbCompat = {
|
||||||
charset: (WIKI.config.db.type === `mysql` || WIKI.config.db.type === `mariadb`)
|
charset: (WIKI.config.db.type === `mysql` || WIKI.config.db.type === `mariadb`)
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
/* global WIKI */
|
||||||
|
|
||||||
exports.up = knex => {
|
exports.up = knex => {
|
||||||
const dbCompat = {
|
const dbCompat = {
|
||||||
charset: (WIKI.config.db.type === `mysql` || WIKI.config.db.type === `mariadb`)
|
charset: (WIKI.config.db.type === `mysql` || WIKI.config.db.type === `mariadb`)
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getMigrationName(migration) {
|
getMigrationName(migration) {
|
||||||
return migration.file;
|
return migration.file
|
||||||
},
|
},
|
||||||
|
|
||||||
getMigration(migration) {
|
getMigration(migration) {
|
||||||
return require(path.join(baseMigrationPath, migration.file));
|
return require(path.join(baseMigrationPath, migration.file))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
|
|
||||||
/* global WIKI */
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
// Query: {
|
// Query: {
|
||||||
// comments(obj, args, context, info) {
|
// comments(obj, args, context, info) {
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
|
|
||||||
/* global WIKI */
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
// Query: {
|
// Query: {
|
||||||
// folders(obj, args, context, info) {
|
// folders(obj, args, context, info) {
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async update(obj, args) {
|
async update(obj, args) {
|
||||||
if(_.some(args.pageRules, pr => {
|
if (_.some(args.pageRules, pr => {
|
||||||
return pr.match === 'REGEX' && !safeRegex(pr.path)
|
return pr.match === 'REGEX' && !safeRegex(pr.path)
|
||||||
})) {
|
})) {
|
||||||
throw new gql.GraphQLError('Some Page Rules contains unsafe or exponential time regex.')
|
throw new gql.GraphQLError('Some Page Rules contains unsafe or exponential time regex.')
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ module.exports = {
|
|||||||
return {
|
return {
|
||||||
responseResult: graphHelper.generateSuccess('Telemetry state updated successfully')
|
responseResult: graphHelper.generateSuccess('Telemetry state updated successfully')
|
||||||
}
|
}
|
||||||
} catch(err) {
|
} catch (err) {
|
||||||
return graphHelper.generateError(err)
|
return graphHelper.generateError(err)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -63,7 +63,7 @@ module.exports = {
|
|||||||
return {
|
return {
|
||||||
responseResult: graphHelper.generateSuccess('Telemetry Client ID has been reset successfully')
|
responseResult: graphHelper.generateSuccess('Telemetry Client ID has been reset successfully')
|
||||||
}
|
}
|
||||||
} catch(err) {
|
} catch (err) {
|
||||||
return graphHelper.generateError(err)
|
return graphHelper.generateError(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,3 @@
|
|||||||
|
|
||||||
/* global WIKI */
|
|
||||||
|
|
||||||
const gql = require('graphql')
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
// Query: {
|
// Query: {
|
||||||
// tags(obj, args, context, info) {
|
// tags(obj, args, context, info) {
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
const crypto = require('crypto')
|
const crypto = require('crypto')
|
||||||
|
|
||||||
/* global WIKI */
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
/**
|
/**
|
||||||
* Generate unique hash from page
|
* Generate unique hash from page
|
||||||
|
|||||||
@@ -66,14 +66,11 @@ module.exports = {
|
|||||||
['date', page.updatedAt],
|
['date', page.updatedAt],
|
||||||
['tags', '']
|
['tags', '']
|
||||||
]
|
]
|
||||||
switch (page.contentType) {
|
const inject = {
|
||||||
case 'markdown':
|
'markdown': '---\n' + meta.map(mt => `${mt[0]}: ${mt[1]}`).join('\n') + '\n---\n\n' + page.content,
|
||||||
return '---\n' + meta.map(mt => `${mt[0]}: ${mt[1]}`).join('\n') + '\n---\n\n' + page.content
|
'html': '<!--\n' + meta.map(mt => `${mt[0]}: ${mt[1]}`).join('\n') + '\n-->\n\n' + page.content
|
||||||
case 'html':
|
|
||||||
return '<!--\n' + meta.map(mt => `${mt[0]}: ${mt[1]}`).join('\n') + '\n-->\n\n' + page.content
|
|
||||||
default:
|
|
||||||
return page.content
|
|
||||||
}
|
}
|
||||||
|
return _.get(inject, page.contentType, page.content)
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Check if path is a reserved path
|
* Check if path is a reserved path
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
const { graphqlUploadExpress } = require('graphql-upload')
|
const { graphqlUploadExpress } = require('graphql-upload')
|
||||||
|
|
||||||
/* global WIKI */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GraphQL File Upload Middleware
|
* GraphQL File Upload Middleware
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -138,6 +138,5 @@ module.exports = class Analytics extends Model {
|
|||||||
bodyEnd: ''
|
bodyEnd: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
|
|
||||||
const DiscordStrategy = require('passport-discord').Strategy
|
const DiscordStrategy = require('passport-discord').Strategy
|
||||||
const _ = require('lodash')
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
init (passport, conf) {
|
init (passport, conf) {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ module.exports = {
|
|||||||
githubConfig.authorizationURL = `https://${conf.enterpriseDomain}/login/oauth/authorize`
|
githubConfig.authorizationURL = `https://${conf.enterpriseDomain}/login/oauth/authorize`
|
||||||
githubConfig.tokenURL = `https://${conf.enterpriseDomain}/login/oauth/access_token`
|
githubConfig.tokenURL = `https://${conf.enterpriseDomain}/login/oauth/access_token`
|
||||||
githubConfig.userProfileURL = conf.enterpriseUserEndpoint
|
githubConfig.userProfileURL = conf.enterpriseUserEndpoint
|
||||||
githubConfig.userEmailURL = `${conf.enterpriseUserEndpoint}/emails`
|
githubConfig.userEmailURL = `${conf.enterpriseUserEndpoint}/emails`
|
||||||
}
|
}
|
||||||
|
|
||||||
passport.use('github',
|
passport.use('github',
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
const fs = require('fs-extra')
|
const fs = require('fs-extra')
|
||||||
const _ = require('lodash')
|
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const tar = require('tar-fs')
|
const tar = require('tar-fs')
|
||||||
const zlib = require('zlib')
|
const zlib = require('zlib')
|
||||||
|
|||||||
43
server/test/helpers/page.test.js
Normal file
43
server/test/helpers/page.test.js
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
const { injectPageMetadata } = require('../../helpers/page')
|
||||||
|
|
||||||
|
describe('injectPageMetadata tests', () => {
|
||||||
|
let page = {
|
||||||
|
title: 'PAGE TITLE',
|
||||||
|
description: 'A PAGE',
|
||||||
|
isPublished: true,
|
||||||
|
updatedAt: new Date(),
|
||||||
|
content: 'TEST CONTENT'
|
||||||
|
}
|
||||||
|
test('injectPageMetadata: default', () => {
|
||||||
|
const expected = 'TEST CONTENT'
|
||||||
|
const result = injectPageMetadata(page)
|
||||||
|
expect(result).toEqual(expected)
|
||||||
|
})
|
||||||
|
test('injectPageMetadata: markdown', () => {
|
||||||
|
page.contentType = 'markdown'
|
||||||
|
const expected = `---
|
||||||
|
title: ${page.title}
|
||||||
|
description: ${page.description}
|
||||||
|
published: ${page.isPublished.toString()}
|
||||||
|
date: ${page.updatedAt}
|
||||||
|
tags: \n---
|
||||||
|
|
||||||
|
TEST CONTENT`
|
||||||
|
const result = injectPageMetadata(page)
|
||||||
|
expect(result).toEqual(expected)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('injectPageMetadata: hmtl', () => {
|
||||||
|
page.contentType = 'html'
|
||||||
|
const expected = `<!--
|
||||||
|
title: ${page.title}
|
||||||
|
description: ${page.description}
|
||||||
|
published: ${page.isPublished.toString()}
|
||||||
|
date: ${page.updatedAt}
|
||||||
|
tags: \n-->
|
||||||
|
|
||||||
|
TEST CONTENT`
|
||||||
|
const result = injectPageMetadata(page)
|
||||||
|
expect(result).toEqual(expected)
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -9,7 +9,7 @@ block body
|
|||||||
v-layout(row)
|
v-layout(row)
|
||||||
v-flex(xs10)
|
v-flex(xs10)
|
||||||
a(href='/'): img(src='/svg/logo-wikijs.svg')
|
a(href='/'): img(src='/svg/logo-wikijs.svg')
|
||||||
v-flex(xs2).text-xs-right
|
v-flex.text-right(xs2)
|
||||||
v-btn(href='/', depressed, color='red darken-3')
|
v-btn(href='/', depressed, color='red darken-3')
|
||||||
v-icon(left) home
|
v-icon(left) home
|
||||||
span Home
|
span Home
|
||||||
|
|||||||
Reference in New Issue
Block a user