mirror of
https://github.com/zadam/trilium.git
synced 2025-10-29 09:16:45 +01:00
Compare commits
3 Commits
v0.5.3-bet
...
v0.5.4-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c5115003b | ||
|
|
e8ed913374 | ||
|
|
5bffba4e2f |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "trilium",
|
"name": "trilium",
|
||||||
"description": "Trilium Notes",
|
"description": "Trilium Notes",
|
||||||
"version": "0.5.3-beta",
|
"version": "0.5.4-beta",
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
"main": "electron.js",
|
"main": "electron.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
21
src/public/javascripts/api.js
Normal file
21
src/public/javascripts/api.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
const api = (function() {
|
||||||
|
const pluginButtonsEl = $("#plugin-buttons");
|
||||||
|
|
||||||
|
async function activateNote(notePath) {
|
||||||
|
await noteTree.activateNode(notePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
function addButtonToToolbar(buttonId, button) {
|
||||||
|
$("#" + buttonId).remove();
|
||||||
|
|
||||||
|
button.attr('id', buttonId);
|
||||||
|
|
||||||
|
pluginButtonsEl.append(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return {
|
||||||
|
addButtonToToolbar,
|
||||||
|
activateNote
|
||||||
|
}
|
||||||
|
})();
|
||||||
@@ -42,7 +42,7 @@ const attributesDialog = (function() {
|
|||||||
dialogEl.dialog({
|
dialogEl.dialog({
|
||||||
modal: true,
|
modal: true,
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 700
|
height: 500
|
||||||
});
|
});
|
||||||
|
|
||||||
attributesModel.loadAttributes();
|
attributesModel.loadAttributes();
|
||||||
|
|||||||
@@ -116,5 +116,6 @@ async function stopWatch(what, func) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function executeScript(script) {
|
function executeScript(script) {
|
||||||
eval("(async function() {" + script + "})()");
|
// last \r\n is necessary if script contains line comment on its last line
|
||||||
|
eval("(async function() {" + script + "\r\n})()");
|
||||||
}
|
}
|
||||||
@@ -108,7 +108,7 @@ span.fancytree-active:not(.fancytree-focused) .fancytree-title {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#header-title {
|
#header-title {
|
||||||
padding: 5px 50px 5px 10px;
|
padding: 5px 20px 5px 10px;
|
||||||
font-size: large;
|
font-size: large;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
@@ -190,11 +190,6 @@ div.ui-tooltip {
|
|||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
#note-id-display {
|
|
||||||
color: lightgrey;
|
|
||||||
margin-left: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#note-source {
|
#note-source {
|
||||||
height: 98%;
|
height: 98%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -245,6 +240,7 @@ div.ui-tooltip {
|
|||||||
right: 10px;
|
right: 10px;
|
||||||
bottom: 5px;
|
bottom: 5px;
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
|
color: lightgrey;
|
||||||
}
|
}
|
||||||
|
|
||||||
#note-type-dropdown {
|
#note-type-dropdown {
|
||||||
|
|||||||
@@ -19,11 +19,12 @@ router.post('/exec', auth.checkApiAuth, wrap(async (req, res, next) => {
|
|||||||
|
|
||||||
router.get('/startup', auth.checkApiAuth, wrap(async (req, res, next) => {
|
router.get('/startup', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||||
const noteIds = await attributes.getNoteIdsWithAttribute("run_on_startup");
|
const noteIds = await attributes.getNoteIdsWithAttribute("run_on_startup");
|
||||||
|
const repository = new Repository(req);
|
||||||
|
|
||||||
const scripts = [];
|
const scripts = [];
|
||||||
|
|
||||||
for (const noteId of noteIds) {
|
for (const noteId of noteIds) {
|
||||||
scripts.push(await getNoteWithSubtreeScript(noteId, req));
|
scripts.push(await getNoteWithSubtreeScript(noteId, repository));
|
||||||
}
|
}
|
||||||
|
|
||||||
res.send(scripts);
|
res.send(scripts);
|
||||||
@@ -41,10 +42,10 @@ router.get('/subtree/:noteId', auth.checkApiAuth, wrap(async (req, res, next) =>
|
|||||||
res.send(subTreeScripts + noteScript);
|
res.send(subTreeScripts + noteScript);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
async function getNoteWithSubtreeScript(noteId, req) {
|
async function getNoteWithSubtreeScript(noteId, repository) {
|
||||||
const noteScript = (await notes.getNoteById(noteId, req)).content;
|
const noteScript = (await repository.getNote(noteId)).content;
|
||||||
|
|
||||||
const subTreeScripts = await getSubTreeScripts(noteId, [noteId], req);
|
const subTreeScripts = await getSubTreeScripts(noteId, [noteId], repository);
|
||||||
|
|
||||||
return subTreeScripts + noteScript;
|
return subTreeScripts + noteScript;
|
||||||
}
|
}
|
||||||
|
|||||||
11
src/scripts/today.js
Normal file
11
src/scripts/today.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
api.addButtonToToolbar('go-today', $('<button class="btn btn-xs" onclick="goToday();"><span class="ui-icon ui-icon-calendar"></span> Today</button>'));
|
||||||
|
|
||||||
|
window.goToday = async function() {
|
||||||
|
const todayDateStr = formatDateISO(new Date());
|
||||||
|
|
||||||
|
const todayNoteId = await server.exec([todayDateStr], async todayDateStr => {
|
||||||
|
return await this.getDateNoteId(todayDateStr);
|
||||||
|
});
|
||||||
|
|
||||||
|
api.activateNote(todayNoteId);
|
||||||
|
};
|
||||||
@@ -65,6 +65,8 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.sort((a, b) => a.date < b.date ? -1 : +1);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -5,32 +5,6 @@ const sync_table = require('./sync_table');
|
|||||||
const attributes = require('./attributes');
|
const attributes = require('./attributes');
|
||||||
const protected_session = require('./protected_session');
|
const protected_session = require('./protected_session');
|
||||||
|
|
||||||
async function updateJsonNote(noteId, data) {
|
|
||||||
const ret = await createNewNote(noteId, {
|
|
||||||
title: name,
|
|
||||||
content: JSON.stringify(data),
|
|
||||||
target: 'into',
|
|
||||||
isProtected: false,
|
|
||||||
type: 'code',
|
|
||||||
mime: 'application/json'
|
|
||||||
});
|
|
||||||
|
|
||||||
return ret.noteId;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function createNewJsonNote(parentNoteId, name, payload) {
|
|
||||||
const ret = await createNewNote(parentNoteId, {
|
|
||||||
title: name,
|
|
||||||
content: JSON.stringify(payload),
|
|
||||||
target: 'into',
|
|
||||||
isProtected: false,
|
|
||||||
type: 'code',
|
|
||||||
mime: 'application/json'
|
|
||||||
});
|
|
||||||
|
|
||||||
return ret.noteId;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function createNewNote(parentNoteId, noteOpts, dataKey, sourceId) {
|
async function createNewNote(parentNoteId, noteOpts, dataKey, sourceId) {
|
||||||
const noteId = utils.newNoteId();
|
const noteId = utils.newNoteId();
|
||||||
const noteTreeId = utils.newNoteTreeId();
|
const noteTreeId = utils.newNoteTreeId();
|
||||||
|
|||||||
@@ -17,15 +17,20 @@
|
|||||||
<button class="btn btn-xs" onclick="jumpToNote.showDialog();" title="CTRL+J">Jump to note</button>
|
<button class="btn btn-xs" onclick="jumpToNote.showDialog();" title="CTRL+J">Jump to note</button>
|
||||||
<button class="btn btn-xs" onclick="recentNotes.showDialog();" title="CTRL+E">Recent notes</button>
|
<button class="btn btn-xs" onclick="recentNotes.showDialog();" title="CTRL+E">Recent notes</button>
|
||||||
<button class="btn btn-xs" onclick="recentChanges.showDialog();">Recent changes</button>
|
<button class="btn btn-xs" onclick="recentChanges.showDialog();">Recent changes</button>
|
||||||
<button class="btn btn-xs" onclick="eventLog.showDialog();">Event log</button>
|
</div>
|
||||||
|
|
||||||
|
<div id="plugin-buttons">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<button class="btn btn-xs" onclick="syncNow();" title="Number of outstanding changes to be pushed to server">
|
<button class="btn btn-xs" onclick="syncNow();" title="Number of outstanding changes to be pushed to server">
|
||||||
|
<span class="ui-icon ui-icon-refresh"></span>
|
||||||
|
|
||||||
Sync now (<span id="changes-to-push-count">0</span>)
|
Sync now (<span id="changes-to-push-count">0</span>)
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button class="btn btn-xs" onclick="settings.showDialog();">Settings</button>
|
<button class="btn btn-xs" onclick="settings.showDialog();">
|
||||||
|
<span class="ui-icon ui-icon-gear"></span> Settings</button>
|
||||||
|
|
||||||
<form action="logout" id="logout-button" method="POST" style="display: inline;">
|
<form action="logout" id="logout-button" method="POST" style="display: inline;">
|
||||||
<input type="submit" class="btn btn-xs" value="Logout">
|
<input type="submit" class="btn btn-xs" value="Logout">
|
||||||
@@ -492,7 +497,7 @@
|
|||||||
<script src="javascripts/link.js"></script>
|
<script src="javascripts/link.js"></script>
|
||||||
<script src="javascripts/sync.js"></script>
|
<script src="javascripts/sync.js"></script>
|
||||||
<script src="javascripts/messaging.js"></script>
|
<script src="javascripts/messaging.js"></script>
|
||||||
|
<script src="javascripts/api.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
// we hide container initally because otherwise it is rendered first without CSS and then flickers into
|
// we hide container initally because otherwise it is rendered first without CSS and then flickers into
|
||||||
|
|||||||
Reference in New Issue
Block a user