From f9056c6754293da6dc2803eb7f04e0902f08be6f Mon Sep 17 00:00:00 2001 From: azivner Date: Mon, 13 Nov 2017 19:45:13 -0500 Subject: [PATCH 1/3] proxy support --- services/sync.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/services/sync.js b/services/sync.js index 045ecdcf6..d8e7bef77 100644 --- a/services/sync.js +++ b/services/sync.js @@ -14,6 +14,7 @@ const syncUpdate = require('./sync_update'); const SYNC_SERVER = config['Sync']['syncServerHost']; const isSyncSetup = !!SYNC_SERVER; const SYNC_TIMEOUT = config['Sync']['syncServerTimeout'] || 5000; +const SYNC_PROXY = config['Sync']['syncProxy']; let syncInProgress = false; @@ -215,14 +216,20 @@ async function syncRequest(syncContext, method, uri, body) { const fullUri = SYNC_SERVER + uri; try { - return await rp({ + const options = { method: method, uri: fullUri, jar: syncContext.cookieJar, json: true, body: body, timeout: SYNC_TIMEOUT - }); + }; + + if (SYNC_PROXY) { + options.proxy = SYNC_PROXY; + } + + return await rp(options); } catch (e) { throw new Error("Request to " + method + " " + fullUri + " failed, inner exception: " + e.stack); From fbce84e779951056c0e8b4d5395ee2fbe426555e Mon Sep 17 00:00:00 2001 From: azivner Date: Mon, 13 Nov 2017 23:35:23 -0500 Subject: [PATCH 2/3] added build date & revision --- public/javascripts/dialogs/settings.js | 17 ++++++++++++++++- routes/api/settings.js | 5 +++++ services/build.js | 1 + set-build.sh | 3 +++ views/index.ejs | 14 ++++++++++++++ 5 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 services/build.js create mode 100755 set-build.sh diff --git a/public/javascripts/dialogs/settings.js b/public/javascripts/dialogs/settings.js index 63ae5aa51..892352b22 100644 --- a/public/javascripts/dialogs/settings.js +++ b/public/javascripts/dialogs/settings.js @@ -21,7 +21,7 @@ const settings = (function() { dialogEl.dialog({ modal: true, - width: 600 + width: 800 }); tabsEl.tabs(); @@ -148,6 +148,21 @@ settings.addModule((function () { return false; }); + return { + settingsLoaded + }; +})()); + +settings.addModule((function () { + const buildDateEl = $("#build-date"); + const buildRevisionEl = $("#build-revision"); + + function settingsLoaded(settings) { + buildDateEl.html(settings['buildDate']); + buildRevisionEl.html(settings['buildRevision']); + buildRevisionEl.attr('href', 'https://github.com/zadam/trilium/commit/' + settings['buildRevision']); + } + return { settingsLoaded }; diff --git a/routes/api/settings.js b/routes/api/settings.js index db08232a3..998f778ce 100644 --- a/routes/api/settings.js +++ b/routes/api/settings.js @@ -7,6 +7,7 @@ const options = require('../../services/options'); const audit_category = require('../../services/audit_category'); const auth = require('../../services/auth'); const utils = require('../../services/utils'); +const build = require('../../services/build'); // options allowed to be updated directly in settings dialog const ALLOWED_OPTIONS = ['encryption_session_timeout', 'history_snapshot_time_interval']; @@ -14,6 +15,8 @@ const ALLOWED_OPTIONS = ['encryption_session_timeout', 'history_snapshot_time_in router.get('/all', auth.checkApiAuth, async (req, res, next) => { const settings = await sql.getMap("SELECT opt_name, opt_value FROM options"); + Object.assign(settings, build); + res.send(settings); }); @@ -21,6 +24,8 @@ router.get('/', auth.checkApiAuth, async (req, res, next) => { const settings = await sql.getMap("SELECT opt_name, opt_value FROM options WHERE opt_name IN (" + ALLOWED_OPTIONS.map(x => '?').join(",") + ")", ALLOWED_OPTIONS); + Object.assign(settings, build); + res.send(settings); }); diff --git a/services/build.js b/services/build.js new file mode 100644 index 000000000..1ce48d712 --- /dev/null +++ b/services/build.js @@ -0,0 +1 @@ +module.exports = { buildDate:"2017-11-13T23:17:28-05:00", buildRevision: "f9056c6754293da6dc2803eb7f04e0902f08be6f" }; diff --git a/set-build.sh b/set-build.sh new file mode 100755 index 000000000..3f59e790b --- /dev/null +++ b/set-build.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +echo 'module.exports = { buildDate:"'`date --iso-8601=seconds`'", buildRevision: "'`git log -1 --format="%H"`'" };' > services/build.js \ No newline at end of file diff --git a/views/index.ejs b/views/index.ejs index 93f2e0424..bf83852c6 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -153,6 +153,7 @@
  • Change password
  • Encryption timeout
  • History snapshots
  • +
  • About Trilium
  • @@ -199,6 +200,19 @@
    +
    + + + + + + + + + + +
    Build date:
    Build revision:
    +
    From 82614c1c73777f39237efd0e07c3d5613c56d5b5 Mon Sep 17 00:00:00 2001 From: azivner Date: Mon, 13 Nov 2017 23:41:44 -0500 Subject: [PATCH 3/3] fix build script --- build.sh | 2 ++ services/build.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index a1fa72c0b..c456d889c 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,7 @@ #!/bin/bash +./set-build.sh + echo "Deleting dist" rm -r dist/* diff --git a/services/build.js b/services/build.js index 1ce48d712..cd4ef4587 100644 --- a/services/build.js +++ b/services/build.js @@ -1 +1 @@ -module.exports = { buildDate:"2017-11-13T23:17:28-05:00", buildRevision: "f9056c6754293da6dc2803eb7f04e0902f08be6f" }; +module.exports = { buildDate:"2017-11-13T23:36:03-05:00", buildRevision: "fbce84e779951056c0e8b4d5395ee2fbe426555e" };