@parameter1/base-cms-marko-web 3.3.1 → 3.7.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
|
|
1
|
+
module.exports = () => ((req, res, next) => {
|
2
|
+
const { disabledFeatures } = req.cookies;
|
3
|
+
res.locals.disabledFeatures = new Set();
|
4
|
+
if (disabledFeatures) {
|
5
|
+
try {
|
6
|
+
disabledFeatures.split(',').forEach((flag) => {
|
7
|
+
const trimmed = flag.trim();
|
8
|
+
if (trimmed) res.locals.disabledFeatures.add(trimmed);
|
9
|
+
});
|
10
|
+
} catch (e) {
|
11
|
+
next();
|
12
|
+
}
|
13
|
+
}
|
14
|
+
next();
|
15
|
+
});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@parameter1/base-cms-marko-web",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.7.2",
|
4
4
|
"description": "Core Marko+Express components for BaseCMS websites",
|
5
5
|
"author": "Jacob Bare <jacob@parameter1.com>",
|
6
6
|
"main": "index.js",
|
@@ -46,5 +46,5 @@
|
|
46
46
|
"publishConfig": {
|
47
47
|
"access": "public"
|
48
48
|
},
|
49
|
-
"gitHead": "
|
49
|
+
"gitHead": "444cbefe6e939cdaa4dc7845e550b5df726253e0"
|
50
50
|
}
|
package/start-server.js
CHANGED
@@ -6,6 +6,7 @@ const { isFunction: isFn, parseBooleanHeader } = require('@parameter1/base-cms-u
|
|
6
6
|
const errorHandlers = require('./express/error-handlers');
|
7
7
|
const express = require('./express');
|
8
8
|
const loadMore = require('./express/load-more');
|
9
|
+
const disabledFeatures = require('./middleware/disabled-features');
|
9
10
|
|
10
11
|
const { env } = process;
|
11
12
|
if (!process.env.LIVERELOAD_PORT) process.env.LIVERELOAD_PORT = 4010;
|
@@ -90,6 +91,8 @@ module.exports = async ({
|
|
90
91
|
// Register load more after onStart to ensure userland middleware is available.
|
91
92
|
loadMore(app);
|
92
93
|
|
94
|
+
app.use(disabledFeatures());
|
95
|
+
|
93
96
|
// Load website routes.
|
94
97
|
if (!isFn(routes)) throw new Error('A routes function is required.');
|
95
98
|
routes(app);
|
@@ -6,6 +6,13 @@ const stringifyAttrs = attrs => Object.keys(attrs).reduce((arr, key) => {
|
|
6
6
|
return arr;
|
7
7
|
}, []).join(' ');
|
8
8
|
|
9
|
+
const buildWrapperClass = ({ caption, credit }) => {
|
10
|
+
const classes = [];
|
11
|
+
if (caption) classes.push('image-with-caption');
|
12
|
+
if (credit) classes.push('image-with-credit');
|
13
|
+
return classes.join(' ');
|
14
|
+
};
|
15
|
+
|
9
16
|
module.exports = (tag, { config } = {}, { lazyloadImages } = {}) => {
|
10
17
|
const lazyload = lazyloadImages == null ? config.lazyloadImages() : lazyloadImages;
|
11
18
|
const src = tag.get('src');
|
@@ -17,10 +24,13 @@ module.exports = (tag, { config } = {}, { lazyloadImages } = {}) => {
|
|
17
24
|
const width = tag.get('width');
|
18
25
|
const height = tag.get('height');
|
19
26
|
|
27
|
+
const wrapperClass = buildWrapperClass({ caption, credit });
|
28
|
+
|
20
29
|
const attrs = {
|
21
30
|
'data-embed-type': tag.type,
|
22
31
|
'data-embed-id': tag.id,
|
23
32
|
'data-embed-align': align,
|
33
|
+
...(wrapperClass && { class: wrapperClass }),
|
24
34
|
};
|
25
35
|
|
26
36
|
const minWidth = 400;
|