Skip to content

Commit 0a1eedc

Browse files
authored
Merge pull request #328 from Cronus1007/isse-325
2 parents 1718445 + b380290 commit 0a1eedc

File tree

7 files changed

+56
-12
lines changed

7 files changed

+56
-12
lines changed

src/components/AttributionDetailsStep.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
:label="$t('stepper.AD.form.creator-profile.label')"
2525
:placeholder="$t('stepper.AD.form.creator-profile.placeholder')"
2626
/>
27+
<v-input
28+
v-if="currentLicenseAttributes.BY"
29+
v-model="yearOfCreation"
30+
:label="$t('stepper.AD.form.year-of-creation.label')"
31+
:placeholder="$t('stepper.AD.form.year-of-creation.placeholder')"
32+
/>
2733
</form>
2834
</div>
2935
</template>
@@ -44,7 +50,7 @@ export default {
4450
}
4551
},
4652
computed: {
47-
...mapState(['attributionDetails']),
53+
...mapState(['attributionDetails', 'currentLicenseAttributes']),
4854
creatorName: {
4955
get() { return this.attributionDetails.creatorName },
5056
set(newVal) {
@@ -68,10 +74,16 @@ export default {
6874
set(newVal) {
6975
this.setWorkUrl(newVal)
7076
}
77+
},
78+
yearOfCreation: {
79+
get() { return this.attributionDetails.yearOfCreation },
80+
set(newVal) {
81+
this.setYearOfCreation(newVal)
82+
}
7183
}
7284
},
7385
methods: {
74-
...mapMutations(['setCreatorName', 'setCreatorProfileUrl', 'setWorkTitle', 'setWorkUrl'])
86+
...mapMutations(['setCreatorName', 'setCreatorProfileUrl', 'setWorkTitle', 'setWorkUrl', 'setYearOfCreation'])
7587
}
7688
7789
}

src/components/LicenseText.vue

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
{{ workTitle }}
1515
</component>
1616
</template>
17+
<template #yearOfCreation>
18+
<component
19+
:is="'span'"
20+
>
21+
{{ yearOfCreation }}
22+
</component>
23+
</template>
1724
<template #creator>
1825
<component
1926
:is="isCreatorLink ? 'a' : 'span'"
@@ -105,9 +112,14 @@ export default {
105112
},
106113
workTitle() {
107114
return this.attributionDetails.workTitle
108-
? this.attributionDetails.workTitle
115+
? `${this.attributionDetails.workTitle}`
109116
: this.$t('license-use.richtext.workTitle')
110117
},
118+
yearOfCreation() {
119+
return this.attributionDetails.yearOfCreation
120+
? `© ${this.attributionDetails.yearOfCreation}`
121+
: ''
122+
},
111123
workUrl() {
112124
const { workUrl } = this.attributionDetails
113125
if (workUrl && !workUrl.startsWith('http')) {

src/locales/en.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@
8484
"work-url": {
8585
"label": "Link to Work",
8686
"placeholder": "https://janedoe.com/best-photo-ever.jpg"
87+
},
88+
"year-of-creation": {
89+
"label": "Year Of Creation",
90+
"placeholder": "YYYY"
8791
}
8892
}
8993
}
@@ -127,12 +131,13 @@
127131
"copy-label": "Copy",
128132
"copied-label": "Copied!",
129133
"richtext": {
130-
"full-text": "{workTitle}{by}{creator}{licenseMark} {license}{print-instructions}",
134+
"full-text": "{workTitle}{yearOfCreation}{by}{creator}{licenseMark} {license}{print-instructions}",
131135
"workTitle": "This work",
132136
"by": " by ",
133137
"licensed-text": " is licensed under",
134138
"marked-text": " is marked with",
135-
"print-instructions": ". To view a copy of this license, visit {linkToLicenseDeed}"
139+
"print-instructions": ". To view a copy of this license, visit {linkToLicenseDeed}",
140+
"yearOfCreation": ""
136141
},
137142
"print": {
138143
"label": " To view a copy of this license, visit {linkToLicenseDeed}"

src/store/index.js

Lines changed: 5 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
}
@@ -85,6 +86,9 @@ const createStore = (state) => {
8586
setWorkUrl(state, newName) {
8687
state.attributionDetails.workUrl = newName
8788
},
89+
setYearOfCreation(state, newName) {
90+
state.attributionDetails.yearOfCreation = newName
91+
},
8892
setAttributionType(state, attrType) {
8993
state.attributionType = attrType
9094
},

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

tests/unit/specs/components/AttributionDetailsStep.spec.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ describe('AttributionDetailsStep Component Rendering', () => {
2121
creatorProfileUrl: '',
2222
workTitle: '',
2323
workUrl: ''
24-
}
24+
},
25+
currentLicenseAttributes: {}
2526
}
2627
}
2728
}
@@ -51,7 +52,8 @@ describe('Store is updated when a user provides input', () => {
5152
creatorProfileUrl: '',
5253
workTitle: '',
5354
workUrl: ''
54-
}
55+
},
56+
currentLicenseAttributes: {}
5557
}
5658

5759
store = new Vuex.Store({

tests/unit/specs/components/LicenseText.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ describe('LicenseText.vue', () => {
7070

7171
it('has correct information all data are provided', async() => {
7272
await wrapper.vm.$store.commit('setCreatorName', TEST_DATA.creatorName)
73-
await wrapper.vm.$store.commit('setWorkTitle', TEST_DATA.workTitle)
73+
await wrapper.vm.$store.commit('setWorkTitle', `${TEST_DATA.workTitle}`)
7474
await wrapper.vm.$store.commit('setCreatorProfileUrl', TEST_DATA.creatorProfileUrl)
7575
await wrapper.vm.$store.commit('setWorkUrl', TEST_DATA.workUrl)
7676
const titleElement = wrapper.find('[property="dct:title"]')

0 commit comments

Comments
 (0)