Skip to content

Commit 40dcfa0

Browse files
authored
Fix generated license html code metadata (#181)
* Add rel="license" to license html * Fix html code generation * Build site
1 parent e0d79d6 commit 40dcfa0

File tree

10 files changed

+36
-30
lines changed

10 files changed

+36
-30
lines changed

docs/css/app.8904f2ba.css renamed to docs/css/app.3dcf1942.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +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>
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.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>

docs/js/app.0c87ab38.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/js/app.0c87ab38.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/js/app.80f3046a.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

docs/js/app.80f3046a.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/components/LicenseCode.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<template v-slot:licensed-text>
4949
<span>{{ $t('license-use.richtext.licensed-text') }}</span>
5050
</template>
51-
<template v-slot:licenseName>
51+
<template v-slot:license>
5252
<a
5353
v-if="isWeb"
5454
:href="licenseUrl('web')"

src/components/LicenseCopy.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,11 @@ export default {
8686
const licenseCodeSpan = this.$i18n.t('license-use.richtext.full-text', {
8787
workTitle: data.workTitle ? data.workTitle : this.$i18n.t('license-use.richtext.workTitle'),
8888
creator: data.creator,
89-
licenseName: this.shortName,
90-
by: data.creator ? this.$i18n.t('license-use.richtext.by') : ''
89+
license: data.licenseLink,
90+
by: data.creator ? this.$i18n.t('license-use.richtext.by') : '',
91+
'licensed-text': this.$i18n.t('license-use.richtext.licensed-text')
9192
})
92-
return `${data.htmlString}${licenseCodeSpan}${data.licenseIconsLink}</p>`
93+
return `${data.htmlString}${licenseCodeSpan}</p>`
9394
},
9495
activeTab: {
9596
get() { return this.currentTab },

src/locales/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
"copy-label": "Copy",
119119
"copied-label": "Copied!",
120120
"richtext": {
121-
"full-text": "{workTitle} {by} {creator}{licensed-text}{licenseName}",
121+
"full-text": "{workTitle} {by} {creator}{licensed-text}{license}",
122122
"workTitle": "This work",
123123
"by": "by",
124124
"licensed-text": " is licensed under ",

src/utils/license-utilities.js

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -119,37 +119,42 @@ function generateHTML(attributionDetails, shortLicenseName) {
119119
htmlString: '',
120120
creator: '',
121121
workTitle: '',
122-
licenseIconsLink: ''
122+
licenseLink: ''
123123
}
124-
dataForHtmlGeneration.htmlString = '<p xmlns:dct="http://purl.org/dc/terms/"' +
124+
const { creatorName, creatorProfileUrl, workTitle, workUrl } = attributionDetails
125+
dataForHtmlGeneration.htmlString =
126+
'<p xmlns:dct="http://purl.org/dc/terms/"' +
125127
' xmlns:cc="http://creativecommons.org/ns#"' +
126128
' class="license-text">'
127-
const iconStyle = 'style="height:22px!important;margin-left: 3px;vertical-align:text-bottom;"'
128-
const baseAssetsPath = 'https://mirrors.creativecommons.org/presskit/icons'
129-
const linkRef = '?ref=chooser-v1'
130-
let licenseIcons = `<img ${iconStyle} src="${baseAssetsPath}/cc.svg/${linkRef}" />`
129+
const iconStyle = 'style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"'
130+
const assetPathBase = 'https://mirrors.creativecommons.org/presskit/icons'
131+
const assetPathRef = '?ref=chooser-v1'
132+
let licenseIcons = `<img ${iconStyle} src="${assetPathBase}/cc.svg${assetPathRef}" />`
131133
if (shortLicenseName.includes('CC0')) {
132134
shortLicenseName = 'CC CC0 1.0'
133135
}
134-
licenseIcons += shortLicenseName.slice(3, shortLicenseName.length - 4).split('-').map(license =>
135-
`<img ${iconStyle} src="${baseAssetsPath}/${license.toLowerCase()}.svg/${linkRef}" />`
136-
).join('')
137-
dataForHtmlGeneration.licenseIconsLink = `<a href="${licenseUrl(shortToAttr(shortLicenseName))}">${licenseIcons}</a>`
136+
licenseIcons += shortLicenseName
137+
.slice(3, shortLicenseName.length - 4)
138+
.split('-')
139+
.map(attr => `<img ${iconStyle} src="${assetPathBase}/${attr.toLowerCase()}.svg${assetPathRef}" />`
140+
).join('')
141+
const licenseHref = licenseUrl(shortToAttr(shortLicenseName))
142+
dataForHtmlGeneration.licenseLink =
143+
`<a rel="license" href="${licenseHref}">${shortLicenseName}${licenseIcons}</a>`
138144

139-
if (attributionDetails.creatorName) {
140-
const creatorSpan = `<span rel="cc:attributionName">${attributionDetails.creatorName}</span>`
141-
if (attributionDetails.creatorProfileUrl) {
142-
dataForHtmlGeneration.creator = `<a rel="cc:attributionURL" href="${attributionDetails.creatorProfileUrl}">${creatorSpan}</a>`
145+
if (creatorName) {
146+
if (creatorProfileUrl) {
147+
dataForHtmlGeneration.creator =
148+
`<a rel="cc:attributionURL dct:creator" property="cc:attributionName" href="${creatorProfileUrl}">${creatorName}</a>`
143149
} else {
144-
dataForHtmlGeneration.creator = creatorSpan
150+
dataForHtmlGeneration.creator = `<span property="cc:attributionName">${creatorName}</span>`
145151
}
146152
}
147-
if (attributionDetails.workTitle) {
148-
const workTitleSpan = `<span rel="dct:title">${attributionDetails.workTitle}</span>`
149-
if (attributionDetails.workUrl) {
150-
dataForHtmlGeneration.workTitle = `<a rel="cc:attributionURL" href="${attributionDetails.workUrl}">${workTitleSpan}</a>`
153+
if (workTitle) {
154+
if (workUrl) {
155+
dataForHtmlGeneration.workTitle = `<a rel="cc:attributionURL" property="dct:title" href="${workUrl}">${workTitle}</a>`
151156
} else {
152-
dataForHtmlGeneration.workTitle = workTitleSpan
157+
dataForHtmlGeneration.workTitle = `<span rel="dct:title">${workTitle}</span>`
153158
}
154159
}
155160
return dataForHtmlGeneration

0 commit comments

Comments
 (0)