diff --git a/package.json b/package.json index 529727159..185f5266f 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,9 @@ }, "scripts": { "start-server": "cross-env TRILIUM_DATA_DIR=./data TRILIUM_ENV=dev node ./src/www", + "start-server-no-dir": "cross-env TRILIUM_ENV=dev node ./src/www", "start-electron": "cross-env TRILIUM_DATA_DIR=./data TRILIUM_ENV=dev electron --inspect=5858 .", + "start-electron-no-dir": "cross-env TRILIUM_ENV=dev electron --inspect=5858 .", "switch-server": "rm -r ./node_modules/better-sqlite3 && npm install", "switch-electron": "rm -r ./node_modules/better-sqlite3 && npm install && ./node_modules/.bin/electron-rebuild", "build-backend-docs": "rm -r ./docs/backend_api && ./node_modules/.bin/jsdoc -c jsdoc-conf.json -d ./docs/backend_api src/becca/entities/*.js src/services/backend_script_api.js src/services/sql.js", diff --git a/src/app.js b/src/app.js index c77189fef..5869e4b13 100644 --- a/src/app.js +++ b/src/app.js @@ -13,6 +13,7 @@ const utils = require('./services/utils'); const assetPath = require('./services/asset_path'); require('./services/handlers'); require('./becca/becca_loader'); +require('./services/help_import'); const app = express(); diff --git a/src/services/help_import.js b/src/services/help_import.js new file mode 100644 index 000000000..99a700db4 --- /dev/null +++ b/src/services/help_import.js @@ -0,0 +1,20 @@ +const sqlInit = require("./sql_init"); +const cls = require("./cls"); +const zipImport = require("../services/import/zip"); +const TaskContext = require("./task_context"); +const becca = require("../becca/becca"); +const fs = require("fs").promises; + +const HELP_FILE_PATH = '/home/adam/Downloads/Help1.zip'; + +sqlInit.dbReady.then(() => { + cls.init(async () => { + const helpRoot = becca.getNote("_help"); + const taskContext = new TaskContext('no-progress-reporting', null, {}); + const data = await fs.readFile(HELP_FILE_PATH, "binary"); + + console.log("BUGGER LENGTH", data.length); + + await zipImport.importZip(taskContext, Buffer.from(data, 'binary'), helpRoot); + }); +}); diff --git a/src/services/hidden_subtree.js b/src/services/hidden_subtree.js index 4580a3e14..28f7cb103 100644 --- a/src/services/hidden_subtree.js +++ b/src/services/hidden_subtree.js @@ -63,6 +63,12 @@ const HIDDEN_SUBTREE_DEFINITION = { { type: 'label', name: 'keepCurrentHoisting' } ] }, + { + id: '_help', + title: 'Help', + type: 'text', + icon: 'bx-help-circle' + }, { // place for user scripts hidden stuff (scripts should not create notes directly under hidden root) id: '_userHidden', diff --git a/src/services/task_context.js b/src/services/task_context.js index f86b6fd59..9aab9d43e 100644 --- a/src/services/task_context.js +++ b/src/services/task_context.js @@ -6,7 +6,7 @@ const ws = require('./ws'); const taskContexts = {}; class TaskContext { - constructor(taskId, taskType, data = null) { + constructor(taskId, taskType = null, data = null) { this.taskId = taskId; this.taskType = taskType; this.data = data;