Merge branch 'in-app-documentation' of https://github.com/Superalgos/Superalgos into in-app-documentation

This commit is contained in:
Julian Molina committed 2021-01-11 12:46:23 +01:00
commit 42888db3de
9 files changed
+152 -69

No files matched your search

+10 -1
View File
@@ -464,11 +464,20 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
} else {
if (schemaDocument.updated === true || schemaDocument.created === true) {
try {
let created = schemaDocument.created
let updated = schemaDocument.updated
schemaDocument.updated = undefined
schemaDocument.created = undefined
let fileContent = JSON.stringify(schemaDocument, undefined, 4)
fs.writeFileSync(filePath + '/' + fileName, fileContent)
console.log('[SUCCESS] ' + filePath + '/' + fileName + ' updated.')
if (created === true) {
console.log('[SUCCESS] ' + filePath + '/' + fileName + ' created.')
} else {
if (updated === true) {
console.log('[SUCCESS] ' + filePath + '/' + fileName + ' updated.')
}
}
} catch (err) {
console.log('[ERROR] httpInterface -> Docs -> Save -> ' + filePath + '/' + fileName + ' could not be created / updated.')
console.log('[ERROR] httpInterface -> Docs -> Save -> Dont worry, the changes are still at the UI, but you will need to do 2 things: 1) Resolve the issue that is preventing the Client to write this file. Look at the error message below as a guide. 2) At the UI, locate this page and edit it with some small change again, so that is flagged that contains changes, otherwise those original changes will be ignored by the Client during the next docs.save command execution.')
@@ -0,0 +1,16 @@
{
"topic": "Docs Commands Messages",
"pageNumber": "2",
"type": "Docs Message Reindexing Started",
"definition": {
"text": "The docs.reindex command you executed succesfully started the rebuing of the Docs Search Engine Index.",
"updated": 1609783396612
},
"paragraphs": [
{
"style": "Success",
"text": "This is a very resourse intensive process. While this happens you will not be able to move arround since all the CPU resources are being used to recreate the index as fast as possible. The size of your workspace impacts the time to reindex the content since every node in it is scanned and all its config and code are indexed. So hold on for a few minutes until the process finishes. Once it does, we will take you to a page that informs you of the result of the process.",
"updated": 1609783508213
}
]
}
@@ -1,6 +1,6 @@
{
"topic": "Docs Commands Messages",
"pageNumber": "2",
"pageNumber": "3",
"type": "Docs Message Reindexing Succeed",
"definition": {
"text": "The docs.reindex command you executed succesfully rebuilt the Docs Search Engine Index.",
@@ -1,6 +1,6 @@
{
"topic": "Docs Commands Messages",
"pageNumber": "3",
"pageNumber": "4",
"type": "Docs Message Deleting Succeed",
"definition": {
"text": "The docs.delete command you executed successfuly delete the page you requested.",
@@ -0,0 +1,16 @@
{
"topic": "Docs Commands Messages",
"pageNumber": "2",
"type": "Docs Message Reindexing Started",
"definition": {
"text": "The docs.reindex command you executed succesfully started the rebuing of the Docs Search Engine Index.",
"updated": 1609783396612
},
"paragraphs": [
{
"style": "Success",
"text": "This is a very resourse intensive process. While this happens you will not be able to move arround since all the CPU resources are being used to recreate the index as fast as possible. The size of your workspace impacts the time to reindex the content since every node in it is scanned and all it's config and code are indexed. So hold on for a few minutes until the process finishes. Once it does, we will take you to a page that informs you of the result of the process.",
"updated": 1610353170958
}
]
}
@@ -324,10 +324,15 @@ function newSuperalgosDocsCommmandInterface() {
}
if (UI.projects.superalgos.spaces.docsSpace.commandInterface.command.indexOf('Docs.Reindex') !== 0 && UI.projects.superalgos.spaces.docsSpace.commandInterface.command.indexOf('docs.reindex') !== 0) { return 'Not Reindex Command' }
UI.projects.superalgos.spaces.docsSpace.setUpWorkspaceSchemas()
UI.projects.superalgos.spaces.docsSpace.searchEngine.setUpSearchEngine()
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Message Reindexing Started')
setTimeout(startReindexingProcess, 100)
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Message Reindexing Succeed')
function startReindexingProcess(){
UI.projects.superalgos.spaces.docsSpace.setUpWorkspaceSchemas()
UI.projects.superalgos.spaces.docsSpace.searchEngine.setUpSearchEngine()
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Message Reindexing Succeed')
}
}
function checkUSaveCommand() {
@@ -425,7 +425,7 @@ function newSuperalgosDocsContextMenu() {
return true
}
if (paragraphNode.id.indexOf('-table') >= 0) {
selectedParagraphData = UI.projects.superalgos.utilities.docs.reverseParseTable(paragraphNode.innerHTML)
selectedParagraphData = UI.projects.superalgos.utilities.docs.reverseParseTable(paragraphNode)
return true
}
if (paragraphNode.id.indexOf('-hierarchy') >= 0) {
@@ -141,7 +141,7 @@ function newSuperalgosDocsDocumentPage() {
let key = 'auto-generated-flag-paragraph'
let paragraph = {
style: "Warning",
text: "This page is flagged to be deleted. Next time you run Docs Save Command, the content will be deleted from the Client's folder. If you refresh the page or close the browser before running the Docs Save Command, the flag is lost and the pade is not deleted. Changes will be applied to the Docs Search Engine Index only after you run the Docs Reindex Command."
text: "This page is flagged to be deleted. Next time you run Docs Save Command, the content will be deleted from the Client's disk. If you refresh the page or close the browser before running the Docs Save Command, the flag is lost and the pade is not deleted. Changes will be applied to the Docs Search Engine Index only after you run the Docs Reindex Command."
}
renderParagraph(paragraph, key)
} else {
@@ -149,7 +149,7 @@ function newSuperalgosDocsDocumentPage() {
let key = 'auto-generated-flag-paragraph'
let paragraph = {
style: "Important",
text: "This page is flagged to be created / updated. Next time you run the Docs Save Command, the content will be saved on the Client's folder. If you refresh the page or close the browser before running the Docs Save Command, changes will be lost. Changes will be applied to the Docs Search Engine Index only after you run the Docs Reindex Command."
text: "This page is flagged to be created / updated. Next time you run the Docs Save Command, the content will be saved on the Client's disk. If you refresh the page or close the browser before running the Docs Save Command, changes will be lost. Changes will be applied to the Docs Search Engine Index only after you run the Docs Reindex Command."
}
renderParagraph(paragraph, key)
}
@@ -169,7 +169,7 @@ function newSuperalgosDocsDocumentPage() {
buildOrderedTopicPageIndex(thisObject.docsSchemaDocument.topic)
/* Topic Title
@@ -198,7 +198,7 @@ function newSuperalgosDocsDocumentPage() {
titleLabel = thisObject.docsSchemaDocument.tutorial + ' Tutorial Navigation'
HTML = HTML + '<div id="docs-main-title-div" class="docs-title-table"><div class="docs-table-cell"><h2 class="docs-h2" id="' + UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.type.toLowerCase().replace(' ', '-') + '" > ' + titleLabel + '</h2></div><div id="projectImageDiv" class="docs-image-container"/></div></div>'
*/
generateTutorialPreviousAndNextPageNavigation()
HTML = HTML = HTML + '<div class="docs-topic-index">' // Container for Tutorial Navigation including buttons, title and index
@@ -314,7 +314,7 @@ function newSuperalgosDocsDocumentPage() {
HTML = HTML + '<div class="docs-topic-navigation"><div>'
if (previousPage !== undefined) {
HTML = HTML + '<span" onClick="UI.projects.superalgos.spaces.docsSpace.navigateTo(\'' + UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project + '\', \'' + 'Topic' + '\', \'' + previousPage.type.replace(/'/g, 'AMPERSAND') + '\')"><button> &#8592; Previous </button></span><br/>'+ previousPage.type
HTML = HTML + '<span" onClick="UI.projects.superalgos.spaces.docsSpace.navigateTo(\'' + UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project + '\', \'' + 'Topic' + '\', \'' + previousPage.type.replace(/'/g, 'AMPERSAND') + '\')"><button> &#8592; Previous </button></span><br/>' + previousPage.type
}
HTML = HTML + '</div><div>'
if (nextPage !== undefined) {
@@ -335,7 +335,7 @@ function newSuperalgosDocsDocumentPage() {
let key = 'auto-generated-index-paragraph-' + autoGeneratedParagraphIndex
let paragraph
for (let i = 0; i < orderedTopicPageIndexArray.length; i++) {
let arrayItem = orderedTopicPageIndexArray[i]
@@ -391,7 +391,7 @@ function newSuperalgosDocsDocumentPage() {
HTML = HTML + '<div class="docs-topic-navigation"><div>'
if (previousPage !== undefined) {
HTML = HTML + '<span" onClick="UI.projects.superalgos.spaces.docsSpace.navigateTo(\'' + UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project + '\', \'' + 'Tutorial' + '\', \'' + previousPage.type.replace(/'/g, 'AMPERSAND') + '\')"><button> &#8592; Previous </button></span><br/>'+ previousPage.type
HTML = HTML + '<span" onClick="UI.projects.superalgos.spaces.docsSpace.navigateTo(\'' + UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project + '\', \'' + 'Tutorial' + '\', \'' + previousPage.type.replace(/'/g, 'AMPERSAND') + '\')"><button> &#8592; Previous </button></span><br/>' + previousPage.type
}
HTML = HTML + '</div><div>'
if (nextPage !== undefined) {
@@ -580,7 +580,7 @@ function newSuperalgosDocsDocumentPage() {
if (SCHEMAS_BY_PROJECT.get(project) === undefined) {
return 'Chapter paragraph style Syntax Error. The Project <i>' + project + '</i> could not be found. Check the Docs Chapter Style Syntax. This error message will dissapear as soon as you fix the problem.'
}
if (category !== 'Topic' && category !== 'Tutorial') {
return 'Category must be either Topic or Tutorial. Found: <i>' + category + '</i>'
}
@@ -649,7 +649,7 @@ function newSuperalgosDocsDocumentPage() {
function addImages() {
addProjectImage()
addDefinitionImage()
addhHerarchyImages()
addHierarchyImages()
if (UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.category === 'Node') {
addMenuItemsImages()
@@ -672,13 +672,25 @@ function newSuperalgosDocsDocumentPage() {
*/
let imageName = appSchemaDocument.type.toLowerCase().replaceAll(' ', '-')
imageElement = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName(imageItem.project, imageName)
if (imageElement === undefined) {
console.log('[WARN] Image for project (' + imageItem.project + ') with name (' + imageName + ') not found. This produces that the Docs Page will be rendered without this icon. ')
continue
}
} else {
if (imageItem.icon === undefined) {
/* This is the default behavious */
imageElement = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndType(imageItem.project, imageItem.type)
if (imageElement === undefined) {
console.log('[WARN] Image for project (' + imageItem.project + ') with name (' + imageItem.type + ') not found. This produces that the Docs Page will be rendered without this icon. ')
continue
}
} else {
/* Here we take the image from the icon specification */
imageElement = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName(imageItem.icon.project, imageItem.icon.name)
if (imageElement === undefined) {
console.log('[WARN] Image for project (' + imageItem.icon.project + ') with name (' + imageItem.icon.name + ') not found. This produces that the Docs Page will be rendered without this icon. ')
continue
}
}
}
@@ -690,7 +702,7 @@ function newSuperalgosDocsDocumentPage() {
}
}
function addhHerarchyImages() {
function addHierarchyImages() {
for (let i = 0; i < hierarchyImagesArray.length; i++) {
let imageItem = hierarchyImagesArray[i]
let collectionImage
@@ -700,14 +712,25 @@ function newSuperalgosDocsDocumentPage() {
if (appSchemaDocument.icon === undefined) {
let imageName = appSchemaDocument.type.toLowerCase().replaceAll(' ', '-')
collectionImage = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName(imageItem.project, imageName)
if (collectionImage === undefined) {
console.log('[WARN] Image for project (' + imageItem.project + ') with name (' + imageName + ') not found. This produces that the hierarchy will be rendered without this icon. ')
continue
}
} else {
collectionImage = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndType(imageItem.project, imageItem.type)
if (collectionImage === undefined) {
console.log('[WARN] Image for project (' + imageItem.project + ') with type (' + imageItem.type + ') not found. This produces that the hierarchy will be rendered without this icon. ')
continue
}
}
} else {
collectionImage = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName(imageItem.project, imageItem.name)
if (collectionImage === undefined) {
console.log('[WARN] Image for project (' + imageItem.project + ') with name (' + imageItem.name + ') not found. This produces that the hierarchy will be rendered without this icon. ')
continue
}
}
let imageElement = collectionImage.cloneNode()
if (imageItem.size !== undefined) {
+65 -51
View File
@@ -15,7 +15,7 @@ function newSuperalgosUtilitiesDocs() {
reverseParseHierarchy: reverseParseHierarchy,
reverseParseTable: reverseParseTable,
addBold: addBold,
addKeyboard: addKeyboard,
addKeyboard: addKeyboard,
addCodeToCamelCase: addCodeToCamelCase,
addCodeToWhiteList: addCodeToWhiteList,
addItalics: addItalics,
@@ -220,36 +220,50 @@ function newSuperalgosUtilitiesDocs() {
return splittedHTML[3]
}
function reverseParseTable(HTML) {
text = removeRGB(HTML)
function reverseParseTable(paragraphNode) {
/* Single occurrance replacements */
text = text.replace('<table class="docs-info-table"> ', '')
text = text.replace('</table>', '')
text = text.replace('<thead>', '')
text = text.replace('</thead>', '')
text = text.replace('<tbody>', '')
text = text.replace('</tbody>', '')
let tableNode = paragraphNode.childNodes[0]
let thead
let tbody
let result = ''
/* All instances replacements */
text = text.replaceAll('<tr>', '')
text = text.replaceAll('<tr class="docs-info-table-alt-bg">', '')
text = text.replaceAll('</td><td>', '|')
text = text.replaceAll('</th><th>', '|')
text = text.replaceAll('<th>', '|')
text = text.replaceAll('</th>', '|')
text = text.replaceAll('<td>', '|')
text = text.replaceAll('</td>', '|')
text = text.replaceAll('</tr>', '')
for (let i = 0; i < tableNode.childNodes.length; i++) {
let childNode = tableNode.childNodes[i]
if (childNode.nodeName === "THEAD") {
thead = childNode
}
if (childNode.nodeName === "TBODY") {
tbody = childNode
}
}
if (thead !== undefined) { processTRs(thead) }
if (tbody !== undefined) { processTRs(tbody) }
function processTRs(TRs) {
for (let i = 0; i < TRs.childNodes.length; i++) {
let TR = TRs.childNodes[i]
for (let j = 0; j < TR.childNodes.length; j++) {
let TD = TR.childNodes[j]
if (TD.innerText.trim() === "") {
let RGB = removeRGB(TD.innerHTML)
result = result + '|' + RGB
} else {
result = result + '|' + TD.innerText
}
}
result = result + '|'
}
}
/* We break lines where needed */
text = text.replaceAll('||', '|' + String.fromCharCode(10) + '|')
return text.trim()
result = result.replaceAll('||', '|' + String.fromCharCode(10) + '|')
return result.trim()
function removeRGB(HTML) {
let text = HTML
text = text.replaceAll('<div style="display: block; background: ', '')
text = text.replaceAll('; border: 1px solid black;">&nbsp;&nbsp;&nbsp;</div>', '')
text = text.replaceAll('&nbsp;', '')
return text.trim()
}
}
@@ -278,53 +292,53 @@ function newSuperalgosUtilitiesDocs() {
for (let i = 0; i < splittedText.length; i++) {
let word = splittedText[i]
if (
word === 'Ctrl' ||
word === 'Alt' ||
word === 'Ctrl' ||
word === 'Alt' ||
word === 'Shift' ||
word === 'Cmd' ||
word === 'F1' ||
word === 'F2' ||
word === 'F3' ||
word === 'F4' ||
word === 'F5' ||
word === 'F6' ||
word === 'F7' ||
word === 'F8' ||
word === 'F9' ||
word === 'F10' ||
word === 'F11' ||
word === 'F12' ||
word === 'Cmd' ||
word === 'F1' ||
word === 'F2' ||
word === 'F3' ||
word === 'F4' ||
word === 'F5' ||
word === 'F6' ||
word === 'F7' ||
word === 'F8' ||
word === 'F9' ||
word === 'F10' ||
word === 'F11' ||
word === 'F12' ||
word === 'Del' ||
word === '←' ||
word === '→' ||
word === '↑' ||
word === '↓' ||
word === 'Key-A' ||
word === '←' ||
word === '→' ||
word === '↑' ||
word === '↓' ||
word === 'Key-A' ||
word === 'Key-B' ||
word === 'Key-C' ||
word === 'Key-D' ||
word === 'Key-D' ||
word === 'Key-E' ||
word === 'Key-F' ||
word === 'Key-G' ||
word === 'Key-G' ||
word === 'Key-H' ||
word === 'Key-I' ||
word === 'Key-J' ||
word === 'Key-J' ||
word === 'Key-K' ||
word === 'Key-L' ||
word === 'Key-M' ||
word === 'Key-M' ||
word === 'Key-N' ||
word === 'Key-O' ||
word === 'Key-P' ||
word === 'Key-P' ||
word === 'Key-Q' ||
word === 'Key-R' ||
word === 'Key-S' || // S
word === 'Key-T' ||
word === 'Key-T' ||
word === 'Key-U' ||
word === 'Key-V' ||
word === 'Key-V' ||
word === 'Key-W' ||
word === 'Key-X' ||
word === 'Key-Y' ||
word === 'Key-Z'
word === 'Key-Y' ||
word === 'Key-Z'
) {
word = '<kbd>' + word + '</kbd>'
}