mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 03:29:02 +01:00 
			
		
		
		
	Merge remote-tracking branch 'origin/master'
This commit is contained in:
		
						commit
						c0aa14f586
					
				| @ -76,8 +76,13 @@ function getContent(note) { | |||||||
|         content = `<img src="api/images/${note.noteId}/${note.title}?${note.utcDateModified}">`; |         content = `<img src="api/images/${note.noteId}/${note.title}?${note.utcDateModified}">`; | ||||||
|     } |     } | ||||||
|     else if (note.type === 'file') { |     else if (note.type === 'file') { | ||||||
|  |         if (note.mime === 'application/pdf') { | ||||||
|  |             content = `<iframe height="800" width="800" src="api/notes/${note.noteId}/view"></iframe>` | ||||||
|  |         } | ||||||
|  |         else { | ||||||
|             content = `<button type="button" onclick="location.href='api/notes/${note.noteId}/download'">Download file</button>`; |             content = `<button type="button" onclick="location.href='api/notes/${note.noteId}/download'">Download file</button>`; | ||||||
|         } |         } | ||||||
|  |     } | ||||||
|     else if (note.type === 'book') { |     else if (note.type === 'book') { | ||||||
|         content = getChildrenList(note); |         content = getChildrenList(note); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -78,6 +78,26 @@ function register(router) { | |||||||
| 
 | 
 | ||||||
|         res.send(note.getContent()); |         res.send(note.getContent()); | ||||||
|     }); |     }); | ||||||
|  |      | ||||||
|  |     router.get('/share/api/notes/:noteId/view', (req, res, next) => { | ||||||
|  |         const {noteId} = req.params; | ||||||
|  |         const note = shaca.getNote(noteId); | ||||||
|  | 
 | ||||||
|  |         if (!note) { | ||||||
|  |             return res.status(404).send(`Not found`); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         const utils = require("../services/utils"); | ||||||
|  | 
 | ||||||
|  |         const filename = utils.formatDownloadTitle(note.title, note.type, note.mime); | ||||||
|  | 
 | ||||||
|  |         // res.setHeader('Content-Disposition', utils.getContentDisposition(filename));
 | ||||||
|  | 
 | ||||||
|  |         res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); | ||||||
|  |         res.setHeader('Content-Type', note.mime); | ||||||
|  | 
 | ||||||
|  |         res.send(note.getContent()); | ||||||
|  |     }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| module.exports = { | module.exports = { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam