Saving working

This commit is contained in:
Luis Fernando Molina committed 2020-12-22 17:32:00 +01:00
1 parent 8cd724fe93
commit 7e204a12a8
9 files changed
+122 -89

No files matched your search

+70 -39
View File
@@ -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.')
@@ -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."
}
]
}
@@ -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"
}
]
}
@@ -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"
}
]
}
@@ -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"
}
]
}
@@ -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"
}
]
}
@@ -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."
}
]
}
@@ -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."
}
]
}
@@ -835,7 +835,7 @@ function newSuperalgosDocSpace() {
"Example: Add Node to Superalgos: Task Manager",
"Option 2: <i>Add</i> Concpet <i>to</i> Project: Concept Name",
"Example: Add Concept to Superalgos: Attaching Nodes",
"Option 3: <i>Add</i> Topic <i>to</i> Project: Topic->Part Name->Page Number",
"Option 3: <i>Add</i> Topic <i>to</i> 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: <i>Delete</i> Concpet <i>from</i> Project: Concept Name",
"Example: Delete Concept from Superalgos: Attaching Nodes",
"Option 3: <i>Delete</i> Topic <i>from</i> Project: Topic->Part Name->Page Number",
"Option 3: <i>Delete</i> Topic <i>from</i> 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 <b>" + type + "</b> already exist."])
renderCommandResultsPage(["Topic Page <b>" + type + "</b> 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 + '<p><a onClick="UI.projects.superalgos.spaces.docsSpace.navigateTo(\'' + result.documentIndex.documentCategory + '\', \'' + result.documentIndex.schemaDocument.type + '\', \'' + result.documentIndex.project + '\', \'' + result.documentIndex.schemaDocument.nodeId + '\')" class="docs-search-result-content-record-title">' + mainLink + '</a></p>'