nodebb-plugin-composer-default 10.3.9 → 10.3.11
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/library.js +3 -21
- package/package.json +1 -1
- package/plugin.json +1 -2
- package/static/lib/composer.js +7 -4
package/library.js
CHANGED
|
@@ -44,25 +44,6 @@ plugin.addAdminNavigation = async function (header) {
|
|
|
44
44
|
return header;
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
plugin.addPrefetchTags = async function (hookData) {
|
|
48
|
-
const { req } = hookData;
|
|
49
|
-
if (req.uid > 0) {
|
|
50
|
-
const prefetch = [
|
|
51
|
-
'/assets/templates/composer.js',
|
|
52
|
-
`/assets/language/${meta.config.defaultLang || 'en-GB'}/topic.json`,
|
|
53
|
-
`/assets/language/${meta.config.defaultLang || 'en-GB'}/modules.json`,
|
|
54
|
-
`/assets/language/${meta.config.defaultLang || 'en-GB'}/tags.json`,
|
|
55
|
-
];
|
|
56
|
-
|
|
57
|
-
hookData.links = hookData.links.concat(prefetch.map(path => ({
|
|
58
|
-
rel: 'prefetch',
|
|
59
|
-
href: `${nconf.get('relative_path') + path}?${meta.config['cache-buster']}`,
|
|
60
|
-
})));
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return hookData;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
47
|
plugin.getFormattingOptions = async function () {
|
|
67
48
|
const defaultVisibility = {
|
|
68
49
|
mobile: true,
|
|
@@ -122,8 +103,9 @@ plugin.filterComposerBuild = async function (hookData) {
|
|
|
122
103
|
|
|
123
104
|
if (req.query.p) {
|
|
124
105
|
try {
|
|
125
|
-
const a =
|
|
126
|
-
|
|
106
|
+
const a = new URL(req.query.p, 'http://localhost.com');
|
|
107
|
+
const path = (a.pathname + a.search).replace(/^\/+/, '');
|
|
108
|
+
return helpers.redirect(res, `/${path}`);
|
|
127
109
|
} catch (e) {
|
|
128
110
|
return helpers.redirect(res, '/');
|
|
129
111
|
}
|
package/package.json
CHANGED
package/plugin.json
CHANGED
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
{ "hook": "static:app.load", "method": "init" },
|
|
7
7
|
{ "hook": "filter:config.get", "method": "appendConfig" },
|
|
8
8
|
{ "hook": "filter:composer.build", "method": "filterComposerBuild" },
|
|
9
|
-
{ "hook": "filter:admin.header.build", "method": "addAdminNavigation" }
|
|
10
|
-
{ "hook": "filter:meta.getLinkTags", "method": "addPrefetchTags" }
|
|
9
|
+
{ "hook": "filter:admin.header.build", "method": "addAdminNavigation" }
|
|
11
10
|
],
|
|
12
11
|
"scss": [
|
|
13
12
|
"./static/scss/composer.scss"
|
package/static/lib/composer.js
CHANGED
|
@@ -566,20 +566,23 @@ define('composer', [
|
|
|
566
566
|
var returnPath = window.location.pathname.slice(1) + window.location.search;
|
|
567
567
|
|
|
568
568
|
// Remove relative path from returnPath
|
|
569
|
-
if (returnPath.startsWith(config.relative_path.slice(1))) {
|
|
570
|
-
returnPath = returnPath.slice(config.relative_path.length);
|
|
569
|
+
if (config.relative_path && returnPath.startsWith(config.relative_path.slice(1))) {
|
|
570
|
+
returnPath = returnPath.slice(config.relative_path.length - 1);
|
|
571
|
+
if (returnPath.startsWith('/')) {
|
|
572
|
+
returnPath = returnPath.slice(1);
|
|
573
|
+
}
|
|
571
574
|
}
|
|
572
575
|
|
|
573
576
|
// Add in return path to be caught by ajaxify when post is completed, or if back is pressed
|
|
574
577
|
window.history.replaceState({
|
|
575
578
|
url: null,
|
|
576
579
|
returnPath: returnPath,
|
|
577
|
-
},
|
|
580
|
+
}, '', `${config.relative_path}/${returnPath}`);
|
|
578
581
|
|
|
579
582
|
// Update address bar in case f5 is pressed
|
|
580
583
|
window.history.pushState({
|
|
581
584
|
url: path,
|
|
582
|
-
},
|
|
585
|
+
}, '', `${config.relative_path}/${returnPath}`);
|
|
583
586
|
}
|
|
584
587
|
|
|
585
588
|
function handleRemotePid(postContainer) {
|