From 824b8310b989a0084c25d67c8055017eddef1bc4 Mon Sep 17 00:00:00 2001
From: Olga Bulat
Date: Thu, 17 Dec 2020 11:15:38 +0300
Subject: [PATCH 1/7] Improve scrolling
---
src/App.vue | 70 +++++++++++++++++++++++++++++++++++++----------------
1 file changed, 49 insertions(+), 21 deletions(-)
diff --git a/src/App.vue b/src/App.vue
index 920bb4f40..32b3285b7 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -37,19 +37,23 @@
/>
-
@@ -82,20 +86,41 @@ export default {
return {
currentStepId: 0,
showLicense: false,
- shouldShake: false
+ shouldShake: false,
+ windowWidth: window.innerWidth
}
},
computed: {
showLicenseUse() {
return this.currentStepId === 7
+ },
+ isBelowTabletWidth() {
+ return this.windowWidth < 769
}
},
watch: {
- currentStepId(newId) {
- const offset = newId === 7 ? -200 : -120
- this.$scrollTo(`.step-${newId}`, { offset: offset })
+ async currentStepId(newId, oldId) {
+ // When the new step opens, the page is scrolled to the top of the
+ // previous step. When the 'Back' button is clicked, the page is
+ // scrolled to the previous step.
+ // If the user chooses No attribution, the page is scrolled to the top
+ // of the disabled steps, i.e. step 2.
+ let stepToScroll = newId === 6 ? 2 : Math.min(newId, oldId)
+ if (newId === 6) {
+ stepToScroll = 2
+ }
+ await this.$nextTick()
+ this.$scrollTo(`.step-${stepToScroll}`)
}
},
+ mounted() {
+ this.$nextTick(() => {
+ window.addEventListener('resize', this.onResize)
+ })
+ },
+ beforeDestroy() {
+ window.removeEventListener('resize', this.onResize)
+ },
created: function() {
// send home to google analytics
if (process.env.NODE_ENV === 'production') {
@@ -113,13 +138,18 @@ export default {
this.showLicense = 0
},
done() {
- const scrollDuration = 800
- const shakeDuration = 3000
+ // Add 'shake' class that triggers animation to the 'LicenseUseCard',
+ // when 'Done' button is clicked, after the scroll has finished.
+ //
+ const scrollDuration = this.isBelowTabletWidth ? 3000 : 800
+ const shakeDuration = 3000 + scrollDuration
const comp = this
-
setTimeout(() => { comp.shouldShake = true }, scrollDuration)
setTimeout(() => { comp.shouldShake = false }, shakeDuration)
- this.$scrollTo(this.$refs.licenseUseCard.$el, 800)
+ this.$scrollTo(this.$refs.licenseUseCard.$el, scrollDuration)
+ },
+ onResize() {
+ this.windowWidth = window.innerWidth
}
}
}
@@ -144,7 +174,7 @@ export default {
@import '~buefy/src/scss/components/_form.scss';
@import '~buefy/src/scss/components/_icon.scss';
- @import "@creativecommons/vocabulary/scss/vocabulary.scss";
+ @import "~@creativecommons/vocabulary/scss/vocabulary.scss";
#app {
-webkit-font-smoothing: antialiased;
@@ -227,14 +257,12 @@ export default {
}
.appear-enter-active {
- transition: all .8s ease;
+ transition: opacity .8s ease;
}
.appear-leave-active {
- transition: all .3s cubic-bezier(1.0, 0.5, 0.8, 1.0);
+ transition: opacity .3s cubic-bezier(1.0, 0.5, 0.8, 1.0);
}
- .appear-enter, .appear-leave-to
- /* .appear-leave-active below version 2.1.8 */ {
- transform: translateY(-10px);
+ .appear-enter, .appear-leave-to {
opacity: 0;
}
From 924853878c262d5ab40e727e3d9dbbe98ec8620a Mon Sep 17 00:00:00 2001
From: Olga Bulat
Date: Thu, 17 Dec 2020 11:57:18 +0300
Subject: [PATCH 2/7] Add waits for scrolling to fix testing
---
tests/e2e/page-objects/chooser.js | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/tests/e2e/page-objects/chooser.js b/tests/e2e/page-objects/chooser.js
index 78530053c..7c2f03662 100644
--- a/tests/e2e/page-objects/chooser.js
+++ b/tests/e2e/page-objects/chooser.js
@@ -4,21 +4,23 @@
const stepperCommands = {
clickYes: function() {
- this.pause(500)
this.click('.radio-input[value="yes"]')
+ this.pause(500)
return this
},
clickNo: function() {
- this.pause(500)
this.click('.radio-input[value="no"]')
+ this.pause(500)
return this
},
clickNext: function() {
this.click('.next-button')
+ this.pause(500)
return this
},
clickPrevious: function() {
this.click('.previous-button')
+ this.pause(500)
return this
},
chooseNo: function() {
@@ -34,7 +36,7 @@ const stepperCommands = {
clickWaiver: function() {
this.click('.v-checkbox:first-child')
.click('.v-checkbox:last-child')
- .click('.next-button')
+ this.clickNext()
return this
},
selectFromDropdown: function(licenseName) {
@@ -43,6 +45,7 @@ const stepperCommands = {
.click('.license-dropdown')
.click(`.license-dropdown option[value="${licenseName}"]`)
.click('.next-button')
+ this.pause(500)
return this
},
assertStepName: function(stepName) {
From cff8dbcb2f8162f8b22f9f5ce2f8e4a0ebbdd6a0 Mon Sep 17 00:00:00 2001
From: Olga Bulat
Date: Thu, 17 Dec 2020 16:23:20 +0300
Subject: [PATCH 3/7] Add xmp download
---
src/App.vue | 3 +-
src/components/CopyTools.vue | 11 +++---
src/components/XmpButton.vue | 34 +++++++++++++++++++
src/utils/xmp.js | 66 ++++++++++++++++++++++++++++++++++++
4 files changed, 105 insertions(+), 9 deletions(-)
create mode 100644 src/components/XmpButton.vue
create mode 100644 src/utils/xmp.js
diff --git a/src/App.vue b/src/App.vue
index 32b3285b7..81b13c2cc 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -67,7 +67,6 @@
import HelpSection from './components/HelpSection'
import Stepper from './components/Stepper'
-import LicenseUseCard from './components/LicenseUseCard'
import HeaderSection from './components/HeaderSection'
import FooterSection from './components/FooterSection'
import LicenseDetailsCard from './components/LicenseDetailsCard'
@@ -78,7 +77,7 @@ export default {
HelpSection,
Stepper,
LicenseDetailsCard,
- LicenseUseCard,
+ LicenseUseCard: () => import('@/components/LicenseUseCard'),
HeaderSection,
FooterSection
},
diff --git a/src/components/CopyTools.vue b/src/components/CopyTools.vue
index 5773f0898..9ebc8a601 100644
--- a/src/components/CopyTools.vue
+++ b/src/components/CopyTools.vue
@@ -12,21 +12,18 @@
>
{{ copyLabel }}
-
- {{ xmpLabel }}
-
+
diff --git a/src/utils/xmp.js b/src/utils/xmp.js
new file mode 100644
index 000000000..3912362fb
--- /dev/null
+++ b/src/utils/xmp.js
@@ -0,0 +1,66 @@
+import { LICENSES, licenseSlug } from '@/utils/license-utilities'
+
+function minify(data) {
+ return data.replace(/ {2,}/gi, '').replace(/\n/gi, '')
+}
+
+export const createXMP = ({ shortName, workUrl = '', workTitle = '', creatorName = '', lang = 'en-US' }) => {
+ const slug = licenseSlug(shortName).replace(/-/gi, '_').toUpperCase()
+
+ const copyrighted = shortName !== LICENSES.CC0.SHORT
+ const xapRights = copyrighted
+ ? `
+ true`
+ : ''
+ const xapWorkUrl = workUrl
+ ? `
+`
+ : ''
+ const xapWorkTitle = workTitle
+ ? `
+
+${workTitle}${workTitle}`
+ : ''
+
+ const licenseUrl = LICENSES[slug].URL
+
+ const ccLicenseUrl = `
+`
+
+ const ccLicenseNotice = `
+This work is licensed under ${LICENSES[slug].FULL}`
+
+ const xapRightsUsageTerms = `
+
+${ccLicenseNotice}
+`
+
+ const xapWebStatement = workUrl
+ ? `
+
+`
+ : ''
+
+ const ccAttributionName = creatorName
+ ? `
+
+${creatorName}`
+ : ''
+ // eslint-disable-line quotes
+ const xmpData = `
+
+
+
+ ${xapRights}
+ ${xapWorkUrl}
+ ${xapWebStatement}
+ ${xapRightsUsageTerms}
+ ${xapWorkTitle}
+ ${ccLicenseUrl}
+ ${ccAttributionName}
+
+
+ `
+ // We return minified string to not increase the size of the licensed file
+ return minify(xmpData)
+}
From 6f09c179a352af6b2ea71887928a72ff3f46cf34 Mon Sep 17 00:00:00 2001
From: Olga Bulat
Date: Thu, 17 Dec 2020 22:03:55 +0300
Subject: [PATCH 4/7] Add Vocabulary Select implementation instead of buefy
select
---
src/App.vue | 3 +-
src/Vocabulary/VSelect.vue | 80 +++++++++++++++++++++++++++++++++
src/components/DropdownStep.vue | 36 +++++++--------
3 files changed, 97 insertions(+), 22 deletions(-)
create mode 100644 src/Vocabulary/VSelect.vue
diff --git a/src/App.vue b/src/App.vue
index 898e500c8..fa57a3652 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -140,11 +140,10 @@ export default {
@import "~bulma";
@import '~buefy/src/scss/utils/_variables.scss';
@import '~buefy/src/scss/components/_modal.scss';
- @import '~buefy/src/scss/components/_select.scss';
@import '~buefy/src/scss/components/_form.scss';
@import '~buefy/src/scss/components/_icon.scss';
- @import "@creativecommons/vocabulary/scss/vocabulary.scss";
+ @import "~@creativecommons/vocabulary/scss/vocabulary.scss";
#app {
-webkit-font-smoothing: antialiased;
diff --git a/src/Vocabulary/VSelect.vue b/src/Vocabulary/VSelect.vue
new file mode 100644
index 000000000..b93b4b5f1
--- /dev/null
+++ b/src/Vocabulary/VSelect.vue
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/DropdownStep.vue b/src/components/DropdownStep.vue
index 239919a85..bf8dd1e0d 100644
--- a/src/components/DropdownStep.vue
+++ b/src/components/DropdownStep.vue
@@ -1,33 +1,29 @@
-
-
+
-
-
+ {{ license }}
+
+
diff --git a/src/components/DropdownStep.vue b/src/components/DropdownStep.vue
index bf8dd1e0d..239919a85 100644
--- a/src/components/DropdownStep.vue
+++ b/src/components/DropdownStep.vue
@@ -1,29 +1,33 @@
-
-
-
+
+
+
import { mapGetters } from 'vuex'
-import VSelect from '@/Vocabulary/VSelect'
export default {
name: 'DropdownStep',
- components: { VSelect },
- inheritAttrs: false,
props: {
+ status: {
+ type: String,
+ validator(value) {
+ return ['active', 'previous', 'inactive'].includes(value)
+ }
+ },
id: Number
},
data() {
From 4f1f9c92bac4b940f9bdae19bd6de3c325233377 Mon Sep 17 00:00:00 2001
From: Olga Bulat
Date: Mon, 4 Jan 2021 20:46:39 +0300
Subject: [PATCH 6/7] Redo the xmp metadata file generation
---
src/utils/xmp.js | 158 +++++++++++++++++++++++++++++++----------------
1 file changed, 106 insertions(+), 52 deletions(-)
diff --git a/src/utils/xmp.js b/src/utils/xmp.js
index 3912362fb..5dfac9732 100644
--- a/src/utils/xmp.js
+++ b/src/utils/xmp.js
@@ -1,66 +1,120 @@
import { LICENSES, licenseSlug } from '@/utils/license-utilities'
-function minify(data) {
- return data.replace(/ {2,}/gi, '').replace(/\n/gi, '')
-}
+/** The xmp metadata is structured in accordance with the Adobe XMP specifications from 2012:
+https://wwwimages2.adobe.com/content/dam/acom/en/devnet/xmp/pdfs/XMP%20SDK%20Release%20cc-2016-08/XMPSpecificationPart1.pdf
+
+The following data is written into the xmp file:
+
+xapRights:WebStatement: A Web URL for a statement of the ownership and usage rights for this resource.
+ Uses the value of the 'Link to Work' field from the Attribution details form.
+xapRights:Marked: Indicates that this is a public-domain or CC0 resource if false. Otherwise, one of the 6 CC licenses.
+xapRights:Owner: A list of legal owners of the resource.
+ Uses the value of the 'Creator of Work' field from the Attribution details form.
+xapRights:UsageTerms: A collection of text instructions on how a resource can be legally used, given in a variety of languages.
+ Uses license statement with the link to the license deed, with '<>"' characters escaped.
+dc:title: A name or title given to the resource, by which it is formally known, given in various languages.
+ Uses the value of the 'Title of Work' field from the Attribution details form.
+cc:license: the link to the CC license deed.
+cc:attributionName
+ Uses the value of the 'Creator of Work' field from the Attribution details form.
+ */
+
+// To make the values of these variables human-readable, and format the resulting document correctly,
+// we use the backtick-formatted strings, but remove the '\n' character in the beginning of the values
+const XAP_WEB_STATEMENT = `
+`.slice(1)
+
+const XAP_MARKED = `
+{isCopyrightedTemplate}`.slice(1)
+
+const XAP_OWNER = `
+
+
+ {creatorNameTemplate}
+
+`.slice(1)
+
+const DC_WORK_TITLE_TEMPLATE = `
+
+
+ {workTitleTemplate}
+ {workTitleTemplate}
+
+`.slice(1)
+
+const CC_LICENSE_URL_TEMPLATE = `
+`.slice(1)
+
+const XAP_RIGHTS_USAGE_TERMS = `
+
+
+ {ccLicenseNoticeTemplate}
+ {ccLicenseNoticeTemplate}
+
+`.slice(1)
+
+const CC_ATTRIBUTION_NAME = `
+{creatorNameTemplate}`.slice(1)
+
+const LINE_START = ' '
+const addIndent = (str) => (str.replace(/\n/gi, '\n' + LINE_START))
export const createXMP = ({ shortName, workUrl = '', workTitle = '', creatorName = '', lang = 'en-US' }) => {
const slug = licenseSlug(shortName).replace(/-/gi, '_').toUpperCase()
- const copyrighted = shortName !== LICENSES.CC0.SHORT
- const xapRights = copyrighted
- ? `
- true`
- : ''
- const xapWorkUrl = workUrl
- ? `
-`
- : ''
- const xapWorkTitle = workTitle
- ? `
-
-${workTitle}${workTitle}`
- : ''
-
const licenseUrl = LICENSES[slug].URL
- const ccLicenseUrl = `
-`
+ const ccLicenseUrl = addIndent(CC_LICENSE_URL_TEMPLATE.replace('{licenseUrlTemplate}', licenseUrl))
- const ccLicenseNotice = `
-This work is licensed under ${LICENSES[slug].FULL}`
+ const ccLicenseNotice = `This work is licensed under ${LICENSES[slug].FULL}`
+ .replace(//gi, '>')
+ .replace(/"/gi, '"')
- const xapRightsUsageTerms = `
-
-${ccLicenseNotice}
-`
+ const xapData = {
+ owner: '',
+ webStatement: '',
+ marked: '',
+ rightsUsageTerms: addIndent(XAP_RIGHTS_USAGE_TERMS
+ .replace('{ccLicenseNoticeTemplate}', ccLicenseNotice)
+ .replace('{langTemplate}', lang))
+ }
- const xapWebStatement = workUrl
- ? `
-
-`
- : ''
+ const copyrighted = shortName !== LICENSES.CC0.SHORT ? 'True' : 'False'
+ xapData.marked = addIndent(XAP_MARKED
+ .replace('{isCopyrightedTemplate}', copyrighted))
- const ccAttributionName = creatorName
- ? `
-
-${creatorName}`
+ if (workUrl) {
+ xapData.webStatement = addIndent(XAP_WEB_STATEMENT
+ .replace('{workUrlTemplate}', workUrl))
+ }
+ const dcWorkTitle = workTitle
+ ? addIndent(DC_WORK_TITLE_TEMPLATE
+ .replace(/{workTitleTemplate}/gi, workTitle)
+ .replace('{langTemplate}', lang))
: ''
- // eslint-disable-line quotes
- const xmpData = `
-
-
-
- ${xapRights}
- ${xapWorkUrl}
- ${xapWebStatement}
- ${xapRightsUsageTerms}
- ${xapWorkTitle}
- ${ccLicenseUrl}
- ${ccAttributionName}
-
-
- `
- // We return minified string to not increase the size of the licensed file
- return minify(xmpData)
+ let ccAttributionName = ''
+ if (creatorName) {
+ ccAttributionName = addIndent(CC_ATTRIBUTION_NAME
+ .replace('{creatorNameTemplate}', creatorName))
+ xapData.owner = addIndent(XAP_OWNER.replace('{creatorNameTemplate}', creatorName))
+ }
+ return `
+
+
+
+
+ ${xapData.marked}
+ ${xapData.owner}
+ ${xapData.webStatement}
+ ${xapData.rightsUsageTerms}
+ ${ccLicenseUrl}
+ ${ccAttributionName}
+ ${dcWorkTitle}
+
+
+
+`.slice(1)
}
From c806ded2d7757d404366019562d6cf538d8fbfb3 Mon Sep 17 00:00:00 2001
From: Olga Bulat
Date: Tue, 12 Jan 2021 16:21:31 +0300
Subject: [PATCH 7/7] Refactor xmp generation
---
package-lock.json | 98 +++++++++++---------------------------
src/utils/xmp.js | 119 +++++++++++++++-------------------------------
2 files changed, 66 insertions(+), 151 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index f9bf77c0f..fa9ccba13 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -2508,6 +2508,17 @@
"unique-filename": "^1.1.1"
}
},
+ "chalk": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz",
+ "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==",
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "ansi-styles": "^4.1.0",
+ "supports-color": "^7.1.0"
+ }
+ },
"chownr": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz",
@@ -2685,6 +2696,18 @@
"webpack-sources": "^1.4.3"
}
},
+ "vue-loader-v16": {
+ "version": "npm:vue-loader@16.1.2",
+ "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.1.2.tgz",
+ "integrity": "sha512-8QTxh+Fd+HB6fiL52iEVLKqE9N1JSlMXLR92Ijm6g8PZrwIxckgpqjPDWRP5TWxdiPaHR+alUWsnu1ShQOwt+Q==",
+ "dev": true,
+ "optional": true,
+ "requires": {
+ "chalk": "^4.1.0",
+ "hash-sum": "^2.0.0",
+ "loader-utils": "^2.0.0"
+ }
+ },
"wrap-ansi": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
@@ -9705,7 +9728,8 @@
"interpret": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz",
- "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA=="
+ "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==",
+ "dev": true
},
"invariant": {
"version": "2.2.4",
@@ -14957,6 +14981,7 @@
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz",
"integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=",
+ "dev": true,
"requires": {
"resolve": "^1.1.6"
}
@@ -15742,6 +15767,7 @@
"version": "0.8.4",
"resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.4.tgz",
"integrity": "sha512-7gk3UZ9kOfPLIAbslLzyWeGiEqx9e3rxwZM0KE6EL8GlGwjym9Mrlx5/p33bWTu9YG6vcS4MBxYZDHYr5lr8BQ==",
+ "dev": true,
"requires": {
"glob": "^7.0.0",
"interpret": "^1.0.0",
@@ -15758,6 +15784,7 @@
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/shx/-/shx-0.3.3.tgz",
"integrity": "sha512-nZJ3HFWVoTSyyB+evEKjJ1STiixGztlqwKLTUNV5KqMWtGey9fTd4KU1gdZ1X9BV6215pswQ/Jew9NsuS/fNDA==",
+ "dev": true,
"requires": {
"minimist": "^1.2.3",
"shelljs": "^0.8.4"
@@ -17830,75 +17857,6 @@
}
}
},
- "vue-loader-v16": {
- "version": "npm:vue-loader@16.1.2",
- "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.1.2.tgz",
- "integrity": "sha512-8QTxh+Fd+HB6fiL52iEVLKqE9N1JSlMXLR92Ijm6g8PZrwIxckgpqjPDWRP5TWxdiPaHR+alUWsnu1ShQOwt+Q==",
- "dev": true,
- "optional": true,
- "requires": {
- "chalk": "^4.1.0",
- "hash-sum": "^2.0.0",
- "loader-utils": "^2.0.0"
- },
- "dependencies": {
- "ansi-styles": {
- "version": "4.3.0",
- "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
- "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
- "dev": true,
- "optional": true,
- "requires": {
- "color-convert": "^2.0.1"
- }
- },
- "chalk": {
- "version": "4.1.0",
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz",
- "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==",
- "dev": true,
- "optional": true,
- "requires": {
- "ansi-styles": "^4.1.0",
- "supports-color": "^7.1.0"
- }
- },
- "color-convert": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
- "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
- "dev": true,
- "optional": true,
- "requires": {
- "color-name": "~1.1.4"
- }
- },
- "color-name": {
- "version": "1.1.4",
- "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
- "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
- "dev": true,
- "optional": true
- },
- "has-flag": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
- "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
- "dev": true,
- "optional": true
- },
- "supports-color": {
- "version": "7.2.0",
- "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
- "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
- "dev": true,
- "optional": true,
- "requires": {
- "has-flag": "^4.0.0"
- }
- }
- }
- },
"vue-scrollto": {
"version": "2.20.0",
"resolved": "https://registry.npmjs.org/vue-scrollto/-/vue-scrollto-2.20.0.tgz",
diff --git a/src/utils/xmp.js b/src/utils/xmp.js
index 5dfac9732..3da0497a7 100644
--- a/src/utils/xmp.js
+++ b/src/utils/xmp.js
@@ -1,3 +1,4 @@
+/* eslint-disable indent, quotes */
import { LICENSES, licenseSlug } from '@/utils/license-utilities'
/** The xmp metadata is structured in accordance with the Adobe XMP specifications from 2012:
@@ -19,102 +20,58 @@ cc:attributionName
Uses the value of the 'Creator of Work' field from the Attribution details form.
*/
-// To make the values of these variables human-readable, and format the resulting document correctly,
-// we use the backtick-formatted strings, but remove the '\n' character in the beginning of the values
-const XAP_WEB_STATEMENT = `
-`.slice(1)
-
-const XAP_MARKED = `
-{isCopyrightedTemplate}`.slice(1)
-
-const XAP_OWNER = `
-
-
- {creatorNameTemplate}
-
-`.slice(1)
-
-const DC_WORK_TITLE_TEMPLATE = `
-
-
- {workTitleTemplate}
- {workTitleTemplate}
-
-`.slice(1)
-
-const CC_LICENSE_URL_TEMPLATE = `
-`.slice(1)
-
-const XAP_RIGHTS_USAGE_TERMS = `
-
-
- {ccLicenseNoticeTemplate}
- {ccLicenseNoticeTemplate}
-
-`.slice(1)
-
-const CC_ATTRIBUTION_NAME = `
-{creatorNameTemplate}`.slice(1)
-
-const LINE_START = ' '
-const addIndent = (str) => (str.replace(/\n/gi, '\n' + LINE_START))
-
export const createXMP = ({ shortName, workUrl = '', workTitle = '', creatorName = '', lang = 'en-US' }) => {
const slug = licenseSlug(shortName).replace(/-/gi, '_').toUpperCase()
const licenseUrl = LICENSES[slug].URL
+ const licenseFullName = LICENSES[slug].FULL
- const ccLicenseUrl = addIndent(CC_LICENSE_URL_TEMPLATE.replace('{licenseUrlTemplate}', licenseUrl))
-
- const ccLicenseNotice = `This work is licensed under ${LICENSES[slug].FULL}`
+ const ccLicenseNotice = `This work is licensed under ${licenseFullName}`
.replace(//gi, '>')
.replace(/"/gi, '"')
- const xapData = {
- owner: '',
- webStatement: '',
- marked: '',
- rightsUsageTerms: addIndent(XAP_RIGHTS_USAGE_TERMS
- .replace('{ccLicenseNoticeTemplate}', ccLicenseNotice)
- .replace('{langTemplate}', lang))
- }
-
- const copyrighted = shortName !== LICENSES.CC0.SHORT ? 'True' : 'False'
- xapData.marked = addIndent(XAP_MARKED
- .replace('{isCopyrightedTemplate}', copyrighted))
+ const isLicensed = shortName !== LICENSES.CC0.SHORT ? 'True' : 'False'
- if (workUrl) {
- xapData.webStatement = addIndent(XAP_WEB_STATEMENT
- .replace('{workUrlTemplate}', workUrl))
- }
- const dcWorkTitle = workTitle
- ? addIndent(DC_WORK_TITLE_TEMPLATE
- .replace(/{workTitleTemplate}/gi, workTitle)
- .replace('{langTemplate}', lang))
- : ''
- let ccAttributionName = ''
- if (creatorName) {
- ccAttributionName = addIndent(CC_ATTRIBUTION_NAME
- .replace('{creatorNameTemplate}', creatorName))
- xapData.owner = addIndent(XAP_OWNER.replace('{creatorNameTemplate}', creatorName))
- }
- return `
-
+ return (`
+ xmlns:cc='http://creativecommons.org/ns#'${workTitle
+ ? `xmlns:dc='http://purl.org/dc/elements/1.1/'`
+ : ''}>
- ${xapData.marked}
- ${xapData.owner}
- ${xapData.webStatement}
- ${xapData.rightsUsageTerms}
- ${ccLicenseUrl}
- ${ccAttributionName}
- ${dcWorkTitle}
+ ${`${isLicensed}`}${creatorName
+ ? `
+
+
+ ${creatorName}
+
+ `
+ : ''}${workUrl
+ ? `
+ `
+ : ''}
+
+
+ ${ccLicenseNotice}
+ ${ccLicenseNotice}
+
+
+ ${creatorName
+ ? `
+ ${creatorName}`
+ : ''}${workTitle
+ ? `
+
+
+ ${workTitle}
+ ${workTitle}
+
+ `
+ : ''}
-`.slice(1)
+`)
}