Skip to content

Commit b4a543f

Browse files
committed
Add license code references and functions
Signed-off-by: Olga Bulat <obulat@gmail.com>
1 parent e2622d1 commit b4a543f

File tree

4 files changed

+50
-5
lines changed

4 files changed

+50
-5
lines changed

src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import '@creativecommons/vocabulary/css/index.css'
3737
3838
import HelpSection from './components/HelpSection'
3939
import Stepper from './components/Stepper'
40-
import SelectedLicenseCard from './components/SelectedLicenseCard'
40+
import SelectedLicenseCard from './components/LicenseDetailsCard'
4141
import LicenseUseCard from './components/LicenseUseCard'
4242
import Header from './components/Header.vue'
4343
import Footer from './components/Footer'

src/components/SelectedLicenseCard.vue renamed to src/components/LicenseDetailsCard.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<span class="readable-string">
2222
<b v-if="item!=='zero'">{{item.toUpperCase()}}:</b>
2323
<b v-else>CC0:</b>
24-
{{$t(`selected-license.item-description.${item}`)}}
24+
{{$t(`license-details-card.item-description.${item}`)}}
2525
</span>
2626
</li>
2727
</transition-group>
@@ -35,7 +35,7 @@ import LicenseIcons from './LicenseIcons'
3535
import { mapGetters } from 'vuex'
3636
3737
export default {
38-
name: 'SelectedLicenseCard',
38+
name: 'LicenseDetailsCard',
3939
components: {
4040
LicenseIcons
4141
},
@@ -49,7 +49,7 @@ export default {
4949
return this.shortName.slice(0, this.shortName.length - 4)
5050
},
5151
licenseKey() {
52-
return `selected-license.full-description.${this.licenseSlug.toLowerCase().replace(' ', '-')}`
52+
return `license-details-card.full-description.${this.licenseSlug.toLowerCase().replace(' ', '-')}`
5353
}
5454
}
5555
}

src/components/LicenseUseCard.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@
2020

2121
<script>
2222
import SelectedLicenseCode from './SelectedLicenseCode'
23+
import LicenseCode from './LicenseCode'
2324
export default {
2425
name: 'LicenseUseCard',
2526
props: ['value'],
2627
components: {
28+
LicenseCode,
2729
SelectedLicenseCode
2830
}
2931
}

src/utils/license-utilities.js

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,47 @@ function licenseIconsArr(licenseAttributes) {
103103
return iconsArray
104104
}
105105

106-
export { defaultAttributes, CC0Attributes, CCBYAttributes, visibleSetters, disabledSetters, shortToAttr, attrToShort, attrToFull, licenseUrl, licenseSlug, licenseIconsArr }
106+
function generateHTML(attributionDetails, shortLicenseName) {
107+
const dataForHtmlGeneration = {
108+
htmlString: '',
109+
creator: '',
110+
workTitle: '',
111+
licenseIconsLink: ''
112+
}
113+
dataForHtmlGeneration.htmlString = '<p xmlns:dct="http://purl.org/dc/terms/"' +
114+
' xmlns:cc="http://creativecommons.org/ns#"' +
115+
' class="license-text">'
116+
const iconStyle = 'style="height:22px!important;margin-left: 3px;vertical-align:text-bottom;"'
117+
const baseAssetsPath = 'https://search.creativecommons.org/static/img'
118+
let licenseIcons = `<img ${iconStyle} src="${baseAssetsPath}/cc_icon.svg" />`
119+
if (shortLicenseName.includes('CC0')) {
120+
shortLicenseName = 'CC CC0 1.0'
121+
}
122+
licenseIcons += shortLicenseName.slice(3, shortLicenseName.length - 4).split('-').map(license =>
123+
`<img ${iconStyle} src="${baseAssetsPath}/cc-${license.toLowerCase()}_icon.svg" />`
124+
).join('')
125+
dataForHtmlGeneration.licenseIconsLink = `<a href="${licenseUrl(shortToAttr(shortLicenseName))}">${licenseIcons}</a>`
126+
127+
if (attributionDetails.creatorName) {
128+
const creatorSpan = `<span rel="cc:attributionName">${attributionDetails.creatorName}</span>`
129+
if (attributionDetails.creatorProfileUrl) {
130+
dataForHtmlGeneration.creator = `<a rel="cc:attributionURL" href="${attributionDetails.creatorProfileUrl}">${creatorSpan}</a>`
131+
} else {
132+
dataForHtmlGeneration.creator = creatorSpan
133+
}
134+
}
135+
if (attributionDetails.workTitle) {
136+
const workTitleSpan = `<span rel="dc:title">${attributionDetails.workTitle}</span>`
137+
if (attributionDetails.workUrl) {
138+
dataForHtmlGeneration.workTitle = `<a rel="cc:attributionURL" href="${attributionDetails.workUrl}">${workTitleSpan}</a>`
139+
} else {
140+
dataForHtmlGeneration.workTitle = workTitleSpan
141+
}
142+
}
143+
return dataForHtmlGeneration
144+
}
145+
export {
146+
defaultAttributes, CC0Attributes, CCBYAttributes, visibleSetters, disabledSetters,
147+
shortToAttr, attrToShort, attrToFull, licenseUrl, licenseSlug, licenseIconsArr,
148+
generateHTML
149+
}

0 commit comments

Comments
 (0)