pinokiod 3.18.2 → 3.18.4

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.
@@ -73,10 +73,13 @@ class Api {
73
73
  meta.icon = meta.icon ? `/api/${api_name}/${meta.icon}?raw=true` : "/pinokio-black.png"
74
74
  meta.path = api_path
75
75
  meta.name = meta.title
76
- meta.link = `/pinokio/browser/${api_name}/dev#n1`
76
+ //meta.link = `/pinokio/browser/${api_name}/dev#n1`
77
+ meta.link = `/p/${api_name}/dev#n1`
77
78
  meta.web_path = `/api/${api_name}`
78
- meta.ui = `/pinokio/browser/${api_name}`
79
- meta.browse = `/pinokio/browser/${api_name}/dev`
79
+ //meta.ui = `/pinokio/browser/${api_name}`
80
+ meta.ui = `/p/${api_name}`
81
+ //meta.browse = `/pinokio/browser/${api_name}/dev`
82
+ meta.browse = `/p/${api_name}/dev`
80
83
  if (!pinokio && !pinokio2 && !pinokio3 ) {
81
84
  meta.init_required = true
82
85
  }
package/kernel/index.js CHANGED
@@ -191,11 +191,13 @@ class Kernel {
191
191
  let result
192
192
  if (type === "web") {
193
193
  if (chunks[0] === "api") {
194
- result = "/pinokio/browser/" + chunks.slice(1).join("/")
194
+ //result = "/pinokio/browser/" + chunks.slice(1).join("/")
195
+ result = "/p/" + chunks.slice(1).join("/")
195
196
  }
196
197
  } else if (type === "browse" || type === "dev") {
197
198
  if (chunks[0] === "api") {
198
- result = "/pinokio/browser/" + chunks.slice(1).join("/") + "/dev"
199
+ //result = "/pinokio/browser/" + chunks.slice(1).join("/") + "/dev"
200
+ result = "/p/" + chunks.slice(1).join("/") + "/dev"
199
201
  }
200
202
  // } else if (type === "web") {
201
203
  // result = "/" + chunks.join("/")
@@ -354,6 +356,8 @@ class Kernel {
354
356
  await this.router.remote()
355
357
  // console.timeEnd("> 7. Router Remote"+ts)
356
358
 
359
+ await this.router.custom_domain()
360
+
357
361
  // 8. update caddy config
358
362
  // console.time("> 8. Router Update"+ts)
359
363
  await this.router.update()
@@ -0,0 +1,21 @@
1
+ const path = require('path')
2
+ const Common = require('./common')
3
+ const Processor = require('./processor')
4
+ class CustomDomainRouter extends Processor {
5
+ constructor(router) {
6
+ super()
7
+ this.router = router
8
+ this.common = new Common(router)
9
+ }
10
+ handle (peer) {
11
+ for(let domain in this.router.custom_domains) {
12
+ let port = this.router.custom_domains[domain]
13
+ this.common.handle({
14
+ match: `${domain}.localhost`,
15
+ dial: `127.0.0.1:${port}`,
16
+ host: this.router.kernel.peer.host,
17
+ })
18
+ }
19
+ }
20
+ }
21
+ module.exports = CustomDomainRouter
@@ -9,6 +9,7 @@ const PeerHomeRouter = require('./peer_home_router')
9
9
  const PeerVariableRouter = require('./peer_variable_router')
10
10
  const PeerPortRouter = require('./peer_port_router')
11
11
  const PeerPeerRouter = require('./peer_peer_router')
12
+ const CustomDomainRouter = require('./custom_domain_router')
12
13
  const Environment = require("../environment")
13
14
  class Router {
14
15
  constructor(kernel) {
@@ -20,6 +21,7 @@ class Router {
20
21
  this.peer_variable_router = new PeerVariableRouter(this)
21
22
  this.peer_port_router = new PeerPortRouter(this)
22
23
  this.peer_peer_router = new PeerPeerRouter(this)
24
+ this.custom_domain_router = new CustomDomainRouter(this)
23
25
  this.default_prefix = "pinokio"
24
26
  this.default_suffix = "localhost"
25
27
  this.default_match = this.default_prefix + "." + this.default_suffix
@@ -55,18 +57,41 @@ class Router {
55
57
 
56
58
  // create a custom_map that maps port to custom router declarations
57
59
  /*
60
+
58
61
  custom_routers = {
59
- PORT1: <caddy handler>,
60
- PORT2: <caddy handler>,
62
+ ports: {
63
+ PORT1: <caddy handler>,
64
+ PORT2: <caddy handler>,
65
+ }
66
+ ...
67
+ }
68
+
69
+ custom_domains = {
70
+ domains: {
71
+ NAME1: PORT1,
72
+ NAME2: PORT2,
73
+ ...
74
+ }
61
75
  ...
62
76
  }
77
+
63
78
  */
64
79
  this.custom_routers = {}
80
+ this.custom_domains = {}
65
81
  for(let router_path of router_paths) {
66
82
  let router_abs_path = this.kernel.path("network", router_path)
67
83
  let config = await this.kernel.require(router_abs_path)
68
- for(let port in config) {
69
- this.custom_routers[port] = config[port]
84
+ if (config.ports) {
85
+ let ports = config.ports
86
+ for(let key in ports) {
87
+ this.custom_routers[key] = ports[key]
88
+ }
89
+ }
90
+ if (config.domains) {
91
+ let domains = config.domains
92
+ for(let key in domains) {
93
+ this.custom_domains[key] = domains[key]
94
+ }
70
95
  }
71
96
  }
72
97
 
@@ -204,6 +229,14 @@ class Router {
204
229
  this.mapping = this._mapping
205
230
  this.info = this._info()
206
231
  }
232
+ async custom_domain() {
233
+ for(let host in this.kernel.peer.info) {
234
+ let peer = this.kernel.peer.info[host]
235
+ this.custom_domain_router.handle(peer)
236
+ }
237
+ //await this.fill()
238
+ this.mapping = this._mapping
239
+ }
207
240
 
208
241
  // update caddy config
209
242
  async update() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "3.18.2",
3
+ "version": "3.18.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/server/index.js CHANGED
@@ -277,7 +277,8 @@ class Server {
277
277
  if (x.run) {
278
278
  browser_url = "/env/api/" + x.name
279
279
  } else {
280
- browser_url = "/pinokio/browser/" + x.name
280
+ //browser_url = "/pinokio/browser/" + x.name
281
+ browser_url = "/p/" + x.name
281
282
  }
282
283
  let browser_browse_url = browser_url + "/dev"
283
284
  return {
@@ -333,6 +334,30 @@ class Server {
333
334
  }
334
335
  }
335
336
  }
337
+ async current_urls(current_path) {
338
+ let router_running = await this.check_router_up()
339
+ let u = new URL("http://localhost:42000")
340
+
341
+ let current_urls = {}
342
+
343
+ // http
344
+ if (current_path) {
345
+ u.pathname = current_path
346
+ }
347
+ current_urls.http = u.toString()
348
+
349
+ // https
350
+ if (router_running.success) {
351
+ let u = new URL("https://pinokio.localhost")
352
+ if (current_path) {
353
+ u.pathname = current_path
354
+ }
355
+ current_urls.https = u.toString()
356
+ }
357
+
358
+ return current_urls
359
+ }
360
+
336
361
  async chrome(req, res, type) {
337
362
 
338
363
  let { requirements, install_required, requirements_pending, error } = await this.kernel.bin.check({
@@ -487,6 +512,7 @@ class Server {
487
512
  feed = this.newsfeed(gitRemote)
488
513
  }
489
514
 
515
+
490
516
  await this.kernel.plugin.init()
491
517
  let plugin = await this.getPlugin(name)
492
518
  let plugin_menu = null
@@ -494,7 +520,12 @@ class Server {
494
520
  let running_dynamic = this.running_dynamic(name, plugin.menu)
495
521
  plugin_menu = plugin.menu.concat(running_dynamic)
496
522
  }
523
+
524
+
525
+ let current_urls = await this.current_urls(req.originalUrl.slice(1))
526
+
497
527
  const result = {
528
+ current_urls,
498
529
  path: this.kernel.path("api", name),
499
530
  plugin_menu,
500
531
  portal: this.portal,
@@ -529,9 +560,9 @@ class Server {
529
560
  if (!this.kernel.proto.config) {
530
561
  await this.kernel.proto.init()
531
562
  }
532
- if (!this.kernel.plugin.config) {
533
- await this.kernel.plugin.init()
534
- }
563
+ // if (!this.kernel.plugin.config) {
564
+ // await this.kernel.plugin.init()
565
+ // }
535
566
  res.render("app", result)
536
567
  }
537
568
  getVariationUrls(req) {
@@ -1398,7 +1429,8 @@ class Server {
1398
1429
  //url: p + "/" + x.name,
1399
1430
  url: _p + "/" + x.name,
1400
1431
  // url: `${U}/${x.name}`,
1401
- browser_url: "/pinokio/browser/" + x.name
1432
+ //browser_url: "/pinokio/browser/" + x.name
1433
+ browser_url: "/p/" + x.name
1402
1434
  }
1403
1435
  })
1404
1436
 
@@ -1456,9 +1488,12 @@ class Server {
1456
1488
  }
1457
1489
  }
1458
1490
 
1491
+ let current_urls = await this.current_urls()
1492
+
1459
1493
  if (meta) {
1460
1494
  items = running.concat(notRunning)
1461
1495
  res.render("index", {
1496
+ current_urls,
1462
1497
  portal: this.portal,
1463
1498
  install: this.install,
1464
1499
  folders: null,
@@ -2374,6 +2409,7 @@ class Server {
2374
2409
  }
2375
2410
  }
2376
2411
  async getPlugin(name) {
2412
+ console.log("getPlugin", name)
2377
2413
  if (this.kernel.plugin.config) {
2378
2414
  try {
2379
2415
  let info = new Info(this.kernel)
@@ -2398,6 +2434,46 @@ class Server {
2398
2434
 
2399
2435
  }
2400
2436
  }
2437
+ async check_router_up() {
2438
+ console.log("/check_router_up")
2439
+ // check if caddy is runnign properly
2440
+ // try https://pinokio.localhost
2441
+ // if it works, proceed
2442
+ // if not, redirect
2443
+ let https_running = false
2444
+ try {
2445
+ let res = await axios.get(`http://127.0.0.1:2019/config/`, {
2446
+ timeout: 2000
2447
+ })
2448
+ let test = /pinokio\.localhost/.test(JSON.stringify(res.data))
2449
+ if (test) {
2450
+ https_running = true
2451
+ }
2452
+ } catch (e) {
2453
+ console.log(e)
2454
+ }
2455
+ console.log({ https_running })
2456
+ if (!https_running) {
2457
+ return { error: "pinokio.host not yet available" }
2458
+ }
2459
+
2460
+
2461
+ // check if pinokio.localhost router is running
2462
+ let router_running = false
2463
+ let router = this.kernel.router.published()
2464
+ for(let ip in router) {
2465
+ let domains = router[ip]
2466
+ if (domains.includes("pinokio.localhost")) {
2467
+ router_running = true
2468
+ break
2469
+ }
2470
+ }
2471
+ if (!router_running) {
2472
+ return { error: "pinokio.localhost not yet available" }
2473
+ }
2474
+
2475
+ return { success: true }
2476
+ }
2401
2477
 
2402
2478
  async start(options) {
2403
2479
  this.debug = false
@@ -2490,12 +2566,15 @@ class Server {
2490
2566
  await fse.remove(p)
2491
2567
  console.log(`[DONE] reset ${p}`)
2492
2568
 
2493
- let p2 = path.resolve(home, "prototype")
2569
+ let p2 = path.resolve(home, "prototype/system")
2494
2570
  await fse.remove(p2)
2495
2571
 
2496
2572
  let p3 = path.resolve(home, "plugin")
2497
2573
  await fse.remove(p3)
2498
2574
 
2575
+ let p4 = path.resolve(home, "network/system")
2576
+ await fse.remove(p4)
2577
+
2499
2578
  let gitconfig = path.resolve(home, "gitconfig")
2500
2579
  await fse.remove(gitconfig)
2501
2580
 
@@ -2826,51 +2905,8 @@ class Server {
2826
2905
  }))
2827
2906
 
2828
2907
  this.app.get("/check_router_up", ex(async (req, res) => {
2829
- console.log("/check_router_up")
2830
- // check if caddy is runnign properly
2831
- // try https://pinokio.localhost
2832
- // if it works, proceed
2833
- // if not, redirect
2834
- let https_running = false
2835
- try {
2836
- let res = await axios.get(`http://127.0.0.1:2019/config/`, {
2837
- timeout: 2000
2838
- })
2839
- let test = /pinokio\.localhost/.test(JSON.stringify(res.data))
2840
- if (test) {
2841
- https_running = true
2842
- }
2843
- } catch (e) {
2844
- console.log(e)
2845
- }
2846
- console.log({ https_running })
2847
- if (!https_running) {
2848
- res.json({ error: "pinokio.host not yet available" })
2849
- // res.redirect("/setup/connect?callback=/connect/" + req.params.provider)
2850
- return
2851
- }
2852
-
2853
-
2854
- // check if pinokio.localhost router is running
2855
- let router_running = false
2856
- let router = this.kernel.router.published()
2857
- for(let ip in router) {
2858
- let domains = router[ip]
2859
- if (domains.includes("pinokio.localhost")) {
2860
- router_running = true
2861
- break
2862
- }
2863
- }
2864
- console.log({ router_running })
2865
- if (!router_running) {
2866
- res.json({ error: "pinokio.localhost not yet available" })
2867
- // res.redirect("/setup/connect?callback=/connect/" + req.params.provider)
2868
- return
2869
- }
2870
-
2871
- console.log("router is up")
2872
-
2873
- res.json({ success: true })
2908
+ let response = await this.check_router_up()
2909
+ res.json(response)
2874
2910
  }))
2875
2911
 
2876
2912
  /*
@@ -3442,6 +3478,10 @@ class Server {
3442
3478
  await rimraf(caddy_path)
3443
3479
  let caddy_path2 = this.kernel.path("cache/XDG_CONFIG_HOME/caddy")
3444
3480
  await rimraf(caddy_path2)
3481
+
3482
+ let custom_network_path = path.resolve(home, "network/system")
3483
+ await fse.remove(custom_network_path)
3484
+
3445
3485
  res.json({ success: true })
3446
3486
  }))
3447
3487
  this.app.get("/requirements_check/:name", ex(async (req, res) => {
@@ -3613,7 +3653,8 @@ class Server {
3613
3653
  // await fs.promises.writeFile(meta_path, JSON.stringify(meta, null, 2))
3614
3654
 
3615
3655
  res.json({
3616
- success: "/pinokio/browser/"+folder
3656
+ //success: "/pinokio/browser/"+folder
3657
+ success: "/p/"+folder
3617
3658
  })
3618
3659
  } catch (e) {
3619
3660
  res.json({
@@ -3627,7 +3668,8 @@ class Server {
3627
3668
  try {
3628
3669
  await fs.promises.cp(src_path, dest_path, { recursive: true })
3629
3670
  res.json({
3630
- success: "/pinokio/browser/"+ req.body.dest + "/dev"
3671
+ //success: "/pinokio/browser/"+ req.body.dest + "/dev"
3672
+ success: "/p/"+ req.body.dest + "/dev"
3631
3673
  })
3632
3674
  } catch (e) {
3633
3675
  res.json({
@@ -4100,7 +4142,8 @@ class Server {
4100
4142
  }
4101
4143
  } else {
4102
4144
  // if pinokio.js doesn't exist, send to /browser/:name
4103
- res.redirect(`/pinokio/browser/${req.params.name}`)
4145
+ //res.redirect(`/pinokio/browser/${req.params.name}`)
4146
+ res.redirect(`/p/${req.params.name}`)
4104
4147
  }
4105
4148
  }))
4106
4149
  this.app.get("/share/:name", ex(async (req, res) => {
@@ -4282,7 +4325,7 @@ class Server {
4282
4325
  }
4283
4326
  }))
4284
4327
  this.app.get("/pinokio/dynamic/:name", ex(async (req, res) => {
4285
- await this.kernel.plugin.init()
4328
+ // await this.kernel.plugin.init()
4286
4329
  let plugin = await this.getPlugin(req.params.name)
4287
4330
  let html = ""
4288
4331
  if (plugin && plugin.menu && Array.isArray(plugin.menu)) {
@@ -4433,6 +4476,7 @@ class Server {
4433
4476
  res.json({ success: true })
4434
4477
  }))
4435
4478
  this.app.get("/pinokio/browser", ex(async (req, res) => {
4479
+ console.log("GET /pinokio/browser")
4436
4480
  if (req.query && req.query.uri) {
4437
4481
  let uri = req.query.uri
4438
4482
  let p = this.kernel.api.resolveBrowserPath(uri)
@@ -4456,6 +4500,18 @@ class Server {
4456
4500
  console.log("run mode")
4457
4501
  this.chrome(req, res, "run")
4458
4502
  }))
4503
+ this.app.get("/p/:name/dev", ex(async (req, res) => {
4504
+ console.log("browse mode")
4505
+ this.chrome(req, res, "browse")
4506
+ }))
4507
+ this.app.get("/p/:name/browse", ex(async (req, res) => {
4508
+ console.log("browse mode")
4509
+ this.chrome(req, res, "browse")
4510
+ }))
4511
+ this.app.get("/p/:name", ex(async (req, res) => {
4512
+ console.log("run mode")
4513
+ this.chrome(req, res, "run")
4514
+ }))
4459
4515
  this.app.post("/pinokio/delete", ex(async (req, res) => {
4460
4516
  try {
4461
4517
  if (req.body.type === 'bin') {
@@ -26,7 +26,10 @@ aside {
26
26
  cursor: auto !important;
27
27
  }
28
28
  header.grabbable {
29
+ /*
29
30
  padding: 32px 10px 0 !important;
31
+ */
32
+ padding: 22px 10px 0 !important;
30
33
  }
31
34
  /*
32
35
  header {
@@ -104,6 +104,8 @@ body.dark *::-webkit-scrollbar-thumb {
104
104
  border-radius: 0 !important;
105
105
  border: 2px dotted silver !important;
106
106
  }
107
+ .app-btns {
108
+ }
107
109
  .drawer {
108
110
  max-height: 100000px;
109
111
  overflow: hidden;
@@ -143,6 +145,48 @@ body.dark .dynamic.selected {
143
145
  */
144
146
  }
145
147
 
148
+ .url-bar {
149
+ font-family: verdana;
150
+ font-size: 13px;
151
+ line-height: 15px;
152
+ padding: 0 10px;
153
+ font-weight: normal;
154
+ flex-grow: 1;
155
+ }
156
+ .url-bar .http-url:hover {
157
+ color: firebrick;
158
+ border-color: firebrick;
159
+ }
160
+ .url-bar .https-url:hover {
161
+ color: firebrick;
162
+ border-color: firebrick;
163
+ }
164
+ .url-bar .https-url {
165
+ cursor: pointer;
166
+ display: block;
167
+ text-decoration: none;
168
+ /*
169
+ color: #83ab32;
170
+ */
171
+ color: silver;
172
+ /*
173
+ padding-left: 5px;
174
+ border-left: 10px solid #83ab32;
175
+ */
176
+ }
177
+ .url-bar .http-url {
178
+ cursor: pointer;
179
+ display: block;
180
+ text-decoration: none;
181
+ /*
182
+ color: royalblue;
183
+ */
184
+ color: silver;
185
+ /*
186
+ padding-left: 5px;
187
+ border-left: 10px solid royalblue;
188
+ */
189
+ }
146
190
 
147
191
  .loader-container {
148
192
  background: rgba(0,0,0,0.2) !important;
@@ -587,7 +631,11 @@ form.search > * {
587
631
  margin: 10px;
588
632
  */
589
633
  }
634
+ body.dark form.search {
635
+ border-left: 10px solid rgba(255,255,255,0.1);
636
+ }
590
637
  form.search {
638
+ border-left: 10px solid rgba(0,0,0,0.04);
591
639
  padding: 0px;
592
640
  /*
593
641
  background: #F5F4FA;
@@ -595,6 +643,7 @@ form.search {
595
643
  margin: 0;
596
644
  display: flex;
597
645
  flex-grow: 1;
646
+ padding: 10px;
598
647
  }
599
648
  .input-form {
600
649
  padding: 10px;
@@ -747,13 +747,21 @@ body.dark .appcanvas {
747
747
  <button class='btn2' id='back'><div><i class="fa-solid fa-chevron-left"></i></div><div>Prev</div></button>
748
748
  <button class='btn2' id='forward'><div><i class="fa-solid fa-chevron-right"></i></div><div>Next</div></button>
749
749
  <button class='btn2' id='refresh-page'><div><i class="fa-solid fa-rotate-right"></i></div><div>Refresh</div></button>
750
- <a class='btn2 create-new' id='create-new-folder'><div><i class="fa-solid fa-folder-plus"></i></div><div>Create</div></a>
750
+ <div class='url-bar'>
751
+ <% if (current_urls.https) { %>
752
+ <a class='https-url' target="_blank" href="<%=current_urls.https%>"><i class="fa-solid fa-square-arrow-up-right"></i> <%=current_urls.https%></a>
753
+ <% } %>
754
+ <% if (current_urls.http) { %>
755
+ <a class='http-url' target="_blank" href="<%=current_urls.http%>"><i class="fa-solid fa-square-arrow-up-right"></i> <%=current_urls.http%></a>
756
+ <% } %>
757
+ </div>
751
758
  <a href="/network" class='btn2'><div><i class="fa-solid fa-wifi"></i></div><div>Network</div></a>
752
759
  <a href="/connect" class='btn2'><div><i class="fa-solid fa-circle-user"></i></div><div>Connect</div></a>
760
+ <!--
753
761
  <input type='url' id='location' readonly value="<%=execUrl%>">
754
762
  <a id='open-location' target="_blank" features="browser"><i class="fa-solid fa-arrow-up-right-from-square"></i></a>
763
+ -->
755
764
  <div class='nav-btns'>
756
- <a class='btn2' id='explore' href="/?mode=explore"><div><i class="fa-solid fa-magnifying-glass"></i></div><div>Discover</div></a>
757
765
  <a class='btn2' href="<%=portal%>" target="_blank"><div><i class="fa-solid fa-question"></i></div><div>Help</div></a>
758
766
  <button class='btn2' id='genlog'><div><i class="fa-solid fa-laptop-code"></i></div><div>Logs</div></button>
759
767
  <a id='downloadlogs' download class='hidden btn2' href="/pinokio/logs.zip"><div><i class="fa-solid fa-download"></i></div><div>Download logs</div></a>
@@ -1106,14 +1114,14 @@ body.dark .appcanvas {
1106
1114
 
1107
1115
  //document.querySelector("#location").value = url
1108
1116
 
1109
- document.querySelector("#open-location").setAttribute('href', target.href)
1110
- if (target.pathname.startsWith("/run")) {
1111
- document.querySelector("#location").value = target.pathname.slice(4)
1112
- } else if (target.pathname.startsWith("/api")) {
1113
- document.querySelector("#location").value = target.pathname
1114
- } else {
1115
- document.querySelector("#location").value = target.href
1116
- }
1117
+ // document.querySelector("#open-location").setAttribute('href', target.href)
1118
+ // if (target.pathname.startsWith("/run")) {
1119
+ // document.querySelector("#location").value = target.pathname.slice(4)
1120
+ // } else if (target.pathname.startsWith("/api")) {
1121
+ // document.querySelector("#location").value = target.pathname
1122
+ // } else {
1123
+ // document.querySelector("#location").value = target.href
1124
+ // }
1117
1125
 
1118
1126
 
1119
1127
  // select the selected target element (tab)
@@ -195,12 +195,10 @@ pre {
195
195
  <button class='btn2' id='back'><div><i class="fa-solid fa-chevron-left"></i></div><div>Prev</div></button>
196
196
  <button class='btn2' id='forward'><div><i class="fa-solid fa-chevron-right"></i></div><div>Next</div></button>
197
197
  <button class='btn2' id='refresh-page'><div><i class="fa-solid fa-rotate-right"></i></div><div>Refresh</div></button>
198
- <a class='btn2 create-new' id='create-new-folder'><div><i class="fa-solid fa-folder-plus"></i></div><div>Create</div></a>
198
+ <div class='flexible'></div>
199
199
  <a href="/network" class='btn2'><div><i class="fa-solid fa-wifi"></i></div><div>Network</div></a>
200
200
  <a href="/connect" class='btn2'><div><i class="fa-solid fa-circle-user"></i></div><div>Connect</div></a>
201
- <div class='flexible'></div>
202
201
  <div class='nav-btns'>
203
- <a class='btn2' id='explore' href="/?mode=explore"><div><i class="fa-solid fa-magnifying-glass"></i></div><div>Discover</div></a>
204
202
  <a class='btn2' href="<%=portal%>" target="_blank"><div><i class="fa-solid fa-question"></i></div><div>Help</div></a>
205
203
  <a class='btn2' href="/?mode=settings"><div><i class="fa-solid fa-gear"></i></div><div>Settings</div></a>
206
204
  <button id='new-window' title='open a new window' class='btn2' data-agent="<%=agent%>"><div><i class="fa-solid fa-plus"></i></div><div>Window</div></button>
@@ -222,6 +222,7 @@ body.dark .config {
222
222
  <script src="/sweetalert2.js"></script>
223
223
  <script src="/common.js"></script>
224
224
  <script src="/opener.js"></script>
225
+ <script src="/nav.js"></script>
225
226
  </head>
226
227
  <body class='<%=theme%>' data-agent="<%=agent%>">
227
228
  <header class='navheader grabbable'>
@@ -230,12 +231,10 @@ body.dark .config {
230
231
  <button class='btn2' id='back'><div><i class="fa-solid fa-chevron-left"></i></div><div>Prev</div></button>
231
232
  <button class='btn2' id='forward'><div><i class="fa-solid fa-chevron-right"></i></div><div>Next</div></button>
232
233
  <button class='btn2' id='refresh-page'><div><i class="fa-solid fa-rotate-right"></i></div><div>Refresh</div></button>
233
- <a class='btn2 create-new' id='create-new-folder'><div><i class="fa-solid fa-folder-plus"></i></div><div>Create</div></a>
234
+ <div class='flexible'></div>
234
235
  <a href="/network" class='btn2'><div><i class="fa-solid fa-wifi"></i></div><div>Network</div></a>
235
236
  <a href="/connect" class='btn2'><div><i class="fa-solid fa-circle-user"></i></div><div>Connect</div></a>
236
- <div class='flexible'></div>
237
237
  <div class='nav-btns'>
238
- <a class='btn2' id='explore' href="/?mode=explore"><div><i class="fa-solid fa-magnifying-glass"></i></div><div>Discover</div></a>
239
238
  <a class='btn2' href="<%=portal%>" target="_blank"><div><i class="fa-solid fa-question"></i></div><div>Help</div></a>
240
239
  <button class='btn2' id='genlog'><div><i class="fa-solid fa-laptop-code"></i></div><div>Logs</div></button>
241
240
  <a id='downloadlogs' download class='hidden btn2' href="/pinokio/logs.zip"><div><i class="fa-solid fa-download"></i></div><div>Download logs</div></a>
@@ -115,12 +115,10 @@ body.frozen {
115
115
  <button class='btn2' id='back'><div><i class="fa-solid fa-chevron-left"></i></div><div>Prev</div></button>
116
116
  <button class='btn2' id='forward'><div><i class="fa-solid fa-chevron-right"></i></div><div>Next</div></button>
117
117
  <button class='btn2' id='refresh-page'><div><i class="fa-solid fa-rotate-right"></i></div><div>Refresh</div></button>
118
- <a class='btn2 create-new' id='create-new-folder'><div><i class="fa-solid fa-folder-plus"></i></div><div>Create</div></a>
119
118
  <a href="/network" class='btn2'><div><i class="fa-solid fa-wifi"></i></div><div>Network</div></a>
120
119
  <a href="/connect" class='btn2'><div><i class="fa-solid fa-circle-user"></i></div><div>Connect</div></a>
121
120
  <div class='flexible'></div>
122
121
  <div class='nav-btns'>
123
- <a class='btn2' id='explore' href="/?mode=explore"><div><i class="fa-solid fa-magnifying-glass"></i></div><div>Discover</div></a>
124
122
  <a class='btn2' href="<%=portal%>" target="_blank"><div><i class="fa-solid fa-question"></i></div><div>Help</div></a>
125
123
  <button class='btn2' id='genlog'><div><i class="fa-solid fa-laptop-code"></i></div><div>Logs</div></button>
126
124
  <a id='downloadlogs' download class='hidden btn2' href="/pinokio/logs.zip"><div><i class="fa-solid fa-download"></i></div><div>Download logs</div></a>
@@ -247,7 +247,8 @@ document.addEventListener("DOMContentLoaded", async () => {
247
247
  })
248
248
  console.log("res" ,res)
249
249
  <% if (init && name) { %>
250
- location.href = "/pinokio/browser/<%=name%>"
250
+ //location.href = "/pinokio/browser/<%=name%>"
251
+ location.href = "/p/<%=name%>"
251
252
  <% } else { %>
252
253
  n.Noty({
253
254
  text: `Updated!`
@@ -124,12 +124,10 @@ body main iframe {
124
124
  <button class='btn2' id='back'><div><i class="fa-solid fa-chevron-left"></i></div><div>Prev</div></button>
125
125
  <button class='btn2' id='forward'><div><i class="fa-solid fa-chevron-right"></i></div><div>Next</div></button>
126
126
  <button class='btn2' id='refresh-page'><div><i class="fa-solid fa-rotate-right"></i></div><div>Refresh</div></button>
127
- <a class='btn2 create-new' id='create-new-folder'><div><i class="fa-solid fa-folder-plus"></i></div><div>Create</div></a>
127
+ <div class='flexible'></div>
128
128
  <a href="/network" class='btn2'><div><i class="fa-solid fa-wifi"></i></div><div>Network</div></a>
129
129
  <a href="/connect" class='btn2'><div><i class="fa-solid fa-circle-user"></i></div><div>Connect</div></a>
130
- <div class='flexible'></div>
131
130
  <div class='nav-btns'>
132
- <a class='btn2' id='explore' href="/?mode=explore"><div><i class="fa-solid fa-magnifying-glass"></i></div><div>Discover</div></a>
133
131
  <a class='btn2' href="<%=portal%>" target="_blank"><div><i class="fa-solid fa-question"></i></div><div>Help</div></a>
134
132
  <button class='btn2' id='genlog'><div><i class="fa-solid fa-laptop-code"></i></div><div>Logs</div></button>
135
133
  <a id='downloadlogs' download class='hidden btn2' href="/pinokio/logs.zip"><div><i class="fa-solid fa-download"></i></div><div>Download logs</div></a>
@@ -182,7 +182,6 @@ body.dark .browser-options-row {
182
182
  </form>
183
183
  <% if (ishome) { %>
184
184
  <div class='nav-btns'>
185
- <a class='btn2' id='explore' href="/?mode=explore"><div><i class="fa-solid fa-magnifying-glass"></i></div><div>Discover</div></a>
186
185
  <a class='btn2' href="<%=portal%>" target="_blank"><div><i class="fa-solid fa-question"></i></div><div>Help</div></a>
187
186
  <% if (agent === "electron") { %>
188
187
  <a class='btn2' data-filepath="<%=filepath%>"><div><i class="fa-regular fa-folder-open"></i></div><div>Files</div></a>
@@ -209,12 +209,10 @@ hr {
209
209
  <button class='btn2' id='back'><div><i class="fa-solid fa-chevron-left"></i></div><div>Prev</div></button>
210
210
  <button class='btn2' id='forward'><div><i class="fa-solid fa-chevron-right"></i></div><div>Next</div></button>
211
211
  <button class='btn2' id='refresh-page'><div><i class="fa-solid fa-rotate-right"></i></div><div>Refresh</div></button>
212
- <a class='btn2 create-new' id='create-new-folder'><div><i class="fa-solid fa-folder-plus"></i></div><div>Create</div></a>
213
212
  <a href="/network" class='btn2'><div><i class="fa-solid fa-wifi"></i></div><div>Network</div></a>
214
213
  <a href="/connect" class='btn2'><div><i class="fa-solid fa-circle-user"></i></div><div>Connect</div></a>
215
214
  <div class='flexible'></div>
216
215
  <div class='nav-btns'>
217
- <a class='btn2' id='explore' href="/?mode=explore"><div><i class="fa-solid fa-magnifying-glass"></i></div><div>Discover</div></a>
218
216
  <a class='btn2' href="<%=portal%>" target="_blank"><div><i class="fa-solid fa-question"></i></div><div>Help</div></a>
219
217
  <button class='btn2' id='genlog'><div><i class="fa-solid fa-laptop-code"></i></div><div>Logs</div></button>
220
218
  <a id='downloadlogs' download class='hidden btn2' href="/pinokio/logs.zip"><div><i class="fa-solid fa-download"></i></div><div>Download logs</div></a>
@@ -257,10 +257,8 @@ body.dark .item .tile .badge {
257
257
  <button class='btn2' id='back'><div><i class="fa-solid fa-chevron-left"></i></div><div>Prev</div></button>
258
258
  <button class='btn2' id='forward'><div><i class="fa-solid fa-chevron-right"></i></div><div>Next</div></button>
259
259
  <button class='btn2' id='refresh-page'><div><i class="fa-solid fa-rotate-right"></i></div><div>Refresh</div></button>
260
- <a class='btn2 create-new' id='create-new-folder'><div><i class="fa-solid fa-folder-plus"></i></div><div>Create</div></a>
261
260
  <div class='flexible'></div>
262
261
  <div class='nav-btns'>
263
- <a class='btn2' id='explore' href="/?mode=explore"><div><i class="fa-solid fa-magnifying-glass"></i></div><div>Discover</div></a>
264
262
  <a class='btn2' href="/?mode=help"><div><i class="fa-regular fa-face-smile"></i></div><div>Community</div></a>
265
263
  <a class='btn2' href="/?mode=settings"><div><i class="fa-solid fa-gear"></i></div><div>Settings</div></a>
266
264
  <button id='new-window' title='open a new window' class='btn2' data-agent="<%=agent%>"><div><i class="fa-solid fa-plus"></i></div><div>Window</div></button>
@@ -117,7 +117,6 @@ a.badge {
117
117
  }
118
118
  body.dark .btn {
119
119
  color: white;
120
- border: 1px solid rgba(255,255,255,0.3);
121
120
  }
122
121
  body.dark .badge {
123
122
  background: rgba(255,255,255,0.1);
@@ -247,10 +246,14 @@ body.dark .open-menu, body.dark .browse {
247
246
  <button class='btn2' id='back'><div><i class="fa-solid fa-chevron-left"></i></div><div>Prev</div></button>
248
247
  <button class='btn2' id='forward'><div><i class="fa-solid fa-chevron-right"></i></div><div>Next</div></button>
249
248
  <button class='btn2' id='refresh-page'><div><i class="fa-solid fa-rotate-right"></i></div><div>Refresh</div></button>
250
- <a class='btn2 create-new' id='create-new-folder'><div><i class="fa-solid fa-folder-plus"></i></div><div>Create</div></a>
251
- <!--
252
- <a href="/new" class='btn2'><div><i class='fa-solid fa-folder-plus'></i></div><div>Create</div></a>
253
- -->
249
+ <div class='url-bar'>
250
+ <% if (current_urls.https) { %>
251
+ <a class='https-url' target="_blank" href="<%=current_urls.https%>"><i class="fa-solid fa-square-arrow-up-right"></i> <%=current_urls.https%></a>
252
+ <% } %>
253
+ <% if (current_urls.http) { %>
254
+ <a class='http-url' target="_blank" href="<%=current_urls.http%>"><i class="fa-solid fa-square-arrow-up-right"></i> <%=current_urls.http%></a>
255
+ <% } %>
256
+ </div>
254
257
  <a href="/network" class='btn2'><div><i class="fa-solid fa-wifi"></i></div><div>Network</div></a>
255
258
  <a href="/connect" class='btn2'><div><i class="fa-solid fa-circle-user"></i></div><div>Connect</div></a>
256
259
  <!--
@@ -264,15 +267,8 @@ body.dark .open-menu, body.dark .browse {
264
267
  <a class='path' href="<%=path.path%>"><%-path.name%></a>
265
268
  <% } %>
266
269
  <% }) %>
267
- <form class='search'>
268
- <% if (display.includes("form")) { %>
269
- <input type='search' class="flexible" placeholder='Filter downloaded apps'>
270
- <% } else { %>
271
- <% } %>
272
- </form>
273
270
  <% if (ishome) { %>
274
271
  <div class='nav-btns'>
275
- <a class='btn2' id='explore' href="/?mode=explore"><div><i class="fa-solid fa-magnifying-glass"></i></div><div>Discover</div></a>
276
272
  <a class='btn2' href="<%=portal%>" target="_blank"><div><i class="fa-solid fa-question"></i></div><div>Help</div></a>
277
273
  <button class='btn2' id='genlog'><div><i class="fa-solid fa-laptop-code"></i></div><div>Logs</div></button>
278
274
  <a id='downloadlogs' download class='hidden btn2' href="/pinokio/logs.zip"><div><i class="fa-solid fa-download"></i></div><div>Download logs</div></a>
@@ -306,51 +302,16 @@ body.dark .open-menu, body.dark .browse {
306
302
  <div id='terminal' class='hidden'></div>
307
303
  <div class='container'>
308
304
  <% if (ishome) { %>
309
- <% if (running.length === 0 && notRunning.length === 0) { %>
310
- <% } else { %>
311
- <% if (false) { %>
312
- <div class='browser-options'>
313
- <% if (agent === "electron") { %>
314
- <div class='browser-options-row'>
315
- <% if (agent === "electron") { %>
316
- <a href="/" target="_blank" class='btn' features="browser"><div><i class="fa-solid fa-square-up-right"></i> Open</div></a>
317
- <% } else { %>
318
- <a href="/" target="_blank" class='btn'><div><i class="fa-solid fa-square-up-right"></i> Open</div></a>
319
- <% } %>
320
- <div class='flexible'>
321
- <h3><i class="fa-solid fa-bolt"></i> Instant Launch</h3>
322
- <div>(Experimental) Directly open pinokio apps from your favorite browser address bar at localhost. If an app you're trying to use is already running, it will instantly load. If it's not, the app will first launch and then load the website.</div>
323
- </div>
324
- </div>
325
- <% } %>
326
- <div class='browser-options-row'>
327
- <a href="/network" class='btn'><div><i class="fa-solid fa-gauge"></i> Configure</div></a>
328
- <div class='flexible'>
329
- <h3><i class="fa-solid fa-wifi"></i> Local Sharing</h3>
330
- <div>Serve Pinokio, installed apps, and even external apps (example: Ollama) to any device on the same network.</div>
331
- </div>
332
- </div>
333
- <div class='browser-options-row hidden'>
334
- <% if (cloudflare_pub) { %>
335
- <a id='cloudflare-stop' class='btn'><div><i class="fa-solid fa-stop"></i> Stop</div></a>
336
- <div class='flexible'>
337
- <h3>Public Share</h3>
338
- <div>Open up your Pinokio server to the open internet (anyone with the URL can access)</div>
339
- <span class='badge'><i class="fa-solid fa-circle-notch fa-spin"></i> Running at <a href="<%=cloudflare_pub%>" target="_blank" features="browser"><%=cloudflare_pub%></a></span>
340
- <a id='cloudflare-qr' class='badge'><i class="fa-solid fa-qrcode"></i> Scan QR Code</a>
341
- </div>
342
- <% } else { %>
343
- <a id='cloudflare' class='btn'><div><i class="fa-solid fa-play"></i> Start</div></a>
344
- <a id='cloudflare-starting' class='btn disabled hidden'><div><i class="fa-solid fa-circle-notch fa-spin"></i> Starting</div></a>
345
- <div class='flexible'>
346
- <h3>Public Share</h3>
347
- <div>Open up your Pinokio server to the open internet (anyone with the URL can access)</div>
348
- </div>
349
- <% } %>
350
- </div>
351
- </div>
305
+ <form class='search'>
306
+ <div class='app-btns'>
307
+ <a class='btn create-new' id='create-new-folder'><i class="fa-solid fa-folder-plus"></i> Create</a>
308
+ <a class='btn' id='explore' href="/?mode=explore"><i class="fa-solid fa-magnifying-glass"></i> Discover</a>
309
+ </div>
310
+ <% if (display.includes("form")) { %>
311
+ <input type='search' class="flexible" placeholder='Filter downloaded apps'>
312
+ <% } else { %>
352
313
  <% } %>
353
- <% } %>
314
+ </form>
354
315
  <% if (running.length > 0) { %>
355
316
  <div class='running-apps'>
356
317
  <!--
@@ -302,8 +302,13 @@ body.dark .config {
302
302
  .config-row input[type=text] {
303
303
  padding: 7px;
304
304
  }
305
- .btn.save {
305
+ .btn {
306
306
  padding: 8px;
307
+ margin-right: 10px;
308
+ }
309
+ .btn.reset {
310
+ background: firebrick;
311
+ color: white !important;
307
312
  }
308
313
  .switcher {
309
314
  position: relative;
@@ -408,6 +413,7 @@ table h3 {
408
413
  <script src="/sweetalert2.js"></script>
409
414
  <script src="/common.js"></script>
410
415
  <script src="/opener.js"></script>
416
+ <script src="/nav.js"></script>
411
417
  </head>
412
418
  <body class='<%=theme%>' data-agent="<%=agent%>">
413
419
  <header class='navheader grabbable'>
@@ -416,12 +422,10 @@ table h3 {
416
422
  <button class='btn2' id='back'><div><i class="fa-solid fa-chevron-left"></i></div><div>Prev</div></button>
417
423
  <button class='btn2' id='forward'><div><i class="fa-solid fa-chevron-right"></i></div><div>Next</div></button>
418
424
  <button class='btn2' id='refresh-page'><div><i class="fa-solid fa-rotate-right"></i></div><div>Refresh</div></button>
419
- <a class='btn2 create-new' id='create-new-folder'><div><i class="fa-solid fa-folder-plus"></i></div><div>Create</div></a>
425
+ <div class='flexible'></div>
420
426
  <a href="/network" class='btn2'><div><i class="fa-solid fa-wifi"></i></div><div>Network</div></a>
421
427
  <a href="/connect" class='btn2'><div><i class="fa-solid fa-circle-user"></i></div><div>Connect</div></a>
422
- <div class='flexible'></div>
423
428
  <div class='nav-btns'>
424
- <a class='btn2' id='explore' href="/?mode=explore"><div><i class="fa-solid fa-magnifying-glass"></i></div><div>Discover</div></a>
425
429
  <a class='btn2' href="<%=portal%>" target="_blank"><div><i class="fa-solid fa-question"></i></div><div>Help</div></a>
426
430
  <button class='btn2' id='genlog'><div><i class="fa-solid fa-laptop-code"></i></div><div>Logs</div></button>
427
431
  <a id='downloadlogs' download class='hidden btn2' href="/pinokio/logs.zip"><div><i class="fa-solid fa-download"></i></div><div>Download logs</div></a>
@@ -457,7 +461,7 @@ table h3 {
457
461
  <div class='advanced'>
458
462
  <div class='row'>
459
463
  <div id='advanced-label' class='link-label label'>Advanced</div>
460
- <div id='reset-label' class='link-label label'>Reset HTTPS Certificates</div>
464
+ <div id='reset-label' class='link-label label'>Reset</div>
461
465
  </div>
462
466
  </div>
463
467
  </div>
@@ -554,7 +558,7 @@ table h3 {
554
558
  document.querySelector("#reset-label").addEventListener("click", async (e) => {
555
559
  e.preventDefault()
556
560
  e.stopPropagation()
557
- let ok = confirm("are you sure you want to re-generate http certificates?")
561
+ let ok = confirm("Are you sure you want to reset the network config? (The peer router will be updated to the latest version; 2. A new HTTPS certificate will be generated)")
558
562
  if (ok) {
559
563
  let r = await fetch("/network/reset", {
560
564
  method: "post",
@@ -278,9 +278,6 @@ body.dark .keys pre {
278
278
  <button class='btn2' id='back'><div><i class="fa-solid fa-chevron-left"></i></div><div>Prev</div></button>
279
279
  <button class='btn2' id='forward'><div><i class="fa-solid fa-chevron-right"></i></div><div>Next</div></button>
280
280
  <button class='btn2' id='refresh-page'><div><i class="fa-solid fa-rotate-right"></i></div><div>Refresh</div></button>
281
- <a class='btn2 create-new' id='create-new-folder'><div><i class="fa-solid fa-folder-plus"></i></div><div>Create</div></a>
282
- <a href="/network" class='btn2'><div><i class="fa-solid fa-wifi"></i></div><div>Network</div></a>
283
- <a href="/connect" class='btn2'><div><i class="fa-solid fa-circle-user"></i></div><div>Connect</div></a>
284
281
  <% paths.forEach((path) => { %>
285
282
  <% if (path.action) { %>
286
283
  <a class='path nav-button' id="<%=path.id%>" onclick="<%=path.action%>"><%-path.name%></a>
@@ -289,8 +286,9 @@ body.dark .keys pre {
289
286
  <% } %>
290
287
  <% }) %>
291
288
  <div class='flexible'></div>
289
+ <a href="/network" class='btn2'><div><i class="fa-solid fa-wifi"></i></div><div>Network</div></a>
290
+ <a href="/connect" class='btn2'><div><i class="fa-solid fa-circle-user"></i></div><div>Connect</div></a>
292
291
  <div class='nav-btns'>
293
- <a class='btn2' id='explore' href="/?mode=explore"><div><i class="fa-solid fa-magnifying-glass"></i></div><div>Discover</div></a>
294
292
  <a class='btn2' href="<%=portal%>" target="_blank"><div><i class="fa-solid fa-question"></i></div><div>Help</div></a>
295
293
  <button class='btn2' id='genlog'><div><i class="fa-solid fa-laptop-code"></i></div><div>Logs</div></button>
296
294
  <a id='downloadlogs' download class='hidden btn2' href="/pinokio/logs.zip"><div><i class="fa-solid fa-download"></i></div><div>Download logs</div></a>