diff --git a/.dockerignore b/.dockerignore index d2114c4..e0780d6 100644 --- a/.dockerignore +++ b/.dockerignore @@ -29,4 +29,5 @@ public/uploads/* !public/uploads/.gitkeep site/ -.git \ No newline at end of file +.git +config.2.json \ No newline at end of file diff --git a/.gitignore b/.gitignore index 82dc4fb..efb7add 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ public/uploads/* site/ .env +config.2.json \ No newline at end of file diff --git a/README.md b/README.md index 645f6a2..7d4799b 100644 --- a/README.md +++ b/README.md @@ -10,3 +10,17 @@ - `docker-compose up -d` +## Setting up PDF Export + +Deploy `browserless/chrome:latest` [Guide](https://www.browserless.io/docs/docker-quickstart) on the container runtime of your choice. Fly.io or Northflank are some free-ish options. + +Setting the following environment variables worked for me: +``` +CHROME_REFRESH_TIME=3600000 +CONNECTION_TIMEOUT=90000 +FUNCTION_ENABLE_INCOGNITO_MODE=true +MAX_CONCURRENT_SESSIONS=3 +PREBOOT_CHROME=true +TOKEN= +``` +Make sure to adjust the token stated here inside your `.env` file. \ No newline at end of file diff --git a/lib/web/userRouter.js b/lib/web/userRouter.js index b697f9a..242199c 100644 --- a/lib/web/userRouter.js +++ b/lib/web/userRouter.js @@ -41,7 +41,7 @@ UserRouter.get('/me', function (req, res) { } }) UserRouter.post('/me/set_templates', jsonParser, function (req, res) { - if (!req.isAuthenticated() || req.body.templates == null || !req.user?.id) { + if (!req.isAuthenticated() || req.body.templates == null || !req.user || !req.user.id) { return res.status(404).json({ error: 'user not found.' }) } diff --git a/public/js/lib/common/login.js b/public/js/lib/common/login.js index bc24998..674e1c2 100644 --- a/public/js/lib/common/login.js +++ b/public/js/lib/common/login.js @@ -71,7 +71,6 @@ export function checkIfAuth (yesCallback, noCallback) { const lastCheck = parseInt(window.localStorage.getItem('lastCheck') || 0) const currentTimestamp = Math.floor(Date.now() * 1000) if ((!checkAuth || typeof cookieLoginState === 'undefined') && (currentTimestamp - lastCheck) > 2000 * 1000) { - console.error('checkIfAuth', lastCheck) window.localStorage.setItem('lastCheck', currentTimestamp) $.get(`${serverurl}/me`) .done(data => { diff --git a/public/js/lib/editor/index.js b/public/js/lib/editor/index.js index d37fff1..37de912 100644 --- a/public/js/lib/editor/index.js +++ b/public/js/lib/editor/index.js @@ -703,3 +703,35 @@ export default class Editor { return this.editor } } +addEventListener('DOMContentLoaded', (event) => { + const targetNode = document.querySelector('.CodeMirror-code') + if (targetNode) { + const observerconfig = { + attributes: false, + childList: true, + subtree: true + } + const spanElements0 = targetNode.querySelectorAll('span.cm-url:not(.CodeMirror-matchingbracket)') + for (const span0 of spanElements0) { + if (span0.textContent.match(/\(https:\/\/.+\/s\/.+\/preview( =\d+x)?\)/)) { + span0.textContent = '(' + span0.textContent.split('/preview')[1] + } + } + const callback = function (mutationsList, observer) { + for (const mutation of mutationsList) { + if (mutation.type === 'childList') { + const spanElements = targetNode.querySelectorAll('span.cm-url:not(.CodeMirror-matchingbracket)') + for (const span of spanElements) { + if ([...mutation.addedNodes].some(o => o && o.querySelector && o.querySelector('span.cm-url') === span) || (mutation.type === 'characterData' && mutation.target === span.firstChild)) { + if (span.textContent.match(/\(https:\/\/.+\/s\/.+\/preview( =\d+x)?\)/)) { + span.textContent = '(' + span.textContent.split('/preview')[1] + } + } + } + } + } + } + const observer = new MutationObserver(callback) + observer.observe(targetNode, observerconfig) + } +}) diff --git a/public/views/index/body.ejs b/public/views/index/body.ejs index 21e9bb9..8c474d4 100644 --- a/public/views/index/body.ejs +++ b/public/views/index/body.ejs @@ -42,7 +42,7 @@

HedgeNext - HedgeNext logo +

<%= __('Best way to write and share your knowledge in markdown in your Nextcloud.') %>