From 7e204a12a8cd5af9c5483b63ba351e50109ca5e1 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 22 Dec 2020 17:32:00 +0100 Subject: [PATCH] Saving working --- Client/httpInterface.js | 109 +++++++++++------- .../Schemas/Docs-Concepts/referencing.json | 14 --- .../contributing-001-to-the-docs.json | 12 ++ .../Schemas/Docs-Topics/contributing-001.json | 16 --- .../Docs-Topics/contributing-002-code.json | 12 ++ .../Schemas/Docs-Topics/contributing-002.json | 16 --- .../testing-002-testing-strategies.json | 12 ++ .../testing-003-testing-systems.json | 12 ++ .../UI/Spaces/Docs-Space/DocsSpace.js | 8 +- 9 files changed, 122 insertions(+), 89 deletions(-) delete mode 100644 Projects/Superalgos/Schemas/Docs-Concepts/referencing.json create mode 100644 Projects/Superalgos/Schemas/Docs-Topics/contributing-001-to-the-docs.json delete mode 100644 Projects/Superalgos/Schemas/Docs-Topics/contributing-001.json create mode 100644 Projects/Superalgos/Schemas/Docs-Topics/contributing-002-code.json delete mode 100644 Projects/Superalgos/Schemas/Docs-Topics/contributing-002.json create mode 100644 Projects/Superalgos/Schemas/Docs-Topics/testing-002-testing-strategies.json create mode 100644 Projects/Superalgos/Schemas/Docs-Topics/testing-003-testing-systems.json diff --git a/Client/httpInterface.js b/Client/httpInterface.js index 8cd5e784a..611e1c252 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -314,23 +314,33 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE let filePath = global.env.PATH_TO_PROJECTS + '/' + project + '/Schemas/Docs-Nodes' const fs = require('fs') + fs.rmdir(filePath, { recursive: true }, onDirDeleted) - fs.rmdirSync(filePath, { recursive: true }) - fs.mkdirSync(filePath) - - for (let i = 0; i < docsSchema.length; i++) { - let schemaDocument = docsSchema[i] - let fileContent = JSON.stringify(schemaDocument, undefined, 4) - - let fileName = schemaDocument.type.toLowerCase() - for (let j = 0; j < 10; j++) { - fileName = fileName.replace(' ', '-') + function onDirDeleted(err) { + if (err && err.code === 'EBUSY') { + throw ('Can not delete the folder ' + filePath + ' because a file in it is open by some other program.') + } + try { + fs.mkdirSync(filePath) + } catch (err) { + if (err.code !== 'EEXIST') { + throw (err) + } } - fileName = fileName + '.json' - fs.writeFileSync(filePath + '/' + fileName, fileContent) + for (let i = 0; i < docsSchema.length; i++) { + let schemaDocument = docsSchema[i] + let fileContent = JSON.stringify(schemaDocument, undefined, 4) + let fileName = schemaDocument.type.toLowerCase() + for (let j = 0; j < 10; j++) { + fileName = fileName.replace(' ', '-') + } + fileName = fileName + '.json' + + fs.writeFileSync(filePath + '/' + fileName, fileContent) + } + respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse) } - respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse) } catch (err) { console.log('[ERROR] httpInterface -> Docs -> Save-Node-Schema -> Method call produced an error.') @@ -357,23 +367,33 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE let filePath = global.env.PATH_TO_PROJECTS + '/' + project + '/Schemas/Docs-Concepts' const fs = require('fs') + fs.rmdir(filePath, { recursive: true }, onDirDeleted) - fs.rmdirSync(filePath, { recursive: true }) - fs.mkdirSync(filePath) - - for (let i = 0; i < docsSchema.length; i++) { - let schemaDocument = docsSchema[i] - let fileContent = JSON.stringify(schemaDocument, undefined, 4) - - let fileName = schemaDocument.type.toLowerCase() - for (let j = 0; j < 10; j++) { - fileName = fileName.replace(' ', '-') + function onDirDeleted(err) { + if (err && err.code === 'EBUSY') { + throw ('Can not delete the folder ' + filePath + ' because a file in it is open by some other program.') + } + try { + fs.mkdirSync(filePath) + } catch (err) { + if (err.code !== 'EEXIST') { + throw (err) + } } - fileName = fileName + '.json' - fs.writeFileSync(filePath + '/' + fileName, fileContent) + for (let i = 0; i < docsSchema.length; i++) { + let schemaDocument = docsSchema[i] + let fileContent = JSON.stringify(schemaDocument, undefined, 4) + let fileName = schemaDocument.type.toLowerCase() + for (let j = 0; j < 10; j++) { + fileName = fileName.replace(' ', '-') + } + fileName = fileName + '.json' + + fs.writeFileSync(filePath + '/' + fileName, fileContent) + } + respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse) } - respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse) } catch (err) { console.log('[ERROR] httpInterface -> Docs -> Save-Concept-Schema -> Method call produced an error.') @@ -400,23 +420,34 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE let filePath = global.env.PATH_TO_PROJECTS + '/' + project + '/Schemas/Docs-Topics' const fs = require('fs') + fs.rmdir(filePath, { recursive: true }, onDirDeleted) - fs.rmdirSync(filePath, { recursive: true }) - fs.mkdirSync(filePath) - - for (let i = 0; i < docsSchema.length; i++) { - let schemaDocument = docsSchema[i] - let fileContent = JSON.stringify(schemaDocument, undefined, 4) - - let fileName = schemaDocument.type.toLowerCase() - for (let j = 0; j < 10; j++) { - fileName = fileName.replace(' ', '-') + function onDirDeleted(err) { + if (err && err.code === 'EBUSY') { + throw ('Can not delete the folder ' + filePath + ' because a file in it is open by some other program.') + } + try { + fs.mkdirSync(filePath) + } catch (err) { + if (err.code !== 'EEXIST') { + throw (err) + } } - fileName = fileName + '.json' - fs.writeFileSync(filePath + '/' + fileName, fileContent) + for (let i = 0; i < docsSchema.length; i++) { + let schemaDocument = docsSchema[i] + let fileContent = JSON.stringify(schemaDocument, undefined, 4) + let pageNumber = '00' + schemaDocument.pageNumber + let fileName = schemaDocument.topic.toLowerCase() + '-' + pageNumber.substring(pageNumber.length - 3, pageNumber.length) + '-' + schemaDocument.type.toLowerCase() + for (let j = 0; j < 10; j++) { + fileName = fileName.replace(' ', '-') + } + fileName = fileName + '.json' + + fs.writeFileSync(filePath + '/' + fileName, fileContent) + } + respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse) } - respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse) } catch (err) { console.log('[ERROR] httpInterface -> Docs -> Save-Topic-Schema -> Method call produced an error.') diff --git a/Projects/Superalgos/Schemas/Docs-Concepts/referencing.json b/Projects/Superalgos/Schemas/Docs-Concepts/referencing.json deleted file mode 100644 index 30fe471a5..000000000 --- a/Projects/Superalgos/Schemas/Docs-Concepts/referencing.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "type": "Referencing", - "definition": "Write here the definition of this Concept.", - "paragraphs": [ - { - "style": "Text", - "text": "This is the content for referencing." - }, - { - "style": "Warning", - "text": "And this is a new paragraph." - } - ] -} \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/contributing-001-to-the-docs.json b/Projects/Superalgos/Schemas/Docs-Topics/contributing-001-to-the-docs.json new file mode 100644 index 000000000..fdf2625a3 --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Topics/contributing-001-to-the-docs.json @@ -0,0 +1,12 @@ +{ + "topic": "Contributing", + "type": "To the Docs", + "definition": "There are many ways to contribute", + "pageNumber": 1, + "paragraphs": [ + { + "style": "Title", + "text": "This is the title of the first page" + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/contributing-001.json b/Projects/Superalgos/Schemas/Docs-Topics/contributing-001.json deleted file mode 100644 index 873e58b72..000000000 --- a/Projects/Superalgos/Schemas/Docs-Topics/contributing-001.json +++ /dev/null @@ -1,16 +0,0 @@ - - { - "topic": "Contributing", - "type": "To the Docs", - "definition": "There are many ways to contribute", - "pageNumber": 1, - "paragraphs": [ - { - "style": "Title", - "text": "This is the title of the first page" - } - ] - } - - - diff --git a/Projects/Superalgos/Schemas/Docs-Topics/contributing-002-code.json b/Projects/Superalgos/Schemas/Docs-Topics/contributing-002-code.json new file mode 100644 index 000000000..f893340ba --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Topics/contributing-002-code.json @@ -0,0 +1,12 @@ +{ + "topic": "Contributing", + "type": "Code", + "definition": "These are other ways to contribute. These are other ways to contribute. These are other ways to contribute. These are other ways to contribute. These are other ways to contribute. These are other ways to contribute. s", + "pageNumber": 2, + "paragraphs": [ + { + "style": "Title", + "text": "bla bla bla bla blaaaaa" + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/contributing-002.json b/Projects/Superalgos/Schemas/Docs-Topics/contributing-002.json deleted file mode 100644 index bfd170da1..000000000 --- a/Projects/Superalgos/Schemas/Docs-Topics/contributing-002.json +++ /dev/null @@ -1,16 +0,0 @@ - - { - "topic": "Contributing", - "type": "Code", - "definition": "These are other ways to contribute. These are other ways to contribute. These are other ways to contribute. These are other ways to contribute. These are other ways to contribute. These are other ways to contribute. s", - "pageNumber": 2, - "paragraphs": [ - { - "style": "Title", - "text": "bla bla bla bla blaaaaa" - } - ] - } - - - diff --git a/Projects/Superalgos/Schemas/Docs-Topics/testing-002-testing-strategies.json b/Projects/Superalgos/Schemas/Docs-Topics/testing-002-testing-strategies.json new file mode 100644 index 000000000..25e6fee7c --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Topics/testing-002-testing-strategies.json @@ -0,0 +1,12 @@ +{ + "topic": "Testing", + "pageNumber": "2", + "type": "Testing Strategies", + "definition": "Write here the definition of this Concept.", + "paragraphs": [ + { + "style": "Text", + "text": "Left click and Edit to enter edit mode and change this text. ENTER to write new paragraphs. ESC to exit edit mode." + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/testing-003-testing-systems.json b/Projects/Superalgos/Schemas/Docs-Topics/testing-003-testing-systems.json new file mode 100644 index 000000000..e26f9cf20 --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Topics/testing-003-testing-systems.json @@ -0,0 +1,12 @@ +{ + "topic": "Testing", + "pageNumber": "3", + "type": "Testing Systems", + "definition": "Write here the definition of this Concept.", + "paragraphs": [ + { + "style": "Text", + "text": "Left click and Edit to enter edit mode and change this text. ENTER to write new paragraphs. ESC to exit edit mode." + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js index efdd4b44f..616594724 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js @@ -835,7 +835,7 @@ function newSuperalgosDocSpace() { "Example: Add Node to Superalgos: Task Manager", "Option 2: Add Concpet to Project: Concept Name", "Example: Add Concept to Superalgos: Attaching Nodes", - "Option 3: Add Topic to Project: Topic->Part Name->Page Number", + "Option 3: Add Topic to Project: Topic->Section Name->Page Number", "Example: Add Topic to Superalgos: Contributing->Code->2" ] ) @@ -905,7 +905,7 @@ function newSuperalgosDocSpace() { "Example: Delete Node from Superalgos: Task Manager", "Option 2: Delete Concpet from Project: Concept Name", "Example: Delete Concept from Superalgos: Attaching Nodes", - "Option 3: Delete Topic from Project: Topic->Part Name->Page Number", + "Option 3: Delete Topic from Project: Topic->Section Name->Page Number", "Example: Delete Topic from Superalgos: Contributing->Code->2" ] ) @@ -1110,7 +1110,7 @@ function newSuperalgosDocSpace() { } let exist = SCHEMAS_BY_PROJECT.get(project).map.docsTopicSchema.get(type) if (exist !== undefined) { - renderCommandResultsPage(["Topic Part " + type + " already exist."]) + renderCommandResultsPage(["Topic Page " + type + " already exist."]) return } @@ -1419,7 +1419,7 @@ function newSuperalgosDocSpace() { if (result.documentIndex.schemaDocument.topic === undefined) { mainLink = result.documentIndex.schemaDocument.type } else { - mainLink = result.documentIndex.schemaDocument.topic + ' - Part ' + result.documentIndex.schemaDocument.pageNumber + ' - ' + result.documentIndex.schemaDocument.type + mainLink = result.documentIndex.schemaDocument.topic + ' - Page ' + result.documentIndex.schemaDocument.pageNumber + ' - ' + result.documentIndex.schemaDocument.type } HTML = HTML + '

' + mainLink + '

'