pinokiod 1.0.31 → 1.0.32
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/server/index.js +9 -0
- package/server/views/browser.ejs +100 -35
- package/server/views/partials/menu.ejs +3 -0
- package/server/views/settings.ejs +17 -4
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -343,6 +343,7 @@ class Server {
|
|
|
343
343
|
} else if (pathComponents.length === 0 && req.query.mode === "settings") {
|
|
344
344
|
let configArray = [{
|
|
345
345
|
key: "home",
|
|
346
|
+
description: "* Do NOT use exFAT drives",
|
|
346
347
|
val: this.kernel.homedir,
|
|
347
348
|
placeholder: "Enter the absolute path to use as your Pinokio home folder (D:\\pinokio, /Users/alice/pinokiofs, etc.)"
|
|
348
349
|
}, {
|
|
@@ -351,6 +352,7 @@ class Server {
|
|
|
351
352
|
options: ["light", "dark"]
|
|
352
353
|
}]
|
|
353
354
|
console.log("agent", this.agent)
|
|
355
|
+
console.log({ configArray })
|
|
354
356
|
res.render("settings", {
|
|
355
357
|
version: this.version,
|
|
356
358
|
logo: this.logo,
|
|
@@ -1168,10 +1170,16 @@ class Server {
|
|
|
1168
1170
|
}
|
|
1169
1171
|
}
|
|
1170
1172
|
}
|
|
1173
|
+
config.menu[i].target = "@" + (config.menu[i].id || config.menu[i].src)
|
|
1171
1174
|
}
|
|
1175
|
+
|
|
1176
|
+
|
|
1172
1177
|
config.menu = config.menu.filter((item) => {
|
|
1173
1178
|
return item.btn
|
|
1174
1179
|
})
|
|
1180
|
+
|
|
1181
|
+
|
|
1182
|
+
|
|
1175
1183
|
console.log("config", JSON.stringify(config,null,2))
|
|
1176
1184
|
return config
|
|
1177
1185
|
} else {
|
|
@@ -1602,6 +1610,7 @@ class Server {
|
|
|
1602
1610
|
if (req.query.mode === 'settings') {
|
|
1603
1611
|
let configArray = [{
|
|
1604
1612
|
key: "home",
|
|
1613
|
+
description: "* Do NOT use exFAT drives",
|
|
1605
1614
|
val: this.kernel.homedir ? this.kernel.homedir : path.resolve(os.homedir(), "pinokio"),
|
|
1606
1615
|
placeholder: "Enter the absolute path to use as your Pinokio home folder (D:\\pinokio, /Users/alice/pinokiofs, etc.)"
|
|
1607
1616
|
}, {
|
package/server/views/browser.ejs
CHANGED
|
@@ -441,12 +441,14 @@ body.dark .loader-container {
|
|
|
441
441
|
-->
|
|
442
442
|
</nav>
|
|
443
443
|
<main class='browserview'>
|
|
444
|
-
<% if (false
|
|
445
|
-
<% config.menu
|
|
446
|
-
<%
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
444
|
+
<% if (false) { %>
|
|
445
|
+
<% if (config.menu) { %>
|
|
446
|
+
<% config.menu.forEach((item) => { %>
|
|
447
|
+
<% if (item.btn && item.src) { %>
|
|
448
|
+
<iframe name='<%=item.src%>' class='hidden'></iframe>
|
|
449
|
+
<% } %>
|
|
450
|
+
<% }) %>
|
|
451
|
+
<% } %>
|
|
450
452
|
<% } %>
|
|
451
453
|
</main>
|
|
452
454
|
</div>
|
|
@@ -467,6 +469,35 @@ const getTarget = (href) => {
|
|
|
467
469
|
return u.pathname
|
|
468
470
|
}
|
|
469
471
|
}
|
|
472
|
+
const subUrlOf = (s, f) => {
|
|
473
|
+
debugger
|
|
474
|
+
|
|
475
|
+
let subsetUrl = (s.startsWith("http") ? s : "http://localhost" + s)
|
|
476
|
+
let fullUrl = (f.startsWith("http") ? f: "http://localhost" + f)
|
|
477
|
+
|
|
478
|
+
const subsetParsed = new URL(subsetUrl)
|
|
479
|
+
const fullParsed = new URL(fullUrl)
|
|
480
|
+
|
|
481
|
+
if (subsetParsed.pathname !== fullParsed.pathname) {
|
|
482
|
+
return false;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// Check if all search parameters in the subset URL are present in the full URL
|
|
486
|
+
for (const [key, val] of subsetParsed.searchParams) {
|
|
487
|
+
|
|
488
|
+
if (!fullParsed.searchParams.has(key)) {
|
|
489
|
+
return false
|
|
490
|
+
}
|
|
491
|
+
console.log("key", key)
|
|
492
|
+
console.log("f", fullParsed.searchParams.get(key))
|
|
493
|
+
console.log("s", val)
|
|
494
|
+
if (fullParsed.searchParams.get(key) !== val) {
|
|
495
|
+
return false
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
return true;
|
|
500
|
+
}
|
|
470
501
|
const renderCursor = () => {
|
|
471
502
|
document.querySelectorAll(".selectable").forEach((el) => {
|
|
472
503
|
el.classList.remove("cursor")
|
|
@@ -504,10 +535,18 @@ const renderSelection = (e, force) => {
|
|
|
504
535
|
document.querySelector(".bar").classList.remove("hidden")
|
|
505
536
|
//let id = getTarget(location.hash.slice(1))
|
|
506
537
|
let id = location.hash.slice(1)
|
|
507
|
-
let type = id[0]
|
|
508
|
-
let index = id.slice(1)
|
|
509
538
|
|
|
510
|
-
|
|
539
|
+
|
|
540
|
+
let selector
|
|
541
|
+
if (id.startsWith("@")) {
|
|
542
|
+
selector = `aside [target='${id.slice(1)}']`
|
|
543
|
+
} else {
|
|
544
|
+
let type = id[0]
|
|
545
|
+
let index = id.slice(1)
|
|
546
|
+
console.log({ type, index })
|
|
547
|
+
selector = `aside .${type} [data-index='${index}']`
|
|
548
|
+
}
|
|
549
|
+
|
|
511
550
|
|
|
512
551
|
// select the selected link
|
|
513
552
|
// document.querySelectorAll(".frame-link").forEach((el) => {
|
|
@@ -529,7 +568,7 @@ const renderSelection = (e, force) => {
|
|
|
529
568
|
}
|
|
530
569
|
} else {
|
|
531
570
|
// if not triggered by an event, look for the target from the location hash
|
|
532
|
-
target = document.querySelector(
|
|
571
|
+
target = document.querySelector(selector)
|
|
533
572
|
}
|
|
534
573
|
|
|
535
574
|
|
|
@@ -560,6 +599,7 @@ const renderSelection = (e, force) => {
|
|
|
560
599
|
})
|
|
561
600
|
|
|
562
601
|
|
|
602
|
+
debugger
|
|
563
603
|
|
|
564
604
|
// Look for the frame
|
|
565
605
|
// 1. if it's hard (".h")
|
|
@@ -568,7 +608,7 @@ const renderSelection = (e, force) => {
|
|
|
568
608
|
// find using the name attribute
|
|
569
609
|
let targetFrame;
|
|
570
610
|
if (target.closest(".h")) {
|
|
571
|
-
let hardFrames = document.querySelectorAll(".browserview iframe[name^=
|
|
611
|
+
let hardFrames = document.querySelectorAll(".browserview iframe[name^='@']")
|
|
572
612
|
let port = new URL(target.href).port
|
|
573
613
|
for(let frame of hardFrames) {
|
|
574
614
|
console.log({ src: frame.src, href: target.href, target: target.target })
|
|
@@ -633,22 +673,30 @@ const renderSelection = (e, force) => {
|
|
|
633
673
|
} else {
|
|
634
674
|
if (e) {
|
|
635
675
|
if (target.closest(".h")) {
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
e.preventDefault()
|
|
644
|
-
e.stopPropagation()
|
|
645
|
-
} else {
|
|
646
|
-
// different url, and the frame's url does not contain the tab url => change the src of the frame and load
|
|
647
|
-
targetFrame.src = target.href
|
|
648
|
-
e.preventDefault()
|
|
649
|
-
e.stopPropagation()
|
|
650
|
-
}
|
|
676
|
+
debugger
|
|
677
|
+
e.preventDefault()
|
|
678
|
+
e.stopPropagation()
|
|
679
|
+
let sub = subUrlOf(target.href, targetFrame.src)
|
|
680
|
+
console.log("issub", sub)
|
|
681
|
+
if (!sub) {
|
|
682
|
+
targetFrame.src = target.href
|
|
651
683
|
}
|
|
684
|
+
//if (target.href === targetFrame.src) {
|
|
685
|
+
// // same url. don't do anything
|
|
686
|
+
// e.preventDefault()
|
|
687
|
+
// e.stopPropagation()
|
|
688
|
+
//} else {
|
|
689
|
+
// if (targetFrame.src.includes(target.href)) {
|
|
690
|
+
// // different url, but the frame's url contains the tab url => don't touch
|
|
691
|
+
// e.preventDefault()
|
|
692
|
+
// e.stopPropagation()
|
|
693
|
+
// } else {
|
|
694
|
+
// // different url, and the frame's url does not contain the tab url => change the src of the frame and load
|
|
695
|
+
// targetFrame.src = target.href
|
|
696
|
+
// e.preventDefault()
|
|
697
|
+
// e.stopPropagation()
|
|
698
|
+
// }
|
|
699
|
+
//}
|
|
652
700
|
} else if (target.closest(".s")) {
|
|
653
701
|
// load unconditionally => .s doesn't change
|
|
654
702
|
e.preventDefault()
|
|
@@ -977,12 +1025,19 @@ document.querySelector("aside").addEventListener("click", async (e) => {
|
|
|
977
1025
|
// location.hash = id
|
|
978
1026
|
|
|
979
1027
|
//location.hash = target.getAttribute("href")
|
|
980
|
-
let index = target.getAttribute("data-index")
|
|
981
|
-
let type = target.closest(".m").getAttribute("data-type")
|
|
982
1028
|
|
|
983
|
-
|
|
1029
|
+
if (target.closest(".h")) {
|
|
1030
|
+
location.hash = target.target
|
|
1031
|
+
} else {
|
|
1032
|
+
let index = target.getAttribute("data-index")
|
|
1033
|
+
let type = target.closest(".m").getAttribute("data-type")
|
|
1034
|
+
|
|
1035
|
+
console.log({ type, index })
|
|
984
1036
|
|
|
985
|
-
|
|
1037
|
+
debugger
|
|
1038
|
+
|
|
1039
|
+
location.hash = type + index
|
|
1040
|
+
}
|
|
986
1041
|
|
|
987
1042
|
document.querySelectorAll(".frame-link").forEach((el) => {
|
|
988
1043
|
el.classList.remove("selected")
|
|
@@ -1035,6 +1090,8 @@ const refresh = async () => {
|
|
|
1035
1090
|
// frame.removeAttribute("name")
|
|
1036
1091
|
// location.hash = ""
|
|
1037
1092
|
// }
|
|
1093
|
+
|
|
1094
|
+
|
|
1038
1095
|
location.hash = ""
|
|
1039
1096
|
|
|
1040
1097
|
|
|
@@ -1049,13 +1106,21 @@ const refresh = async () => {
|
|
|
1049
1106
|
}
|
|
1050
1107
|
window.addEventListener('message', (event) => {
|
|
1051
1108
|
console.log("Message received from the child: ", event.data); // Message received from child
|
|
1052
|
-
if (event.data
|
|
1053
|
-
if (event.data.action
|
|
1054
|
-
|
|
1055
|
-
|
|
1109
|
+
if (event.data) {
|
|
1110
|
+
if (event.data.action) {
|
|
1111
|
+
if (event.data.action.type === "newtab") {
|
|
1112
|
+
console.log("create tab", event.data.action.url)
|
|
1113
|
+
addTab(event.data.action.url)
|
|
1114
|
+
}
|
|
1115
|
+
} else if (event.data.type) {
|
|
1116
|
+
if (event.data.type === 'disconnect') {
|
|
1117
|
+
// location.hash = ""
|
|
1118
|
+
refresh()
|
|
1119
|
+
} else {
|
|
1120
|
+
refresh()
|
|
1121
|
+
}
|
|
1056
1122
|
}
|
|
1057
1123
|
} else {
|
|
1058
|
-
console.log("data", event.data)
|
|
1059
1124
|
refresh()
|
|
1060
1125
|
}
|
|
1061
1126
|
});
|
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
</div>
|
|
11
11
|
<% } else { %>
|
|
12
12
|
<% if (item.btn) { %>
|
|
13
|
+
<!--
|
|
13
14
|
<a data-index="<%=index%>" target="h<%=index%>" data-mode="<%=item.mode%>" href="<%=item.href%>" class='btn header-item frame-link'>
|
|
15
|
+
-->
|
|
16
|
+
<a data-index="<%=index%>" target="<%=item.target%>" data-mode="<%=item.mode%>" href="<%=item.href%>" class='btn header-item frame-link'>
|
|
14
17
|
<div class='tab'><%-item.btn%></div>
|
|
15
18
|
<% if (item.running) { %>
|
|
16
19
|
<div class='loader'>
|
|
@@ -63,18 +63,28 @@
|
|
|
63
63
|
border-top: 1px solid rgba(255,255,255,0.1);
|
|
64
64
|
border-bottom: 1px solid rgba(255,255,255,0.1);
|
|
65
65
|
*/
|
|
66
|
-
padding:
|
|
66
|
+
padding: 20px 0;
|
|
67
|
+
}
|
|
68
|
+
.titleview h1 {
|
|
69
|
+
font-size: 40px;
|
|
70
|
+
text-transform: uppercase;
|
|
71
|
+
letter-spacing: 0;
|
|
67
72
|
}
|
|
68
73
|
.item button {
|
|
69
74
|
padding: 10px 20px;
|
|
70
75
|
}
|
|
71
76
|
.item label {
|
|
72
77
|
display: block;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
font-size: 14px;
|
|
78
|
+
text-transform: uppercase;
|
|
79
|
+
font-size: 30px;
|
|
76
80
|
padding-bottom: 5px;
|
|
77
81
|
}
|
|
82
|
+
.item .explanation {
|
|
83
|
+
padding-top: 5px;
|
|
84
|
+
color: brown;
|
|
85
|
+
font-size: 14px;
|
|
86
|
+
font-weight: bold;
|
|
87
|
+
}
|
|
78
88
|
body.dark .item input[type=text] {
|
|
79
89
|
background: rgba(255,255,255,0.1);
|
|
80
90
|
color: white;
|
|
@@ -228,6 +238,9 @@ header .home {
|
|
|
228
238
|
<input class='homepath' name="<%=c.key%>" type='text' placeholder="<%=c.placeholder ? c.placeholder : ''%>">
|
|
229
239
|
<% } %>
|
|
230
240
|
<% } %>
|
|
241
|
+
<% if (c.description) { %>
|
|
242
|
+
<div class='explanation'><%=c.description%></div>
|
|
243
|
+
<% } %>
|
|
231
244
|
</div>
|
|
232
245
|
<% }) %>
|
|
233
246
|
<br>
|