Skip to content

Commit

Permalink
smaller picture embeddings
Browse files Browse the repository at this point in the history
  • Loading branch information
git committed Mar 19, 2023
1 parent e0792a9 commit b610d69
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ public/uploads/*
!public/uploads/.gitkeep

site/
.git
.git
config.2.json
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ public/uploads/*

site/
.env
config.2.json
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=<A secure token here!!!>
```
Make sure to adjust the token stated here inside your `.env` file.
2 changes: 1 addition & 1 deletion lib/web/userRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.' })
}

Expand Down
1 change: 0 additions & 1 deletion public/js/lib/common/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
32 changes: 32 additions & 0 deletions public/js/lib/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
2 changes: 1 addition & 1 deletion public/views/index/body.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<div class="inner cover">
<h1 class="cover-heading">
HedgeNext
<img src="<%- serverURL %>/icons/logo.png width="400" alt="HedgeNext logo">
<!-- <img src="<%- serverURL %>/icons/logo.png" alt="HedgeNext logo"> -->
</h1>
<p class="lead">
<%= __('Best way to write and share your knowledge in markdown in your Nextcloud.') %>
Expand Down

0 comments on commit b610d69

Please sign in to comment.