Compare commits

...

18 Commits

Author SHA1 Message Date
azivner
fd02c6102d release 0.6.2 2018-02-15 23:08:02 -05:00
azivner
30c712a6be updated package-lock 2018-02-15 23:07:58 -05:00
azivner
3928c96640 electron update to 1.8.2 stable 2018-02-15 23:05:18 -05:00
azivner
d86f655658 attempt to mitigate problem with creating day subnotes 2018-02-15 23:04:50 -05:00
azivner
abdad1c3ae log error messages with ERROR: prefix (there's wasn't anyt other distinction before) 2018-02-15 22:30:05 -05:00
azivner
9e5f1a0a87 Global shortcut registration logs failure, closes #47 2018-02-15 22:17:18 -05:00
azivner
8028b09351 release 0.6.1 2018-02-13 23:27:34 -05:00
azivner
ebe66eaed9 after creating new note, unselect previous active, fixes #45 2018-02-13 23:25:28 -05:00
azivner
5bce9a5f94 added hide_in_autocomplete attribute to weight script 2018-02-13 22:50:12 -05:00
azivner
dfd9927310 added createAttribute method to script API 2018-02-13 22:46:45 -05:00
azivner
9bf1735bde reddit notes will be created with "hide_in_autocomplete" attribute 2018-02-13 22:34:33 -05:00
azivner
2e8eeda5ab new attribute "hide_in_autocomplete", fixes #16 2018-02-13 22:30:33 -05:00
azivner
1cef0ce5f9 removed CTRL-ALT-C global shortcut with pasting from clipboard, keeping only CTRL-ALT-P without clipboard 2018-02-13 19:55:04 -05:00
azivner
1efac99828 limit number of autocomplete results to 100, closes #44 2018-02-13 19:37:07 -05:00
azivner
0e9473119e global keyboard shortcuts for quick creating sub-notes under day note 2018-02-12 23:53:00 -05:00
azivner
7bbfef7af3 better positioning of the recent notes dialog 2018-02-12 21:20:30 -05:00
azivner
5cb93509c1 stop trying to wrap autocomplete with underlying dialog - seems to be impossible to get it right on all platforms 2018-02-12 21:09:50 -05:00
azivner
89e89e04d8 alt+t is now shortcut for today script 2018-02-12 00:30:02 -05:00
20 changed files with 191 additions and 100 deletions

View File

@@ -0,0 +1 @@
CREATE INDEX IDX_attributes_name_value ON attributes (name, value);

View File

@@ -120,6 +120,7 @@ CREATE INDEX IDX_note_images_noteId ON note_images (noteId);
CREATE INDEX IDX_note_images_imageId ON note_images (imageId);
CREATE INDEX IDX_note_images_noteId_imageId ON note_images (noteId, imageId);
CREATE INDEX IDX_attributes_noteId ON attributes (noteId);
CREATE INDEX IDX_attributes_name_value ON attributes (name, value);
CREATE TABLE IF NOT EXISTS "api_tokens"
(

View File

@@ -3,9 +3,11 @@
const electron = require('electron');
const path = require('path');
const config = require('./src/services/config');
const log = require('./src/services/log');
const url = require("url");
const app = electron.app;
const globalShortcut = electron.globalShortcut;
// Adds debug features like hotkeys for triggering dev tools and reload
require('electron-debug')();
@@ -67,6 +69,26 @@ app.on('activate', () => {
app.on('ready', () => {
mainWindow = createMainWindow();
const result = globalShortcut.register('CommandOrControl+Alt+P', async () => {
const date_notes = require('./src/services/date_notes');
const utils = require('./src/services/utils');
const parentNoteId = await date_notes.getDateNoteId(utils.nowDate());
// window may be hidden / not in focus
mainWindow.focus();
mainWindow.webContents.send('create-day-sub-note', parentNoteId);
});
if (!result) {
log.error("Could not register global shortcut CTRL+ALT+P");
}
});
app.on('will-quit', () => {
globalShortcut.unregisterAll();
});
require('./src/www');

78
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "trilium",
"version": "0.4.1",
"version": "0.6.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -3061,19 +3061,19 @@
"integrity": "sha1-zIcsFoiArjxxiXYv1f/ACJbJUYo="
},
"electron": {
"version": "1.8.2-beta.4",
"resolved": "https://registry.npmjs.org/electron/-/electron-1.8.2-beta.4.tgz",
"integrity": "sha1-GDayBO6s6dx3Bi7Ugg/bxsvZoZU=",
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/electron/-/electron-1.8.2.tgz",
"integrity": "sha512-0TV5Hy92g8ACnPn+PVol6a/2uk+khzmRtWxhah/FcKs6StCytm5hD14QqOdZxEdJN8HljXIVCayN/wJX+0wDiQ==",
"requires": {
"@types/node": "8.5.9",
"@types/node": "8.9.4",
"electron-download": "3.3.0",
"extract-zip": "1.6.5"
},
"dependencies": {
"@types/node": {
"version": "8.5.9",
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.5.9.tgz",
"integrity": "sha512-s+c3AjymyAccTI4hcgNFK4mToH8l+hyPDhu4LIkn71lRy56FLijGu00fyLgldjM/846Pmk9N4KFUs2P8GDs0pA=="
"version": "8.9.4",
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.9.4.tgz",
"integrity": "sha512-dSvD36qnQs78G1BPsrZFdPpvLgMW/dnvr5+nTW2csMs5TiP9MOXrjUbnMZOEwnIuBklXtn7b6TPA2Cuq07bDHA=="
}
}
},
@@ -3325,9 +3325,9 @@
}
},
"electron-packager": {
"version": "10.1.1",
"resolved": "https://registry.npmjs.org/electron-packager/-/electron-packager-10.1.1.tgz",
"integrity": "sha1-MWp/ossf/CYz9YBcn8IJE8vAnZQ=",
"version": "11.0.1",
"resolved": "https://registry.npmjs.org/electron-packager/-/electron-packager-11.0.1.tgz",
"integrity": "sha1-wtH/nsqBEL6evIGCbiqSHATRIA4=",
"dev": true,
"requires": {
"asar": "0.14.0",
@@ -3343,13 +3343,19 @@
"pify": "3.0.0",
"plist": "2.1.0",
"pruner": "0.0.7",
"rcedit": "0.9.0",
"rcedit": "1.0.0",
"resolve": "1.4.0",
"sanitize-filename": "1.6.1",
"semver": "5.4.1",
"yargs-parser": "8.1.0"
"yargs-parser": "9.0.2"
},
"dependencies": {
"camelcase": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz",
"integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=",
"dev": true
},
"electron-download": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/electron-download/-/electron-download-4.1.0.tgz",
@@ -3437,6 +3443,12 @@
"integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=",
"dev": true
},
"rcedit": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/rcedit/-/rcedit-1.0.0.tgz",
"integrity": "sha512-W7DNa34x/3OgWyDHsI172AG/Lr/lZ+PkavFkHj0QhhkBRcV9QTmRJE1tDKrWkx8XHPSBsmZkNv9OKue6pncLFQ==",
"dev": true
},
"sumchecker": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/sumchecker/-/sumchecker-2.0.2.tgz",
@@ -3456,20 +3468,29 @@
}
}
}
},
"yargs-parser": {
"version": "9.0.2",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-9.0.2.tgz",
"integrity": "sha1-nM9qQ0YP5O1Aqbto9I1DuKaMwHc=",
"dev": true,
"requires": {
"camelcase": "4.1.0"
}
}
}
},
"electron-prebuilt-compile": {
"version": "1.8.2-beta.4",
"resolved": "https://registry.npmjs.org/electron-prebuilt-compile/-/electron-prebuilt-compile-1.8.2-beta.4.tgz",
"integrity": "sha512-whVdRgFEDovWSFrAsbMXIiush6RQ8IV3XhYdL59zShck4U1eXGmdkaBCy+2tlkGmUGr0fRu+S4FpUx2ebBkRhQ==",
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/electron-prebuilt-compile/-/electron-prebuilt-compile-1.8.2.tgz",
"integrity": "sha512-wiDVjy8S0PA/K/TUM0lw5gzZ+SmyVVGQ0qt9iFYXHJc6t8TzDXFY3DsoK37H3A7nWnkvXvoPdpJ5/h9KbTMoAw==",
"dev": true,
"requires": {
"babel-plugin-array-includes": "2.0.3",
"babel-plugin-transform-async-to-generator": "6.24.1",
"babel-preset-es2016-node5": "1.1.2",
"babel-preset-react": "6.24.1",
"electron": "1.8.2-beta.4",
"electron": "1.8.2",
"electron-compile": "6.4.2",
"electron-compilers": "5.9.0",
"yargs": "6.6.0"
@@ -8472,12 +8493,6 @@
}
}
},
"rcedit": {
"version": "0.9.0",
"resolved": "https://registry.npmjs.org/rcedit/-/rcedit-0.9.0.tgz",
"integrity": "sha1-ORDfVzRTmeKwMl9KUZAH+J5V7xw=",
"dev": true
},
"read-all-stream": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/read-all-stream/-/read-all-stream-3.1.0.tgz",
@@ -11694,23 +11709,6 @@
}
}
},
"yargs-parser": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-8.1.0.tgz",
"integrity": "sha512-yP+6QqN8BmrgW2ggLtTbdrOyBNSI7zBa4IykmiV5R1wl1JWNxQvWhMfMdmzIYtKU7oP3OOInY/tl2ov3BDjnJQ==",
"dev": true,
"requires": {
"camelcase": "4.1.0"
},
"dependencies": {
"camelcase": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz",
"integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=",
"dev": true
}
}
},
"yauzl": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz",

View File

@@ -1,7 +1,7 @@
{
"name": "trilium",
"description": "Trilium Notes",
"version": "0.6.0-beta",
"version": "0.6.2",
"license": "AGPL-3.0-only",
"main": "electron.js",
"repository": {
@@ -27,7 +27,7 @@
"debug": "~3.1.0",
"devtron": "^1.4.0",
"ejs": "~2.5.7",
"electron": "^1.8.2-beta.4",
"electron": "^1.8.2",
"electron-debug": "^1.5.0",
"electron-in-page-search": "^1.2.4",
"express": "~4.16.2",
@@ -60,8 +60,8 @@
},
"devDependencies": {
"electron-compile": "^6.4.2",
"electron-packager": "^10.1.1",
"electron-prebuilt-compile": "1.8.2-beta.4",
"electron-packager": "^11.0.1",
"electron-prebuilt-compile": "1.8.2",
"electron-rebuild": "^1.7.3",
"tape": "^4.8.0",
"xo": "^0.18.0"

View File

@@ -38,6 +38,7 @@ async function getDateNoteIdForReddit(dateTimeStr, rootNoteId) {
redditDateNoteId = await createNote(dateNoteId, "Reddit");
await attributes.createAttribute(redditDateNoteId, REDDIT_DATE_ATTRIBUTE, dateStr);
await attributes.createAttribute(redditDateNoteId, "hide_in_autocomplete");
}
return redditDateNoteId;

View File

@@ -30,7 +30,8 @@ const recentNotes = (function() {
$dialog.dialog({
modal: true,
width: 800,
height: 400
height: 100,
position: { my: "center top+100", at: "top", of: window }
});
$searchInput.val('');

View File

@@ -126,6 +126,10 @@ $.ui.autocomplete.filter = (array, terms) => {
if (found) {
results.push(item);
if (results.length > 100) {
break;
}
}
}
@@ -192,4 +196,21 @@ $(document).ready(() => {
executeScript(script);
}
});
});
});
if (isElectron()) {
require('electron').ipcRenderer.on('create-day-sub-note', async function(event, parentNoteId) {
// this might occur when day note had to be created
if (!noteTree.noteExists(parentNoteId)) {
await noteTree.reload();
}
await noteTree.activateNode(parentNoteId);
setTimeout(() => {
const node = noteTree.getCurrentNode();
noteTree.createNote(node, node.data.noteId, 'into', node.data.isProtected);
}, 500);
});
}

View File

@@ -116,6 +116,32 @@ const noteEditor = (function() {
isNewNoteCreated = true;
}
function setContent(content) {
if (currentNote.detail.type === 'text') {
// temporary workaround for https://github.com/ckeditor/ckeditor5-enter/issues/49
editor.setData(content ? content : "<p></p>");
noteDetailEl.show();
noteDetailCodeEl.hide();
noteDetailRenderEl.html('').hide();
}
else if (currentNote.detail.type === 'code') {
noteDetailEl.hide();
noteDetailCodeEl.show();
noteDetailRenderEl.html('').hide();
// this needs to happen after the element is shown, otherwise the editor won't be refresheds
codeEditor.setValue(content);
const info = CodeMirror.findModeByMIME(currentNote.detail.mime);
if (info) {
codeEditor.setOption("mode", info.mime);
CodeMirror.autoLoadMode(codeEditor, info.mode);
}
}
}
async function loadNoteToEditor(noteId) {
currentNote = await loadNote(noteId);
@@ -146,30 +172,7 @@ const noteEditor = (function() {
noteType.setNoteType(currentNote.detail.type);
noteType.setNoteMime(currentNote.detail.mime);
if (currentNote.detail.type === 'text') {
// temporary workaround for https://github.com/ckeditor/ckeditor5-enter/issues/49
editor.setData(currentNote.detail.content ? currentNote.detail.content : "<p></p>");
noteDetailEl.show();
noteDetailCodeEl.hide();
noteDetailRenderEl.html('').hide();
}
else if (currentNote.detail.type === 'code') {
noteDetailEl.hide();
noteDetailCodeEl.show();
noteDetailRenderEl.html('').hide();
// this needs to happen after the element is shown, otherwise the editor won't be refresheds
codeEditor.setValue(currentNote.detail.content);
const info = CodeMirror.findModeByMIME(currentNote.detail.mime);
if (info) {
codeEditor.setOption("mode", info.mime);
CodeMirror.autoLoadMode(codeEditor, info.mode);
}
}
else if (currentNote.detail.type === 'render') {
if (currentNote.detail.type === 'render') {
noteDetailEl.hide();
noteDetailCodeEl.hide();
noteDetailRenderEl.html('').show();
@@ -179,7 +182,7 @@ const noteEditor = (function() {
noteDetailRenderEl.html(subTree);
}
else {
throwError("Unrecognized type " + currentNote.detail.type);
setContent(currentNote.detail.content);
}
noteChangeDisabled = false;
@@ -314,6 +317,7 @@ const noteEditor = (function() {
getEditor,
focus,
executeCurrentNote,
loadAttributeList
loadAttributeList,
setContent
};
})();

View File

@@ -14,6 +14,8 @@ const noteTree = (function() {
let parentChildToNoteTreeId = {};
let noteIdToTitle = {};
let hiddenInAutocomplete = {};
function getNoteTreeId(parentNoteId, childNoteId) {
assertArguments(parentNoteId, childNoteId);
@@ -640,16 +642,21 @@ const noteTree = (function() {
return document.location.hash.substr(1); // strip initial #
}
function loadTree() {
return server.get('tree').then(resp => {
startNotePath = resp.start_note_path;
async function loadTree() {
const resp = await server.get('tree');
startNotePath = resp.start_note_path;
if (document.location.hash) {
startNotePath = getNotePathFromAddress();
}
if (document.location.hash) {
startNotePath = getNotePathFromAddress();
}
return prepareNoteTree(resp.notes);
});
hiddenInAutocomplete = {};
for (const noteId of resp.hiddenInAutocomplete) {
hiddenInAutocomplete[noteId] = true;
}
return prepareNoteTree(resp.notes);
}
$(() => loadTree().then(noteTree => initFancyTree(noteTree)));
@@ -706,6 +713,10 @@ const noteTree = (function() {
const autocompleteItems = [];
for (const childNoteId of parentToChildren[parentNoteId]) {
if (hiddenInAutocomplete[childNoteId]) {
continue;
}
const childNotePath = (notePath ? (notePath + '/') : '') + childNoteId;
const childTitlePath = (titlePath ? (titlePath + ' / ') : '') + getNoteTitle(childNoteId, parentNoteId);
@@ -775,7 +786,7 @@ const noteTree = (function() {
};
if (target === 'after') {
node.appendSibling(newNode).setActive(true);
await node.appendSibling(newNode).setActive(true);
}
else if (target === 'into') {
if (!node.getChildren() && node.isFolder()) {
@@ -785,7 +796,7 @@ const noteTree = (function() {
node.addChildren(newNode);
}
node.getLastChild().setActive(true);
await node.getLastChild().setActive(true);
node.folder = true;
node.renderTitle();
@@ -794,6 +805,8 @@ const noteTree = (function() {
throwError("Unrecognized target: " + target);
}
clearSelectedNodes(); // to unmark previously active node
showMessage("Created!");
}
@@ -803,6 +816,10 @@ const noteTree = (function() {
await reload();
}
function noteExists(noteId) {
return !!childToParents[noteId];
}
$(document).bind('keydown', 'ctrl+o', e => {
const node = getCurrentNode();
const parentNoteId = node.data.parentNoteId;
@@ -876,6 +893,7 @@ const noteTree = (function() {
removeParentChildRelation,
setParentChildRelation,
getSelectedNodes,
sortAlphabetically
sortAlphabetically,
noteExists
};
})();

View File

@@ -268,8 +268,4 @@ div.ui-tooltip {
#attribute-list button {
padding: 2px;
margin-right: 5px;
}
.recent-notes-autocomplete {
border: 0 !important;
}

View File

@@ -29,8 +29,20 @@ router.get('/', auth.checkApiAuth, wrap(async (req, res, next) => {
protected_session.decryptNotes(req, notes);
const hiddenInAutocomplete = await sql.getColumn(`
SELECT
DISTINCT noteId
FROM
attributes
JOIN notes USING(noteId)
WHERE
attributes.name = 'hide_in_autocomplete'
AND attributes.isDeleted = 0
AND notes.isDeleted = 0`);
res.send({
notes: notes,
hiddenInAutocomplete: hiddenInAutocomplete,
start_note_path: await options.getOption('start_note_path')
});
}));

View File

@@ -61,10 +61,8 @@ router.put('/:noteTreeId/move-before/:beforeNoteTreeId', auth.checkApiAuth, wrap
await sync_table.addNoteReorderingSync(beforeNote.parentNoteId, sourceId);
const now = utils.nowDate();
await sql.execute("UPDATE note_tree SET parentNoteId = ?, notePosition = ?, dateModified = ? WHERE noteTreeId = ?",
[beforeNote.parentNoteId, beforeNote.notePosition, now, noteTreeId]);
[beforeNote.parentNoteId, beforeNote.notePosition, utils.nowDate(), noteTreeId]);
await sync_table.addNoteTreeSync(noteTreeId, sourceId);
});

View File

@@ -8,4 +8,6 @@ window.goToday = async function() {
});
api.activateNote(todayNoteId);
};
};
$(document).bind('keydown', "alt+t", window.goToday);

View File

@@ -40,7 +40,8 @@
await this.createNote(parentNoteId, 'data', jsonContent, {
json: true,
attributes: {
date_data: date
date_data: date,
hide_in_autocomplete: null
}
});
}
@@ -70,7 +71,9 @@
return data;
});
var config = {
const ctx = $("#canvas")[0].getContext("2d");
new Chart(ctx, {
type: 'line',
data: {
labels: data.map(row => row.date),
@@ -82,10 +85,7 @@
fill: false
}]
}
};
var ctx = $("#canvas")[0].getContext("2d");
new Chart(ctx, config);
});
}
$("#weight-form").submit(event => {

View File

@@ -3,7 +3,7 @@
const build = require('./build');
const packageJson = require('../../package');
const APP_DB_VERSION = 75;
const APP_DB_VERSION = 76;
module.exports = {
app_version: packageJson.version,

View File

@@ -5,7 +5,12 @@ const utils = require('./utils');
const sync_table = require('./sync_table');
const Repository = require('./repository');
const BUILTIN_ATTRIBUTES = [ 'run_on_startup', 'disable_versioning', 'calendar_root' ];
const BUILTIN_ATTRIBUTES = [
'run_on_startup',
'disable_versioning',
'calendar_root',
'hide_in_autocomplete'
];
async function getNoteAttributeMap(noteId) {
return await sql.getMap(`SELECT name, value FROM attributes WHERE noteId = ?`, [noteId]);

View File

@@ -22,7 +22,7 @@ function info(message) {
function error(message) {
// we're using .info() instead of .error() because simple-node-logger emits weird error for showError()
info(message);
info("ERROR: " + message);
}
const requestBlacklist = [ "/libraries", "/javascripts", "/images", "/stylesheets" ];

View File

@@ -54,6 +54,8 @@ function ScriptContext(noteId, dataKey) {
return noteId;
};
this.createAttribute = attributes.createAttribute;
this.updateEntity = this.repository.updateEntity;
this.log = function(message) {

View File

@@ -43,6 +43,14 @@ function nowDate() {
return dateStr(new Date());
}
function localDate() {
const date = new Date();
return date.getFullYear() + "-"
+ (date.getMonth() < 9 ? "0" : "") + (date.getMonth() + 1) + "-"
+ (date.getDate() < 10 ? "0" : "") + date.getDate();
}
function dateStr(date) {
return date.toISOString();
}
@@ -125,6 +133,7 @@ module.exports = {
randomSecureToken,
randomString,
nowDate,
localDate,
dateStr,
parseDate,
parseDateTime,