Skip to content

Commit 425298d

Browse files
committed
Add mode to license url generation to remove '?ref=ccchooser' from the link in print version
Signed-off-by: Olga Bulat <obulat@gmail.com>
1 parent 22335a2 commit 425298d

File tree

4 files changed

+12
-18
lines changed

4 files changed

+12
-18
lines changed

src/components/LicenseCode.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
{{$t(byString)}}
1919
</template>
2020
<template v-slot:licenseName>
21-
<a v-if="isWeb" :href="licenseUrl" target="_blank" rel="license noopener noreferrer"
21+
<a v-if="isWeb" :href="licenseUrl('web')" target="_blank" rel="license noopener noreferrer"
2222
style="display: inline-block;">{{shortName}}</a>
2323
<span v-else>{{shortName}}</span>
2424
<LicenseIcons
@@ -28,7 +28,7 @@
2828
</template>
2929
</i18n>
3030
<i18n path="license-use.richtext.print-instructions" tag="span" v-if="!isWeb">
31-
<template v-slot:linkToLicenseDeed>{{licenseUrl}}</template>
31+
<template v-slot:linkToLicenseDeed>{{licenseUrl('print')}}</template>
3232
</i18n>
3333
</p>
3434
</template>

src/components/LicenseDetailsCard.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<div class="selected-license-card">
33
<h3 class="vocab ha h3a">{{$t('license-details-card.heading')}}</h3>
44
<h4 class="vocab h4b hb">
5-
<a :href="licenseUrl" class="license-name">{{fullName}} ({{shortName}})
5+
<a :href="licenseUrl('web')" class="license-name">{{fullName}} ({{shortName}})
66
<LicenseIcons
7-
:url="licenseUrl"
7+
:url="licenseUrl('web')"
88
:iconsArr="iconsList"/>
99
</a>
1010
</h4>

src/store/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ export default new Vuex.Store({
3030
fullName: state => {
3131
return attrToFull(state.currentLicenseAttributes)
3232
},
33-
licenseUrl: state => {
34-
return licenseUrl(state.currentLicenseAttributes)
33+
licenseUrl: state => (mode) => {
34+
return licenseUrl(state.currentLicenseAttributes, mode)
3535
},
3636
iconsList: state => {
3737
return licenseIconsArr(state.currentLicenseAttributes)

src/utils/license-utilities.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,17 @@ function attrToFull(attr) {
6363
base += ' 4.0 International'
6464
return base
6565
}
66-
// function licenseUrl(shortLicenseName) {
67-
// Returns url to license from short license name with version number (eg. 'CC BY 4.0')
68-
// TODO: check how it works: it doesn't use '-' to join elements ?
69-
// if (shortLicenseName.includes('CC0')) {
70-
// return 'https://creativecommons.org/publicdomain/zero/1.0/?ref=ccchooser'
71-
// }
72-
// const short = shortLicenseName.toLowerCase().slice(3, shortLicenseName.length - 4)
73-
// return 'https://creativecommons.org/licenses/' + short + '/4.0/?ref=ccchooser'
74-
// }
75-
function licenseUrl(attr) {
66+
67+
function licenseUrl(attr, mode) {
7668
// Returns url to license from short license name with version number (eg. 'CC BY 4.0')
69+
// mode: web/ print (?ref=ccchooser is added to the end of the link if mode is web)
70+
const linkRef = mode === 'web' ? '/?ref=ccchooser' : ''
7771
if (attr.BY === false) {
78-
return 'https://creativecommons.org/publicdomain/zero/1.0/?ref=ccchooser'
72+
return `https://creativecommons.org/publicdomain/zero/1.0${linkRef}`
7973
}
8074
let short = attrToShort(attr).toLowerCase().slice(3)
8175
short = short.slice(0, short.length - 4)
82-
return 'https://creativecommons.org/licenses/' + short + '/4.0/?ref=ccchooser'
76+
return `https://creativecommons.org/licenses/${short}/4.0${linkRef}`
8377
}
8478

8579
function licenseSlug(shortLicenseName) {

0 commit comments

Comments
 (0)