mirror of
https://github.com/zadam/trilium.git
synced 2025-10-26 15:56:29 +01:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
257cced182 | ||
|
|
3af27845b5 | ||
|
|
9b425025c9 | ||
|
|
e8797a137f | ||
|
|
947e875b6c | ||
|
|
15610626f1 | ||
|
|
eb84cfbef2 | ||
|
|
e4381d10e8 | ||
|
|
b4a566df9e | ||
|
|
b20ff78653 | ||
|
|
15888a5f8f | ||
|
|
a90c164bbe |
@@ -7,13 +7,13 @@ fi
|
||||
|
||||
VERSION=$1
|
||||
PKG_DIR=dist/trilium-linux-x64-server
|
||||
NODE_VERSION=10.9.0
|
||||
NODE_VERSION=8.11.4
|
||||
|
||||
rm -r $PKG_DIR
|
||||
mkdir $PKG_DIR
|
||||
cd $PKG_DIR
|
||||
|
||||
wget https://nodejs.org/dist/latest-v10.x/node-v${NODE_VERSION}-linux-x64.tar.xz
|
||||
wget https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz
|
||||
tar xvfJ node-v${NODE_VERSION}-linux-x64.tar.xz
|
||||
rm node-v${NODE_VERSION}-linux-x64.tar.xz
|
||||
|
||||
|
||||
BIN
bin/deps/sqlite/node-v64-linux-x64/node_sqlite3.node
Executable file
BIN
bin/deps/sqlite/node-v64-linux-x64/node_sqlite3.node
Executable file
Binary file not shown.
@@ -213,3 +213,4 @@ INSERT INTO attributes VALUES('0p8vtV5LoH0e','L9qettZi0csz','label','taskTodoRoo
|
||||
INSERT INTO attributes VALUES('lCyxJnXmNy5x','L9qettZi0csz','label','child:task','',1,'2018-08-28T21:11:09.138Z','2018-08-28T21:11:09.138Z',0,'EarSd1tApi',0);
|
||||
INSERT INTO attributes VALUES('ifqAReEYdFh6','L9qettZi0csz','relation','child:template','HbtlYiMvmm4V',2,'2018-08-28T21:11:09.143Z','2018-08-28T21:11:09.143Z',0,'JXcAyc3in4',0);
|
||||
INSERT INTO attributes VALUES('1hmYf4fJQmBk','L9qettZi0csz','label','child:cssClass','todo',3,'2018-09-01T11:20:29.168Z','2018-09-01T11:20:29.168Z',0,'toS3GWHG/9',0);
|
||||
INSERT INTO attributes VALUES('rZBWHIojcLGl','7YEYLSrnFpIi','label','run','frontendStartup',0,'2018-09-10T22:00:30.600Z','2018-09-10T22:00:30.600Z',0,'Z+589x5RRa',0);
|
||||
|
||||
@@ -83,7 +83,7 @@ INSERT INTO branches VALUES('FIurtaYkU3mn','gDrEI7LFWqrP','1Heh2acXfPNt',26,NULL
|
||||
INSERT INTO branches VALUES('bryQseMhyzaI','IlULcDiOTI4K','1Heh2acXfPNt',2,NULL,0,0,'2018-08-29T17:10:47.987Z','wX6dY3pq/D','1970-01-01T00:00:00.000Z');
|
||||
INSERT INTO branches VALUES('u84s3tBBB92g','TlGCAdcfxkOT','eXHZAKsMYgur',2,NULL,0,0,'2018-08-29T17:11:16.550Z','Ei4ozqDMWi','2018-08-29T17:11:16.550Z');
|
||||
INSERT INTO branches VALUES('yMhwsE7uvEij','3oldoiMUPOlr','HJusZTbBU494',1,NULL,1,0,'2018-08-29T17:20:59.012Z','7U4pIRsbwO','1970-01-01T00:00:00.000Z');
|
||||
INSERT INTO branches VALUES('NTlSXCbgt5Va','Lt8IUldw7d7H','3RkyK9LI18dO',3,NULL,0,0,'2018-08-29T17:23:45.198Z','QjebjIeHUj','2018-08-29T17:23:45.198Z');
|
||||
INSERT INTO branches VALUES('NTlSXCbgt5Va','Lt8IUldw7d7H','3RkyK9LI18dO',2,NULL,0,0,'2018-08-29T17:23:45.198Z','QjebjIeHUj','2018-08-29T17:23:45.198Z');
|
||||
INSERT INTO branches VALUES('0fpnraUGs9Kl','rz5t0r9Qr2WC','HJusZTbBU494',2,NULL,1,0,'2018-08-29T17:26:27.928Z','rw9k0n9SUb','1970-01-01T00:00:00.000Z');
|
||||
INSERT INTO branches VALUES('uMt25KxpV45Y','tX80udgxnW5n','3oldoiMUPOlr',1,NULL,1,0,'2018-08-29T17:29:24.554Z','XlDqz7PX7X','2018-08-29T17:29:24.554Z');
|
||||
INSERT INTO branches VALUES('IsCUFfM1QzHl','rUsGgtpohm7T','3oldoiMUPOlr',21,NULL,0,0,'2018-08-29T17:29:32.942Z','o8ZNDOfGSB','2018-08-29T17:29:32.942Z');
|
||||
@@ -126,3 +126,4 @@ INSERT INTO branches VALUES('iTtVoNfVBdex','d04CnuZxPXj2','nUgD4SYx2gt7',0,NULL,
|
||||
INSERT INTO branches VALUES('7XqFyRCCbbFR','Lom0LEnCes1l','nUgD4SYx2gt7',1,NULL,0,0,'2018-08-30T08:04:45.853Z','xPKVn25yMG','2018-08-29T19:43:44.024Z');
|
||||
INSERT INTO branches VALUES('5OwmqXXREhwW','uP3V8BqwXC05','sXti7HgialF2',2,'TODO',NULL,0,'2018-08-30T08:04:55.389Z','SBwS31n2Cp','2018-08-29T19:43:02.012Z');
|
||||
INSERT INTO branches VALUES('Bu2TmxdlNlTi','i3cLVxiO6GlW','1Heh2acXfPNt',3,NULL,0,0,'2018-09-01T11:47:59.762Z','imw6rHOkkw','2018-09-01T11:47:52.505Z');
|
||||
INSERT INTO branches VALUES('MKMv2KLxfXhp','7YEYLSrnFpIi','3RkyK9LI18dO',3,NULL,0,0,'2018-09-10T22:00:30.553Z','c8DQDwMIOI','2018-09-10T22:00:30.553Z');
|
||||
|
||||
@@ -105,3 +105,4 @@ INSERT INTO notes VALUES('ZC78NlmdXeC6','Linux','',0,0,'2017-12-23T01:22:55.255Z
|
||||
INSERT INTO notes VALUES('h4OfLEAYspud','Security','',0,0,'2017-12-23T04:04:00.715Z','2018-09-03T18:12:28.613Z','text','text/html','BiMTeajSw5');
|
||||
INSERT INTO notes VALUES('QbL3pTvhgzM8','Processes','<p>bla bla ...</p>',0,0,'2017-12-23T04:06:43.841Z','2018-09-03T18:12:37.910Z','text','text/html','3ZbW13jHCM');
|
||||
INSERT INTO notes VALUES('yK4SBJfwD3tY','Work','<p>Expand note on the left pane to see content.</p><p> </p><p> </p>',0,0,'2017-12-23T04:06:32.833Z','2018-08-29T18:23:35.049Z','text','text/html','my57OxteKd');
|
||||
INSERT INTO notes VALUES('7YEYLSrnFpIi','Today',replace('api.addButtonToToolbar({\n title: ''Today'',\n icon: ''calendar'',\n shortcut: ''alt+t'',\n action: async function() {\n const todayDateStr = api.formatDateISO(new Date());\n\n const todayNote = await api.runOnServer(async todayDateStr => {\n return await api.getDateNote(todayDateStr);\n }, [todayDateStr]);\n\n const dateCreated = api.parseDate(todayNote.dateCreated);\n\n // newly created note isn''t in the tree cache yet\n if (new Date().getTime() - dateCreated.getTime() < 60 * 1000) {\n await api.refreshTree();\n }\n\n api.activateNote(todayNote.noteId);\n }\n});','\n',char(10)),0,0,'2018-09-10T22:00:30.550Z','2018-09-10T22:00:30.550Z','code','application/javascript;env=frontend','DsEGPQTtA3');
|
||||
|
||||
4719
package-lock.json
generated
4719
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
19
package.json
19
package.json
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "trilium",
|
||||
"description": "Trilium Notes",
|
||||
"version": "0.22.0",
|
||||
"version": "0.22.1",
|
||||
"license": "AGPL-3.0-only",
|
||||
"main": "electron.js",
|
||||
"bin": {
|
||||
@@ -26,11 +26,12 @@
|
||||
"build-docs": "npm run build-backend-docs && npm run build-frontend-docs"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mlink/scrypt": "6.1.2",
|
||||
"async-mutex": "0.1.3",
|
||||
"axios": "0.18",
|
||||
"body-parser": "1.18.3",
|
||||
"cls-hooked": "4.2.2",
|
||||
"commonmark": "^0.28.1",
|
||||
"commonmark": "0.28.1",
|
||||
"cookie-parser": "1.4.3",
|
||||
"debug": "3.1.0",
|
||||
"devtron": "1.4.0",
|
||||
@@ -50,7 +51,7 @@
|
||||
"imagemin-mozjpeg": "7.0.0",
|
||||
"imagemin-pngquant": "6.0.0",
|
||||
"ini": "1.3.5",
|
||||
"jimp": "0.3.11",
|
||||
"jimp": "0.4.0",
|
||||
"moment": "2.22.2",
|
||||
"multer": "1.3.1",
|
||||
"open": "0.0.5",
|
||||
@@ -62,24 +63,22 @@
|
||||
"sanitize-filename": "1.6.1",
|
||||
"serve-favicon": "2.5.0",
|
||||
"session-file-store": "1.2.0",
|
||||
"simple-node-logger": "0.93.37",
|
||||
"simple-node-logger": "0.93.40",
|
||||
"sqlite": "3.0.0",
|
||||
"tar-stream": "1.6.1",
|
||||
"turndown": "^5.0.1",
|
||||
"turndown": "5.0.1",
|
||||
"unescape": "1.0.1",
|
||||
"ws": "6.0.0",
|
||||
"xml2js": "0.4.19",
|
||||
"@mlink/scrypt": "6.1.2"
|
||||
"xml2js": "0.4.19"
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "2.0.7",
|
||||
"electron": "2.0.9",
|
||||
"electron-compile": "6.4.3",
|
||||
"electron-packager": "12.1.1",
|
||||
"electron-prebuilt-compile": "2.0.7",
|
||||
"electron-rebuild": "1.8.2",
|
||||
"lorem-ipsum": "1.0.6",
|
||||
"tape": "4.9.1",
|
||||
"xo": "0.22.0"
|
||||
"xo": "0.23.0"
|
||||
},
|
||||
"config": {
|
||||
"forge": {
|
||||
|
||||
@@ -223,7 +223,6 @@ addTabHandler((function() {
|
||||
const $syncServerTimeout = $("#sync-server-timeout");
|
||||
const $syncProxy = $("#sync-proxy");
|
||||
const $testSyncButton = $("#test-sync-button");
|
||||
const $syncToServerButton = $("#sync-to-server-button");
|
||||
|
||||
function optionsLoaded(options) {
|
||||
$syncServerHost.val(options['syncServerHost']);
|
||||
@@ -244,22 +243,11 @@ addTabHandler((function() {
|
||||
$testSyncButton.click(async () => {
|
||||
const result = await server.post('sync/test');
|
||||
|
||||
if (result.connection === "Success") {
|
||||
infoService.showMessage("Sync server handshake has been successful");
|
||||
if (result.success) {
|
||||
infoService.showMessage(result.message);
|
||||
}
|
||||
else {
|
||||
infoService.showError("Sync server handshake failed, error: " + result.error);
|
||||
}
|
||||
});
|
||||
|
||||
$syncToServerButton.click(async () => {
|
||||
const resp = await server.post("setup/sync-to-server");
|
||||
|
||||
if (resp.success) {
|
||||
infoService.showMessage("Sync has been established to the server instance. It will take some time to finish.");
|
||||
}
|
||||
else {
|
||||
infoService.showError('Sync setup failed: ' + resp.error);
|
||||
infoService.showError("Sync server handshake failed, error: " + result.message);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ async function importToBranch(req) {
|
||||
const parentNoteId = req.params.parentNoteId;
|
||||
const file = req.file;
|
||||
|
||||
if (file) {
|
||||
if (!file) {
|
||||
return [400, "No file has been uploaded"];
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ async function loginSync(req) {
|
||||
const givenHash = req.body.hash;
|
||||
|
||||
if (expectedHash !== givenHash) {
|
||||
return [400, { message: "Sync login hash doesn't match" }];
|
||||
return [400, { message: "Sync login credentials are incorrect." }];
|
||||
}
|
||||
|
||||
req.session.loggedIn = true;
|
||||
|
||||
@@ -2,10 +2,14 @@
|
||||
|
||||
const sqlInit = require('../../services/sql_init');
|
||||
const setupService = require('../../services/setup');
|
||||
const optionService = require('../../services/options');
|
||||
const syncService = require('../../services/sync');
|
||||
const log = require('../../services/log');
|
||||
const rp = require('request-promise');
|
||||
|
||||
async function getStatus() {
|
||||
return {
|
||||
isInitialized: await sqlInit.isDbInitialized(),
|
||||
schemaExists: await sqlInit.schemaExists()
|
||||
};
|
||||
}
|
||||
|
||||
async function setupNewDocument(req) {
|
||||
const { username, password } = req.body;
|
||||
@@ -19,42 +23,6 @@ async function setupSyncFromServer(req) {
|
||||
return await setupService.setupSyncFromSyncServer(syncServerHost, syncProxy, username, password);
|
||||
}
|
||||
|
||||
async function setupSyncToSyncServer() {
|
||||
log.info("Initiating sync to server");
|
||||
|
||||
const syncServerHost = await optionService.getOption('syncServerHost');
|
||||
const syncProxy = await optionService.getOption('syncProxy');
|
||||
|
||||
const rpOpts = {
|
||||
uri: syncServerHost + '/api/setup/sync-seed',
|
||||
method: 'POST',
|
||||
json: true,
|
||||
body: {
|
||||
options: await setupService.getSyncSeedOptions()
|
||||
}
|
||||
};
|
||||
|
||||
if (syncProxy) {
|
||||
rpOpts.proxy = syncProxy;
|
||||
}
|
||||
|
||||
try {
|
||||
await rp(rpOpts);
|
||||
}
|
||||
catch (e) {
|
||||
return { success: false, error: e.message };
|
||||
}
|
||||
|
||||
// this is completely new sync, need to reset counters. If this would not be new sync,
|
||||
// the previous request would have failed.
|
||||
await optionService.setOption('lastSyncedPush', 0);
|
||||
await optionService.setOption('lastSyncedPull', 0);
|
||||
|
||||
syncService.sync();
|
||||
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
async function saveSyncSeed(req) {
|
||||
const options = req.body.options;
|
||||
|
||||
@@ -68,9 +36,9 @@ async function getSyncSeed() {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getStatus,
|
||||
setupNewDocument,
|
||||
setupSyncFromServer,
|
||||
setupSyncToSyncServer,
|
||||
getSyncSeed,
|
||||
saveSyncSeed
|
||||
};
|
||||
@@ -8,17 +8,26 @@ const sqlInit = require('../../services/sql_init');
|
||||
const optionService = require('../../services/options');
|
||||
const contentHashService = require('../../services/content_hash');
|
||||
const log = require('../../services/log');
|
||||
const syncOptions = require('../../services/sync_options');
|
||||
|
||||
async function testSync() {
|
||||
try {
|
||||
if (!await syncOptions.isSyncSetup()) {
|
||||
return { success: false, message: "Sync server host is not configured. Please configure sync first." };
|
||||
}
|
||||
|
||||
await syncService.login();
|
||||
|
||||
return { connection: "Success" };
|
||||
// login was successful so we'll kick off sync now
|
||||
// this is important in case when sync server has been just initialized
|
||||
syncService.sync();
|
||||
|
||||
return { success: true, message: "Sync server handshake has been successful, sync has been started." };
|
||||
}
|
||||
catch (e) {
|
||||
return {
|
||||
connection: "Failure",
|
||||
error: e.message
|
||||
success: false,
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,9 +166,9 @@ function register(app) {
|
||||
apiRoute(PUT, '/api/recent-notes/:branchId/:notePath', recentNotesRoute.addRecentNote);
|
||||
apiRoute(GET, '/api/app-info', appInfoRoute.getAppInfo);
|
||||
|
||||
route(GET, '/api/setup/status', [], setupApiRoute.getStatus, apiResultHandler);
|
||||
route(POST, '/api/setup/new-document', [auth.checkAppNotInitialized], setupApiRoute.setupNewDocument, apiResultHandler);
|
||||
route(POST, '/api/setup/sync-from-server', [auth.checkAppNotInitialized], setupApiRoute.setupSyncFromServer, apiResultHandler, false);
|
||||
apiRoute(POST, '/api/setup/sync-to-server', setupApiRoute.setupSyncToSyncServer);
|
||||
route(GET, '/api/setup/sync-seed', [auth.checkBasicAuth], setupApiRoute.getSyncSeed, apiResultHandler);
|
||||
route(POST, '/api/setup/sync-seed', [auth.checkAppNotInitialized], setupApiRoute.saveSyncSeed, apiResultHandler, false);
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
module.exports = { buildDate:"2018-09-09T10:08:45+02:00", buildRevision: "d24899414364b37fc7b270e11fcabf0305b58bb8" };
|
||||
module.exports = { buildDate:"2018-09-11T10:15:15+02:00", buildRevision: "3af27845b5aeecd8311d4529c0b46252f5e3077c" };
|
||||
|
||||
@@ -3,6 +3,14 @@ const syncService = require('./sync');
|
||||
const log = require('./log');
|
||||
const sqlInit = require('./sql_init');
|
||||
const repository = require('./repository');
|
||||
const optionService = require('./options');
|
||||
const syncOptions = require('./sync_options');
|
||||
|
||||
async function hasSyncServerSchemaAndSeed() {
|
||||
const response = await requestToSyncServer('GET', '/api/setup/status');
|
||||
|
||||
return response.schemaExists;
|
||||
}
|
||||
|
||||
function triggerSync() {
|
||||
log.info("Triggering sync.");
|
||||
@@ -15,6 +23,39 @@ function triggerSync() {
|
||||
});
|
||||
}
|
||||
|
||||
async function sendSeedToSyncServer() {
|
||||
log.info("Initiating sync to server");
|
||||
|
||||
await requestToSyncServer('POST', '/api/setup/sync-seed', {
|
||||
options: await getSyncSeedOptions()
|
||||
});
|
||||
|
||||
// this is completely new sync, need to reset counters. If this would not be new sync,
|
||||
// the previous request would have failed.
|
||||
await optionService.setOption('lastSyncedPush', 0);
|
||||
await optionService.setOption('lastSyncedPull', 0);
|
||||
}
|
||||
|
||||
async function requestToSyncServer(method, path, body = null) {
|
||||
const rpOpts = {
|
||||
uri: await syncOptions.getSyncServerHost() + path,
|
||||
method: method,
|
||||
json: true
|
||||
};
|
||||
|
||||
if (body) {
|
||||
rpOpts.body = body;
|
||||
}
|
||||
|
||||
const syncProxy = await syncOptions.getSyncProxy();
|
||||
|
||||
if (syncProxy) {
|
||||
rpOpts.proxy = syncProxy;
|
||||
}
|
||||
|
||||
return await rp(rpOpts);
|
||||
}
|
||||
|
||||
async function setupSyncFromSyncServer(syncServerHost, syncProxy, username, password) {
|
||||
if (await sqlInit.isDbInitialized()) {
|
||||
return {
|
||||
@@ -64,7 +105,9 @@ async function getSyncSeedOptions() {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
hasSyncServerSchemaAndSeed,
|
||||
triggerSync,
|
||||
sendSeedToSyncServer,
|
||||
setupSyncFromSyncServer,
|
||||
getSyncSeedOptions,
|
||||
triggerSync
|
||||
getSyncSeedOptions
|
||||
};
|
||||
@@ -44,7 +44,7 @@ async function isDbInitialized() {
|
||||
async function initDbConnection() {
|
||||
await cls.init(async () => {
|
||||
if (!await isDbInitialized()) {
|
||||
log.info("DB not initialized, please visit setup page to initialize Trilium.");
|
||||
log.info("DB not initialized, please visit setup page to see instructions on how to initialize Trilium.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -69,6 +69,16 @@ async function sync() {
|
||||
}
|
||||
|
||||
async function login() {
|
||||
const setupService = require('./setup'); // circular dependency issue
|
||||
|
||||
if (!await setupService.hasSyncServerSchemaAndSeed()) {
|
||||
await setupService.sendSeedToSyncServer();
|
||||
}
|
||||
|
||||
return await doLogin();
|
||||
}
|
||||
|
||||
async function doLogin() {
|
||||
const timestamp = dateUtils.nowDate();
|
||||
|
||||
const documentSecret = await optionService.getOption('documentSecret');
|
||||
|
||||
@@ -483,15 +483,9 @@
|
||||
|
||||
<h4>Sync test</h4>
|
||||
|
||||
<p>This will test connection and handshake to the sync server.</p>
|
||||
<p>This will test connection and handshake to the sync server. If sync server isn't initialized, this will set it up to sync with local document.</p>
|
||||
|
||||
<button id="test-sync-button" class="btn btn-sm">Test sync</button>
|
||||
|
||||
<h4>Sync document to the server instance</h4>
|
||||
|
||||
<p>This is used when you want to sync your local document to the server instance configured above. This is a one time action after which the documents are synced automatically and transparently.</p>
|
||||
|
||||
<button id="sync-to-server-button" class="btn btn-sm">Sync local document to the server instance</button>
|
||||
</div>
|
||||
<div id="advanced">
|
||||
<h4 style="margin-top: 0px;">Sync</h4>
|
||||
|
||||
Reference in New Issue
Block a user