mirror of
https://github.com/zadam/trilium.git
synced 2024-11-10 09:02:48 +08:00
Merge remote-tracking branch 'origin/stable'
# Conflicts: # Dockerfile # package-lock.json # package.json # src/services/cloning.js
This commit is contained in:
commit
17dd6141fb
13 changed files with 58 additions and 11 deletions
|
@ -1,3 +1,4 @@
|
|||
# !!! Don't try to build this Dockerfile directly, run it through bin/build-docker.sh script !!!
|
||||
FROM node:16.14.0-alpine
|
||||
|
||||
# Create app directory
|
||||
|
|
|
@ -47,8 +47,11 @@ find $DIR/node_modules -name demo -exec rm -rf {} \;
|
|||
|
||||
find $DIR/libraries -name "*.map" -type f -delete
|
||||
|
||||
cp $DIR/src/public/app/share.js $DIR/src/public/app-dist/
|
||||
|
||||
rm -rf $DIR/src/public/app
|
||||
|
||||
sed -i -e 's/app\/desktop.js/app-dist\/desktop.js/g' $DIR/src/views/desktop.ejs
|
||||
sed -i -e 's/app\/mobile.js/app-dist\/mobile.js/g' $DIR/src/views/mobile.ejs
|
||||
sed -i -e 's/app\/setup.js/app-dist\/setup.js/g' $DIR/src/views/setup.ejs
|
||||
sed -i -e 's/app\/share.js/app-dist\/share.js/g' $DIR/src/views/share/*.ejs
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
"electron-dl": "3.3.0",
|
||||
"electron-find": "1.0.7",
|
||||
"electron-window-state": "5.0.3",
|
||||
"@electron/remote": "2.0.4",
|
||||
"@electron/remote": "2.0.8",
|
||||
"express": "4.17.2",
|
||||
"express-partial-content": "1.0.2",
|
||||
"express-rate-limit": "6.2.1",
|
||||
|
@ -82,8 +82,8 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"cross-env": "7.0.3",
|
||||
"electron": "16.0.8",
|
||||
"electron-builder": "22.14.13",
|
||||
"electron": "16.1.0",
|
||||
"electron-builder": "22.14.5",
|
||||
"electron-packager": "15.4.0",
|
||||
"electron-rebuild": "3.2.7",
|
||||
"esm": "3.2.25",
|
||||
|
|
|
@ -25,6 +25,7 @@ app.use(helmet({
|
|||
|
||||
app.use(express.text({limit: '500mb'}));
|
||||
app.use(express.json({limit: '500mb'}));
|
||||
app.use(express.raw({limit: '500mb'}));
|
||||
app.use(express.urlencoded({extended: false}));
|
||||
app.use(cookieParser());
|
||||
app.use(express.static(path.join(__dirname, 'public')));
|
||||
|
|
|
@ -1127,6 +1127,7 @@ class Note extends AbstractEntity {
|
|||
if (this.isProtected && !this.isDecrypted && protectedSessionService.isProtectedSessionAvailable()) {
|
||||
try {
|
||||
this.title = protectedSessionService.decryptString(this.title);
|
||||
this.flatTextCache = null;
|
||||
|
||||
this.isDecrypted = true;
|
||||
}
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
User-agent: *
|
||||
Allow: /share/
|
||||
Disallow: /
|
||||
|
|
|
@ -93,6 +93,8 @@ body {
|
|||
|
||||
--ck-color-labeled-field-label-background: var(--accented-background-color);
|
||||
|
||||
--ck-color-editable-blur-selection: var(--accented-background-color);
|
||||
|
||||
/* todo lists */
|
||||
|
||||
--ck-color-todo-list-checkmark-border: var(--main-border-color);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
body {
|
||||
font-family: 'Lucida Grande', 'Lucida Sans Unicode', arial, sans-serif;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
#layout {
|
||||
|
|
|
@ -138,7 +138,7 @@ function processContent(images, note, content) {
|
|||
value: imageNote.noteId
|
||||
}).save();
|
||||
|
||||
console.log(`Replacing ${imageId} with ${url}`);
|
||||
log.info(`Replacing ${imageId} with ${url} in note ${note.noteId}`);
|
||||
|
||||
rewrittenContent = utils.replaceAll(rewrittenContent, imageId, url);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ function getNotesWithLabel(name, value) {
|
|||
|
||||
// TODO: should be in search service
|
||||
/** @returns {Note|null} */
|
||||
function getNoteWithLabel(name, value) {
|
||||
function getNoteWithLabel(name, value = undefined) {
|
||||
// optimized version (~20 times faster) without using normal search, useful for e.g. finding date notes
|
||||
const attrs = becca.findAttributes('label', name);
|
||||
|
||||
|
|
|
@ -17,8 +17,7 @@ async function processImage(uploadBuffer, originalName, shrinkImageSwitch) {
|
|||
const compressImages = optionService.getOptionBool("compressImages");
|
||||
const origImageFormat = getImageType(uploadBuffer);
|
||||
|
||||
if (origImageFormat && ["webp", "svg", "gif"].includes(origImageFormat.ext)) {
|
||||
// JIMP does not support webp at the moment: https://github.com/oliver-moran/jimp/issues/144
|
||||
if (!origImageFormat || !["jpg", "png"].includes(origImageFormat.ext)) {
|
||||
shrinkImageSwitch = false;
|
||||
}
|
||||
else if (isAnimated(uploadBuffer)) {
|
||||
|
@ -26,9 +25,18 @@ async function processImage(uploadBuffer, originalName, shrinkImageSwitch) {
|
|||
shrinkImageSwitch = false;
|
||||
}
|
||||
|
||||
const finalImageBuffer = (compressImages && shrinkImageSwitch) ? await shrinkImage(uploadBuffer, originalName) : uploadBuffer;
|
||||
let finalImageBuffer;
|
||||
let imageFormat;
|
||||
|
||||
const imageFormat = getImageType(finalImageBuffer);
|
||||
if (compressImages && shrinkImageSwitch) {
|
||||
finalImageBuffer = await shrinkImage(uploadBuffer, originalName);
|
||||
imageFormat = getImageType(finalImageBuffer);
|
||||
} else {
|
||||
finalImageBuffer = uploadBuffer;
|
||||
imageFormat = origImageFormat || {
|
||||
ext: 'dat'
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
buffer: finalImageBuffer,
|
||||
|
@ -43,7 +51,9 @@ function getImageType(buffer) {
|
|||
}
|
||||
}
|
||||
else {
|
||||
return imageType(buffer) || "jpg"; // optimistic JPG default
|
||||
return imageType(buffer) || {
|
||||
ext: "jpg"
|
||||
}; // optimistic JPG default
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,7 +85,7 @@ function updateImage(noteId, uploadBuffer, originalName) {
|
|||
}
|
||||
|
||||
function saveImage(parentNoteId, uploadBuffer, originalName, shrinkImageSwitch, trimFilename = false) {
|
||||
log.info(`Saving image ${originalName}`);
|
||||
log.info(`Saving image ${originalName} into parent ${parentNoteId}`);
|
||||
|
||||
if (trimFilename && originalName.length > 40) {
|
||||
// https://github.com/zadam/trilium/issues/2307
|
||||
|
|
25
test-etapi/put-note-content-binary.http
Normal file
25
test-etapi/put-note-content-binary.http
Normal file
|
@ -0,0 +1,25 @@
|
|||
POST {{triliumHost}}/etapi/create-note
|
||||
Authorization: {{authToken}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"parentNoteId": "root",
|
||||
"title": "Hello",
|
||||
"type": "image",
|
||||
"mime": "image/png",
|
||||
"content": ""
|
||||
}
|
||||
|
||||
> {% client.global.set("createdNoteId", response.body.note.noteId); %}
|
||||
|
||||
###
|
||||
|
||||
PUT {{triliumHost}}/etapi/notes/{{createdNoteId}}/content
|
||||
Authorization: {{authToken}}
|
||||
Content-Type: application/octet-stream
|
||||
Content-Transfer-Encoding: binary
|
||||
|
||||
< ../images/icon-color.png
|
||||
|
||||
> {% client.assert(response.status === 204); %}
|
||||
|
|
@ -20,6 +20,8 @@ Content-Type: text/plain
|
|||
|
||||
Changed content
|
||||
|
||||
> {% client.assert(response.status === 200); %}
|
||||
|
||||
###
|
||||
|
||||
GET {{triliumHost}}/etapi/notes/{{createdNoteId}}/content
|
||||
|
|
Loading…
Reference in a new issue