Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
server-ts: Port share/share_root
Elian Doranb07df6061f03
diff --git a/src/share/content_renderer.js b/src/share/content_renderer.jsindex 9065fec08e..89b3cea4a1 100644--- a/src/share/content_renderer.js+++ b/src/share/content_renderer.js@@ -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) {diff --git a/src/share/routes.js b/src/share/routes.jsindex 4ad5a15c6c..e540bf9e1e 100644--- a/src/share/routes.js+++ b/src/share/routes.js@@ -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 viewtry {- 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];diff --git a/src/share/shaca/shaca_loader.js b/src/share/shaca/shaca_loader.jsindex 5d1648f495..f68d6d4c9c 100644--- a/src/share/shaca/shaca_loader.js+++ b/src/share/shaca/shaca_loader.js@@ -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();});diff --git a/src/share/share_root.js b/src/share/share_root.tssimilarity index 64%rename from src/share/share_root.jsrename to src/share/share_root.tsindex ec63597f21..a500d5ac47 100644--- a/src/share/share_root.js+++ b/src/share/share_root.ts@@ -1,3 +1,3 @@-module.exports = {+export = {SHARE_ROOT_NOTE_ID: '_share'}