@saltcorn/server 0.5.4-beta.1 → 0.5.5
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/load_plugins.js +12 -3
- package/locales/en.json +3 -1
- package/package.json +8 -8
- package/public/saltcorn.css +3 -0
- package/public/saltcorn.js +42 -0
- package/routes/actions.js +9 -2
- package/routes/plugins.js +7 -5
- package/serve.js +1 -1
- package/wrapper.js +6 -0
package/load_plugins.js
CHANGED
|
@@ -54,7 +54,7 @@ const loadPlugin = async (plugin, force) => {
|
|
|
54
54
|
const res = await requirePlugin(plugin, force);
|
|
55
55
|
// register plugin
|
|
56
56
|
getState().registerPlugin(
|
|
57
|
-
plugin.name,
|
|
57
|
+
res.plugin_module.plugin_name || plugin.name,
|
|
58
58
|
res.plugin_module,
|
|
59
59
|
plugin.configuration,
|
|
60
60
|
res.location
|
|
@@ -176,7 +176,12 @@ const loadAndSaveNewPlugin = async (plugin, force, noSignalOrDB) => {
|
|
|
176
176
|
);
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
|
-
getState().registerPlugin(
|
|
179
|
+
getState().registerPlugin(
|
|
180
|
+
plugin_module.plugin_name || plugin.name,
|
|
181
|
+
plugin_module,
|
|
182
|
+
undefined,
|
|
183
|
+
location
|
|
184
|
+
);
|
|
180
185
|
if (plugin_module.onLoad) {
|
|
181
186
|
try {
|
|
182
187
|
await plugin_module.onLoad(plugin.configuration);
|
|
@@ -187,7 +192,11 @@ const loadAndSaveNewPlugin = async (plugin, force, noSignalOrDB) => {
|
|
|
187
192
|
if (version) plugin.version = version;
|
|
188
193
|
if (!noSignalOrDB) await plugin.upsert();
|
|
189
194
|
if (!noSignalOrDB && process.send)
|
|
190
|
-
process.send({
|
|
195
|
+
process.send({
|
|
196
|
+
installPlugin: plugin,
|
|
197
|
+
tenant: db.getTenantSchema(),
|
|
198
|
+
force,
|
|
199
|
+
});
|
|
191
200
|
};
|
|
192
201
|
|
|
193
202
|
module.exports = {
|
package/locales/en.json
CHANGED
|
@@ -781,5 +781,7 @@
|
|
|
781
781
|
"Show older messages": "Show older messages",
|
|
782
782
|
"New table name": "New table name",
|
|
783
783
|
"Password Repeat": "Password Repeat",
|
|
784
|
-
"Remember me": "Remember me"
|
|
784
|
+
"Remember me": "Remember me",
|
|
785
|
+
"Column width": "Column width",
|
|
786
|
+
"Column width units": "Column width units"
|
|
785
787
|
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saltcorn/server",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"description": "Server app for Saltcorn, open-source no-code platform",
|
|
5
5
|
"homepage": "https://saltcorn.com",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@saltcorn/base-plugin": "0.5.
|
|
10
|
-
"@saltcorn/builder": "0.5.
|
|
11
|
-
"@saltcorn/data": "0.5.
|
|
9
|
+
"@saltcorn/base-plugin": "0.5.5",
|
|
10
|
+
"@saltcorn/builder": "0.5.5",
|
|
11
|
+
"@saltcorn/data": "0.5.5",
|
|
12
12
|
"greenlock-express": "^4.0.3",
|
|
13
|
-
"@saltcorn/markup": "0.5.
|
|
14
|
-
"@saltcorn/sbadmin2": "0.5.
|
|
13
|
+
"@saltcorn/markup": "0.5.5",
|
|
14
|
+
"@saltcorn/sbadmin2": "0.5.5",
|
|
15
15
|
"@socket.io/cluster-adapter": "^0.1.0",
|
|
16
16
|
"@socket.io/sticky": "^1.0.1",
|
|
17
17
|
"connect-flash": "^0.1.1",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"greenlock": "^4.0.4",
|
|
31
31
|
"helmet": "^3.23.3",
|
|
32
32
|
"i18n": "^0.13.2",
|
|
33
|
-
"live-plugin-manager": "^0.
|
|
33
|
+
"live-plugin-manager": "^0.16.0",
|
|
34
34
|
"moment": "^2.27.0",
|
|
35
35
|
"node-fetch": "^2.6.1",
|
|
36
36
|
"passport": "^0.4.1",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"passport-http-bearer": "^1.0.1",
|
|
39
39
|
"pg": "^8.2.1",
|
|
40
40
|
"pluralize": "^8.0.0",
|
|
41
|
-
"socket.io": "4.
|
|
41
|
+
"socket.io": "4.2.0",
|
|
42
42
|
"tmp-promise": "^3.0.2"
|
|
43
43
|
},
|
|
44
44
|
"optionalDependencies": {
|
package/public/saltcorn.css
CHANGED
package/public/saltcorn.js
CHANGED
|
@@ -106,28 +106,70 @@ function reindex(element, oldix, newix) {
|
|
|
106
106
|
);
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
function get_form_subset_record(e) {
|
|
110
|
+
const rec = {};
|
|
111
|
+
e.find("input[name],select[name]").each(function () {
|
|
112
|
+
rec[$(this).attr("name")] = $(this).val();
|
|
113
|
+
});
|
|
114
|
+
return rec;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function apply_form_subset_record(e, vals) {
|
|
118
|
+
e.find("input[name],select[name]").each(function () {
|
|
119
|
+
var name = $(this).attr("name");
|
|
120
|
+
if (vals[name]) $(this).val(vals[name]);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function reindex_form_record(vals, oldix, newix) {
|
|
125
|
+
const rec = {};
|
|
126
|
+
Object.keys(vals).forEach((k) => {
|
|
127
|
+
const newkey = k.split("_" + oldix).join("_" + newix);
|
|
128
|
+
rec[newkey] = vals[k];
|
|
129
|
+
});
|
|
130
|
+
return rec;
|
|
131
|
+
}
|
|
132
|
+
|
|
109
133
|
function rep_up(e) {
|
|
110
134
|
var myrep = $(e).closest(".form-repeat");
|
|
135
|
+
var theform = $(e).closest("form");
|
|
111
136
|
var ix = myrep.index();
|
|
112
137
|
var parent = myrep.parent();
|
|
113
138
|
if (ix > 0) {
|
|
114
139
|
var swap_with = parent.children(".form-repeat").eq(ix - 1);
|
|
140
|
+
var vals1 = reindex_form_record(get_form_subset_record(myrep), ix, ix - 1);
|
|
141
|
+
var vals2 = reindex_form_record(
|
|
142
|
+
get_form_subset_record(swap_with),
|
|
143
|
+
ix - 1,
|
|
144
|
+
ix
|
|
145
|
+
);
|
|
115
146
|
reindex(myrep, ix, ix - 1);
|
|
116
147
|
reindex(swap_with, ix - 1, ix);
|
|
117
148
|
$(myrep).swapWith(swap_with);
|
|
149
|
+
apply_form_subset_record(theform, vals2);
|
|
150
|
+
apply_form_subset_record(theform, vals1);
|
|
118
151
|
}
|
|
119
152
|
}
|
|
120
153
|
|
|
121
154
|
function rep_down(e) {
|
|
122
155
|
var myrep = $(e).closest(".form-repeat");
|
|
156
|
+
var theform = $(e).closest("form");
|
|
123
157
|
var ix = myrep.index();
|
|
124
158
|
var parent = myrep.parent();
|
|
125
159
|
var nchildren = parent.children(".form-repeat").length;
|
|
126
160
|
if (ix < nchildren - 1) {
|
|
127
161
|
var swap_with = parent.children(".form-repeat").eq(ix + 1);
|
|
162
|
+
var vals1 = reindex_form_record(get_form_subset_record(myrep), ix, ix + 1);
|
|
163
|
+
var vals2 = reindex_form_record(
|
|
164
|
+
get_form_subset_record(swap_with),
|
|
165
|
+
ix + 1,
|
|
166
|
+
ix
|
|
167
|
+
);
|
|
128
168
|
reindex(myrep, ix, ix + 1);
|
|
129
169
|
reindex(swap_with, ix + 1, ix);
|
|
130
170
|
$(myrep).swapWith(swap_with);
|
|
171
|
+
apply_form_subset_record(theform, vals2);
|
|
172
|
+
apply_form_subset_record(theform, vals1);
|
|
131
173
|
}
|
|
132
174
|
}
|
|
133
175
|
function initialize_page() {
|
package/routes/actions.js
CHANGED
|
@@ -41,6 +41,7 @@ const {
|
|
|
41
41
|
td,
|
|
42
42
|
h6,
|
|
43
43
|
pre,
|
|
44
|
+
text,
|
|
44
45
|
hr,
|
|
45
46
|
} = require("@saltcorn/markup/tags");
|
|
46
47
|
const Table = require("@saltcorn/data/models/table");
|
|
@@ -557,11 +558,17 @@ router.get(
|
|
|
557
558
|
const output = [];
|
|
558
559
|
const fakeConsole = {
|
|
559
560
|
log(...s) {
|
|
560
|
-
|
|
561
|
+
console.log(...s);
|
|
562
|
+
output.push(div(code(pre(text(s.join(" "))))));
|
|
561
563
|
},
|
|
562
564
|
error(...s) {
|
|
563
565
|
output.push(
|
|
564
|
-
div(
|
|
566
|
+
div(
|
|
567
|
+
code(
|
|
568
|
+
{ style: "color:red;font-weight:bold;" },
|
|
569
|
+
pre(text(s.join(" ")))
|
|
570
|
+
)
|
|
571
|
+
)
|
|
565
572
|
);
|
|
566
573
|
},
|
|
567
574
|
};
|
package/routes/plugins.js
CHANGED
|
@@ -529,16 +529,18 @@ router.get(
|
|
|
529
529
|
})
|
|
530
530
|
);
|
|
531
531
|
router.get(
|
|
532
|
-
"/public/:plugin
|
|
532
|
+
"/public/:plugin/*",
|
|
533
533
|
setTenant,
|
|
534
534
|
error_catcher(async (req, res) => {
|
|
535
|
-
const { plugin
|
|
536
|
-
|
|
535
|
+
const { plugin } = req.params;
|
|
536
|
+
const filepath = req.params[0];
|
|
537
537
|
const location = getState().plugin_locations[plugin];
|
|
538
538
|
if (location) {
|
|
539
|
-
const safeFile = path
|
|
539
|
+
const safeFile = path
|
|
540
|
+
.normalize(filepath)
|
|
541
|
+
.replace(/^(\.\.(\/|\\|$))+/, "");
|
|
540
542
|
const fullpath = path.join(location, "public", safeFile);
|
|
541
|
-
if (fs.existsSync(fullpath)) res.sendFile(fullpath, { maxAge: "
|
|
543
|
+
if (fs.existsSync(fullpath)) res.sendFile(fullpath, { maxAge: "1d" });
|
|
542
544
|
else res.status(404).send(req.__("Not found"));
|
|
543
545
|
} else {
|
|
544
546
|
res.status(404).send(req.__("Not found"));
|
package/serve.js
CHANGED
|
@@ -120,7 +120,7 @@ module.exports = async ({
|
|
|
120
120
|
? +process.env.SALTCORN_NWORKERS
|
|
121
121
|
: defaultNCPUs;
|
|
122
122
|
|
|
123
|
-
const letsEncrypt = getConfig("letsencrypt", false);
|
|
123
|
+
const letsEncrypt = await getConfig("letsencrypt", false);
|
|
124
124
|
const masterState = {
|
|
125
125
|
started: false,
|
|
126
126
|
listeningTo: new Set([]),
|
package/wrapper.js
CHANGED
|
@@ -245,6 +245,11 @@ module.exports = (version_tag) =>
|
|
|
245
245
|
const renderToHtml = layout.renderBody
|
|
246
246
|
? (h, role) => layout.renderBody({ title, body: h, role, alerts })
|
|
247
247
|
: defaultRenderToHtml;
|
|
248
|
+
res.header(
|
|
249
|
+
"Cache-Control",
|
|
250
|
+
"private, no-cache, no-store, must-revalidate"
|
|
251
|
+
);
|
|
252
|
+
|
|
248
253
|
res.set("Page-Title", encodeURIComponent(title));
|
|
249
254
|
res.send(
|
|
250
255
|
html.length === 1
|
|
@@ -256,6 +261,7 @@ module.exports = (version_tag) =>
|
|
|
256
261
|
const currentUrl = req.originalUrl.split("?")[0];
|
|
257
262
|
|
|
258
263
|
const pageHeaders = typeof opts === "string" ? [] : opts.headers;
|
|
264
|
+
|
|
259
265
|
res.send(
|
|
260
266
|
layout.wrap({
|
|
261
267
|
title,
|