Skip to content

Commit 7c53ccb

Browse files
committed
Improvements
1 parent fe6ae02 commit 7c53ccb

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

src/components/LicenseText.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
</component>
1616
</template>
1717
<template #yearOfCreation>
18-
© {{ yearOfCreation }}
18+
<component
19+
:is="'span'"
20+
>
21+
{{ yearOfCreation }}
22+
</component>
1923
</template>
2024
<template #creator>
2125
<component
@@ -112,9 +116,10 @@ export default {
112116
: this.$t('license-use.richtext.workTitle')
113117
},
114118
yearOfCreation() {
119+
console.log(this.attributionDetails.yearOfCreation)
115120
return this.attributionDetails.yearOfCreation
116121
? this.attributionDetails.yearOfCreation
117-
: this.$t('license-use.richtext.yearOfCreation')
122+
: ''
118123
},
119124
workUrl() {
120125
const { workUrl } = this.attributionDetails

src/store/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ export const defaultState = {
1010
creatorName: '',
1111
creatorProfileUrl: '',
1212
workTitle: '',
13-
workUrl: ''
13+
workUrl: '',
14+
yearOfCreation: ''
1415
},
1516
attributionType: 'short'
1617
}

src/utils/license-utilities.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ function generateWorkCode(title, workUrl, isTitleDefault) {
198198
if (isTitleDefault && !workUrl) {
199199
return title
200200
}
201-
202201
const titleMeta = 'property="dct:title"'
203202
if (!workUrl) {
204203
return `<span ${titleMeta}>${title}</span>`
@@ -208,6 +207,15 @@ function generateWorkCode(title, workUrl, isTitleDefault) {
208207
return `<a ${isTitleDefault ? '' : titleMeta} rel="cc:attributionURL" href="${absoluteUrl}">${title}</a>`
209208
}
210209

210+
/**
211+
* Generates the HTML for the rich text Year of Creation , including the year of Creation
212+
* @param {number} yearOfCreation
213+
* @returns {string}
214+
*/
215+
function generateYearOfCreation(yearOfCreation) {
216+
const yearMeta = 'property="dct:title"'
217+
return `<span ${yearMeta}> © ${yearOfCreation}</span>`
218+
}
211219
/**
212220
* Generates the html for the rich text license information, including license name,
213221
* link to the license deed, and license icons
@@ -235,11 +243,11 @@ function generateLicenseLink(licenseIcons, licenseUrl, licenseName) {
235243
* @param {ShortLicenseName} shortLicenseName
236244
* @param {Boolean} useFullName - Should the license name be full (short by default)
237245
* @param {Boolean} isTitleDefault
238-
* @returns {{creator: string, work: string, license: string}}
246+
* @returns {{creator: string, work: string, license: string, year: string}}
239247
*/
240248
function generateHTML(attributionDetails, shortLicenseName, useFullName = false, isTitleDefault = true) {
241249
const data = {}
242-
const { creatorName, creatorProfileUrl, workUrl, workTitle } = attributionDetails
250+
const { creatorName, creatorProfileUrl, workUrl, workTitle, yearOfCreation } = attributionDetails
243251

244252
const licenseSlug = slugFromShort(shortLicenseName)
245253
const { ICONS: icons, URL: url, FULL: fullLicenseName } = LICENSES[licenseSlug]
@@ -248,6 +256,7 @@ function generateHTML(attributionDetails, shortLicenseName, useFullName = false,
248256
data.license = generateLicenseLink(icons, url, licenseName)
249257
data.creator = generateCreatorCode(creatorName, creatorProfileUrl)
250258
data.work = generateWorkCode(workTitle, workUrl, isTitleDefault)
259+
data.year = generateYearOfCreation(yearOfCreation)
251260
return data
252261
}
253262

0 commit comments

Comments
 (0)