Skip to content

Fix generated license html code metadata #181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/css/app.8904f2ba.css → docs/css/app.3dcf1942.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="Want to license your work with Creative Commons, but not sure where to start, or which license is right for you? Use our license chooser!"><link rel=icon href=/favicon.ico><link rel=icon type=image/png href=https://d15omoko64skxi.cloudfront.net/wp-content/uploads/2016/05/cc-site-icon-300x300.png sizes=192x192><link rel=apple-touch-icon-precomposed href=https://d15omoko64skxi.cloudfront.net/wp-content/uploads/2016/05/cc-site-icon-300x300.png><meta name=twitter:card content=summary><meta name=twitter:site content=@creativecommons><meta name=twitter:creator content=@creativecommons><meta property=og:url content=https://beta-chooser.creativecommons.org><meta property=og:title content="Choose a License"><meta property=og:type content=website><meta property=og:description content="Want to license your work with Creative Commons, but not sure where to start, or which license is right for you? Use our license chooser!"><meta property=og:image content=https://mirrors.creativecommons.org/presskit/logos/cc.logo.large.png><meta property=og:locale content=en_US><meta property=og:locale:alternate content=ru_RU><title>Choose a License</title><link href=/css/app.8904f2ba.css rel=preload as=style><link href=/js/app.80f3046a.js rel=preload as=script><link href=/js/chunk-vendors.d33edbf3.js rel=preload as=script><link href=/css/app.8904f2ba.css rel=stylesheet></head><body><noscript><strong>We're sorry but License Chooser doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/js/chunk-vendors.d33edbf3.js></script><script src=/js/app.80f3046a.js></script></body></html>
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="Want to license your work with Creative Commons, but not sure where to start, or which license is right for you? Use our license chooser!"><link rel=icon href=/favicon.ico><link rel=icon type=image/png href=https://d15omoko64skxi.cloudfront.net/wp-content/uploads/2016/05/cc-site-icon-300x300.png sizes=192x192><link rel=apple-touch-icon-precomposed href=https://d15omoko64skxi.cloudfront.net/wp-content/uploads/2016/05/cc-site-icon-300x300.png><meta name=twitter:card content=summary><meta name=twitter:site content=@creativecommons><meta name=twitter:creator content=@creativecommons><meta property=og:url content=https://beta-chooser.creativecommons.org><meta property=og:title content="Choose a License"><meta property=og:type content=website><meta property=og:description content="Want to license your work with Creative Commons, but not sure where to start, or which license is right for you? Use our license chooser!"><meta property=og:image content=https://mirrors.creativecommons.org/presskit/logos/cc.logo.large.png><meta property=og:locale content=en_US><meta property=og:locale:alternate content=ru_RU><title>Choose a License</title><link href=/css/app.3dcf1942.css rel=preload as=style><link href=/js/app.0c87ab38.js rel=preload as=script><link href=/js/chunk-vendors.d33edbf3.js rel=preload as=script><link href=/css/app.3dcf1942.css rel=stylesheet></head><body><noscript><strong>We're sorry but License Chooser doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/js/chunk-vendors.d33edbf3.js></script><script src=/js/app.0c87ab38.js></script></body></html>
2 changes: 2 additions & 0 deletions docs/js/app.0c87ab38.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/js/app.0c87ab38.js.map

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions docs/js/app.80f3046a.js

This file was deleted.

1 change: 0 additions & 1 deletion docs/js/app.80f3046a.js.map

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/LicenseCode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<template v-slot:licensed-text>
<span>{{ $t('license-use.richtext.licensed-text') }}</span>
</template>
<template v-slot:licenseName>
<template v-slot:license>
<a
v-if="isWeb"
:href="licenseUrl('web')"
Expand Down
7 changes: 4 additions & 3 deletions src/components/LicenseCopy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ export default {
const licenseCodeSpan = this.$i18n.t('license-use.richtext.full-text', {
workTitle: data.workTitle ? data.workTitle : this.$i18n.t('license-use.richtext.workTitle'),
creator: data.creator,
licenseName: this.shortName,
by: data.creator ? this.$i18n.t('license-use.richtext.by') : ''
license: data.licenseLink,
by: data.creator ? this.$i18n.t('license-use.richtext.by') : '',
'licensed-text': this.$i18n.t('license-use.richtext.licensed-text')
})
return `${data.htmlString}${licenseCodeSpan}${data.licenseIconsLink}</p>`
return `${data.htmlString}${licenseCodeSpan}</p>`
},
activeTab: {
get() { return this.currentTab },
Expand Down
2 changes: 1 addition & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
"copy-label": "Copy",
"copied-label": "Copied!",
"richtext": {
"full-text": "{workTitle} {by} {creator}{licensed-text}{licenseName}",
"full-text": "{workTitle} {by} {creator}{licensed-text}{license}",
"workTitle": "This work",
"by": "by",
"licensed-text": " is licensed under ",
Expand Down
45 changes: 25 additions & 20 deletions src/utils/license-utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,37 +119,42 @@ function generateHTML(attributionDetails, shortLicenseName) {
htmlString: '',
creator: '',
workTitle: '',
licenseIconsLink: ''
licenseLink: ''
}
dataForHtmlGeneration.htmlString = '<p xmlns:dct="http://purl.org/dc/terms/"' +
const { creatorName, creatorProfileUrl, workTitle, workUrl } = attributionDetails
dataForHtmlGeneration.htmlString =
'<p xmlns:dct="http://purl.org/dc/terms/"' +
' xmlns:cc="http://creativecommons.org/ns#"' +
' class="license-text">'
const iconStyle = 'style="height:22px!important;margin-left: 3px;vertical-align:text-bottom;"'
const baseAssetsPath = 'https://mirrors.creativecommons.org/presskit/icons'
const linkRef = '?ref=chooser-v1'
let licenseIcons = `<img ${iconStyle} src="${baseAssetsPath}/cc.svg/${linkRef}" />`
const iconStyle = 'style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"'
const assetPathBase = 'https://mirrors.creativecommons.org/presskit/icons'
const assetPathRef = '?ref=chooser-v1'
let licenseIcons = `<img ${iconStyle} src="${assetPathBase}/cc.svg${assetPathRef}" />`
if (shortLicenseName.includes('CC0')) {
shortLicenseName = 'CC CC0 1.0'
}
licenseIcons += shortLicenseName.slice(3, shortLicenseName.length - 4).split('-').map(license =>
`<img ${iconStyle} src="${baseAssetsPath}/${license.toLowerCase()}.svg/${linkRef}" />`
).join('')
dataForHtmlGeneration.licenseIconsLink = `<a href="${licenseUrl(shortToAttr(shortLicenseName))}">${licenseIcons}</a>`
licenseIcons += shortLicenseName
.slice(3, shortLicenseName.length - 4)
.split('-')
.map(attr => `<img ${iconStyle} src="${assetPathBase}/${attr.toLowerCase()}.svg${assetPathRef}" />`
).join('')
const licenseHref = licenseUrl(shortToAttr(shortLicenseName))
dataForHtmlGeneration.licenseLink =
`<a rel="license" href="${licenseHref}">${shortLicenseName}${licenseIcons}</a>`

if (attributionDetails.creatorName) {
const creatorSpan = `<span rel="cc:attributionName">${attributionDetails.creatorName}</span>`
if (attributionDetails.creatorProfileUrl) {
dataForHtmlGeneration.creator = `<a rel="cc:attributionURL" href="${attributionDetails.creatorProfileUrl}">${creatorSpan}</a>`
if (creatorName) {
if (creatorProfileUrl) {
dataForHtmlGeneration.creator =
`<a rel="cc:attributionURL dct:creator" property="cc:attributionName" href="${creatorProfileUrl}">${creatorName}</a>`
} else {
dataForHtmlGeneration.creator = creatorSpan
dataForHtmlGeneration.creator = `<span property="cc:attributionName">${creatorName}</span>`
}
}
if (attributionDetails.workTitle) {
const workTitleSpan = `<span rel="dct:title">${attributionDetails.workTitle}</span>`
if (attributionDetails.workUrl) {
dataForHtmlGeneration.workTitle = `<a rel="cc:attributionURL" href="${attributionDetails.workUrl}">${workTitleSpan}</a>`
if (workTitle) {
if (workUrl) {
dataForHtmlGeneration.workTitle = `<a rel="cc:attributionURL" property="dct:title" href="${workUrl}">${workTitle}</a>`
} else {
dataForHtmlGeneration.workTitle = workTitleSpan
dataForHtmlGeneration.workTitle = `<span rel="dct:title">${workTitle}</span>`
}
}
return dataForHtmlGeneration
Expand Down