-
-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathHTMLGenerator.vue
220 lines (212 loc) · 9.18 KB
/
HTMLGenerator.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<template>
<div>
<b-collapse :open="true" aria-id="contentIdForA11y1">
<button
class="button is-primary is-fullwidth collapsible-button"
slot="trigger"
aria-controls="contentIdForA11y1">
<h3 class="title is-3">Have a Website?</h3>
</button>
<div class="content">
<span id="attribution-richtext-container">
<span id="attribution-richtext" class="photo_usage-attribution" ref="photoAttribution">
<a :href="workLocation"
v-if="workTitle && workLocation"
target="_blank"
rel="noopener">"{{ workTitle }}"
</a>
<a v-if="!workTitle && workLocation"
:href="workLocation">
This work
</a>
<p v-if="!workTitle && !workLocation">This work</p>
<p v-if="workTitle && !workLocation">{{ workTitle }}</p>
<span v-if="attributeToName">
by
<a v-if="attributeToURL"
:href="attributeToURL"
target="_blank"
rel="noopener">{{ attributeToName }}</a>
<span v-else>{{ attributeToName }}</span>
</span>
is licensed under
<a class="photo_license" :href="licenseURL" target="_blank" rel="noopener">
{{ shortLicenseName }}
</a>
</span>
<LicenseIcons
:url="licenseURL"
:iconsArr="iconsArr"/>
</span>
<CopyButton id="copy-richtext-btn"
el="#attribution-richtext"
title="Copy the attribution to paste into your blog or document">
Copy Rich Text
</CopyButton>
<div class="control" id="generated-html-container">
<textarea id="attribution-html"
class="textarea"
:value="attributionHTML()"
readonly>
</textarea>
</div>
<CopyButton id="copy-html-btn"
el="#attribution-html"
title="Copy the attribution to paste into your blog or document">
Copy HTML
</CopyButton>
<div id="generator-meta-inputs">
<b id="generator-meta-inputs-heading">
Filling out the boxes below is optional, but it adds more data
to the generated HTML and rich text above!
</b>
<div class="metadata-input-row">
<div class="columns">
<div class="column">
<b-field label="Title of Work">
<b-input
v-model="workTitle"
placeholder="workTitle">
</b-input>
</b-field>
<p class="help">The title of the work being licensed.</p>
</div>
<div class="column">
<b-field label="Work Location">
<b-input
v-model="workLocation"
placeholder="workLocation">
</b-input>
</b-field>
<p class="help">The URL where the work will be hosted or located.</p>
</div>
</div>
</div>
<div class="metadata-input-row">
<div class="columns">
<div class="column">
<b-field label="Attribute Work to URL">
<b-input
v-model="attributeToURL"
placeholder="attributeToURL"
></b-input>
</b-field>
<p class="help">The URL to which the work should be attributed.</p>
</div>
<div class="column">
<b-field label="Source Work URL">
<b-input
v-model="sourceWorkURL"
placeholder="sourceWorkURL"
></b-input>
</b-field>
<p class="help">The URL of the work upon which this work is based or derived.</p>
</div>
</div>
</div>
<div class="metadata-input-row">
<div class="columns">
<div class="column">
<b-field label="More Permissions URL">
<b-input
v-model="morePermsURL"
placeholder="morePermsURL"
></b-input>
</b-field>
<p class="help">A URL where a user can find information about obtaining rights that are not already permitted by the CC license.</p>
</div>
<div class="column">
<b-field label="Attribute Work to Name">
<b-input
v-model="attributeToName"
placeholder="attributeToName">
</b-input>
</b-field>
<p class="help">The name of the person who should receive attribution for the work.</p>
</div>
</div>
</div>
</div>
</div>
</b-collapse>
</div>
</template>
<script>
import CopyButton from './CopyButton'
import LicenseIcons from './LicenseIcons'
import LicenseIconography from '@creativecommons/vocabulary/vocabulary.common'
import attributionHtml from '@/utils/attributionHtml'
import licenseUrl from '@/utils/licenseUrl'
import shortNameToIconsArray from '@/utils/licenseUtils'
export default {
name: 'HTMLGenerator',
props: ['shortLicenseName'],
components: {
CopyButton,
LicenseIcons,
LicenseIconography
},
data() {
return {
workTitle: "",
attributeToName: "",
attributeToURL: "",
sourceWorkURL: "",
morePermsURL: "",
workLocation: ""
}
},
methods: {
attributionHTML() {
return attributionHtml({
workLocation: this.workLocation,
workTitle: this.workTitle,
attributeToName: this.attributeToName,
attributeToURL: this.attributeToURL,
},
this.licenseURL,
this.$props.shortLicenseName
);
}
},
computed: {
licenseURL() {
return licenseUrl(this.$props.shortLicenseName)
},
iconsArr() {
return this.$props.shortLicenseName.toLowerCase().slice(3, this.$props.shortLicenseName.length - 4).split('-')
}
}
}
</script>
<style scoped>
.collapsible-button {
height: 70px;
background-color: #ef9421 !important;
}
#generator-meta-inputs-heading {
margin-bottom: 1rem;
display: block;
}
b {
text-align: center;
}
.field {
margin-bottom: 0px;
}
#attribution-richtext-container {
margin-top: 1rem;
display: block;
}
#attribution-richtext-container .photo-license-icons {
vertical-align: middle;
margin-top: 0px;
margin-left: 2px;
}
#attribution-richtext p {
display: inline
}
#generated-html-container {
margin-top: 1.5rem
}
</style>