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

View File

@ -73,6 +73,16 @@
persistent-hint
: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
.overline.grey--text.pa-4 SEO
.px-3.pb-3
@ -251,8 +261,7 @@
<script>
import _ from 'lodash'
import { get, sync } from 'vuex-pathify'
import siteConfigQuery from 'gql/admin/site/site-query-config.gql'
import siteUpdateConfigMutation from 'gql/admin/site/site-mutation-save-config.gql'
import gql from 'graphql-tag'
import editorStore from '../../store/editor'
@ -281,6 +290,7 @@ export default {
analyticsService: '',
analyticsId: '',
company: '',
contentLicense: '',
logoUrl: '',
featureAnalytics: false,
featurePageRatings: false,
@ -317,13 +327,82 @@ export default {
siteTitle: sync('site/title'),
logoUrl: sync('site/logoUrl'),
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: {
async save () {
try {
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: {
host: _.get(this.config, 'host', ''),
title: _.get(this.config, 'title', ''),
@ -332,6 +411,7 @@ export default {
analyticsService: _.get(this.config, 'analyticsService', ''),
analyticsId: _.get(this.config, 'analyticsId', ''),
company: _.get(this.config, 'company', ''),
contentLicense: _.get(this.config, 'contentLicense', ''),
logoUrl: _.get(this.config, 'logoUrl', ''),
featurePageRatings: _.get(this.config, 'featurePageRatings', false),
featurePageComments: _.get(this.config, 'featurePageComments', false),
@ -356,6 +436,7 @@ export default {
})
this.siteTitle = this.config.title
this.company = this.config.company
this.contentLicense = this.config.contentLicense
this.logoUrl = this.config.logoUrl
} catch (err) {
this.$store.commit('pushGraphError', err)
@ -379,7 +460,34 @@ export default {
},
apollo: {
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',
update: (data) => _.cloneDeep(data.site.config),
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 = {
company: siteConfig.company,
contentLicense: siteConfig.contentLicense,
dark: siteConfig.darkMode,
mascot: true,
title: siteConfig.title,

View File

@ -1,7 +1,9 @@
<template lang="pug">
v-footer.justify-center(:color='bgColor', inset)
.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]
</template>
@ -26,6 +28,7 @@ export default {
},
computed: {
company: get('site/company'),
contentLicense: get('site/contentLicense'),
darkMode: get('site/dark'),
bgColor() {
if (!this.darkMode) {

View File

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

View File

@ -15,6 +15,7 @@ module.exports = {
host: WIKI.config.host,
title: WIKI.config.title,
company: WIKI.config.company,
contentLicense: WIKI.config.contentLicense,
logoUrl: WIKI.config.logoUrl,
...WIKI.config.seo,
...WIKI.config.features,
@ -28,6 +29,7 @@ module.exports = {
WIKI.config.host = args.host
WIKI.config.title = args.title
WIKI.config.company = args.company
WIKI.config.contentLicense = args.contentLicense
WIKI.config.seo = {
description: args.description,
robots: args.robots,
@ -50,7 +52,7 @@ module.exports = {
securityCSP: args.securityCSP,
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) {
WIKI.app.enable('trust proxy')

View File

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

View File

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