unprint 0.7.2 → 0.8.1
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/package.json +1 -1
- package/src/app.js +38 -2
- package/tests/index.html +4 -2
- package/tests/init.js +3 -0
package/package.json
CHANGED
package/src/app.js
CHANGED
|
@@ -283,9 +283,20 @@ function queryUrl(context, selector = 'a', customOptions) {
|
|
|
283
283
|
};
|
|
284
284
|
|
|
285
285
|
const url = queryContent(context, selector, options);
|
|
286
|
-
const curatedUrl = prefixUrl(url, options.origin, customOptions);
|
|
287
286
|
|
|
288
|
-
return
|
|
287
|
+
return prefixUrl(url, options.origin, customOptions);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function queryUrls(context, selector = 'a', customOptions) {
|
|
291
|
+
const options = {
|
|
292
|
+
...context.options,
|
|
293
|
+
attribute: 'href',
|
|
294
|
+
...customOptions,
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
const urls = queryContents(context, selector, options);
|
|
298
|
+
|
|
299
|
+
return urls.map((url) => prefixUrl(url, options.origin, customOptions));
|
|
289
300
|
}
|
|
290
301
|
|
|
291
302
|
function getImageUrl(context, selector, options) {
|
|
@@ -405,6 +416,28 @@ function queryVideos(context, selector = 'source', customOptions) {
|
|
|
405
416
|
return videoUrls.map((videoUrl) => prefixUrl(videoUrl, options.origin, options));
|
|
406
417
|
}
|
|
407
418
|
|
|
419
|
+
function queryPoster(context, selector = 'video', customOptions) {
|
|
420
|
+
const options = {
|
|
421
|
+
attribute: 'poster',
|
|
422
|
+
...customOptions,
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
const posterUrl = queryContent(context, selector, options);
|
|
426
|
+
|
|
427
|
+
return prefixUrl(posterUrl, options.origin, options);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function queryPosters(context, selector = 'video', customOptions) {
|
|
431
|
+
const options = {
|
|
432
|
+
attribute: 'poster',
|
|
433
|
+
...customOptions,
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
const posterUrls = queryContents(context, selector, options);
|
|
437
|
+
|
|
438
|
+
return posterUrls.map((posterUrl) => prefixUrl(posterUrl, options.origin, options));
|
|
439
|
+
}
|
|
440
|
+
|
|
408
441
|
function extractJson(element) {
|
|
409
442
|
if (!element) {
|
|
410
443
|
return null;
|
|
@@ -546,6 +579,8 @@ const queryFns = {
|
|
|
546
579
|
num: queryNumber,
|
|
547
580
|
numbers: queryNumbers,
|
|
548
581
|
nums: queryNumbers,
|
|
582
|
+
poster: queryPoster,
|
|
583
|
+
posters: queryPosters,
|
|
549
584
|
date: queryDate,
|
|
550
585
|
dates: queryDates,
|
|
551
586
|
duration: queryDuration,
|
|
@@ -553,6 +588,7 @@ const queryFns = {
|
|
|
553
588
|
sourceSet: querySourceSet,
|
|
554
589
|
srcSet: querySourceSet,
|
|
555
590
|
url: queryUrl,
|
|
591
|
+
urls: queryUrls,
|
|
556
592
|
video: queryVideo,
|
|
557
593
|
videos: queryVideos,
|
|
558
594
|
};
|
package/tests/index.html
CHANGED
|
@@ -20,7 +20,9 @@
|
|
|
20
20
|
<li class="number">789.0</li>
|
|
21
21
|
</ul>
|
|
22
22
|
|
|
23
|
-
<a id="link" href="http://localhost:3101/html">Get
|
|
23
|
+
<a id="link" class="link" href="http://localhost:3101/html">Get URL</a>
|
|
24
|
+
<a id="link" class="link" href="http://localhost:3101/html">Get URL</a>
|
|
25
|
+
|
|
24
26
|
<a id="path" href="/json">Get data</a>
|
|
25
27
|
<a id="relativePath" href="./json">Get data</a>
|
|
26
28
|
|
|
@@ -37,7 +39,7 @@
|
|
|
37
39
|
|
|
38
40
|
<img class="srcset" srcset="https://i.redd.it/e91oo4ueyeb71.jpg 240w, https://i.redd.it/vn9h981hlx281.png 480w, https://i.redd.it/e91oo4ueyeb71.jpg 640w">
|
|
39
41
|
|
|
40
|
-
<video id="video"><source src="https://i.imgur.com/eDQmLys.mp4"></video>
|
|
42
|
+
<video id="video" poster="https://i.imgur.com/eDQmLys.jpg"><source src="https://i.imgur.com/eDQmLys.mp4"></video>
|
|
41
43
|
|
|
42
44
|
<script id="json" type="application/js">{"foo": "bar", "lorem": "ipsum", "hello": "world"}</script>
|
|
43
45
|
</body>
|
package/tests/init.js
CHANGED
|
@@ -26,6 +26,7 @@ async function initTest() {
|
|
|
26
26
|
console.log('data', res.context.query.json('#json'));
|
|
27
27
|
console.log('items', res.context.query.contents('.item'));
|
|
28
28
|
console.log('link', res.context.query.url('#link'));
|
|
29
|
+
console.log('links', res.context.query.urls('.link'));
|
|
29
30
|
console.log('image', res.context.query.img('.image'));
|
|
30
31
|
console.log('images', res.context.query.imgs('.image'));
|
|
31
32
|
console.log('srcset', res.context.query.sourceSet('.srcset'));
|
|
@@ -33,6 +34,8 @@ async function initTest() {
|
|
|
33
34
|
console.log('relative path', res.context.query.url('#relativePath'));
|
|
34
35
|
console.log('exists', res.context.query.exists('#title'));
|
|
35
36
|
console.log('count', res.context.query.count('.item'), res.context.query.count('.foo'));
|
|
37
|
+
console.log('video', res.context.query.video());
|
|
38
|
+
console.log('poster', res.context.query.poster());
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
async function initServer() {
|