Commit 0f9ddf1e authored by rbtprograms's avatar rbtprograms Committed by Nicolas Giard

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
parent 2142b5f6
......@@ -42,7 +42,8 @@
export default {
props: {
value: {
type: Object
type: Object,
default: () => ({})
}
},
data() {
......
......@@ -186,7 +186,6 @@
v-subheader.pl-0 Regular Expressions
span Expressions that are deemed unsafe or could result in exponential time processing will be rejected upon saving.
</template>
<script>
......@@ -196,7 +195,8 @@ import nanoid from 'nanoid/non-secure/generate'
export default {
props: {
value: {
type: Object
type: Object,
default: () => ({})
}
},
data() {
......
......@@ -57,7 +57,8 @@ import unassignUserMutation from 'gql/admin/groups/groups-mutation-unassign.gql'
export default {
props: {
value: {
type: Object
type: Object,
default: () => ({})
}
},
components: {
......
......@@ -8,7 +8,7 @@
import 'grapesjs/dist/css/grapes.min.css'
import grapesjs from 'grapesjs'
let editor
let editor // eslint-disable-line no-unused-vars
export default {
mounted() {
......@@ -31,7 +31,7 @@ export default {
}, {
id: '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',
label: 'Image',
......
......@@ -22,7 +22,7 @@ export default {
],
backendOptions: [
{
expirationTime: 1000*60*60*24 // 24h
expirationTime: 1000 * 60 * 60 * 24 // 24h
},
{
loadPath: '{{lng}}/{{ns}}',
......
import { make } from 'vuex-pathify'
/* global siteConfig */
const state = {
info: {
currentVersion: 'n/a',
......
......@@ -8,6 +8,8 @@ import page from './page'
import site from './site'
import user from './user'
/* global WIKI */
Vue.use(Vuex)
const state = {
......
......@@ -236,6 +236,7 @@
"i18next-localstorage-backend": "3.0.0",
"i18next-xhr-backend": "3.0.1",
"ignore-loader": "0.1.2",
"jest": "24.8.0",
"js-cookie": "2.2.0",
"mini-css-extract-plugin": "0.8.0",
"moment-duration-format": "2.3.2",
......@@ -343,9 +344,15 @@
"requireSpaceAfterCodeOperator": true,
"requireStrictEqualityOperators": true,
"validateAttributeQuoteMarks": "'",
"validateAttributeSeparator": ", ",
"validateAttributeSeparator": { "separator": ", ", "multiLineSeparator": "\n " },
"validateDivTags": true,
"validateIndentation": 2
"validateIndentation": 2,
"excludeFiles": [
"node_modules/**",
"server/views/master.pug",
"server/views/setup.pug",
"server/views/legacy/master.pug"
]
},
"collective": {
"type": "opencollective",
......
......@@ -12,8 +12,8 @@ const bruteforce = new ExpressBrute(new BruteKnex({
knex: WIKI.models.knex
}), {
freeRetries: 5,
minWait: 5*60*1000, // 5 minutes
maxWait: 60*60*1000, // 1 hour
minWait: 5 * 60 * 1000, // 5 minutes
maxWait: 60 * 60 * 1000, // 1 hour
failCallback: (req, res, next) => {
res.status(401).send('Too many failed attempts. Try again later.')
}
......
/* global WIKI */
exports.up = knex => {
const dbCompat = {
blobLength: (WIKI.config.db.type === `mysql` || WIKI.config.db.type === `mariadb`)
......
/* global WIKI */
exports.up = knex => {
const dbCompat = {
charset: (WIKI.config.db.type === `mysql` || WIKI.config.db.type === `mariadb`)
......
/* global WIKI */
exports.up = knex => {
const dbCompat = {
charset: (WIKI.config.db.type === `mysql` || WIKI.config.db.type === `mariadb`)
......
......@@ -20,10 +20,10 @@ module.exports = {
},
getMigrationName(migration) {
return migration.file;
return migration.file
},
getMigration(migration) {
return require(path.join(baseMigrationPath, migration.file));
return require(path.join(baseMigrationPath, migration.file))
}
}
/* global WIKI */
module.exports = {
// Query: {
// comments(obj, args, context, info) {
......
/* global WIKI */
module.exports = {
// Query: {
// folders(obj, args, context, info) {
......
......@@ -74,7 +74,7 @@ module.exports = {
}
},
async update(obj, args) {
if(_.some(args.pageRules, pr => {
if (_.some(args.pageRules, pr => {
return pr.match === 'REGEX' && !safeRegex(pr.path)
})) {
throw new gql.GraphQLError('Some Page Rules contains unsafe or exponential time regex.')
......
......@@ -51,7 +51,7 @@ module.exports = {
return {
responseResult: graphHelper.generateSuccess('Telemetry state updated successfully')
}
} catch(err) {
} catch (err) {
return graphHelper.generateError(err)
}
},
......@@ -63,7 +63,7 @@ module.exports = {
return {
responseResult: graphHelper.generateSuccess('Telemetry Client ID has been reset successfully')
}
} catch(err) {
} catch (err) {
return graphHelper.generateError(err)
}
}
......
/* global WIKI */
const gql = require('graphql')
module.exports = {
// Query: {
// tags(obj, args, context, info) {
......
const crypto = require('crypto')
/* global WIKI */
module.exports = {
/**
* Generate unique hash from page
......
......@@ -66,14 +66,11 @@ module.exports = {
['date', page.updatedAt],
['tags', '']
]
switch (page.contentType) {
case 'markdown':
return '---\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
const inject = {
'markdown': '---\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
}
return _.get(inject, page.contentType, page.content)
},
/**
* Check if path is a reserved path
......
const { graphqlUploadExpress } = require('graphql-upload')
/* global WIKI */
/**
* GraphQL File Upload Middleware
*/
......
......@@ -138,6 +138,5 @@ module.exports = class Analytics extends Model {
bodyEnd: ''
}
}
}
}
......@@ -5,7 +5,6 @@
// ------------------------------------
const DiscordStrategy = require('passport-discord').Strategy
const _ = require('lodash')
module.exports = {
init (passport, conf) {
......
const fs = require('fs-extra')
const _ = require('lodash')
const path = require('path')
const tar = require('tar-fs')
const zlib = require('zlib')
......
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-flex(xs10)
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-icon(left) home
span Home
......
This diff was suppressed by a .gitattributes entry.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment