mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 03:29:02 +01:00 
			
		
		
		
	server-ts: Port share/share_root
This commit is contained in:
		
							parent
							
								
									80a1b8b44d
								
							
						
					
					
						commit
						b07df6061f
					
				| @ -1,7 +1,7 @@ | ||||
| const {JSDOM} = require("jsdom"); | ||||
| const { JSDOM } = require("jsdom"); | ||||
| const shaca = require('./shaca/shaca.js'); | ||||
| const assetPath = require('../services/asset_path'); | ||||
| const shareRoot = require('./share_root.js'); | ||||
| const shareRoot = require('./share_root'); | ||||
| const escapeHtml = require('escape-html'); | ||||
| 
 | ||||
| function getContent(note) { | ||||
|  | ||||
| @ -5,7 +5,7 @@ const ejs = require("ejs"); | ||||
| 
 | ||||
| const shaca = require('./shaca/shaca.js'); | ||||
| const shacaLoader = require('./shaca/shaca_loader.js'); | ||||
| const shareRoot = require('./share_root.js'); | ||||
| const shareRoot = require('./share_root'); | ||||
| const contentRenderer = require('./content_renderer.js'); | ||||
| const assetPath = require('../services/asset_path'); | ||||
| const appPath = require('../services/app_path'); | ||||
| @ -152,9 +152,9 @@ function register(router) { | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         const {header, content, isEmpty} = contentRenderer.getContent(note); | ||||
|         const { header, content, isEmpty } = contentRenderer.getContent(note); | ||||
|         const subRoot = getSharedSubTreeRoot(note); | ||||
|         const opts = {note, header, content, isEmpty, subRoot, assetPath, appPath}; | ||||
|         const opts = { note, header, content, isEmpty, subRoot, assetPath, appPath }; | ||||
|         let useDefaultView = true; | ||||
| 
 | ||||
|         // Check if the user has their own template
 | ||||
| @ -176,7 +176,7 @@ function register(router) { | ||||
| 
 | ||||
|                 // Try to render user's template, w/ fallback to default view
 | ||||
|                 try { | ||||
|                     const ejsResult = ejs.render(templateNote.getContent(), opts, {includer}); | ||||
|                     const ejsResult = ejs.render(templateNote.getContent(), opts, { includer }); | ||||
|                     res.send(ejsResult); | ||||
|                     useDefaultView = false; // Rendering went okay, don't use default view
 | ||||
|                 } | ||||
| @ -205,7 +205,7 @@ function register(router) { | ||||
|     router.get('/share/:shareId', (req, res, next) => { | ||||
|         shacaLoader.ensureLoad(); | ||||
| 
 | ||||
|         const {shareId} = req.params; | ||||
|         const { shareId } = req.params; | ||||
| 
 | ||||
|         const note = shaca.aliasToNote[shareId] || shaca.notes[shareId]; | ||||
| 
 | ||||
| @ -346,13 +346,13 @@ function register(router) { | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         const {search} = req.query; | ||||
|         const { search } = req.query; | ||||
| 
 | ||||
|         if (!search?.trim()) { | ||||
|             return res.status(400).json({ message: "'search' parameter is mandatory." }); | ||||
|         } | ||||
| 
 | ||||
|         const searchContext = new SearchContext({ancestorNoteId: ancestorNoteId}); | ||||
|         const searchContext = new SearchContext({ ancestorNoteId: ancestorNoteId }); | ||||
|         const searchResults = searchService.findResultsWithQuery(search, searchContext); | ||||
|         const filteredResults = searchResults.map(sr => { | ||||
|             const fullNote = shaca.notes[sr.noteId]; | ||||
|  | ||||
| @ -7,7 +7,7 @@ const SNote = require('./entities/snote.js'); | ||||
| const SBranch = require('./entities/sbranch.js'); | ||||
| const SAttribute = require('./entities/sattribute.js'); | ||||
| const SAttachment = require('./entities/sattachment.js'); | ||||
| const shareRoot = require('../share_root.js'); | ||||
| const shareRoot = require('../share_root'); | ||||
| const eventService = require('../../services/events'); | ||||
| 
 | ||||
| function load() { | ||||
| @ -89,7 +89,7 @@ function ensureLoad() { | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| eventService.subscribe([ eventService.ENTITY_CREATED, eventService.ENTITY_CHANGED, eventService.ENTITY_DELETED, eventService.ENTITY_CHANGE_SYNCED, eventService.ENTITY_DELETE_SYNCED ], ({ entityName, entity }) => { | ||||
| eventService.subscribe([eventService.ENTITY_CREATED, eventService.ENTITY_CHANGED, eventService.ENTITY_DELETED, eventService.ENTITY_CHANGE_SYNCED, eventService.ENTITY_DELETE_SYNCED], ({ entityName, entity }) => { | ||||
|     shaca.reset(); | ||||
| }); | ||||
| 
 | ||||
|  | ||||
| @ -1,3 +1,3 @@ | ||||
| module.exports = { | ||||
| export = { | ||||
|     SHARE_ROOT_NOTE_ID: '_share' | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran