From 7f96a878d14044ec5be587b5b145ec4b5111f29a Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 16 Dec 2020 11:28:15 +0100 Subject: [PATCH] Preparing for Docs Concpts --- Client/httpInterface.js | 27 +++++++++++++++---- .../Superalgos/Schemas/ConceptSchema.json | 8 ------ .../Schemas/Docs-Concepts/attaching.json | 8 ++++++ .../Schemas/Docs-Concepts/referencing.json | 8 ++++++ .../Schemas/Docs-Topics/contributing.json | 8 ++++++ UI/AppPostLoader.js | 4 +-- 6 files changed, 48 insertions(+), 15 deletions(-) delete mode 100644 Projects/Superalgos/Schemas/ConceptSchema.json create mode 100644 Projects/Superalgos/Schemas/Docs-Concepts/attaching.json create mode 100644 Projects/Superalgos/Schemas/Docs-Concepts/referencing.json create mode 100644 Projects/Superalgos/Schemas/Docs-Topics/contributing.json diff --git a/Client/httpInterface.js b/Client/httpInterface.js index 23dc7e189..1ff185c48 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -454,7 +454,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE case 'Schema': { - sendSchema(global.env.PATH_TO_PROJECTS + '/' + requestParameters[2] + '/Schemas/', requestParameters[3] + '.json') + sendSchema(global.env.PATH_TO_PROJECTS + '/' + requestParameters[2] + '/Schemas/', requestParameters[3]) } break @@ -889,10 +889,11 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE lsWithGrep(); } - function sendSchema(filePath, fileName) { + function sendSchema(filePath, schemaType) { let fs = require('fs') - if (fileName === 'AppSchema.json') { + if (schemaType === 'AppSchema') { + let fileName = 'AppSchema.json' try { filePath = filePath + fileName fs.readFile(filePath, onFileRead) @@ -909,11 +910,27 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE } } else { try { + let folder = '' + switch (schemaType) { + case 'DocsNodeSchema': { + folder = 'Docs-Nodes' + break + } + case 'DocsConceptSchema': { + folder = 'Docs-Concepts' + break + } + case 'DocsTopictSchema': { + folder = 'Docs-Topics' + break + } + } + let schemaArray = [] - let fileList = fs.readdirSync(filePath + '/Docs-Nodes') + let fileList = fs.readdirSync(filePath + '/' + folder) for (let k = 0; k < fileList.length; k++) { let name = fileList[k] - let fileContent = fs.readFileSync(filePath + '/Docs-Nodes/' + name) + let fileContent = fs.readFileSync(filePath + '/' + folder + '/' + name) let nodeDefinition = JSON.parse(fileContent) schemaArray.push(nodeDefinition) } diff --git a/Projects/Superalgos/Schemas/ConceptSchema.json b/Projects/Superalgos/Schemas/ConceptSchema.json deleted file mode 100644 index efeeaa440..000000000 --- a/Projects/Superalgos/Schemas/ConceptSchema.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - { - "type": "Concept 1", - "definition": "This is concept 1 definition" - } -] - - diff --git a/Projects/Superalgos/Schemas/Docs-Concepts/attaching.json b/Projects/Superalgos/Schemas/Docs-Concepts/attaching.json new file mode 100644 index 000000000..de73f9eb4 --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Concepts/attaching.json @@ -0,0 +1,8 @@ + + { + "type": "Attaching", + "definition": "Nodes can be attached" + } + + + diff --git a/Projects/Superalgos/Schemas/Docs-Concepts/referencing.json b/Projects/Superalgos/Schemas/Docs-Concepts/referencing.json new file mode 100644 index 000000000..1a20e058a --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Concepts/referencing.json @@ -0,0 +1,8 @@ + + { + "type": "Referencing", + "definition": "Nodes can reference other nodes" + } + + + diff --git a/Projects/Superalgos/Schemas/Docs-Topics/contributing.json b/Projects/Superalgos/Schemas/Docs-Topics/contributing.json new file mode 100644 index 000000000..0cdd8b6c3 --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Topics/contributing.json @@ -0,0 +1,8 @@ + + { + "type": "Contributing", + "definition": "There are many ways to contribute" + } + + + diff --git a/UI/AppPostLoader.js b/UI/AppPostLoader.js index db12ac1be..03c379edf 100644 --- a/UI/AppPostLoader.js +++ b/UI/AppPostLoader.js @@ -72,7 +72,7 @@ function newAppPostLoader() { } totalWebServerCalls++ - httpRequest(undefined, 'Schema/' + project + '/DocSchema', onResponseDocSchema) + httpRequest(undefined, 'Schema/' + project + '/DocsNodeSchema', onResponseDocSchema) function onResponseDocSchema(err, schema) { try { @@ -92,7 +92,7 @@ function newAppPostLoader() { } totalWebServerCalls++ - httpRequest(undefined, 'Schema/' + project + '/ConceptSchema', onResponseConceptSchema) + httpRequest(undefined, 'Schema/' + project + '/DocsConceptSchema', onResponseConceptSchema) function onResponseConceptSchema(err, schema) { try {