-
-
Notifications
You must be signed in to change notification settings - Fork 162
/
Copy pathLicenseHTML.vue
72 lines (65 loc) · 1.88 KB
/
LicenseHTML.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<template>
<div
id="attribution-html"
:aria-label="$t('license-use.html-label')"
class="textarea-html"
readonly
>
{{ htmlLicenseParagraph.replace(/ {2,}/g, ' ') }}
</div>
</template>
<script>
import { mapGetters, mapState } from 'vuex';
import { generateHTML, LICENSES } from '@/utils/license-utilities';
export default {
name: 'LicenseHTML',
computed: {
...mapGetters(['shortName', 'fullName', 'iconsList', 'licenseUrl']),
...mapState(['attributionDetails', 'attributionType']),
htmlLicenseParagraph() {
const useFullName = this.attributionType === 'full';
const { workTitle } = this.attributionDetails;
const isTitleDefault = !workTitle;
const attributionDetails = {
...this.attributionDetails,
workTitle: workTitle || this.$t('license-use.richtext.workTitle'),
};
const { work, creator, license } = generateHTML(
attributionDetails,
this.shortName,
useFullName,
isTitleDefault,
);
const licenseCodeSpan = this.$t('license-use.richtext.full-text', {
workTitle: work,
creator: creator,
license: license,
by: creator ? this.$t('license-use.richtext.by') : '',
licenseMark:
this.shortName === LICENSES.CC0.SHORT
? this.$t('license-use.richtext.marked-text')
: this.$t('license-use.richtext.licensed-text'),
});
const metadata = `xmlns:cc="http://creativecommons.org/ns#" ${
isTitleDefault ? '' : 'xmlns:dct="http://purl.org/dc/terms/"'
}`;
return `<p ${metadata}>${licenseCodeSpan}</p>`;
},
},
};
</script>
<style lang="scss" scoped>
.textarea-html {
height: 100px;
overflow-x: hidden;
word-break: break-all;
border: 0.125rem solid #d8d8d8;
border-radius: 4px;
font-size: 13px;
&:hover,
&:active,
&:focus {
border-color: #b0b0b0;
}
}
</style>