qumra-engine 2.0.25 → 2.0.27
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/dist/extensions/index.d.ts +1 -0
- package/dist/extensions/index.js +3 -1
- package/dist/extensions/logic/qumra-head copy.d.ts +7 -0
- package/dist/extensions/logic/qumra-head copy.js +37 -0
- package/dist/extensions/logic/qumra-head.js +5 -2
- package/dist/extensions/logic/qumra-scripts.d.ts +7 -0
- package/dist/extensions/logic/qumra-scripts.js +20 -0
- package/dist/filters/logic/colors/color_to_hex.js +3 -10
- package/dist/middleware/mergeData.middleware.js +5 -5
- package/dist/middleware/render.middleware.js +3 -1
- package/dist/types/sharedTypes.d.ts +17 -1
- package/package.json +2 -2
|
@@ -5,3 +5,4 @@ export { default as header } from './logic/header';
|
|
|
5
5
|
export { default as footer } from './logic/footer';
|
|
6
6
|
export { default as content } from './logic/content';
|
|
7
7
|
export { default as qumra_head } from './logic/qumra-head';
|
|
8
|
+
export { default as qumra_scripts } from './logic/qumra-scripts';
|
package/dist/extensions/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.qumra_head = exports.content = exports.footer = exports.header = exports.form = exports.widget = exports.seo = void 0;
|
|
6
|
+
exports.qumra_scripts = exports.qumra_head = exports.content = exports.footer = exports.header = exports.form = exports.widget = exports.seo = void 0;
|
|
7
7
|
var seo_1 = require("./logic/seo");
|
|
8
8
|
Object.defineProperty(exports, "seo", { enumerable: true, get: function () { return __importDefault(seo_1).default; } });
|
|
9
9
|
var widget_1 = require("./logic/widget");
|
|
@@ -18,3 +18,5 @@ var content_1 = require("./logic/content");
|
|
|
18
18
|
Object.defineProperty(exports, "content", { enumerable: true, get: function () { return __importDefault(content_1).default; } });
|
|
19
19
|
var qumra_head_1 = require("./logic/qumra-head");
|
|
20
20
|
Object.defineProperty(exports, "qumra_head", { enumerable: true, get: function () { return __importDefault(qumra_head_1).default; } });
|
|
21
|
+
var qumra_scripts_1 = require("./logic/qumra-scripts");
|
|
22
|
+
Object.defineProperty(exports, "qumra_scripts", { enumerable: true, get: function () { return __importDefault(qumra_scripts_1).default; } });
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const nunjucks_1 = require("nunjucks");
|
|
4
|
+
const globals_1 = require("../../store/globals");
|
|
5
|
+
exports.default = new (class SeoExtension {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.tags = ["qumra_head"];
|
|
8
|
+
}
|
|
9
|
+
parse(parser, nodes) {
|
|
10
|
+
const tok = parser.nextToken();
|
|
11
|
+
parser.advanceAfterBlockEnd(tok.value);
|
|
12
|
+
return new nodes.CallExtension(this, "run", null);
|
|
13
|
+
}
|
|
14
|
+
run({ env, ctx }) {
|
|
15
|
+
const injectionCode = (0, globals_1.getGlobal)("injectionCode");
|
|
16
|
+
return new nunjucks_1.runtime.SafeString(`
|
|
17
|
+
${injectionCode.head}
|
|
18
|
+
<script>
|
|
19
|
+
window.__qumra__ = window.__qumra__ || {};
|
|
20
|
+
window.__qumra__.context = ${JSON.stringify(ctx.context)};
|
|
21
|
+
window.__qumra__.globals = ${JSON.stringify(ctx.globals)};
|
|
22
|
+
</script>
|
|
23
|
+
<style>
|
|
24
|
+
:root {
|
|
25
|
+
--primary-color: #0070f3;
|
|
26
|
+
--secondary-color: #7928ca;
|
|
27
|
+
--background-color: #f9f9f9;
|
|
28
|
+
--text-color: #333333;
|
|
29
|
+
--border-color: #eaeaea;
|
|
30
|
+
--success-color: #22c55e;
|
|
31
|
+
--danger-color: #ef4444;
|
|
32
|
+
--warning-color: #facc15;
|
|
33
|
+
}
|
|
34
|
+
</style>
|
|
35
|
+
`);
|
|
36
|
+
}
|
|
37
|
+
})();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const nunjucks_1 = require("nunjucks");
|
|
4
|
+
const globals_1 = require("../../store/globals");
|
|
4
5
|
exports.default = new (class SeoExtension {
|
|
5
6
|
constructor() {
|
|
6
7
|
this.tags = ["qumra_head"];
|
|
@@ -11,11 +12,13 @@ exports.default = new (class SeoExtension {
|
|
|
11
12
|
return new nodes.CallExtension(this, "run", null);
|
|
12
13
|
}
|
|
13
14
|
run({ env, ctx }) {
|
|
14
|
-
const
|
|
15
|
+
const injectionCode = (0, globals_1.getGlobal)("injectionCode");
|
|
15
16
|
return new nunjucks_1.runtime.SafeString(`
|
|
17
|
+
${injectionCode.head}
|
|
16
18
|
<script>
|
|
17
19
|
window.__qumra__ = window.__qumra__ || {};
|
|
18
|
-
window.__qumra__.context = ${
|
|
20
|
+
window.__qumra__.context = ${JSON.stringify(ctx.context)};
|
|
21
|
+
window.__qumra__.globals = ${JSON.stringify(ctx.globals)};
|
|
19
22
|
</script>
|
|
20
23
|
<style>
|
|
21
24
|
:root {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const nunjucks_1 = require("nunjucks");
|
|
4
|
+
const globals_1 = require("../../store/globals");
|
|
5
|
+
exports.default = new (class SeoExtension {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.tags = ["qumra_scripts"];
|
|
8
|
+
}
|
|
9
|
+
parse(parser, nodes) {
|
|
10
|
+
const tok = parser.nextToken();
|
|
11
|
+
parser.advanceAfterBlockEnd(tok.value);
|
|
12
|
+
return new nodes.CallExtension(this, "run", null);
|
|
13
|
+
}
|
|
14
|
+
run({ env, ctx }) {
|
|
15
|
+
const injectionCode = (0, globals_1.getGlobal)("injectionCode");
|
|
16
|
+
return new nunjucks_1.runtime.SafeString(`
|
|
17
|
+
${injectionCode.body}
|
|
18
|
+
`);
|
|
19
|
+
}
|
|
20
|
+
})();
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.default = color_to_hex;
|
|
7
|
-
const
|
|
4
|
+
const colord_1 = require("colord");
|
|
8
5
|
function color_to_hex(color) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
catch (err) {
|
|
13
|
-
return color;
|
|
14
|
-
}
|
|
6
|
+
const result = (0, colord_1.colord)(color);
|
|
7
|
+
return result.isValid() ? result.toHex() : color;
|
|
15
8
|
}
|
|
@@ -3,15 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.mergeDataMiddleware = void 0;
|
|
4
4
|
const mergeDataMiddleware = async (req, res, next) => {
|
|
5
5
|
try {
|
|
6
|
-
const widgets = res.locals.render.engine
|
|
6
|
+
const widgets = res.locals.render.engine?.page?.widgets ?? [];
|
|
7
7
|
res.locals.env.addGlobal("engineData", res.locals.render.engine);
|
|
8
8
|
res.locals.env.addGlobal("widgets", widgets);
|
|
9
9
|
res.locals.env.addGlobal("pageData", {
|
|
10
|
-
layout: res.locals.render.engine
|
|
11
|
-
title: res.locals.render.engine
|
|
12
|
-
handle: res.locals.render.engine
|
|
10
|
+
layout: res.locals.render.engine?.page?.layout,
|
|
11
|
+
title: res.locals.render.engine?.page?.title,
|
|
12
|
+
handle: res.locals.render.engine?.page?.handle,
|
|
13
13
|
});
|
|
14
|
-
const settingsData = res.locals.render.engine
|
|
14
|
+
const settingsData = res.locals.render.engine?.settings;
|
|
15
15
|
console.log("🚀 ~ settingsData:", settingsData);
|
|
16
16
|
res.locals.env.addGlobal("settings", settingsData);
|
|
17
17
|
next();
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.renderMiddleware = void 0;
|
|
4
4
|
const resolveTranslations_1 = require("../utils/resolveTranslations");
|
|
5
|
+
const globals_1 = require("../store/globals");
|
|
5
6
|
const renderMiddleware = (req, res, next) => {
|
|
6
7
|
const render = res.locals.render;
|
|
7
|
-
const { context, globals } = render;
|
|
8
|
+
const { context, globals, engine } = render;
|
|
9
|
+
(0, globals_1.setGlobal)("injectionCode", engine?.injectionCode);
|
|
8
10
|
const env = res.locals.env;
|
|
9
11
|
const pageLayout = env.getGlobal("pageData").layout ?? "layout";
|
|
10
12
|
env.render(`layouts/${pageLayout}.njk`, (0, resolveTranslations_1.resolveTranslations)({
|
|
@@ -11,7 +11,23 @@ export type TMode = "production" | "devlopment";
|
|
|
11
11
|
export interface MainData {
|
|
12
12
|
globals?: Globals;
|
|
13
13
|
context?: RenderContext;
|
|
14
|
-
engine?:
|
|
14
|
+
engine?: {
|
|
15
|
+
page: {
|
|
16
|
+
title: string;
|
|
17
|
+
handle: string;
|
|
18
|
+
layout: string;
|
|
19
|
+
widgets: Array<{
|
|
20
|
+
type: string;
|
|
21
|
+
data: Record<string, any>;
|
|
22
|
+
id: string;
|
|
23
|
+
}>;
|
|
24
|
+
};
|
|
25
|
+
settings: Record<string, any>;
|
|
26
|
+
injectionCode: {
|
|
27
|
+
head: string;
|
|
28
|
+
body: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
15
31
|
themePath: string;
|
|
16
32
|
assetsPath?: string;
|
|
17
33
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qumra-engine",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.27",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"chalk": "^5.4.1",
|
|
14
|
-
"
|
|
14
|
+
"colord": "^2.9.3",
|
|
15
15
|
"express": "^5.1.0",
|
|
16
16
|
"express-session": "^1.18.1",
|
|
17
17
|
"morgan": "^1.10.0",
|