Skip to content

Build your personal knowledge base with Trilium Notes

refactoring of "date-notes" to "special-notes"

zadam2d82da32d457
diff --git a/src/public/app/services/date_notes.js b/src/public/app/services/date_notes.js
index e9d228bb10..dc1a4b13c1 100644
--- a/src/public/app/services/date_notes.js
+++ b/src/public/app/services/date_notes.js
@@ -4,7 +4,7 @@ import ws from "./ws.js";
/** @return {NoteShort} */
async function getInboxNote() {
- const note = await server.get('date-notes/inbox/' + dayjs().format("YYYY-MM-DD"), "date-note");
+ const note = await server.get('special-notes/inbox/' + dayjs().format("YYYY-MM-DD"), "date-note");
return await froca.getNote(note.noteId);
}
@@ -16,7 +16,7 @@ async function getTodayNote() {
/** @return {NoteShort} */
async function getDateNote(date) {
- const note = await server.get('date-notes/date/' + date, "date-note");
+ const note = await server.get('special-notes/date/' + date, "date-note");
await ws.waitForMaxKnownEntityChangeId();
@@ -25,7 +25,7 @@ async function getDateNote(date) {
/** @return {NoteShort} */
async function getMonthNote(month) {
- const note = await server.get('date-notes/month/' + month, "date-note");
+ const note = await server.get('special-notes/month/' + month, "date-note");
await ws.waitForMaxKnownEntityChangeId();
@@ -34,7 +34,7 @@ async function getMonthNote(month) {
/** @return {NoteShort} */
async function getYearNote(year) {
- const note = await server.get('date-notes/year/' + year, "date-note");
+ const note = await server.get('special-notes/year/' + year, "date-note");
await ws.waitForMaxKnownEntityChangeId();
@@ -43,7 +43,7 @@ async function getYearNote(year) {
/** @return {NoteShort} */
async function createSqlConsole() {
- const note = await server.post('sql-console');
+ const note = await server.post('special-notes/sql-console');
await ws.waitForMaxKnownEntityChangeId();
@@ -52,7 +52,7 @@ async function createSqlConsole() {
/** @return {NoteShort} */
async function createSearchNote(opts = {}) {
- const note = await server.post('search-note', opts);
+ const note = await server.post('special-notes/search-note', opts);
await ws.waitForMaxKnownEntityChangeId();
diff --git a/src/public/app/services/froca.js b/src/public/app/services/froca.js
index 87476432b6..6870ffc82c 100644
--- a/src/public/app/services/froca.js
+++ b/src/public/app/services/froca.js
@@ -174,7 +174,7 @@ class Froca {
return;
}
- const searchResultNoteIds = await server.get('search-note/' + note.noteId);
+ const searchResultNoteIds = await server.get('special-notes/search-note/' + note.noteId);
if (!Array.isArray(searchResultNoteIds)) {
throw new Error(`Search note ${note.noteId} failed: ${searchResultNoteIds}`);
diff --git a/src/public/app/widgets/buttons/calendar_menu.js b/src/public/app/widgets/buttons/calendar_menu.js
index f3a82c8111..5c2292aa01 100644
--- a/src/public/app/widgets/buttons/calendar_menu.js
+++ b/src/public/app/widgets/buttons/calendar_menu.js
@@ -145,7 +145,7 @@ export default class CalendarMenuWidget extends BasicWidget {
async createMonth() {
const month = utils.formatDateISO(this.date).substr(0, 7);
- const dateNotesForMonth = await server.get('date-notes/notes-for-month/' + month);
+ const dateNotesForMonth = await server.get('special-notes/notes-for-month/' + month);
this.$month.empty();
diff --git a/src/public/app/widgets/ribbon_widgets/search_definition.js b/src/public/app/widgets/ribbon_widgets/search_definition.js
index ad9288cd9d..5ffdeb9188 100644
--- a/src/public/app/widgets/ribbon_widgets/search_definition.js
+++ b/src/public/app/widgets/ribbon_widgets/search_definition.js
@@ -268,7 +268,7 @@ export default class SearchDefinitionWidget extends NoteContextAwareWidget {
this.$saveToNoteButton = this.$widget.find('.save-to-note-button');
this.$saveToNoteButton.on('click', async () => {
- const {notePath} = await server.post("save-search-note", {searchNoteId: this.noteId});
+ const {notePath} = await server.post("special-notes/save-search-note", {searchNoteId: this.noteId});
await ws.waitForMaxKnownEntityChangeId();
diff --git a/src/public/app/widgets/type_widgets/editable_code.js b/src/public/app/widgets/type_widgets/editable_code.js
index 348cf4bf6f..88682a3656 100644
--- a/src/public/app/widgets/type_widgets/editable_code.js
+++ b/src/public/app/widgets/type_widgets/editable_code.js
@@ -40,7 +40,7 @@ export default class EditableCodeTypeWidget extends TypeWidget {
this.$executeButton = this.$widget.find('.execute-button');
this.$saveToNoteButton = this.$widget.find('.save-to-note-button');
this.$saveToNoteButton.on('click', async () => {
- const {notePath} = await server.post("save-sql-console", {sqlConsoleNoteId: this.noteId});
+ const {notePath} = await server.post("special-notes/save-sql-console", {sqlConsoleNoteId: this.noteId});
await ws.waitForMaxKnownEntityChangeId();
diff --git a/src/routes/api/date_notes.js b/src/routes/api/special_notes.js
similarity index 92%
rename from src/routes/api/date_notes.js
rename to src/routes/api/special_notes.js
index 0f4e7969af..6cfe055f14 100644
--- a/src/routes/api/date_notes.js
+++ b/src/routes/api/special_notes.js
@@ -137,6 +137,22 @@ function getSpecialNoteRoot() {
return specialNoteRoot;
}
+function getGlobalLinkMapNote() {
+ let globalLinkMapNote = becca.getNote('global-link-map');
+
+ if (!globalLinkMapNote) {
+ globalLinkMapNote = noteService.createNewNote({
+ noteId: 'global-link-map',
+ title: 'global-link-map',
+ type: 'global-link-map',
+ content: '',
+ parentNoteId: getSpecialNoteRoot().noteId
+ }).note;
+ }
+
+ return globalLinkMapNote;
+}
+
function getSqlConsoleRoot() {
let sqlConsoleRoot = becca.getNote('sqlconsole');
diff --git a/src/routes/routes.js b/src/routes/routes.js
index 6df8ca2987..aa034e197a 100644
--- a/src/routes/routes.js
+++ b/src/routes/routes.js
@@ -31,7 +31,7 @@ const scriptRoute = require('./api/script');
const senderRoute = require('./api/sender');
const filesRoute = require('./api/files');
const searchRoute = require('./api/search');
-const dateNotesRoute = require('./api/date_notes');
+const specialNotesRoute = require('./api/special_notes.js');
const linkMapRoute = require('./api/link_map');
const clipperRoute = require('./api/clipper');
const similarNotesRoute = require('./api/similar_notes');
@@ -222,15 +222,15 @@ function register(app) {
apiRoute(POST, '/api/notes/:noteId/link-map', linkMapRoute.getLinkMap);
- apiRoute(GET, '/api/date-notes/inbox/:date', dateNotesRoute.getInboxNote);
- apiRoute(GET, '/api/date-notes/date/:date', dateNotesRoute.getDateNote);
- apiRoute(GET, '/api/date-notes/month/:month', dateNotesRoute.getMonthNote);
- apiRoute(GET, '/api/date-notes/year/:year', dateNotesRoute.getYearNote);
- apiRoute(GET, '/api/date-notes/notes-for-month/:month', dateNotesRoute.getDateNotesForMonth);
- apiRoute(POST, '/api/sql-console', dateNotesRoute.createSqlConsole);
- apiRoute(POST, '/api/save-sql-console', dateNotesRoute.saveSqlConsole);
- apiRoute(POST, '/api/search-note', dateNotesRoute.createSearchNote);
- apiRoute(POST, '/api/save-search-note', dateNotesRoute.saveSearchNote);
+ apiRoute(GET, '/api/special-notes/inbox/:date', specialNotesRoute.getInboxNote);
+ apiRoute(GET, '/api/special-notes/date/:date', specialNotesRoute.getDateNote);
+ apiRoute(GET, '/api/special-notes/month/:month', specialNotesRoute.getMonthNote);
+ apiRoute(GET, '/api/special-notes/year/:year', specialNotesRoute.getYearNote);
+ apiRoute(GET, '/api/special-notes/notes-for-month/:month', specialNotesRoute.getDateNotesForMonth);
+ apiRoute(POST, '/api/special-notes/sql-console', specialNotesRoute.createSqlConsole);
+ apiRoute(POST, '/api/special-notes/save-sql-console', specialNotesRoute.saveSqlConsole);
+ apiRoute(POST, '/api/special-notes/search-note', specialNotesRoute.createSearchNote);
+ apiRoute(POST, '/api/special-notes/save-search-note', specialNotesRoute.saveSearchNote);
route(GET, '/api/images/:noteId/:filename', [auth.checkApiAuthOrElectron], imageRoute.returnImage);
route(POST, '/api/images', [auth.checkApiAuthOrElectron, uploadMiddleware, csrfMiddleware], imageRoute.uploadImage, apiResultHandler);