pinokiod 2.15.38 → 2.15.40

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.
@@ -75,12 +75,17 @@ class FS {
75
75
  /*
76
76
  params := {
77
77
  path: <filepath>,
78
+ mode: "view(default)|open"
78
79
  }
79
80
  open finder/file explorer at path
80
81
  */
81
82
  let dirPath = path.resolve(req.cwd, req.params.path)
82
83
  ondata({ raw: `\r\nopening path: ${dirPath}\r\n` })
83
- Util.openfs(dirPath)
84
+ if (req.params.mode) {
85
+ Util.openfs(dirPath, req.params.mode)
86
+ } else {
87
+ Util.openfs(dirPath)
88
+ }
84
89
  }
85
90
 
86
91
  async link(req, ondata, kernel) {
package/kernel/util.js CHANGED
@@ -61,19 +61,38 @@ const parse_env = async (filename) => {
61
61
  return {}
62
62
  }
63
63
  }
64
- const openfs = (dirPath) => {
64
+ const openfs = (dirPath, options) => {
65
65
  let command = '';
66
66
  const platform = os.platform()
67
- switch (platform) {
68
- case 'darwin':
69
- command = `open -R "${dirPath}"`;
70
- break;
71
- case 'win32':
72
- command = `explorer /select,"${dirPath}" & timeout /t 1 >nul`;
73
- break;
74
- default:
75
- command = `xdg-open "${dirPath}"`;
76
- break;
67
+ let type = (options && options.
68
+ let mode = "view"
69
+ if (options && options.mode) {
70
+ mode = options.mode
71
+ }
72
+ if (mode === "view") {
73
+ switch (platform) {
74
+ case 'darwin':
75
+ command = `open -R "${dirPath}"`;
76
+ break;
77
+ case 'win32':
78
+ command = `explorer /select,"${dirPath}" & timeout /t 1 >nul`;
79
+ break;
80
+ default:
81
+ command = `xdg-open "${dirPath}"`;
82
+ break;
83
+ }
84
+ } else if (mode === "open") {
85
+ switch (platform) {
86
+ case 'darwin':
87
+ command = `open "${dirPath}"`;
88
+ break;
89
+ case 'win32':
90
+ command = `explorer "${dirPath}"`;
91
+ break;
92
+ default:
93
+ command = `xdg-open "${dirPath}"`;
94
+ break;
95
+ }
77
96
  }
78
97
  child_process.exec(command)
79
98
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "2.15.38",
3
+ "version": "2.15.40",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/server/index.js CHANGED
@@ -1329,6 +1329,7 @@ class Server {
1329
1329
  readme,
1330
1330
  filepath,
1331
1331
  mode: null,
1332
+ kernel: this.kernel,
1332
1333
  //mode: (req.query && req.query.mode ? req.query.mode : null),
1333
1334
  items
1334
1335
  })
@@ -2087,10 +2088,14 @@ class Server {
2087
2088
  origin: '*'
2088
2089
  }));
2089
2090
 
2091
+ this.app.use(express.static(this.kernel.path("web/public")))
2090
2092
  this.app.use(express.static(path.resolve(__dirname, 'public')));
2091
2093
  this.app.use("/web", express.static(path.resolve(__dirname, "..", "..", "web")))
2092
2094
  this.app.set('view engine', 'ejs');
2093
- this.app.set("views", path.resolve(__dirname, "views"))
2095
+ this.app.set("views", [
2096
+ this.kernel.path("web/views"),
2097
+ path.resolve(__dirname, "views")
2098
+ ])
2094
2099
  this.app.use(express.json());
2095
2100
  this.app.use(express.urlencoded({ extended: true }));
2096
2101
  this.app.use(cookieParser());
@@ -2229,7 +2234,7 @@ class Server {
2229
2234
  }))
2230
2235
 
2231
2236
  this.app.post("/openfs", ex(async (req, res) => {
2232
- Util.openfs(req.body.path)
2237
+ Util.openfs(req.body.path, req.body.mode)
2233
2238
  res.json({ success: true })
2234
2239
  }))
2235
2240
  this.app.get("/proxy", ex(async (req, res) => {
@@ -2645,10 +2650,21 @@ class Server {
2645
2650
  if (req.query && 'fs' in req.query) {
2646
2651
  // open in file system
2647
2652
  let full_filepath = this.kernel.path("api", ...pathComponents)
2648
- Util.openfs(full_filepath)
2649
- res.render("fs", {
2650
- path: full_filepath
2651
- })
2653
+ if (req.query.fs) {
2654
+ if (req.query.fs === 'open') {
2655
+ // open
2656
+ Util.openfs(full_filepath, { mode: "open" })
2657
+ } else if (req.query.fs === 'view') {
2658
+ // view
2659
+ Util.openfs(full_filepath, { mode: "view" })
2660
+ } else {
2661
+ // view
2662
+ Util.openfs(full_filepath, { mode: "view" })
2663
+ }
2664
+ res.render("fs", {
2665
+ path: full_filepath
2666
+ })
2667
+ }
2652
2668
  } else {
2653
2669
  try {
2654
2670
  await this.render(req, res, pathComponents)
@@ -854,7 +854,6 @@ document.addEventListener("click", async (e) => {
854
854
  actions: "hidden"
855
855
  }
856
856
  });
857
- debugger
858
857
  let res = await fetch("/pinokio/delete", {
859
858
  method: "post",
860
859
  headers: {
@@ -233,6 +233,8 @@ hr {
233
233
  <div class='nav-btns'>
234
234
  <a class='btn2' id='explore'><div><i class="fa-solid fa-globe"></i></div><div>Discover</div></a>
235
235
  <a class='btn2' href="https://portal.pinokio.computer/" target="_blank"><div><i class="fa-solid fa-question"></i></div><div>Help</div></a>
236
+ <button class='btn2' id='genlog'><div><i class="fa-solid fa-laptop-code"></i></div><div>Debug</div></button>
237
+ <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>
236
238
  <a class='btn2' href="/?mode=settings"><div><i class="fa-solid fa-gear"></i></div><div>Settings</div></a>
237
239
  <button id='new-window' title='open a new window' class='btn2'><div><i class="fa-solid fa-plus"></i></div><div>Window</div></button>
238
240
  </div>
@@ -454,6 +456,24 @@ document.addEventListener("DOMContentLoaded", async () => {
454
456
  document.querySelector("#forward").addEventListener("click", (e) => {
455
457
  history.forward()
456
458
  })
459
+ if (document.querySelector("#genlog")) {
460
+ document.querySelector("#genlog").addEventListener("click", (e) => {
461
+ e.preventDefault()
462
+ e.stopPropagation()
463
+ e.target.innerHTML = '<i class="fa-solid fa-circle-notch fa-spin"></i>'
464
+ fetch("/pinokio/log", {
465
+ method: "post",
466
+ }).then((res) => {
467
+ console.log("RES", res)
468
+ let btn = document.querySelector("#genlog")
469
+ let btn2 = document.querySelector("#downloadlogs")
470
+ btn2.classList.remove("hidden")
471
+ btn.classList.add("hidden")
472
+ btn.innerHTML = '<i class="fa-solid fa-circle-check"></i> Generated!'
473
+ //btn.classList.add("hidden")
474
+ })
475
+ })
476
+ }
457
477
  document.querySelector("#explore").addEventListener("click", async (e) => {
458
478
  e.preventDefault()
459
479
  e.stopPropagation()