mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	Merge remote-tracking branch 'origin/stable'
# Conflicts: # Dockerfile # package-lock.json # package.json # src/services/cloning.js
This commit is contained in:
		| @@ -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 | FROM node:16.14.0-alpine | ||||||
|  |  | ||||||
| # Create app directory | # Create app directory | ||||||
|   | |||||||
| @@ -47,8 +47,11 @@ find $DIR/node_modules -name demo -exec rm -rf {} \; | |||||||
|  |  | ||||||
| find $DIR/libraries -name "*.map" -type f -delete | 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 | 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\/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\/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\/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-dl": "3.3.0", | ||||||
|     "electron-find": "1.0.7", |     "electron-find": "1.0.7", | ||||||
|     "electron-window-state": "5.0.3", |     "electron-window-state": "5.0.3", | ||||||
|     "@electron/remote": "2.0.4", |     "@electron/remote": "2.0.8", | ||||||
|     "express": "4.17.2", |     "express": "4.17.2", | ||||||
|     "express-partial-content": "1.0.2", |     "express-partial-content": "1.0.2", | ||||||
|     "express-rate-limit": "6.2.1", |     "express-rate-limit": "6.2.1", | ||||||
| @@ -82,8 +82,8 @@ | |||||||
|   }, |   }, | ||||||
|   "devDependencies": { |   "devDependencies": { | ||||||
|     "cross-env": "7.0.3", |     "cross-env": "7.0.3", | ||||||
|     "electron": "16.0.8", |     "electron": "16.1.0", | ||||||
|     "electron-builder": "22.14.13", |     "electron-builder": "22.14.5", | ||||||
|     "electron-packager": "15.4.0", |     "electron-packager": "15.4.0", | ||||||
|     "electron-rebuild": "3.2.7", |     "electron-rebuild": "3.2.7", | ||||||
|     "esm": "3.2.25", |     "esm": "3.2.25", | ||||||
|   | |||||||
| @@ -25,6 +25,7 @@ app.use(helmet({ | |||||||
|  |  | ||||||
| app.use(express.text({limit: '500mb'})); | app.use(express.text({limit: '500mb'})); | ||||||
| app.use(express.json({limit: '500mb'})); | app.use(express.json({limit: '500mb'})); | ||||||
|  | app.use(express.raw({limit: '500mb'})); | ||||||
| app.use(express.urlencoded({extended: false})); | app.use(express.urlencoded({extended: false})); | ||||||
| app.use(cookieParser()); | app.use(cookieParser()); | ||||||
| app.use(express.static(path.join(__dirname, 'public'))); | app.use(express.static(path.join(__dirname, 'public'))); | ||||||
|   | |||||||
| @@ -1127,6 +1127,7 @@ class Note extends AbstractEntity { | |||||||
|         if (this.isProtected && !this.isDecrypted && protectedSessionService.isProtectedSessionAvailable()) { |         if (this.isProtected && !this.isDecrypted && protectedSessionService.isProtectedSessionAvailable()) { | ||||||
|             try { |             try { | ||||||
|                 this.title = protectedSessionService.decryptString(this.title); |                 this.title = protectedSessionService.decryptString(this.title); | ||||||
|  |                 this.flatTextCache = null; | ||||||
|  |  | ||||||
|                 this.isDecrypted = true; |                 this.isDecrypted = true; | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -1,2 +1,3 @@ | |||||||
| User-agent: * | User-agent: * | ||||||
|  | Allow: /share/ | ||||||
| Disallow: / | Disallow: / | ||||||
|   | |||||||
| @@ -93,6 +93,8 @@ body { | |||||||
|  |  | ||||||
|     --ck-color-labeled-field-label-background: var(--accented-background-color); |     --ck-color-labeled-field-label-background: var(--accented-background-color); | ||||||
|  |  | ||||||
|  |     --ck-color-editable-blur-selection: var(--accented-background-color); | ||||||
|  |  | ||||||
|     /* todo lists */ |     /* todo lists */ | ||||||
|  |  | ||||||
|     --ck-color-todo-list-checkmark-border: var(--main-border-color); |     --ck-color-todo-list-checkmark-border: var(--main-border-color); | ||||||
|   | |||||||
| @@ -1,5 +1,6 @@ | |||||||
| body { | body { | ||||||
|     font-family: 'Lucida Grande', 'Lucida Sans Unicode', arial, sans-serif; |     font-family: 'Lucida Grande', 'Lucida Sans Unicode', arial, sans-serif; | ||||||
|  |     line-height: 1.5; | ||||||
| } | } | ||||||
|  |  | ||||||
| #layout { | #layout { | ||||||
|   | |||||||
| @@ -138,7 +138,7 @@ function processContent(images, note, content) { | |||||||
|                 value: imageNote.noteId |                 value: imageNote.noteId | ||||||
|             }).save(); |             }).save(); | ||||||
|  |  | ||||||
|             console.log(`Replacing ${imageId} with ${url}`); |             log.info(`Replacing ${imageId} with ${url} in note ${note.noteId}`); | ||||||
|  |  | ||||||
|             rewrittenContent = utils.replaceAll(rewrittenContent, imageId, url); |             rewrittenContent = utils.replaceAll(rewrittenContent, imageId, url); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -20,7 +20,7 @@ function getNotesWithLabel(name, value) { | |||||||
|  |  | ||||||
| // TODO: should be in search service | // TODO: should be in search service | ||||||
| /** @returns {Note|null} */ | /** @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 |     // optimized version (~20 times faster) without using normal search, useful for e.g. finding date notes | ||||||
|     const attrs = becca.findAttributes('label', name); |     const attrs = becca.findAttributes('label', name); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -17,8 +17,7 @@ async function processImage(uploadBuffer, originalName, shrinkImageSwitch) { | |||||||
|     const compressImages = optionService.getOptionBool("compressImages"); |     const compressImages = optionService.getOptionBool("compressImages"); | ||||||
|     const origImageFormat = getImageType(uploadBuffer); |     const origImageFormat = getImageType(uploadBuffer); | ||||||
|  |  | ||||||
|     if (origImageFormat && ["webp", "svg", "gif"].includes(origImageFormat.ext)) { |     if (!origImageFormat || !["jpg", "png"].includes(origImageFormat.ext)) { | ||||||
|         // JIMP does not support webp at the moment: https://github.com/oliver-moran/jimp/issues/144 |  | ||||||
|         shrinkImageSwitch = false; |         shrinkImageSwitch = false; | ||||||
|     } |     } | ||||||
|     else if (isAnimated(uploadBuffer)) { |     else if (isAnimated(uploadBuffer)) { | ||||||
| @@ -26,9 +25,18 @@ async function processImage(uploadBuffer, originalName, shrinkImageSwitch) { | |||||||
|         shrinkImageSwitch = false; |         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 { |     return { | ||||||
|         buffer: finalImageBuffer, |         buffer: finalImageBuffer, | ||||||
| @@ -43,7 +51,9 @@ function getImageType(buffer) { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     else { |     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) { | 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) { |     if (trimFilename && originalName.length > 40) { | ||||||
|         // https://github.com/zadam/trilium/issues/2307 |         // 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 | Changed content | ||||||
|  |  | ||||||
|  | > {% client.assert(response.status === 200); %} | ||||||
|  |  | ||||||
| ### | ### | ||||||
|  |  | ||||||
| GET {{triliumHost}}/etapi/notes/{{createdNoteId}}/content | GET {{triliumHost}}/etapi/notes/{{createdNoteId}}/content | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user