Skip to content

Commit 48077fc

Browse files
committed
feat(admin): make page extensions configurable
1 parent 18ac9da commit 48077fc

File tree

5 files changed

+55
-30
lines changed

5 files changed

+55
-30
lines changed

client/components/admin/admin-general.vue

+42-24
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,19 @@
164164
//- disabled
165165
//- )
166166
167+
v-card.mt-5.animated.fadeInUp.wait-p6s
168+
v-toolbar(color='primary', dark, dense, flat)
169+
v-toolbar-title.subtitle-1 URL Handling
170+
v-card-text
171+
v-text-field(
172+
outlined
173+
:label='$t(`admin:general.pageExtensions`)'
174+
v-model='config.pageExtensions'
175+
prepend-icon='mdi-format-text-wrapping-overflow'
176+
:hint='$t(`admin:general.pageExtensionsHint`)'
177+
persistent-hint
178+
)
179+
167180
component(:is='activeModal')
168181

169182
</template>
@@ -202,7 +215,8 @@ export default {
202215
featurePageRatings: false,
203216
featurePageComments: false,
204217
featurePersonalWikis: false,
205-
featureTinyPNG: false
218+
featureTinyPNG: false,
219+
pageExtensions: ''
206220
},
207221
metaRobots: [
208222
{ text: 'Index', value: 'index' },
@@ -247,32 +261,34 @@ export default {
247261
await this.$apollo.mutate({
248262
mutation: gql`
249263
mutation (
250-
$host: String!
251-
$title: String!
252-
$description: String!
253-
$robots: [String]!
254-
$analyticsService: String!
255-
$analyticsId: String!
256-
$company: String!
257-
$contentLicense: String!
258-
$logoUrl: String!
259-
$featurePageRatings: Boolean!
260-
$featurePageComments: Boolean!
261-
$featurePersonalWikis: Boolean!
264+
$host: String
265+
$title: String
266+
$description: String
267+
$robots: [String]
268+
$analyticsService: String
269+
$analyticsId: String
270+
$company: String
271+
$contentLicense: String
272+
$logoUrl: String
273+
$pageExtensions: String
274+
$featurePageRatings: Boolean
275+
$featurePageComments: Boolean
276+
$featurePersonalWikis: Boolean
262277
) {
263278
site {
264279
updateConfig(
265-
host: $host,
266-
title: $title,
267-
description: $description,
268-
robots: $robots,
269-
analyticsService: $analyticsService,
270-
analyticsId: $analyticsId,
271-
company: $company,
272-
contentLicense: $contentLicense,
273-
logoUrl: $logoUrl,
274-
featurePageRatings: $featurePageRatings,
275-
featurePageComments: $featurePageComments,
280+
host: $host
281+
title: $title
282+
description: $description
283+
robots: $robots
284+
analyticsService: $analyticsService
285+
analyticsId: $analyticsId
286+
company: $company
287+
contentLicense: $contentLicense
288+
logoUrl: $logoUrl
289+
pageExtensions: $pageExtensions
290+
featurePageRatings: $featurePageRatings
291+
featurePageComments: $featurePageComments
276292
featurePersonalWikis: $featurePersonalWikis
277293
) {
278294
responseResult {
@@ -295,6 +311,7 @@ export default {
295311
company: _.get(this.config, 'company', ''),
296312
contentLicense: _.get(this.config, 'contentLicense', ''),
297313
logoUrl: _.get(this.config, 'logoUrl', ''),
314+
pageExtensions: _.get(this.config, 'pageExtensions', ''),
298315
featurePageRatings: _.get(this.config, 'featurePageRatings', false),
299316
featurePageComments: _.get(this.config, 'featurePageComments', false),
300317
featurePersonalWikis: _.get(this.config, 'featurePersonalWikis', false)
@@ -347,6 +364,7 @@ export default {
347364
company
348365
contentLicense
349366
logoUrl
367+
pageExtensions
350368
featurePageRatings
351369
featurePageComments
352370
featurePersonalWikis

server/app/data.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ defaults:
4545
company: ''
4646
contentLicense: ''
4747
logoUrl: https://static.requarks.io/logo/wikijs-butterfly.svg
48+
pageExtensions:
49+
- md
50+
- html
51+
- txt
4852
mail:
4953
host: ''
5054
secure: true
@@ -152,8 +156,4 @@ reservedPaths:
152156
- img
153157
- js
154158
- svg
155-
pageExtensions:
156-
- md
157-
- html
158-
- txt
159159
# ---------------------------------

server/controllers/common.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ router.get('/_userav/:uid', async (req, res, next) => {
414414
* View document / asset
415415
*/
416416
router.get('/*', async (req, res, next) => {
417-
const stripExt = _.some(WIKI.data.pageExtensions, ext => _.endsWith(req.path, `.${ext}`))
417+
const stripExt = _.some(WIKI.config.pageExtensions, ext => _.endsWith(req.path, `.${ext}`))
418418
const pageArgs = pageHelper.parsePath(req.path, { stripExt })
419419
const isPage = (stripExt || pageArgs.path.indexOf('.') === -1)
420420

server/graph/resolvers/site.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module.exports = {
1818
company: WIKI.config.company,
1919
contentLicense: WIKI.config.contentLicense,
2020
logoUrl: WIKI.config.logoUrl,
21+
pageExtensions: WIKI.config.pageExtensions.join(', '),
2122
...WIKI.config.seo,
2223
...WIKI.config.features,
2324
...WIKI.config.security,
@@ -62,6 +63,10 @@ module.exports = {
6263
WIKI.config.logoUrl = _.trim(args.logoUrl)
6364
}
6465

66+
if (args.hasOwnProperty('pageExtensions')) {
67+
WIKI.config.pageExtensions = _.trim(args.pageExtensions).split(',').map(p => p.trim().toLowerCase()).filter(p => p !== '')
68+
}
69+
6570
WIKI.config.seo = {
6671
description: _.get(args, 'description', WIKI.config.seo.description),
6772
robots: _.get(args, 'robots', WIKI.config.seo.robots),
@@ -104,7 +109,7 @@ module.exports = {
104109
forceDownload: _.get(args, 'uploadForceDownload', WIKI.config.uploads.forceDownload)
105110
}
106111

107-
await WIKI.configSvc.saveToDb(['host', 'title', 'company', 'contentLicense', 'seo', 'logoUrl', 'auth', 'features', 'security', 'uploads'])
112+
await WIKI.configSvc.saveToDb(['host', 'title', 'company', 'contentLicense', 'seo', 'logoUrl', 'pageExtensions', 'auth', 'features', 'security', 'uploads'])
108113

109114
if (WIKI.config.security.securityTrustProxy) {
110115
WIKI.app.enable('trust proxy')

server/graph/schemas/site.graphql

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type SiteMutation {
3333
company: String
3434
contentLicense: String
3535
logoUrl: String
36+
pageExtensions: String
3637
authAutoLogin: Boolean
3738
authEnforce2FA: Boolean
3839
authHideLocal: Boolean
@@ -74,6 +75,7 @@ type SiteConfig {
7475
company: String
7576
contentLicense: String
7677
logoUrl: String
78+
pageExtensions: String
7779
authAutoLogin: Boolean
7880
authEnforce2FA: Boolean
7981
authHideLocal: Boolean

0 commit comments

Comments
 (0)