Merge pull request #325 from Luis-Fernando-Molina/in-app-documentation

Contribution to Superalgos
This commit is contained in:
Luis Fernando Molina authored and GitHub committed 2021-01-07 10:53:31 +01:00
commit 43c664e854
26 files changed
+445 -29

No files matched your search

+59 -1
View File
@@ -464,6 +464,60 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
}
break
}
case 'Save-Tutorial-Schema': {
getBody(processRequest)
async function processRequest(body) {
try {
let docsSchema = JSON.parse(body)
let project = requestParameters[3]
let filePath = global.env.PATH_TO_PROJECTS + '/' + project + '/Schemas/Docs-Tutorials'
const fs = require('fs')
fs.rmdir(filePath, { recursive: true }, onDirDeleted)
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)
}
}
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.tutorial.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)
}
} catch (err) {
console.log('[ERROR] httpInterface -> Docs -> Save-Tutorial-Schema -> Method call produced an error.')
console.log('[ERROR] httpInterface -> Docs -> Save-Tutorial-Schema -> err.stack = ' + err.stack)
console.log('[ERROR] httpInterface -> Docs -> Save-Tutorial-Schema -> Params Received = ' + body)
let error = {
result: 'Fail Because',
message: err.message,
stack: err.stack
}
respondWithContent(JSON.stringify(error), httpResponse)
}
}
break
}
case 'Save-Book-Schema': {
getBody(processRequest)
@@ -565,7 +619,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
const owner = 'Superalgos'
const head = username + ':in-app-documentation'
const base = 'in-app-documentation'
const title = 'Contribution to Superalgos'
const title = 'Contribution: ' + commitMessage
try {
await octokit.pulls.create({
@@ -1225,6 +1279,10 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
folder = 'Docs-Topics'
break
}
case 'DocsTutorialSchema': {
folder = 'Docs-Tutorials'
break
}
case 'DocsBookSchema': {
folder = 'Docs-Books'
break
@@ -0,0 +1,16 @@
{
"topic": "Docs Basics",
"pageNumber": "5",
"type": "Docs Tutorial Name",
"definition": {
"text": "Refers to the name of the tutorial, which in turn is a collection of related pages at the Docs.",
"updated": 1609182060836
},
"paragraphs": [
{
"style": "Text",
"text": "Tutorial names are used to group a set of related pages under a certain tutorial. ",
"updated": 1609182145551
}
]
}
@@ -1,6 +1,6 @@
{
"topic": "Docs Basics",
"pageNumber": "5",
"pageNumber": "6",
"type": "Docs Page Number",
"definition": {
"text": "Each topic page must have an assigned page number. The page number is used to build the topic index displayed at the top of each Docs Topic Page.",
@@ -1,6 +1,6 @@
{
"topic": "Docs Basics",
"pageNumber": "6",
"pageNumber": "7",
"type": "Docs Node Page",
"definition": {
"text": "Each node of each Project have a corresponding Node Page at the Docs, explaining everything to be known about that node.",
@@ -1,6 +1,6 @@
{
"topic": "Docs Basics",
"pageNumber": "7",
"pageNumber": "8",
"type": "Docs Concept Page",
"definition": {
"text": "Write here a summary for this topic page."
@@ -1,6 +1,6 @@
{
"topic": "Docs Basics",
"pageNumber": "8",
"pageNumber": "9",
"type": "Docs Topic Page",
"definition": {
"text": "Write here a summary for this topic page."
@@ -1,6 +1,6 @@
{
"topic": "Docs Basics",
"pageNumber": "9",
"pageNumber": "10",
"type": "Docs Page",
"definition": {
"text": "The Docs is a collection of pages classified in 3 different categories: Docs Nodes, Docs Concepts and Docs Topics. A page contains information valuable for the users of the system.",
@@ -1,6 +1,6 @@
{
"topic": "Docs Basics",
"pageNumber": "10",
"pageNumber": "11",
"type": "Docs Paragraoh",
"definition": {
"text": "Write here a summary for this topic page."
@@ -1,6 +1,6 @@
{
"topic": "Docs Basics",
"pageNumber": "11",
"pageNumber": "12",
"type": "Docs Page Block",
"definition": {
"text": "A Page Block is a set of paragraphs within a specific Docs Page. A single Docs Page may have 0 to any number of paragraphs.",
@@ -1,6 +1,6 @@
{
"topic": "Docs Basics",
"pageNumber": "12",
"pageNumber": "13",
"type": "Docs Nodes",
"definition": {
"text": "Docs Nodes is the set of all pages in the Docs under the Docs Page Category of Node.",
@@ -1,6 +1,6 @@
{
"topic": "Docs Basics",
"pageNumber": "13",
"pageNumber": "14",
"type": "Docs Concepts",
"definition": {
"text": "Docs Concepts is the set of all pages in the Docs under the Docs Page Category of Concept.",
@@ -1,6 +1,6 @@
{
"topic": "Docs Basics",
"pageNumber": "14",
"pageNumber": "15",
"type": "Docs Topics",
"definition": {
"text": "Docs Topics is the set of all pages in the Docs under the Docs Page Category of Topic.",
@@ -1,6 +1,6 @@
{
"topic": "Docs Basics",
"pageNumber": "15",
"pageNumber": "16",
"type": "Docs Books",
"definition": {
"text": "A book is page in the Docs that contains chapters. Chapters points to a Docs Topics and are rendered as the index table of the topic they point to.",
@@ -1,6 +1,6 @@
{
"topic": "Docs Basics",
"pageNumber": "16",
"pageNumber": "17",
"type": "Docs Paragraph Styles",
"definition": {
"text": "Each paragraph at a Docs Page, need to be assigend a style. The most commonly used style is the Docs Text Style.",
@@ -1,6 +1,6 @@
{
"topic": "Docs Basics",
"pageNumber": "17",
"pageNumber": "18",
"type": "Docs Search Engine",
"definition": {
"text": "The Docs contains a search engine that allows users to search through the collection of pages.\n",
@@ -1,6 +1,6 @@
{
"topic": "Docs Basics",
"pageNumber": "18",
"pageNumber": "19",
"type": "Docs Search Engine Index",
"definition": {
"text": "The Docs Search Engine builds an in-memory index that contains all the phrases of all Docs Pages, plus the name, type, config and code of all nodes of the current Workspace.",
@@ -1,7 +1,7 @@
{
"topic": "Docs Commands Errors",
"pageNumber": "15",
"type": "Docs Error Toopic Mismatch",
"type": "Docs Error Topic Mismatch",
"definition": {
"text": "The Docs Topic Name provided does not match with the Docs Topic Name found at the page you want to delete.",
"updated": 1609181659359
@@ -0,0 +1,34 @@
{
"topic": "Docs Commands Errors",
"pageNumber": "16",
"type": "Docs Error Tutorial Mismatch",
"definition": {
"text": "The Docs Tutorial Name provided does not match with the Docs Tutorial Name found at the page you want to delete.",
"updated": 1610012937766
},
"paragraphs": [
{
"style": "Anchor",
"text": "Anchor Topic Mismatch",
"updated": 1609181600300
},
{
"style": "Error",
"text": "Tutorial Mismatch. The Docs Tutorial Name provided does not match the Docs Tutorial Name of the page to be deleted.",
"updated": 1610012998692
},
{
"style": "Success",
"text": "Check the page you want to delete and get the right Docs Tutorial Name to use at the command.",
"updated": 1610013007982
},
{
"style": "Title",
"text": "Applies to"
},
{
"style": "List",
"text": "Docs Delete Command"
}
]
}
@@ -0,0 +1,14 @@
{
"tutorial": "Test Tut",
"pageNumber": "1",
"type": "First Page",
"definition": {
"text": "Write here a summary for this tutorial page."
},
"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."
}
]
}
@@ -136,6 +136,10 @@ function newSuperalgosDocsCommmandInterface() {
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsTopicSchema.get(type)
break
}
case 'tutorial': {
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(type)
break
}
case 'book': {
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsBookSchema.get(type)
break
@@ -213,6 +217,15 @@ function newSuperalgosDocsCommmandInterface() {
addTopic(splittedPrimaryCommand[3], splittedSecondaryCommand[0], splittedSecondaryCommand[1], splittedSecondaryCommand[2])
return
}
case 'tutorial': {
let splittedSecondaryCommand = secondaryCommand.split('->')
if (splittedSecondaryCommand.length < 3) {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error Too Few Parameters', 'Anchor Too Few Paramenters')
return
}
addTutorial(splittedPrimaryCommand[3], splittedSecondaryCommand[0], splittedSecondaryCommand[1], splittedSecondaryCommand[2])
return
}
case 'book': {
addBook(splittedPrimaryCommand[3], secondaryCommand)
return
@@ -282,6 +295,15 @@ function newSuperalgosDocsCommmandInterface() {
deleteTopic(splittedPrimaryCommand[3], splittedSecondaryCommand[0], splittedSecondaryCommand[1], splittedSecondaryCommand[2])
return
}
case 'tutorial': {
let splittedSecondaryCommand = secondaryCommand.split('->')
if (splittedSecondaryCommand.length < 3) {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error Too Few Parameters', 'Anchor Too Few Paramenters')
return
}
deleteTutorial(splittedPrimaryCommand[3], splittedSecondaryCommand[0], splittedSecondaryCommand[1], splittedSecondaryCommand[2])
return
}
case 'book': {
deleteBook(splittedPrimaryCommand[3], secondaryCommand)
return
@@ -334,6 +356,10 @@ function newSuperalgosDocsCommmandInterface() {
httpRequest(JSON.stringify(docsSchema), 'Docs/Save-Topic-Schema/' + project, onResponse)
requestsSent++
docsSchema = SCHEMAS_BY_PROJECT.get(project).array.docsTutorialSchema
httpRequest(JSON.stringify(docsSchema), 'Docs/Save-Tutorial-Schema/' + project, onResponse)
requestsSent++
docsSchema = SCHEMAS_BY_PROJECT.get(project).array.docsBookSchema
httpRequest(JSON.stringify(docsSchema), 'Docs/Save-Book-Schema/' + project, onResponse)
requestsSent++
@@ -438,6 +464,34 @@ function newSuperalgosDocsCommmandInterface() {
UI.projects.superalgos.spaces.docsSpace.navigateTo(project, 'Topic', type)
}
function addTutorial(project, tutorial, type, pageNumber) {
let template = {
tutorial: tutorial,
pageNumber: pageNumber,
type: type,
definition: { text: "Write here a summary for this tutorial page." },
paragraphs: [
{
style: "Text",
text: UI.projects.superalgos.globals.docs.NEW_PARAGRAPH_TEXT
}
]
}
if (SCHEMAS_BY_PROJECT.get(project) === undefined) {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error Project Does Not Exist', 'Anchor Project Does Not Exist')
return
}
let exist = SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(type)
if (exist !== undefined) {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error Page Already Exists', 'Anchor Page Already Exists')
return
}
SCHEMAS_BY_PROJECT.get(project).array.docsTutorialSchema.push(template)
SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.set(type, template)
UI.projects.superalgos.spaces.docsSpace.navigateTo(project, 'Tutorial', type)
}
function addBook(project, type) {
let template = {
type: type,
@@ -543,6 +597,38 @@ function newSuperalgosDocsCommmandInterface() {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Message Deleting Succeed')
}
function deleteTutorial(project, tutorial, type, pageNumber) {
if (SCHEMAS_BY_PROJECT.get(project) === undefined) {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error Project Does Not Exist', 'Anchor Project Does Not Exist')
return
}
let exist = SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(type)
if (exist === undefined) {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error Page Does Not Exist', 'Anchor Page Does Not Exist')
return
} else {
if (exist.pageNumber !== pageNumber) {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error Page Number Mismatch', 'Anchor Page Number Mismatch')
return
}
if (exist.tutorial !== tutorial) {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error Tutorial Mismatch', 'Anchor Tutorial Mismatch')
return
}
}
SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.delete(type)
for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsTutorialSchema.length; i++) {
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).array.docsTutorialSchema[i]
if (docsSchemaDocument.type === type) {
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).array.docsTutorialSchema.splice(i, 1)
break
}
}
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Message Deleting Succeed')
}
function deleteBook(project, type) {
if (SCHEMAS_BY_PROJECT.get(project) === undefined) {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error Project Does Not Exist', 'Anchor Project Does Not Exist')
@@ -16,7 +16,7 @@ function newSuperalgosDocSpace() {
currentDocumentBeingRendered: undefined,
previousDocumentBeingRendered: undefined,
currentBookBeingRendered: undefined,
paragraphMap: undefined, // Here we will store a map of paragraphs from the Docs Node, Concept, Topics or Books Schema in order to find it when we need to update them.
paragraphMap: undefined, // Here we will store a map of paragraphs from the Docs Node, Concept, Topics, Tutorials or Books Schema in order to find it when we need to update them.
textArea: undefined,
setUpWorkspaceSchemas: setUpWorkspaceSchemas,
changeLanguage: changeLanguage,
@@ -45,6 +45,10 @@ function newSuperalgosDocsDocumentPage() {
thisObject.docsSchemaDocument = SCHEMAS_BY_PROJECT.get(UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project).map.docsTopicSchema.get(UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.type)
break
}
case 'Tutorial': {
thisObject.docsSchemaDocument = SCHEMAS_BY_PROJECT.get(UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project).map.docsTutorialSchema.get(UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.type)
break
}
case 'Workspace': {
thisObject.docsSchemaDocument = SCHEMAS_BY_PROJECT.get(UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project).map.workspaceSchema.get(UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.nodeId)
break
@@ -119,6 +123,7 @@ function newSuperalgosDocsDocumentPage() {
let definitionImagesArray = []
let hierarchyImagesArray = []
let orderedTopicPageIndexArray = []
let orderedTutorialPageIndexArray = []
let HTML = ''
HTML = HTML + '<section id="docs-search-results-div" class="docs-search-page-container">'
@@ -145,12 +150,23 @@ function newSuperalgosDocsDocumentPage() {
if (UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.category === 'Topic') {
buildOrderedTopicPageIndex(thisObject.docsSchemaDocument.topic)
generatePreviousAndNextPageNavigation()
generateTopicPreviousAndNextPageNavigation()
/* Topic Title */
titleLabel = thisObject.docsSchemaDocument.topic + ' Topic Content'
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>'
generateMultiPageIndex()
generateTopicMultiPageIndex()
}
if (UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.category === 'Tutorial') {
buildOrderedTutorialPageIndex(thisObject.docsSchemaDocument.tutorial)
generateTutorialPreviousAndNextPageNavigation()
/* Tutorial Title */
titleLabel = thisObject.docsSchemaDocument.tutorial + ' Tutorial Content'
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>'
generateTutorialMultiPageIndex()
}
HTML = HTML + '</div>' // Common Style Container Ends
@@ -183,7 +199,7 @@ function newSuperalgosDocsDocumentPage() {
/* We will test if we can draw an image here or not*/
let testElement = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndType(project, type)
if ((category === 'Topic' || category === 'Concept' || category === 'Book') && testElement === undefined) {
if ((category === 'Topic' || category === 'Tutorial' || category === 'Concept' || category === 'Book') && testElement === undefined) {
HTML = HTML + '<div id="definition-summary-editable-paragraph" class="docs-summary"><b>Summary:</b> ' + UI.projects.superalgos.utilities.docs.addToolTips(definitionText, UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.type) + '</div>'
} else {
HTML = HTML + '<div class="docs-definition-table">'
@@ -231,7 +247,7 @@ function newSuperalgosDocsDocumentPage() {
}
}
function generatePreviousAndNextPageNavigation() {
function generateTopicPreviousAndNextPageNavigation() {
let previousPage
let nextPage
@@ -256,7 +272,7 @@ function newSuperalgosDocsDocumentPage() {
}
}
function generateMultiPageIndex() {
function generateTopicMultiPageIndex() {
/*
We will go through all the schema docuents array for the current project and pick
the documents that share the same key thatn the document we are rendering now.
@@ -277,6 +293,80 @@ function newSuperalgosDocsDocumentPage() {
}
}
function buildOrderedTutorialPageIndex(tutorial) {
orderedTutorialPageIndexArray = []
let schemaArray = SCHEMAS_BY_PROJECT.get(UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project).array.docsTutorialSchema
for (let i = 0; i < schemaArray.length; i++) {
let arrayItem = schemaArray[i]
if (arrayItem.tutorial === tutorial) {
let itemAdded = false
if (orderedTutorialPageIndexArray.length === 0) {
orderedTutorialPageIndexArray.push(arrayItem)
itemAdded = true
} else {
for (let j = 0; j < orderedTutorialPageIndexArray.length; j++) {
let orderedArrayItem = orderedTutorialPageIndexArray[j]
if (Number(arrayItem.pageNumber) < Number(orderedArrayItem.pageNumber)) {
orderedTutorialPageIndexArray.splice(j, 0, arrayItem)
itemAdded = true
break
}
}
}
if (itemAdded === false) {
orderedTutorialPageIndexArray.push(arrayItem)
}
}
}
}
function generateTutorialPreviousAndNextPageNavigation() {
let previousPage
let nextPage
for (let i = 0; i < orderedTutorialPageIndexArray.length; i++) {
let arrayItem = orderedTutorialPageIndexArray[i]
if (thisObject.docsSchemaDocument.type === arrayItem.type) {
previousPage = orderedTutorialPageIndexArray[i - 1]
nextPage = orderedTutorialPageIndexArray[i + 1]
HTML = HTML + '<div class="docs-tutorial-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>' + previousPage.type + '</button></span>'
}
HTML = HTML + '</div><div> << Current Page: ' + thisObject.docsSchemaDocument.pageNumber + ' >> </div><div>'
if (nextPage !== undefined) {
HTML = HTML + '<span" onClick="UI.projects.superalgos.spaces.docsSpace.navigateTo(\'' + UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project + '\', \'' + 'Tutorial' + '\', \'' + nextPage.type.replace(/'/g, 'AMPERSAND') + '\')"><button>' + nextPage.type + '</button></span>'
}
HTML = HTML + '</div></div>'
return
}
}
}
function generateTutorialMultiPageIndex() {
/*
We will go through all the schema docuents array for the current project and pick
the documents that share the same key thatn the document we are rendering now.
With the info on those picked document we will build the index.
*/
let key = 'auto-generated-index-paragraph-' + autoGeneratedParagraphIndex
let paragraph
for (let i = 0; i < orderedTutorialPageIndexArray.length; i++) {
let arrayItem = orderedTutorialPageIndexArray[i]
key = 'auto-generated-index-paragraph-' + autoGeneratedParagraphIndex
paragraph = {
style: "Title",
text: "" + arrayItem.type + ""
}
autoGeneratedParagraphIndex++
HTML = HTML + '<p>' + arrayItem.pageNumber + '. ' + '<a class="docs-link" onClick="UI.projects.superalgos.spaces.docsSpace.navigateTo(\'' + UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project + '\', \'' + 'Tutorial' + '\', \'' + arrayItem.type.replace(/'/g, 'AMPERSAND') + '\')">' + paragraph.text + '</a></p>'
}
}
function addContent() {
HTML = HTML + '<div id="docs-content">'
if (thisObject.docsSchemaDocument.paragraphs !== undefined) {
@@ -357,11 +447,15 @@ function newSuperalgosDocsDocumentPage() {
includedSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsTopicSchema.get(type)
break
}
case 'Tutorial': {
includedSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(type)
break
}
case 'Book': {
includedSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsBookSchema.get(type)
break
}
default: return 'Category provided (' + category + ') not valid. Use Node, Concept, Topic or Book instead.'
default: return 'Category provided (' + category + ') not valid. Use Node, Concept, Topic, Tutorial or Book instead.'
}
if (includedSchemaDocument === undefined) {
return category + ' document ' + type + ' not found at project ' + project
@@ -451,7 +545,7 @@ function newSuperalgosDocsDocumentPage() {
autoGeneratedParagraphIndex++
}
generateMultiPageIndex()
generateTopicMultiPageIndex()
}
}
@@ -57,6 +57,17 @@ function newSuperalgosDocsSearchEngine() {
indexDocument(documentIndex)
thisObject.docsIndex.push(documentIndex)
}
/* Search in Tutorials */
for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsTutorialSchema.length; i++) {
documentIndex = {
phraseCount: {}, // here we have an object with properties matching it paragraph style, and each property is a map of phrases and their total count.
docsSchemaDocument: SCHEMAS_BY_PROJECT.get(project).array.docsTutorialSchema[i],
category: 'Tutorial',
project: project
}
indexDocument(documentIndex)
thisObject.docsIndex.push(documentIndex)
}
/* Search in Books */
for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsBookSchema.length; i++) {
documentIndex = {
@@ -94,6 +105,13 @@ function newSuperalgosDocsSearchEngine() {
}
indexParagraph(paragraph)
}
if (documentIndex.docsSchemaDocument.tutorial !== undefined) {
let paragraph = {
style: 'Tutorial',
text: documentIndex.docsSchemaDocument.tutorial
}
indexParagraph(paragraph)
}
if (documentIndex.docsSchemaDocument.type !== undefined) {
let paragraph = {
style: 'Type',
@@ -44,12 +44,21 @@ function newSuperalgosDocsSearchResultsPage() {
documentPoints = documentPoints + thisPhraseCount * 200
}
}
if (documentIndex.docsSchemaDocument.tutorial !== undefined) {
if (key === UI.projects.superalgos.utilities.strings.cleanTextOfCommonWordEndings(documentIndex.docsSchemaDocument.tutorial.toLowerCase())) {
documentPoints = documentPoints + thisPhraseCount * 200
}
}
switch (style) {
case 'topic': {
documentPoints = documentPoints + thisPhraseCount * 100
break
}
case 'tutorial': {
documentPoints = documentPoints + thisPhraseCount * 100
break
}
case 'type': {
documentPoints = documentPoints + thisPhraseCount * 50
break
@@ -185,7 +194,7 @@ function newSuperalgosDocsSearchResultsPage() {
}
function buildHTML() {
const tabs = ['All', 'Nodes', 'Concepts', 'Topics', 'Books', 'Workspace']
const tabs = ['All', 'Nodes', 'Concepts', 'Topics', 'Tutorials', 'Books', 'Workspace']
let HTML = ''
HTML = HTML + '<section id="docs-search-results-div" class="docs-search-page-container">'
HTML = HTML + UI.projects.superalgos.spaces.docsSpace.mainSearchPage.addSearchHeader()
@@ -246,10 +255,19 @@ function newSuperalgosDocsSearchResultsPage() {
HTML = HTML + '<p class="docs-search-result-content-record-project-category">' + result.documentIndex.project + ' > ' + result.documentIndex.category + path + '</p>'
let mainLink = ''
if (result.documentIndex.docsSchemaDocument.topic === undefined) {
mainLink = result.documentIndex.docsSchemaDocument.type
} else {
mainLink = result.documentIndex.docsSchemaDocument.topic + ' - Page ' + result.documentIndex.docsSchemaDocument.pageNumber + ' - ' + result.documentIndex.docsSchemaDocument.type
switch (result.documentIndex.category) {
case 'Topic': {
mainLink = result.documentIndex.docsSchemaDocument.topic + ' - Page ' + result.documentIndex.docsSchemaDocument.pageNumber + ' - ' + result.documentIndex.docsSchemaDocument.type
break
}
case 'Tutorial': {
mainLink = result.documentIndex.docsSchemaDocument.tutorial + ' - Page ' + result.documentIndex.docsSchemaDocument.pageNumber + ' - ' + result.documentIndex.docsSchemaDocument.type
break
}
default: {
mainLink = result.documentIndex.docsSchemaDocument.type
}
}
HTML = HTML + '<p><a onClick="UI.projects.superalgos.spaces.docsSpace.navigateTo(\'' + result.documentIndex.project + '\', \'' + result.documentIndex.category + '\', \'' + result.documentIndex.docsSchemaDocument.type.replace(/'/g, 'AMPERSAND') + '\', ' + undefined + ' ,\'' + result.documentIndex.docsSchemaDocument.nodeId + '\')" class="docs-search-result-content-record-title">' + mainLink + '</a></p>'
+56
View File
@@ -396,6 +396,11 @@ function newSuperalgosUtilitiesDocs() {
found = true
break
}
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(type)
if (docsSchemaDocument !== undefined) {
found = true
break
}
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsBookSchema.get(type)
if (docsSchemaDocument !== undefined) {
found = true
@@ -608,6 +613,57 @@ function newSuperalgosUtilitiesDocs() {
break
}
/* Search in docsTutorialSchema */
if (SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(cleanPhrase5) !== undefined) {
if (cleanPhrase5 !== excludedType) {
taggedText = taggedText + phrase5.replace(cleanPhrase5, TAGGING_STRING_SEPARATOR + 'Tutorial' + '|' + cleanPhrase5 + '|' + project + TAGGING_STRING_SEPARATOR) + ' '
} else {
taggedText = taggedText + phrase5 + ' '
}
i = i + 4
found = true
break
}
if (SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(cleanPhrase4) !== undefined) {
if (cleanPhrase4 !== excludedType) {
taggedText = taggedText + phrase4.replace(cleanPhrase4, TAGGING_STRING_SEPARATOR + 'Tutorial' + '|' + cleanPhrase4 + '|' + project + TAGGING_STRING_SEPARATOR) + ' '
} else {
taggedText = taggedText + phrase4 + ' '
}
i = i + 3
found = true
break
}
if (SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(cleanPhrase3) !== undefined) {
if (cleanPhrase3 !== excludedType) {
taggedText = taggedText + phrase3.replace(cleanPhrase3, TAGGING_STRING_SEPARATOR + 'Tutorial' + '|' + cleanPhrase3 + '|' + project + TAGGING_STRING_SEPARATOR) + ' '
} else {
taggedText = taggedText + phrase3 + ' '
}
i = i + 2
found = true
break
}
if (SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(cleanPhrase2) !== undefined) {
if (cleanPhrase2 !== excludedType) {
taggedText = taggedText + phrase2.replace(cleanPhrase2, TAGGING_STRING_SEPARATOR + 'Tutorial' + '|' + cleanPhrase2 + '|' + project + TAGGING_STRING_SEPARATOR) + ' '
} else {
taggedText = taggedText + phrase2 + ' '
}
i = i + 1
found = true
break
}
if (SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(cleanPhrase1) !== undefined) {
if (cleanPhrase1 !== excludedType) {
taggedText = taggedText + phrase1.replace(cleanPhrase1, TAGGING_STRING_SEPARATOR + 'Tutorial' + '|' + cleanPhrase1 + '|' + project + TAGGING_STRING_SEPARATOR) + ' '
} else {
taggedText = taggedText + phrase1 + ' '
}
found = true
break
}
/* Search in docsBookSchema */
if (SCHEMAS_BY_PROJECT.get(project).map.docsBookSchema.get(cleanPhrase5) !== undefined) {
if (cleanPhrase5 !== excludedType) {
+22
View File
@@ -43,6 +43,7 @@ function newAppPostLoader() {
docsNodeSchema: [],
docsConceptSchema: [],
docsTopicSchema: [],
docsTutorialSchema: [],
docsBookSchema: []
},
map: {
@@ -50,6 +51,7 @@ function newAppPostLoader() {
docsNodeSchema: new Map(),
docsConceptSchema: new Map(),
docsTopicSchema: new Map(),
docsTutorialSchema: new Map(),
docsBookSchema: new Map()
}
}
@@ -135,6 +137,26 @@ function newAppPostLoader() {
if (webServerResponses === totalWebServerCalls) { startCanvas() }
}
totalWebServerCalls++
httpRequest(undefined, 'Schema/' + project + '/DocsTutorialSchema', onResponseTutorialSchema)
function onResponseTutorialSchema(err, schema) {
try {
schemas.array.docsTutorialSchema = JSON.parse(schema)
for (let j = 0; j < schemas.array.docsTutorialSchema.length; j++) {
let schemaDocument = schemas.array.docsTutorialSchema[j]
let key = schemaDocument.type
schemas.map.docsTutorialSchema.set(key, schemaDocument)
}
} catch (err) {
console.log(err.stack)
}
webServerResponses++
if (webServerResponses === totalWebServerCalls) { startCanvas() }
}
totalWebServerCalls++
httpRequest(undefined, 'Schema/' + project + '/DocsBookSchema', onResponseBookSchema)