From 78cb07e566c6ea59d336cd328ff67df800c3a287 Mon Sep 17 00:00:00 2001 From: Tom Kunze Date: Mon, 16 Oct 2023 15:09:02 +0200 Subject: [PATCH] Fix broken export link if URL does not contain /p/ Fixes #118 Fallback with clientVars.padId does not work at this point, because clientVars is not populated with padId at document.ready state. --- ep.json | 1 - index.js | 4 ---- static/js/main.js | 7 ------- static/js/markdown.js | 4 ++++ templates/scripts.html | 1 - 5 files changed, 4 insertions(+), 13 deletions(-) delete mode 100644 static/js/main.js delete mode 100644 templates/scripts.html diff --git a/ep.json b/ep.json index e42354f..90fa663 100644 --- a/ep.json +++ b/ep.json @@ -5,7 +5,6 @@ "hooks":{ "expressCreateServer": "ep_markdown/express", "eejsBlock_exportColumn": "ep_markdown/index", - "eejsBlock_scripts": "ep_markdown/index", "eejsBlock_mySettings": "ep_markdown/index", "import": "ep_markdown/index" }, diff --git a/index.js b/index.js index 79d3c3d..cd6f389 100644 --- a/index.js +++ b/index.js @@ -9,10 +9,6 @@ exports.eejsBlock_exportColumn = (hookName, context) => { context.content += eejs.require('./templates/exportcolumn.html', {}, module); }; -exports.eejsBlock_scripts = (hookName, context) => { - context.content += eejs.require('./templates/scripts.html', {}, module); -}; - exports.eejsBlock_styles = (hookName, context) => { context.content += eejs.require('./templates/styles.html', {}, module); }; diff --git a/static/js/main.js b/static/js/main.js deleted file mode 100644 index 2b26b72..0000000 --- a/static/js/main.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -$(document).ready(() => { - const padRootPath = new RegExp(/.*\/p\/[^/]+/) - .exec(document.location.pathname) || clientVars.padId; - $('#exportmarkdowna').attr('href', `${padRootPath}/export/markdown`); -}); diff --git a/static/js/markdown.js b/static/js/markdown.js index 48a76d8..db8b82a 100644 --- a/static/js/markdown.js +++ b/static/js/markdown.js @@ -1,6 +1,10 @@ 'use strict'; exports.postAceInit = (hookName, context) => { + const padRootPath = new RegExp(/.*\/p\/[^/]+/) + .exec(document.location.pathname) || clientVars.padId; + $('#exportmarkdowna').attr('href', `${padRootPath}/export/markdown`); + const enable = () => { // add css class markdown $('iframe[name="ace_outer"]').contents().find('iframe') diff --git a/templates/scripts.html b/templates/scripts.html deleted file mode 100644 index 82aafa2..0000000 --- a/templates/scripts.html +++ /dev/null @@ -1 +0,0 @@ -