feat: content license notice option

This commit is contained in:
NGPixel 2020-02-23 15:20:55 -05:00
parent c5a22f6d13
commit f7c0daec9a
10 changed files with 127 additions and 85 deletions

View File

@ -7,7 +7,7 @@
v-spacer v-spacer
v-navigation-drawer.pb-0.admin-sidebar(v-model='adminDrawerShown', app, fixed, clipped, :right='$vuetify.rtl', permanent, width='300') v-navigation-drawer.pb-0.admin-sidebar(v-model='adminDrawerShown', app, fixed, clipped, :right='$vuetify.rtl', permanent, width='300')
vue-scroll(:ops='scrollStyle') vue-scroll(:ops='scrollStyle')
v-list(dense, nav) v-list.radius-0(dense, nav)
v-list-item(to='/dashboard', color='primary') v-list-item(to='/dashboard', color='primary')
v-list-item-avatar(size='24', tile): v-icon mdi-view-dashboard-variant v-list-item-avatar(size='24', tile): v-icon mdi-view-dashboard-variant
v-list-item-title {{ $t('admin:dashboard.title') }} v-list-item-title {{ $t('admin:dashboard.title') }}

View File

@ -73,6 +73,16 @@
persistent-hint persistent-hint
:hint='$t(`admin:general.companyNameHint`)' :hint='$t(`admin:general.companyNameHint`)'
) )
v-select.mt-3(
outlined
:label='$t(`admin:general.contentLicense`)'
:items='contentLicenses'
v-model='config.contentLicense'
prepend-icon='mdi-creative-commons'
:return-object='false'
:hint='$t(`admin:general.contentLicenseHint`)'
persistent-hint
)
v-divider v-divider
.overline.grey--text.pa-4 SEO .overline.grey--text.pa-4 SEO
.px-3.pb-3 .px-3.pb-3
@ -251,8 +261,7 @@
<script> <script>
import _ from 'lodash' import _ from 'lodash'
import { get, sync } from 'vuex-pathify' import { get, sync } from 'vuex-pathify'
import siteConfigQuery from 'gql/admin/site/site-query-config.gql' import gql from 'graphql-tag'
import siteUpdateConfigMutation from 'gql/admin/site/site-mutation-save-config.gql'
import editorStore from '../../store/editor' import editorStore from '../../store/editor'
@ -281,6 +290,7 @@ export default {
analyticsService: '', analyticsService: '',
analyticsId: '', analyticsId: '',
company: '', company: '',
contentLicense: '',
logoUrl: '', logoUrl: '',
featureAnalytics: false, featureAnalytics: false,
featurePageRatings: false, featurePageRatings: false,
@ -317,13 +327,82 @@ export default {
siteTitle: sync('site/title'), siteTitle: sync('site/title'),
logoUrl: sync('site/logoUrl'), logoUrl: sync('site/logoUrl'),
company: sync('site/company'), company: sync('site/company'),
activeModal: sync('editor/activeModal') contentLicense: sync('site/contentLicense'),
activeModal: sync('editor/activeModal'),
contentLicenses () {
return [
{ value: '', text: this.$t('common:license.none') },
{ value: 'alr', text: this.$t('common:license.alr') },
{ value: 'cc0', text: this.$t('common:license.cc0') },
{ value: 'ccby', text: this.$t('common:license.ccby') },
{ value: 'ccbysa', text: this.$t('common:license.ccbysa') },
{ value: 'ccbynd', text: this.$t('common:license.ccbynd') },
{ value: 'ccbync', text: this.$t('common:license.ccbync') },
{ value: 'ccbyncsa', text: this.$t('common:license.ccbyncsa') },
{ value: 'ccbyncnd', text: this.$t('common:license.ccbyncnd') }
]
}
}, },
methods: { methods: {
async save () { async save () {
try { try {
await this.$apollo.mutate({ await this.$apollo.mutate({
mutation: siteUpdateConfigMutation, mutation: gql`
mutation (
$host: String!
$title: String!
$description: String!
$robots: [String]!
$analyticsService: String!
$analyticsId: String!
$company: String!
$contentLicense: String!
$logoUrl: String!
$featurePageRatings: Boolean!
$featurePageComments: Boolean!
$featurePersonalWikis: Boolean!
$securityIframe: Boolean!
$securityReferrerPolicy: Boolean!
$securityTrustProxy: Boolean!
$securitySRI: Boolean!
$securityHSTS: Boolean!
$securityHSTSDuration: Int!
$securityCSP: Boolean!
$securityCSPDirectives: String!
) {
site {
updateConfig(
host: $host,
title: $title,
description: $description,
robots: $robots,
analyticsService: $analyticsService,
analyticsId: $analyticsId,
company: $company,
contentLicense: $contentLicense,
logoUrl: $logoUrl,
featurePageRatings: $featurePageRatings,
featurePageComments: $featurePageComments,
featurePersonalWikis: $featurePersonalWikis,
securityIframe: $securityIframe,
securityReferrerPolicy: $securityReferrerPolicy,
securityTrustProxy: $securityTrustProxy,
securitySRI: $securitySRI,
securityHSTS: $securityHSTS,
securityHSTSDuration: $securityHSTSDuration,
securityCSP: $securityCSP,
securityCSPDirectives: $securityCSPDirectives
) {
responseResult {
succeeded
errorCode
slug
message
}
}
}
}
`,
variables: { variables: {
host: _.get(this.config, 'host', ''), host: _.get(this.config, 'host', ''),
title: _.get(this.config, 'title', ''), title: _.get(this.config, 'title', ''),
@ -332,6 +411,7 @@ export default {
analyticsService: _.get(this.config, 'analyticsService', ''), analyticsService: _.get(this.config, 'analyticsService', ''),
analyticsId: _.get(this.config, 'analyticsId', ''), analyticsId: _.get(this.config, 'analyticsId', ''),
company: _.get(this.config, 'company', ''), company: _.get(this.config, 'company', ''),
contentLicense: _.get(this.config, 'contentLicense', ''),
logoUrl: _.get(this.config, 'logoUrl', ''), logoUrl: _.get(this.config, 'logoUrl', ''),
featurePageRatings: _.get(this.config, 'featurePageRatings', false), featurePageRatings: _.get(this.config, 'featurePageRatings', false),
featurePageComments: _.get(this.config, 'featurePageComments', false), featurePageComments: _.get(this.config, 'featurePageComments', false),
@ -356,6 +436,7 @@ export default {
}) })
this.siteTitle = this.config.title this.siteTitle = this.config.title
this.company = this.config.company this.company = this.config.company
this.contentLicense = this.config.contentLicense
this.logoUrl = this.config.logoUrl this.logoUrl = this.config.logoUrl
} catch (err) { } catch (err) {
this.$store.commit('pushGraphError', err) this.$store.commit('pushGraphError', err)
@ -379,7 +460,34 @@ export default {
}, },
apollo: { apollo: {
config: { config: {
query: siteConfigQuery, query: gql`
{
site {
config {
host
title
description
robots
analyticsService
analyticsId
company
contentLicense
logoUrl
featurePageRatings
featurePageComments
featurePersonalWikis
securityIframe
securityReferrerPolicy
securityTrustProxy
securitySRI
securityHSTS
securityHSTSDuration
securityCSP
securityCSPDirectives
}
}
}
`,
fetchPolicy: 'network-only', fetchPolicy: 'network-only',
update: (data) => _.cloneDeep(data.site.config), update: (data) => _.cloneDeep(data.site.config),
watchLoading (isLoading) { watchLoading (isLoading) {

View File

@ -1,52 +0,0 @@
mutation (
$host: String!
$title: String!
$description: String!
$robots: [String]!
$analyticsService: String!
$analyticsId: String!
$company: String!
$logoUrl: String!
$featurePageRatings: Boolean!
$featurePageComments: Boolean!
$featurePersonalWikis: Boolean!
$securityIframe: Boolean!
$securityReferrerPolicy: Boolean!
$securityTrustProxy: Boolean!
$securitySRI: Boolean!
$securityHSTS: Boolean!
$securityHSTSDuration: Int!
$securityCSP: Boolean!
$securityCSPDirectives: String!
) {
site {
updateConfig(
host: $host,
title: $title,
description: $description,
robots: $robots,
analyticsService: $analyticsService,
analyticsId: $analyticsId,
company: $company,
logoUrl: $logoUrl,
featurePageRatings: $featurePageRatings,
featurePageComments: $featurePageComments,
featurePersonalWikis: $featurePersonalWikis,
securityIframe: $securityIframe,
securityReferrerPolicy: $securityReferrerPolicy,
securityTrustProxy: $securityTrustProxy,
securitySRI: $securitySRI,
securityHSTS: $securityHSTS,
securityHSTSDuration: $securityHSTSDuration,
securityCSP: $securityCSP,
securityCSPDirectives: $securityCSPDirectives
) {
responseResult {
succeeded
errorCode
slug
message
}
}
}
}

View File

@ -1,25 +0,0 @@
{
site {
config {
host
title
description
robots
analyticsService
analyticsId
company
logoUrl
featurePageRatings
featurePageComments
featurePersonalWikis
securityIframe
securityReferrerPolicy
securityTrustProxy
securitySRI
securityHSTS
securityHSTSDuration
securityCSP
securityCSPDirectives
}
}
}

View File

@ -4,6 +4,7 @@ import { make } from 'vuex-pathify'
const state = { const state = {
company: siteConfig.company, company: siteConfig.company,
contentLicense: siteConfig.contentLicense,
dark: siteConfig.darkMode, dark: siteConfig.darkMode,
mascot: true, mascot: true,
title: siteConfig.title, title: siteConfig.title,

View File

@ -1,7 +1,9 @@
<template lang="pug"> <template lang="pug">
v-footer.justify-center(:color='bgColor', inset) v-footer.justify-center(:color='bgColor', inset)
.caption.grey--text.text--darken-1 .caption.grey--text.text--darken-1
span(v-if='company && company.length > 0') {{ $t('common:footer.copyright', { company: company, year: currentYear, interpolation: { escapeValue: false } }) }} |&nbsp; template(v-if='company && company.length > 0 && contentLicense !== ``')
span(v-if='contentLicense === `alr`') {{ $t('common:footer.copyright', { company: company, year: currentYear, interpolation: { escapeValue: false } }) }} |&nbsp;
span(v-else) {{ $t('common:footer.license', { company: company, license: $t('common:license.' + contentLicense), interpolation: { escapeValue: false } }) }} |&nbsp;
span {{ $t('common:footer.poweredBy') }} #[a(href='https://wiki.js.org', ref='nofollow') Wiki.js] span {{ $t('common:footer.poweredBy') }} #[a(href='https://wiki.js.org', ref='nofollow') Wiki.js]
</template> </template>
@ -26,6 +28,7 @@ export default {
}, },
computed: { computed: {
company: get('site/company'), company: get('site/company'),
contentLicense: get('site/contentLicense'),
darkMode: get('site/dark'), darkMode: get('site/dark'),
bgColor() { bgColor() {
if (!this.darkMode) { if (!this.darkMode) {

View File

@ -42,6 +42,8 @@ defaults:
clientId: '' clientId: ''
isEnabled: false isEnabled: false
title: Wiki.js title: Wiki.js
company: ''
contentLicense: ''
logoUrl: https://static.requarks.io/logo/wikijs-butterfly.svg logoUrl: https://static.requarks.io/logo/wikijs-butterfly.svg
theming: theming:
theme: 'default' theme: 'default'

View File

@ -15,6 +15,7 @@ module.exports = {
host: WIKI.config.host, host: WIKI.config.host,
title: WIKI.config.title, title: WIKI.config.title,
company: WIKI.config.company, company: WIKI.config.company,
contentLicense: WIKI.config.contentLicense,
logoUrl: WIKI.config.logoUrl, logoUrl: WIKI.config.logoUrl,
...WIKI.config.seo, ...WIKI.config.seo,
...WIKI.config.features, ...WIKI.config.features,
@ -28,6 +29,7 @@ module.exports = {
WIKI.config.host = args.host WIKI.config.host = args.host
WIKI.config.title = args.title WIKI.config.title = args.title
WIKI.config.company = args.company WIKI.config.company = args.company
WIKI.config.contentLicense = args.contentLicense
WIKI.config.seo = { WIKI.config.seo = {
description: args.description, description: args.description,
robots: args.robots, robots: args.robots,
@ -50,7 +52,7 @@ module.exports = {
securityCSP: args.securityCSP, securityCSP: args.securityCSP,
securityCSPDirectives: args.securityCSPDirectives securityCSPDirectives: args.securityCSPDirectives
} }
await WIKI.configSvc.saveToDb(['host', 'title', 'company', 'seo', 'logoUrl', 'features', 'security']) await WIKI.configSvc.saveToDb(['host', 'title', 'company', 'contentLicense', 'seo', 'logoUrl', 'features', 'security'])
if (WIKI.config.security.securityTrustProxy) { if (WIKI.config.security.securityTrustProxy) {
WIKI.app.enable('trust proxy') WIKI.app.enable('trust proxy')

View File

@ -31,6 +31,7 @@ type SiteMutation {
analyticsService: String! analyticsService: String!
analyticsId: String! analyticsId: String!
company: String! company: String!
contentLicense: String!
logoUrl: String! logoUrl: String!
featurePageRatings: Boolean! featurePageRatings: Boolean!
featurePageComments: Boolean! featurePageComments: Boolean!
@ -58,6 +59,7 @@ type SiteConfig {
analyticsService: String! analyticsService: String!
analyticsId: String! analyticsId: String!
company: String! company: String!
contentLicense: String!
logoUrl: String! logoUrl: String!
featurePageRatings: Boolean! featurePageRatings: Boolean!
featurePageComments: Boolean! featurePageComments: Boolean!

View File

@ -145,6 +145,7 @@ module.exports = async () => {
lang: WIKI.config.lang.code, lang: WIKI.config.lang.code,
rtl: WIKI.config.lang.rtl, rtl: WIKI.config.lang.rtl,
company: WIKI.config.company, company: WIKI.config.company,
contentLicense: WIKI.config.contentLicense,
logoUrl: WIKI.config.logoUrl logoUrl: WIKI.config.logoUrl
} }
res.locals.langs = await WIKI.models.locales.getNavLocales({ cache: true }) res.locals.langs = await WIKI.models.locales.getNavLocales({ cache: true })