-
-
Notifications
You must be signed in to change notification settings - Fork 167
.xmp
support in license attribution
#272
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
Changes from 3 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
824b831
Improve scrolling
obulat 9248538
Add waits for scrolling to fix testing
obulat cff8dbc
Add xmp download
obulat 6f09c17
Add Vocabulary Select implementation instead of buefy select
obulat 11b58a4
Revert "Add Vocabulary Select implementation instead of buefy select"
obulat aaafd9b
Merge branch 'master' of https://github.com/creativecommons/chooser i…
obulat d4d8f05
Merge branch 'master' of https://github.com/creativecommons/chooser i…
obulat 669a2ce
Merge branch 'master' into xmp_download
obulat 4f1f9c9
Redo the xmp metadata file generation
obulat 5716cf1
Merge branch 'master' into xmp_download
obulat c806ded
Refactor xmp generation
obulat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<template> | ||
<a | ||
ref="xmp" | ||
class="button donate small copy-button is-xmp" | ||
type="text/xml" | ||
:href="xmpHref" | ||
:download="xmpFilename" | ||
> | ||
{{ xmpLabel }} | ||
</a> | ||
</template> | ||
|
||
<script> | ||
import { createXMP } from '@/utils/xmp' | ||
import { mapGetters } from 'vuex' | ||
|
||
export default { | ||
name: 'XmpButton', | ||
computed: { | ||
...mapGetters(['shortName']), | ||
xmpLabel() { return this.$t('license-use.xmp-label') }, | ||
xmpFilename() { | ||
return `${this.shortName}.xmp` | ||
}, | ||
xmpHref() { | ||
const shortName = this.$store.getters.shortName | ||
const { workUrl, workTitle, creatorName } = this.$store.state.attributionDetails | ||
const xmp = createXMP({ shortName, workUrl, workTitle, creatorName }) | ||
const xmpBlob = new Blob([xmp], { type: 'text/xml;charset=utf-8' }) | ||
return URL.createObjectURL(xmpBlob) | ||
} | ||
} | ||
} | ||
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { LICENSES, licenseSlug } from '@/utils/license-utilities' | ||
|
||
function minify(data) { | ||
return data.replace(/ {2,}/gi, '').replace(/\n/gi, '') | ||
} | ||
|
||
export const createXMP = ({ shortName, workUrl = '', workTitle = '', creatorName = '', lang = 'en-US' }) => { | ||
const slug = licenseSlug(shortName).replace(/-/gi, '_').toUpperCase() | ||
|
||
const copyrighted = shortName !== LICENSES.CC0.SHORT | ||
const xapRights = copyrighted | ||
? `<rdf:Description rdf:about='' xmlns:xapRights='http://ns.adobe.com/xap/1.0/rights/'> | ||
<xapRights:Marked>true</xapRights:Marked></rdf:Description>` | ||
: '' | ||
const xapWorkUrl = workUrl | ||
? `<rdf:Description rdf:about='' xmlns:xapRights='http://ns.adobe.com/xap/1.0/rights/'> | ||
<xapRights:WebStatement rdf:resource='${workUrl}'/></rdf:Description>` | ||
: '' | ||
const xapWorkTitle = workTitle | ||
? ` | ||
<rdf:Description rdf:about='' xmlns:dc='http://purl.org/dc/elements/1.1/'><dc:title><rdf:Alt><rdf:li xml:lang='x-default'> | ||
${workTitle}</rdf:li><rdf:li xml:lang='${lang}'>${workTitle}</rdf:li></rdf:Alt></dc:title></rdf:Description>` | ||
: '' | ||
|
||
const licenseUrl = LICENSES[slug].URL | ||
|
||
const ccLicenseUrl = ` | ||
<rdf:Description rdf:about='' xmlns:cc='http://creativecommons.org/ns#'><cc:license rdf:resource='${licenseUrl}'/></rdf:Description>` | ||
|
||
const ccLicenseNotice = ` | ||
This work is licensed under <a rel="license noopener noreferrer" target="_blank" href="${licenseUrl}">${LICENSES[slug].FULL}</a>` | ||
obulat marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const xapRightsUsageTerms = ` | ||
<rdf:Description rdf:about='' xmlns:xapRights='http://ns.adobe.com/xap/1.0/rights/'> | ||
<xapRights:UsageTerms><rdf:Alt><rdf:li xml:lang='${lang}' >${ccLicenseNotice}</rdf:li></rdf:Alt> | ||
</xapRights:UsageTerms></rdf:Description>` | ||
|
||
const xapWebStatement = workUrl | ||
? ` | ||
<rdf:Description rdf:about='' xmlns:xapRights='http://ns.adobe.com/xap/1.0/rights/'> | ||
<xapRights:WebStatement rdf:resource='${workUrl}'/></rdf:Description>` | ||
: '' | ||
|
||
const ccAttributionName = creatorName | ||
? ` | ||
<rdf:Description rdf:about='' xmlns:cc='http://creativecommons.org/ns#'> | ||
<cc:attributionName>${creatorName}</cc:attributionName></rdf:Description>` | ||
: '' | ||
// eslint-disable-line quotes | ||
const xmpData = ` | ||
<?xpacket begin='' id=''?> | ||
<x:xmpmeta xmlns:x='adobe:ns:meta/'> | ||
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'> | ||
${xapRights} | ||
${xapWorkUrl} | ||
${xapWebStatement} | ||
${xapRightsUsageTerms} | ||
${xapWorkTitle} | ||
${ccLicenseUrl} | ||
${ccAttributionName} | ||
</rdf:RDF> | ||
</x:xmpmeta> | ||
<?xpacket end='r'?>` | ||
// We return minified string to not increase the size of the licensed file | ||
return minify(xmpData) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.