@ucd-lib/theme-elements 0.0.15 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +5 -1
- package/brand/ucd-theme-author-profile/ucd-theme-author-profile.js +214 -0
- package/brand/ucd-theme-author-profile/ucd-theme-author-profile.tpl.js +193 -0
- package/brand/ucd-theme-subnav/ucd-theme-subnav.js +0 -1
- package/package.json +5 -1
- package/ucdlib/ucdlib-md/ucdlib-md-content.js +31 -0
- package/ucdlib/ucdlib-md/ucdlib-md.js +120 -0
- package/ucdlib/ucdlib-sils-permalink/README.md +22 -0
- package/ucdlib/ucdlib-sils-permalink/ucdlib-sils-permalink-controller.js +36 -0
- package/ucdlib/ucdlib-sils-permalink/ucdlib-sils-permalink.js +324 -0
- package/ucdlib/ucdlib-sils-permalink/ucdlib-sils-permalink.tpl.js +337 -0
- package/utils/controllers/task.js +36 -0
- package/utils/ip-check.js +133 -0
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import { LitElement} from 'lit';
|
|
2
|
+
import {render, styles} from "./ucdlib-sils-permalink.tpl.js";
|
|
3
|
+
import {PermalinkController} from './ucdlib-sils-permalink-controller.js';
|
|
4
|
+
import {TaskController} from '../../utils/controllers/task.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @class UcdlibSilsPermalink
|
|
8
|
+
* @description This component allows you to easily add individual objects from
|
|
9
|
+
* the UC SILS catalog into your webpage.
|
|
10
|
+
* @property {String} href - Pointer to the permalink
|
|
11
|
+
* @property {String} cite - Specify the citation style
|
|
12
|
+
*
|
|
13
|
+
* <ucdlib-sils-permalink href="https://search.library.ucdavis.edu/permalink/01UCD_INST/1uov27j/alma9981249369903126"/>
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export default class UcdlibSilsPermalink extends LitElement {
|
|
17
|
+
static get properties() {
|
|
18
|
+
return {
|
|
19
|
+
results : {type: Object, attribute:false},
|
|
20
|
+
permalink : {type: String},
|
|
21
|
+
image : {type: String},
|
|
22
|
+
title : {type: String},
|
|
23
|
+
authorFull : {type: String},
|
|
24
|
+
authorLast : {type: String, attribute:false},
|
|
25
|
+
authorFirst: {type: String, attribute:false},
|
|
26
|
+
authorID: {type: Array, attribute:false},
|
|
27
|
+
year : { type: String},
|
|
28
|
+
summary : {type: String},
|
|
29
|
+
tags : {type: Array},
|
|
30
|
+
host_url : {type: String},
|
|
31
|
+
teaserType : {type: String, attribute:false},
|
|
32
|
+
publisher : {type: String, attribute:false},
|
|
33
|
+
placePublication : {type: String, attribute:false},
|
|
34
|
+
notes : {type: Array, attribute:false},
|
|
35
|
+
language: {type: String, attribute:false},
|
|
36
|
+
randomClass: {type: String, attribute:false},
|
|
37
|
+
elemClass: {type: Array, attribute:false},
|
|
38
|
+
url: {type: String, attribute:false},
|
|
39
|
+
form: {type: Boolean, attribute:false},
|
|
40
|
+
isCustom: {type:Boolean},
|
|
41
|
+
index: {type:Number},
|
|
42
|
+
newPermalink: {type: Array, hasChanged(newVal, oldVal) {
|
|
43
|
+
return newVal !== oldVal;
|
|
44
|
+
}, attribute:false},
|
|
45
|
+
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static get styles() {
|
|
50
|
+
return styles();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
constructor() {
|
|
54
|
+
super();
|
|
55
|
+
this.PENDING = false;
|
|
56
|
+
this.LOADING = false;
|
|
57
|
+
this.COMPLETE = false;
|
|
58
|
+
this.ERROR = false;
|
|
59
|
+
this.results = {};
|
|
60
|
+
this.loading = false;
|
|
61
|
+
this.resultsPerPage = 9999;
|
|
62
|
+
this.page = 1;
|
|
63
|
+
this.permalink = '';
|
|
64
|
+
this.authorLast = '';
|
|
65
|
+
this.authorFirst = '';
|
|
66
|
+
this.authorFull = '';
|
|
67
|
+
this.title = '';
|
|
68
|
+
this.year = '';
|
|
69
|
+
this.summary= '';
|
|
70
|
+
this.host_url= '';
|
|
71
|
+
this.tags = [];
|
|
72
|
+
this.authorID = [];
|
|
73
|
+
this.teaserType = '';
|
|
74
|
+
this.publisher = '';
|
|
75
|
+
this.placePublication = '';
|
|
76
|
+
this.notes = [];
|
|
77
|
+
this.language = '';
|
|
78
|
+
this.randomClass = '';
|
|
79
|
+
this.elemClass = ['tahoe', 'california', 'quad'];
|
|
80
|
+
this.image = '';
|
|
81
|
+
this.url = '';
|
|
82
|
+
this.isCustom = false;
|
|
83
|
+
this.newPermalink = [];
|
|
84
|
+
this.form = false;
|
|
85
|
+
this.index = 0;
|
|
86
|
+
this.tagEntryField = [{url: '', label: '', default: true}];
|
|
87
|
+
this.authorEntryField = [{value: '', default: true}];
|
|
88
|
+
this.errorMessage = 'Href is not a permalink.';
|
|
89
|
+
this.render=render.bind(this);
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @method firstUpdated
|
|
95
|
+
*
|
|
96
|
+
* @description updated when the page first renders
|
|
97
|
+
*
|
|
98
|
+
* @param {Object} changedProperties
|
|
99
|
+
*
|
|
100
|
+
*/
|
|
101
|
+
firstUpdated(changedProperties){
|
|
102
|
+
if(this.permalink != ''){
|
|
103
|
+
this.perma = new TaskController(this, this._requestUrl());
|
|
104
|
+
|
|
105
|
+
this.requestUpdate();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
validationLink(url){
|
|
114
|
+
// let match = url.match(/([^\/]+)([a-z0-9]+)$/g);
|
|
115
|
+
|
|
116
|
+
// let id = url.includes("/9fle3i/") ? 'L' : url.includes("/1hjlc2p/") ? 'PC' : 'Error';
|
|
117
|
+
// if(url.match(/https:\/\/search.library.ucdavis.edu\/permalink\/01UCD_INST\/([^\/]+)\/([a-zA-Z0-9_]*)/g)){
|
|
118
|
+
// url = 'https://search.library.ucdavis.edu/primaws/rest/pub/pnxs/' + id + '/' + match[0] +'?vid=01UCD_INST:UCD&lang=en&search_scope=DN_and_CI';
|
|
119
|
+
// return url;
|
|
120
|
+
// }
|
|
121
|
+
let id;
|
|
122
|
+
if(url != "") id = url.split("/alma")[1];
|
|
123
|
+
|
|
124
|
+
url = "https://open-na.hosted.exlibrisgroup.com/alma/01UCD_INST/bibs/" + id;
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
return url;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
_onPending(){
|
|
131
|
+
this.PENDING = true;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
_onError(e){
|
|
136
|
+
this.ERROR = true;
|
|
137
|
+
console.log("Error:", e);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
handleEdit() {
|
|
141
|
+
this.form = true;
|
|
142
|
+
|
|
143
|
+
this.requestUpdate();
|
|
144
|
+
|
|
145
|
+
}
|
|
146
|
+
handleDelete(){
|
|
147
|
+
let tempDelete = JSON.parse(sessionStorage.getItem("newPermalink"));
|
|
148
|
+
|
|
149
|
+
delete tempDelete[this.index];
|
|
150
|
+
tempDelete = Object.fromEntries(Object.entries(tempDelete).filter(([_, v]) => v != null));
|
|
151
|
+
|
|
152
|
+
this.requestUpdate;
|
|
153
|
+
sessionStorage.setItem("newPermalink", JSON.stringify(tempDelete));
|
|
154
|
+
location.reload();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* @method _addTag
|
|
160
|
+
*
|
|
161
|
+
* @description Bound to click event on website add button. adds another
|
|
162
|
+
* iteration of the element to the DOM and List
|
|
163
|
+
*
|
|
164
|
+
* @param {Object} element
|
|
165
|
+
*
|
|
166
|
+
*/
|
|
167
|
+
_addTag(){
|
|
168
|
+
this.tagEntryField.push({url: '', label: '', default: false});
|
|
169
|
+
this.requestUpdate();
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* @method _addAuthor
|
|
174
|
+
*
|
|
175
|
+
* @description Bound to click event of add email button.
|
|
176
|
+
* adds another iteration of the element to the DOM and List
|
|
177
|
+
*
|
|
178
|
+
* @param {Object} element
|
|
179
|
+
*
|
|
180
|
+
*/
|
|
181
|
+
_addAuthor(){
|
|
182
|
+
this.authorEntryField.push({value: '', default: false});
|
|
183
|
+
this.requestUpdate();
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* @method _sendValues
|
|
188
|
+
*
|
|
189
|
+
* @description Get the values from the form that is given.
|
|
190
|
+
*
|
|
191
|
+
* @param {Object} element
|
|
192
|
+
*
|
|
193
|
+
*/
|
|
194
|
+
_sendValues(){
|
|
195
|
+
let formData = {};
|
|
196
|
+
let authorList = [];
|
|
197
|
+
let tagtitle = [];
|
|
198
|
+
let url = [];
|
|
199
|
+
let image = [];
|
|
200
|
+
let tags = [];
|
|
201
|
+
|
|
202
|
+
formData.title = this.shadowRoot.getElementById("permalink-title").value;
|
|
203
|
+
formData.year = this.shadowRoot.getElementById("permalink-date").value;
|
|
204
|
+
formData.summary = this.shadowRoot.getElementById("permalink-summary").value;
|
|
205
|
+
formData.image = this.shadowRoot.getElementById("permalink-image").value;
|
|
206
|
+
formData.permalink = this.shadowRoot.getElementById("permalink-permalink").value;
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
for(let i of this.shadowRoot.querySelectorAll("[id^='permalink-author']").values()){
|
|
210
|
+
authorList.push({"label" : i.value});
|
|
211
|
+
}
|
|
212
|
+
formData.author = authorList;
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
for(let i of this.shadowRoot.querySelectorAll("[id^='permalink-image']").values())
|
|
216
|
+
image.push(i.value);
|
|
217
|
+
formData.image = image[0];
|
|
218
|
+
|
|
219
|
+
for(let i of this.shadowRoot.querySelectorAll("[id^='permalink-tags ']").values())
|
|
220
|
+
tagtitle.push(i.value);
|
|
221
|
+
|
|
222
|
+
for(let i of this.shadowRoot.querySelectorAll("[id^='permalink-tags-url']").values())
|
|
223
|
+
url.push(i.value);
|
|
224
|
+
|
|
225
|
+
for(let i in tagtitle)
|
|
226
|
+
tags[i] = {"@id": url[i], "label": tagtitle[i]};
|
|
227
|
+
formData.tags = tags;
|
|
228
|
+
|
|
229
|
+
if(sessionStorage.getItem("newPermalink")){
|
|
230
|
+
this.newPermalink = JSON.parse(sessionStorage.getItem("newPermalink"));
|
|
231
|
+
this.newPermalink = Object.values(this.newPermalink);
|
|
232
|
+
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
this.newPermalink.push(formData);
|
|
236
|
+
|
|
237
|
+
this.form = false;
|
|
238
|
+
|
|
239
|
+
this.requestUpdate;
|
|
240
|
+
sessionStorage.setItem("newPermalink", JSON.stringify(this.newPermalink));
|
|
241
|
+
location.reload();
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
getCreatedPermalink(){
|
|
247
|
+
super.requestUpdate();
|
|
248
|
+
|
|
249
|
+
return this.newPermalink;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
_onComplete(results){
|
|
254
|
+
|
|
255
|
+
/* Note:
|
|
256
|
+
ISBN has multiple options so later address which items to pick and whether
|
|
257
|
+
to use default thumbnail
|
|
258
|
+
*/
|
|
259
|
+
|
|
260
|
+
this.COMPLETE = true;
|
|
261
|
+
this.PENDING = false;
|
|
262
|
+
this.LOADING = false;
|
|
263
|
+
this.results = results;
|
|
264
|
+
this.teaserType = this.results["@type"];
|
|
265
|
+
let img = [];
|
|
266
|
+
for(let i = 0; i < this.results.identifier.length; i++){
|
|
267
|
+
if(this.results.identifier[i]['@type']){
|
|
268
|
+
if(this.results.identifier[i]['@type'].includes('bibo:isbn'))
|
|
269
|
+
img = img.concat(this.results.identifier[i].label);
|
|
270
|
+
if(this.results.identifier[i]['@type'].includes('bibo:ean'))
|
|
271
|
+
img = img.concat(this.results.identifier[i].label);
|
|
272
|
+
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
}
|
|
276
|
+
let identifer = img[0];
|
|
277
|
+
|
|
278
|
+
if(this.teaserType == 'Video' || this.teaserType == 'Music'){
|
|
279
|
+
this.image = 'https://syndetics.com/index.php?client=primo&isbn='+ identifer + '/sc.gif';
|
|
280
|
+
}
|
|
281
|
+
else{
|
|
282
|
+
this.image = 'https://syndetics.com/index.php?client=primo&isbn='+ identifer + '/sc.jpg';
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
this.year = this.results.date;
|
|
286
|
+
this.title = this.results.title.substring(0, this.results.title.lastIndexOf("/"));
|
|
287
|
+
this.authorFull = !Array.isArray(this.results.creator) ? [this.results.creator] : this.results.creator;
|
|
288
|
+
|
|
289
|
+
this.authorLast = this.authorFull[0];
|
|
290
|
+
this.authorFirst = this.authorFull[1];
|
|
291
|
+
this.summary = this.results.description;
|
|
292
|
+
this.publisher = this.results.publisher;
|
|
293
|
+
this.placePublication = this.results.place_of_publication.split(' ')[0];
|
|
294
|
+
this.language = this.results.language;
|
|
295
|
+
|
|
296
|
+
for (let i = 0; i < Object.keys(this.results.subject).length; i++){
|
|
297
|
+
this.tags = this.tags.concat({"id": this.results.subject[i]["@id"], "subject": this.results.subject[i]["label"]});
|
|
298
|
+
}
|
|
299
|
+
this.tags = this.results.subject;
|
|
300
|
+
|
|
301
|
+
this.notes = this.results.note;
|
|
302
|
+
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
_requestUrl(){
|
|
307
|
+
let url =this.permalink;
|
|
308
|
+
let validate = this.validationLink(url);
|
|
309
|
+
if(validate == this.errorMessage) console.error(url);
|
|
310
|
+
this.requestUpdate();
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
url = validate;
|
|
314
|
+
return url;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
_onLoading(){
|
|
318
|
+
this.LOADING = true;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
customElements.define('ucdlib-sils-permalink',UcdlibSilsPermalink);
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import { html, css } from 'lit';
|
|
2
|
+
|
|
3
|
+
import normalizeCss from "@ucd-lib/theme-sass/normalize.css.js";
|
|
4
|
+
import teaserStyles from "@ucd-lib/theme-sass/4_component/_index.css.js";
|
|
5
|
+
import baseStyles from "@ucd-lib/theme-sass/1_base_html/_index.css.js";
|
|
6
|
+
import buttons from "@ucd-lib/theme-sass/2_base_class/_index.css.js";
|
|
7
|
+
export function styles() {
|
|
8
|
+
const elementStyles = css`
|
|
9
|
+
:host {
|
|
10
|
+
display: block;
|
|
11
|
+
}
|
|
12
|
+
form {
|
|
13
|
+
width:100%;
|
|
14
|
+
}
|
|
15
|
+
#tag {
|
|
16
|
+
width:75%;
|
|
17
|
+
display: inline-block;
|
|
18
|
+
}
|
|
19
|
+
#tag-color {
|
|
20
|
+
width:24%;
|
|
21
|
+
display: inline-block;
|
|
22
|
+
}
|
|
23
|
+
#delete {
|
|
24
|
+
width:24%;
|
|
25
|
+
display: inline-block;
|
|
26
|
+
}
|
|
27
|
+
#permalink-author {
|
|
28
|
+
width:75%;
|
|
29
|
+
display: inline-block;
|
|
30
|
+
}
|
|
31
|
+
#permalink-tags {
|
|
32
|
+
width:75%;
|
|
33
|
+
display: inline-block;
|
|
34
|
+
}
|
|
35
|
+
#permalink-tags-url {
|
|
36
|
+
width:75%;
|
|
37
|
+
display: inline-block;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
`;
|
|
42
|
+
|
|
43
|
+
return [elementStyles,baseStyles,teaserStyles,normalizeCss, buttons];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function render() {
|
|
47
|
+
return html`
|
|
48
|
+
<style>
|
|
49
|
+
.vm-teaser__figure.category_loading{
|
|
50
|
+
background-color:#dcdcdc;
|
|
51
|
+
height:165px;
|
|
52
|
+
width:135px;
|
|
53
|
+
}
|
|
54
|
+
.load_teaser_a{
|
|
55
|
+
background-color:#dcdcdc;
|
|
56
|
+
width: 85%;
|
|
57
|
+
height:25px;
|
|
58
|
+
}
|
|
59
|
+
.load_teaser_b{
|
|
60
|
+
background-color:#dcdcdc;
|
|
61
|
+
width: 67%;
|
|
62
|
+
height:20px;
|
|
63
|
+
}
|
|
64
|
+
.load_teaser_c{
|
|
65
|
+
background-color:#dcdcdc;
|
|
66
|
+
width: 33.3%;
|
|
67
|
+
height:18px;
|
|
68
|
+
}
|
|
69
|
+
</style>
|
|
70
|
+
<!--
|
|
71
|
+
Starts the Permalink Fetch
|
|
72
|
+
-->
|
|
73
|
+
${this.perma ? html`
|
|
74
|
+
${this.perma.render({
|
|
75
|
+
complete: (result) => this._onComplete(result),
|
|
76
|
+
initial: () => this._onLoading(),
|
|
77
|
+
pending: () => this._onPending(),
|
|
78
|
+
error: (e) => this._onError(e)
|
|
79
|
+
})
|
|
80
|
+
}`:html``
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
<article class="vm-teaser ">
|
|
84
|
+
${!this.LOADING ? html`
|
|
85
|
+
<!--
|
|
86
|
+
If it is completed permalink fetch
|
|
87
|
+
-->
|
|
88
|
+
${!this.form ?
|
|
89
|
+
|
|
90
|
+
html`
|
|
91
|
+
<!--
|
|
92
|
+
This is the original permalink read that fires if there is are
|
|
93
|
+
attributes added to the permalink. If the form is not triggered
|
|
94
|
+
-->
|
|
95
|
+
|
|
96
|
+
<div class="vm-teaser__figure category">
|
|
97
|
+
<a href="${this.image}"><img src="${this.image}" alt="" class="" width="135" loading="eager" />
|
|
98
|
+
</a>
|
|
99
|
+
</div>
|
|
100
|
+
<div class="vm-teaser__body">
|
|
101
|
+
<h3 class="vm-teaser__title"><a href="${this.host_url ? this.host_url : this.permalink}">${this.title}</a></h3>
|
|
102
|
+
|
|
103
|
+
<ul class="vm-teaser__byline">
|
|
104
|
+
<li>
|
|
105
|
+
|
|
106
|
+
${this.authorFull ?
|
|
107
|
+
typeof this.authorFull === 'string' || this.authorFull instanceof String ?
|
|
108
|
+
JSON.parse(this.authorFull).map(author => author["label"] != "" ? html`<span class="byline"> ${author["label"]}.</span>--<br />` : html``)
|
|
109
|
+
:this.authorFull.map(author => author["label"] != "" ? html`<span class="byline"> ${author["label"]}.</span>--<br />` : html``)
|
|
110
|
+
:html``
|
|
111
|
+
}
|
|
112
|
+
</li>
|
|
113
|
+
<li>${this.year}</li>
|
|
114
|
+
</ul>
|
|
115
|
+
<ul class="vm-teaser__categories">
|
|
116
|
+
${this.tags ?
|
|
117
|
+
typeof this.tags === 'string' || this.tags instanceof String ?
|
|
118
|
+
JSON.parse(this.tags).map(tag => html`<li class="vm-teaser__cat-marker tahoe"><a href="${tag['@id']}">${tag['label']}</a></li>`)
|
|
119
|
+
:this.tags.map(tag => tag["label"] != "" ? html`<li class="vm-teaser__cat-marker ${this.elemClass[Math.floor(Math.random() * this.elemClass.length)]}"><a href="${tag['@id']}">${tag['label']}</a></li>`:html``)
|
|
120
|
+
:html``
|
|
121
|
+
}
|
|
122
|
+
</ul>
|
|
123
|
+
<div class="vm-teaser__summary">${this.summary}</div>
|
|
124
|
+
</div>
|
|
125
|
+
${this.isCustom ? html`
|
|
126
|
+
<button id="delete-permalink" class="btn btn--alt2" @click="${this.handleDelete}">Delete Permalink</button>
|
|
127
|
+
|
|
128
|
+
`: html`
|
|
129
|
+
<button id="edit-permalink" class="btn--primary" @click="${this.handleEdit}">Edit Permalink</button>
|
|
130
|
+
`}
|
|
131
|
+
|
|
132
|
+
`:html`
|
|
133
|
+
<!--
|
|
134
|
+
This is if the form is triggered meaning the edit permalink is occuring
|
|
135
|
+
so that it adds to the entries to the session. Also takes info from what
|
|
136
|
+
is already in the permalink. This is the edit form
|
|
137
|
+
-->
|
|
138
|
+
<form method="post">
|
|
139
|
+
<!-- START OF FORM -->
|
|
140
|
+
|
|
141
|
+
<fieldset>
|
|
142
|
+
|
|
143
|
+
<!-- Title -->
|
|
144
|
+
<div class="field-container">
|
|
145
|
+
<label for="permalink-title">Title</label>
|
|
146
|
+
<input id="permalink-title" .value=${this.title ? this.title : ""} type="text" placeholder=${this.title ? this.title : "Enter Your Title"} />
|
|
147
|
+
</div>
|
|
148
|
+
|
|
149
|
+
<!-- Host URL -->
|
|
150
|
+
<div class="field-container">
|
|
151
|
+
<label for="permalink-permalink">Permalink Host URL</label>
|
|
152
|
+
<input id="permalink-permalink" .value=${this.permalink ? this.permalink : ""} type="text" placeholder=${this.permalink ? this.permalink : "Enter Your Title"} />
|
|
153
|
+
</div>
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
<br />
|
|
157
|
+
<br />
|
|
158
|
+
<br />
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
<!-- Author -->
|
|
162
|
+
${this.authorFull ?
|
|
163
|
+
html`
|
|
164
|
+
<!-- If permalink already has authors -->
|
|
165
|
+
<div class="author">
|
|
166
|
+
<div style="border-style: solid; margin: 25px 0; padding:5px;">
|
|
167
|
+
${this.authorFull.map((author, index) =>
|
|
168
|
+
html`
|
|
169
|
+
<div class="field-container">
|
|
170
|
+
<label for="permalink-author no-${index}">Author</label>
|
|
171
|
+
<input id="permalink-author no-${index}" type="author" .value=${author['label']} placeholder="${author['label'].split(",")[0]}, ${author['label'].split(",")[1] ? author['label'].split(",")[1] : ""} " />
|
|
172
|
+
</div> `
|
|
173
|
+
)}
|
|
174
|
+
</div>
|
|
175
|
+
<br />
|
|
176
|
+
<div>
|
|
177
|
+
|
|
178
|
+
<h5>New Author Entry</h5>
|
|
179
|
+
${this.authorEntryField.map((item, index) =>
|
|
180
|
+
html`
|
|
181
|
+
<div class="field-container">
|
|
182
|
+
<label for="permalink-author no-${index}">Author</label>
|
|
183
|
+
<input id="permalink-author no-${index}" type="author" .value=${item.value} placeholder="Enter the Authors of the Work" />
|
|
184
|
+
</div>
|
|
185
|
+
|
|
186
|
+
`
|
|
187
|
+
)}
|
|
188
|
+
<a @click="${this._addAuthor}" class="btn--alt3 btn--sm" >Add Author Field</a>
|
|
189
|
+
</div>
|
|
190
|
+
</div>
|
|
191
|
+
`
|
|
192
|
+
:html`
|
|
193
|
+
<!-- If permalink DOES NOT has authors -->
|
|
194
|
+
|
|
195
|
+
<div>
|
|
196
|
+
|
|
197
|
+
<div class="author">
|
|
198
|
+
<br />
|
|
199
|
+
<h5>New Author Entry</h5>
|
|
200
|
+
${this.authorEntryField.map((item, index) =>
|
|
201
|
+
html`
|
|
202
|
+
<div class="field-container">
|
|
203
|
+
<label for="permalink-author no-${index}">Author</label>
|
|
204
|
+
<input id="permalink-author no-${index}" type="author" .value=${item.value} placeholder="Enter the Authors of the Work" />
|
|
205
|
+
</div>
|
|
206
|
+
|
|
207
|
+
`
|
|
208
|
+
)}
|
|
209
|
+
<a @click="${this._addAuthor}" class="btn--alt3 btn--sm" >Add Author Field</a>
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
`}
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
<br />
|
|
216
|
+
<br />
|
|
217
|
+
<br />
|
|
218
|
+
|
|
219
|
+
<!-- Year -->
|
|
220
|
+
<div class="field-container">
|
|
221
|
+
<label for="permalink-date">Year of Publication</label>
|
|
222
|
+
<input id="permalink-date" value=${this.year ? this.year : ""} type="text" placeholder=${this.year ? this.year : "Year of Publication"} />
|
|
223
|
+
</div>
|
|
224
|
+
|
|
225
|
+
<!-- Image -->
|
|
226
|
+
<div class="field-container">
|
|
227
|
+
<label for="permalink-image">Image JPEG URL</label>
|
|
228
|
+
<input id="permalink-image" value=${this.image ? this.image : ""} type="url" placeholder=${this.year ? this.year : "Year of Publication"} />
|
|
229
|
+
</div>
|
|
230
|
+
|
|
231
|
+
<br />
|
|
232
|
+
<br />
|
|
233
|
+
<br />
|
|
234
|
+
|
|
235
|
+
<!-- Tags -->
|
|
236
|
+
${this.tags ?
|
|
237
|
+
html`
|
|
238
|
+
|
|
239
|
+
<!-- If permalink already has Tags -->
|
|
240
|
+
<div class="tag">
|
|
241
|
+
<div style="border-style: solid; margin: 25px 0; padding:5px;">
|
|
242
|
+
${this.tags.map((tag, index)=>
|
|
243
|
+
html`
|
|
244
|
+
<div id="tag" class="field-container">
|
|
245
|
+
<label for="permalink-tags no-${index}">Tag</label>
|
|
246
|
+
<input id="permalink-tags no-${index}" type="url" .value=${tag['label']} placeholder="${tag['label']}" />
|
|
247
|
+
</div>
|
|
248
|
+
|
|
249
|
+
<label for="permalink-tags-url no-${index}">URL</label>
|
|
250
|
+
<input id="permalink-tags-url no-${index}" .value=${tag['@id'] ? tag['@id']: ''} type="url" placeholder="${tag['@id'] ? tag['@id']: 'URL Not Defined'}" />
|
|
251
|
+
|
|
252
|
+
<br />
|
|
253
|
+
<br />
|
|
254
|
+
<br />
|
|
255
|
+
`
|
|
256
|
+
)}
|
|
257
|
+
</div>
|
|
258
|
+
|
|
259
|
+
<h5>New Tag Entry</h5>
|
|
260
|
+
${this.tagEntryField.map((item, index) =>
|
|
261
|
+
html`
|
|
262
|
+
<div class="tag">
|
|
263
|
+
<div id="tag" class="field-container">
|
|
264
|
+
<label for="permalink-tags no-${index}">Tag</label>
|
|
265
|
+
<input id="permalink-tags no-${index}" type="url" .value=${item.label} placeholder="Name Your Permalink Tag" />
|
|
266
|
+
<label for="permalink-tags-url no-${index}">URL</label>
|
|
267
|
+
<input id="permalink-tags-url no-${index}" .value=${item.url} type="url" placeholder="URL of Permalink Tag" />
|
|
268
|
+
</div>
|
|
269
|
+
</div>
|
|
270
|
+
`
|
|
271
|
+
)}
|
|
272
|
+
|
|
273
|
+
<br />
|
|
274
|
+
<a @click="${this._addTag}" id="form-apply"class="btn--alt3 btn--sm">Add Tag Field</a>
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
`:html `
|
|
278
|
+
<!-- If permalink DOES NOT has Tags -->
|
|
279
|
+
<h5>New Tag Entry</h5>
|
|
280
|
+
${this.tagEntryField.map((item, index) =>
|
|
281
|
+
html`
|
|
282
|
+
<div class="tag">
|
|
283
|
+
<div id="tag" class="field-container">
|
|
284
|
+
<label for="permalink-tags no-${index}">Tag</label>
|
|
285
|
+
<input id="permalink-tags no-${index}" type="url" .value=${item.label} placeholder="Name Your Permalink Tag" />
|
|
286
|
+
<label for="permalink-tags-url no-${index}">URL</label>
|
|
287
|
+
<input id="permalink-tags-url no-${index}" .value=${item.url} type="url" placeholder="URL of Permalink Tag" />
|
|
288
|
+
</div>
|
|
289
|
+
</div>
|
|
290
|
+
`
|
|
291
|
+
|
|
292
|
+
)}
|
|
293
|
+
|
|
294
|
+
<br />
|
|
295
|
+
<a @click="${this._addTag}" id="form-apply"class="btn--alt3 btn--sm">Add Tag Field</a>
|
|
296
|
+
|
|
297
|
+
`}
|
|
298
|
+
|
|
299
|
+
<br />
|
|
300
|
+
<!-- Summary -->
|
|
301
|
+
<div class="field-container">
|
|
302
|
+
<label for="permalink-summary">Summary</label>
|
|
303
|
+
<textarea id="permalink-summary" .value=${this.summary ? this.summary : ""} rows="5" placeholder=${this.summary ? this.summary : "Write Summary Here"}></textarea>
|
|
304
|
+
</div>
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
</fieldset>
|
|
308
|
+
|
|
309
|
+
<!-- Apply Button -->
|
|
310
|
+
<div class="field-container--small views-filters__submit-field">
|
|
311
|
+
<a @click="${this._sendValues}" class="btn--primary">Apply</a>
|
|
312
|
+
<a onClick="window.location.reload();" class="btn--alt">Cancel</a>
|
|
313
|
+
</div>
|
|
314
|
+
|
|
315
|
+
<!-- END OF FORM -->
|
|
316
|
+
</form>
|
|
317
|
+
`}
|
|
318
|
+
`:html`
|
|
319
|
+
<!--
|
|
320
|
+
If it is in the loading stage of the permalink fetch
|
|
321
|
+
it will render this
|
|
322
|
+
look.
|
|
323
|
+
-->
|
|
324
|
+
<div class="vm-teaser__figure category_loading"></div>
|
|
325
|
+
<div class="vm-teaser__body">
|
|
326
|
+
<div class="load_teaser_a"></div>
|
|
327
|
+
<br/>
|
|
328
|
+
<div class="load_teaser_b"></div>
|
|
329
|
+
<br/>
|
|
330
|
+
<div class="load_teaser_c"></div>
|
|
331
|
+
<br/>
|
|
332
|
+
<div class="load_teaser_c"></div>
|
|
333
|
+
</div>
|
|
334
|
+
`}
|
|
335
|
+
</article>
|
|
336
|
+
`;
|
|
337
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {Task} from '@lit-labs/task';
|
|
2
|
+
|
|
3
|
+
export class TaskController {
|
|
4
|
+
// host;
|
|
5
|
+
// value;
|
|
6
|
+
// kinds = Names.kinds;
|
|
7
|
+
// task;
|
|
8
|
+
constructor(host, url) {
|
|
9
|
+
const baseUrl = url;
|
|
10
|
+
this.url = baseUrl;
|
|
11
|
+
this.host = host;
|
|
12
|
+
this.task = new Task(
|
|
13
|
+
this.host,
|
|
14
|
+
async () => {
|
|
15
|
+
const response = await fetch(`${baseUrl}`);
|
|
16
|
+
const result = await response.json();
|
|
17
|
+
const error = result.error;
|
|
18
|
+
if (error !== undefined) {
|
|
19
|
+
throw new Error(error);
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
() => [this.url]
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
render(renderFunctions) {
|
|
31
|
+
return this.task.render(renderFunctions);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
}
|