pinokiod 1.3.41 → 1.3.42

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.
@@ -1053,10 +1053,18 @@ class Api {
1053
1053
  } else if (request.method) {
1054
1054
 
1055
1055
  if (request.params && request.params.path) {
1056
- request.params.path = this.resolvePath(this.userdir, request.params.path)
1056
+ if (request.cwd) {
1057
+ console.log("request.cwd", request.cwd)
1058
+ let rendered_cwd = this.kernel.template.render(request.cwd, { kernel: this.kernel }, { allow_undefined: true })
1059
+ console.log("rendered_cwd", rendered_cwd)
1060
+ request.params.path = this.resolvePath(rendered_cwd, request.params.path)
1061
+ } else {
1062
+ request.params.path = this.resolvePath(this.userdir, request.params.path)
1063
+ }
1057
1064
  }
1058
1065
 
1059
1066
  // Kernel Call
1067
+ console.log("REQUEST", request)
1060
1068
  let resolved = await this.resolveMethod(request)
1061
1069
  try {
1062
1070
  resolved.dirname = resolved.dirname
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "1.3.41",
3
+ "version": "1.3.42",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/server/index.js CHANGED
@@ -2020,9 +2020,18 @@ class Server {
2020
2020
  // }
2021
2021
  })
2022
2022
 
2023
-
2024
-
2025
-
2023
+ this.app.get("/edit/*", async (req, res) => {
2024
+ let pathComponents = req.params[0].split("/")
2025
+ let filepath = path.resolve(this.kernel.homedir, req.params[0])
2026
+ const content = await fs.promises.readFile(filepath, "utf8")
2027
+ console.log({ pathComponents, content })
2028
+ res.render("general_editor", {
2029
+ theme: this.theme,
2030
+ filepath,
2031
+ content,
2032
+ agent: this.agent,
2033
+ })
2034
+ })
2026
2035
  this.app.get("/script/:name", (req, res) => {
2027
2036
  if (req.params.name === "start") {
2028
2037
  res.json(this.startScripts)
@@ -0,0 +1,208 @@
1
+ <html class='columns'>
2
+ <head>
3
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
4
+ <script src="/hotkeys.min.js"></script>
5
+ <script src="/ace/ace.js"></script>
6
+ <script src="/noty.js"></script>
7
+ <script src="/notyq.js"></script>
8
+ <script src="/xterm.js"></script>
9
+ <script src="/xterm-addon-fit.js"></script>
10
+ <script src="/xterm-addon-web-links.js"></script>
11
+ <script src="/xterm-theme.js"></script>
12
+ <script src="/xterm-addon-search.js"></script>
13
+ <script src="/xterm-addon-search-bar.js"></script>
14
+ <script src="/sweetalert2.js"></script>
15
+ <script src="/Socket.js"></script>
16
+ <script src="/common.js"></script>
17
+ <script src="/he.js"></script>
18
+ <script src="/opener.js"></script>
19
+ <script src="/nav.js"></script>
20
+ <script src="/autoexpand.js"></script>
21
+ <script src="/modalinput.js"></script>
22
+ <script src="/simplemodal.js"></script>
23
+ <script src="/waitmodal.js"></script>
24
+ <script src="/notifyinput.js"></script>
25
+ <script src="/report.js"></script>
26
+ <link href="/xterm.min.css" rel="stylesheet" />
27
+ <link href="/css/fontawesome.min.css" rel="stylesheet">
28
+ <link href="/css/solid.min.css" rel="stylesheet">
29
+ <link href="/css/regular.min.css" rel="stylesheet">
30
+ <link href="/css/brands.min.css" rel="stylesheet">
31
+ <link href="/style.css" rel="stylesheet"/>
32
+ <link href="/noty.css" rel="stylesheet"/>
33
+ <% if (agent === "electron") { %>
34
+ <link href="/electron.css" rel="stylesheet"/>
35
+ <% } %>
36
+ <style>
37
+ body.frozen {
38
+ display: flex;
39
+ flex-direction: column;
40
+ height: 100%;
41
+ }
42
+ #table > table {
43
+ border-left: 2px solid black;
44
+ padding-left: 5px;
45
+ margin: 10px 0;
46
+ }
47
+ .highlight {
48
+ background: yellow;
49
+ width: 100px;
50
+ }
51
+ th {
52
+ background: rgba(0,0,0,0.1);
53
+ padding: 10px;
54
+ font-size: 12px;
55
+ }
56
+ td {
57
+ font-size: 12px;
58
+ padding: 10px;
59
+ }
60
+ td.val {
61
+ background: rgba(0,0,0,0.06);
62
+ }
63
+ td.key {
64
+ background: rgba(0,0,0,0.1);
65
+ }
66
+ .button {
67
+ cursor: pointer;
68
+ background: rgba(0,0,0,0.8);
69
+ color: white;
70
+ padding: 5px 10px;
71
+ border-radius: 4px;
72
+ }
73
+ .button:hover {
74
+
75
+ }
76
+ #editor {
77
+ background: var(--dark-bg);
78
+ }
79
+ header .runner {
80
+ padding: 10px 0 0;
81
+ }
82
+ .disabled {
83
+ opacity: 0.7;
84
+ }
85
+ </style>
86
+ <script>
87
+ document.addEventListener("DOMContentLoaded", async () => {
88
+ let editor = ace.edit("editor");
89
+ //editor.setTheme("ace/theme/tomorrow");
90
+ //editor.setTheme("ace/theme/ambiance");
91
+ //editor.setTheme("ace/theme/idle_fingers");
92
+ editor.setTheme("ace/theme/nord_dark");
93
+ //editor.setTheme("ace/theme/textmate");
94
+ editor.setOptions({
95
+ maxLines: Infinity, // set to a large number
96
+ minLines: 1 // set to a small number
97
+ });
98
+ console.log("location.pathname", location.pathname)
99
+ if (location.pathname.endsWith("ENVIRONMENT")) {
100
+ editor.session.setMode("ace/mode/python");
101
+ }
102
+ //editor.session.setMode("ace/mode/javascript");
103
+ //editor.setValue(file)
104
+ editor.clearSelection()
105
+ if (location.hash && location.hash.length > 1) {
106
+ let parsedHash = location.hash.slice(1)
107
+ let line_re = /L([0-9]+)/
108
+ let line_match = line_re.exec(parsedHash)
109
+ if (line_match && line_match.length > 0) {
110
+ let line = parseInt(line_match[1])
111
+ editor.gotoLine(line)
112
+ editor.selection.selectLine()
113
+ editor.gotoLine(line)
114
+ editor.focus()
115
+ }
116
+ // let range_re = /L[0-9]+-L[0-9]+/
117
+
118
+ // let range_match = range_re.exec(parsedHash)
119
+ // if (range_match && range_match.length > 0) {
120
+ //
121
+ // }
122
+ }
123
+ let dirty
124
+ let str;
125
+ let original = editor.getValue()
126
+ editor.getSession().on("change", () => {
127
+ let v = editor.getValue()
128
+ if (original === v) {
129
+ dirty = false
130
+ document.querySelector("#save").classList.add("disabled")
131
+ } else {
132
+ dirty = true
133
+ document.querySelector("#save").classList.remove("disabled")
134
+ }
135
+ str = v
136
+ });
137
+ const n = new N()
138
+ class RPC {
139
+ constructor() {
140
+ this.socket = new Socket()
141
+ }
142
+ save() {
143
+ return new Promise((resolve, reject) => {
144
+ // remove `/edit/`
145
+ let filepath = location.pathname.slice(6)
146
+ this.socket.close()
147
+ this.socket.run({
148
+ method: "fs.write",
149
+ cwd: "{{kernel.homedir}}",
150
+ params: {
151
+ path: filepath,
152
+ text: str,
153
+ }
154
+ }, (packet) => {
155
+ if (packet.type === "result" && packet.id === "fs.write") {
156
+ dirty = false
157
+ document.querySelector("#save").classList.add("disabled")
158
+ resolve()
159
+ }
160
+ })
161
+ })
162
+ }
163
+ }
164
+ const rpc = new RPC()
165
+ if (document.querySelector("#save")) {
166
+ document.querySelector("#save").addEventListener("click", async (e) => {
167
+ console.log("SAVE")
168
+ await rpc.save()
169
+ n.Noty({
170
+ text: `saved`,
171
+ })
172
+ })
173
+ }
174
+ if (document.querySelector("#lv")) {
175
+ document.querySelector("#lv").addEventListener("click", (e) => {
176
+ let m = e.target.closest(".memory")
177
+ m.classList.toggle("collapsed")
178
+ if (m.classList.contains("collapsed")) {
179
+ m.querySelector("i").className = "fa-solid fa-sort-down"
180
+ } else {
181
+ m.querySelector("i").className = "fa-solid fa-sort-up"
182
+ }
183
+ })
184
+ }
185
+ })
186
+ </script>
187
+ </head>
188
+ <body class='columns <%=theme%>'>
189
+ <header class='navheader grabbable'>
190
+ <h1>
191
+ <a class='home' href="/"><i class="fa-solid fa-house"></i></a>
192
+ <%=filepath%>
193
+ </h1>
194
+ <div class='runner'>
195
+ <div id='save' class='btn disabled'>
196
+ <span class='save'><i class="fa-solid fa-check"></i> Save</span>
197
+ </div>
198
+ <button class='btn' id='open-fs' data-filepath="<%=filepath%>"><i class="fa-solid fa-eye"></i> Open in File Explorer</button>
199
+ </div>
200
+ </header>
201
+ <div class='containers'>
202
+ <main>
203
+ <div id='editor'><%=content%></div>
204
+ </main>
205
+ </div>
206
+ <footer><b>Ready</b></footer>
207
+ </body>
208
+ </html>
@@ -126,9 +126,9 @@ header .runner {
126
126
  <a class='btn2' href="/?mode=help"><div><i class="fa-regular fa-face-smile"></i></div><div>Community</div></a>
127
127
  <% if (agent === "electron") { %>
128
128
  <a class='btn2' data-filepath="<%=filepath%>"><div><i class="fa-regular fa-folder-open"></i></div><div>Files</div></a>
129
+ <a href="/" target="_blank" class='btn2' features="browser"><div><i class="fa-solid fa-arrow-up-right-from-square"></i></div><div>Popout</div></a>
129
130
  <% } %>
130
131
  <a id='wifi' data-proxy="<%=proxy.proxy%>" class='btn2'><div><i class="fa-solid fa-wifi"></i></div><div>WiFi Share</div></a>
131
- <a href="/" target="_blank" class='btn2'><div><i class="fa-solid fa-arrow-up-right-from-square"></i></div><div>Popout</div></a>
132
132
  <!--
133
133
  <a class='btn2' id='report'><div><i class="fa-solid fa-bug"></i></div><div>Report Bug</div></a>
134
134
  <a class='btn2' href='https://discord.gg/TQdNwadtE4' target="_blank"><div><i class="fa-brands fa-discord"></i></div><div>Discord</div></a>
@@ -291,6 +291,15 @@ hr {
291
291
  <i class="fa-solid fa-circle-notch fa-spin"></i> Stand by. Do not close this window..
292
292
  </div>
293
293
  <hr/>
294
+ <div class='advanced'>
295
+ <h1>Advanced Settings</h1>
296
+ <br>
297
+ <br>
298
+ <div>Edit the system ENVIRONMENT file to customize pinokio system wide settings, such as where files are stored, terminal behavior, etc.</div>
299
+ <br>
300
+ <a class='btn' href="/edit/ENVIRONMENT">Edit ENVIRONMENT</a>
301
+ </div>
302
+ <hr/>
294
303
  <% if (locals.bin) { %>
295
304
  <div class='troubleshoot'>
296
305
  <h1>Troubleshoot</h1>