Merge branch 'develop' of https://github.com/Superalgos/Superalgos into develop

This commit is contained in:
Julian Molina committed 2021-01-14 14:46:51 +01:00
commit 40ff8cf21f
6 files changed
+114 -35

No files matched your search

@@ -0,0 +1,27 @@
{
"topic": "Docs Languages",
"pageNumber": "4",
"type": "Docs In Italian",
"definition": {
"text": "The Docs articles are fully written in English. The system allow users to search / browse articles in other languages as well, as long as other users contribute translations."
},
"paragraphs": [
{
"style": "Text",
"text": "Superalgos and any other integrated project are written in English, since English is considered the default language. Node types, variable names, etc., all is originally in English language. "
},
{
"style": "Text",
"text": "The Docs content can be translated by anyone willing to contribute some time doing so. That helps users to read the contents of the Docs in their native language. "
},
{
"style": "Success",
"text": " Users can switch between languages using the links provided at the footer of every page at the Docs. ",
"updated": 1609085068937
},
{
"style": "Note",
"text": "You can only add or delete pages to the Docs if you are navigating it in English, because English is the default language, and from there pages are later translated. "
}
]
}
@@ -58,6 +58,7 @@ function newSuperalgosDocsFooter() {
HTML = HTML + '<li><a href="#" onClick="UI.projects.superalgos.spaces.docsSpace.changeLanguage(\'EN\')">English</a></li>'
HTML = HTML + '<li><a href="#" onClick="UI.projects.superalgos.spaces.docsSpace.changeLanguage(\'ES\')">Spanish</a></li>'
HTML = HTML + '<li><a href="#" onClick="UI.projects.superalgos.spaces.docsSpace.changeLanguage(\'RU\')">Russian</a></li>'
HTML = HTML + '<li><a href="#" onClick="UI.projects.superalgos.spaces.docsSpace.changeLanguage(\'IT\')">Italian</a></li>'
HTML = HTML + '</ul>'
HTML = HTML + '</div>'
@@ -73,7 +73,12 @@ function newConfigEditor() {
thisObject.payload.uiObject.uiObjectTitle.exitEditMode()
let textArea = document.getElementById('textArea')
textArea.value = JSON.stringify(JSON.parse(thisObject.payload.node.config), undefined, 4)
try {
textArea.value = JSON.stringify(JSON.parse(thisObject.payload.node.config), undefined, 4)
} catch(err) {
textArea.value = thisObject.payload.node.config
}
textArea.style = 'resize: none;' +
' border: none;' +
' outline: none;' +
@@ -288,7 +288,7 @@ function newSuperalgosTutorialSpace() {
config.controlDocs.page !== undefined &&
config.controlDocs.page.project !== undefined &&
config.controlDocs.page.category !== undefined &&
config.controlDocs.page.type !== undefined &&
config.controlDocs.page.type !== undefined &&
config.controlDocs.page.project !== '' &&
config.controlDocs.page.category !== '' &&
config.controlDocs.page.type !== ''
@@ -680,7 +680,7 @@ function newSuperalgosTutorialSpace() {
} catch (err) {
return
}
let position = nodeConfig.position
let position = nodeConfig.position
if (UI.projects.superalgos.spaces.docsSpace.isVisible === true) {
position = 'Left'
}
@@ -1135,12 +1135,12 @@ function newSuperalgosTutorialSpace() {
function buildHTML() {
let nodeConfig = JSON.parse(currentNode.config)
if (nodeConfig.docs === undefined) {
if (nodeConfig.docs === undefined) {
/* The current node is not referencing any page at the Docs */
return
return
}
let schemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(nodeConfig.docs.type)
let schemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(nodeConfig.docs.type)
newConfig = currentNode.config
newDocument = JSON.stringify(schemaDocument) + ' - ' + UI.projects.superalgos.spaces.docsSpace.language
@@ -1151,11 +1151,50 @@ function newSuperalgosTutorialSpace() {
let title
syncConfigIconWithDocumentIcon()
transformDocsInfoIntoTutorialInfo()
createTheHTML()
UI.projects.superalgos.spaces.docsSpace.navigateTo(nodeConfig.docs.project, 'Tutorial', nodeConfig.docs.type)
function syncConfigIconWithDocumentIcon() {
/*
We update here the image of the document with whatever we find at the config, since
we need to mechanism to keep this syncronized.
*/
if (nodeConfig.icon === undefined) {
nodeConfig.icon = {
name: nodeConfig.image, // This property comes from the migration
project: 'Superalgos'
}
nodeConfig.image = undefined // Removing this legacy property.
currentNode.config = JSON.stringify(nodeConfig)
}
if (nodeConfig.icon.name !== undefined) {
if (schemaDocument.definition.icon !== undefined) {
if (nodeConfig.icon.name + '-' + nodeConfig.icon.project !== schemaDocument.definition.icon.name + '-' + schemaDocument.definition.icon.project) {
schemaDocument.definition.icon = {
name: nodeConfig.icon.name,
project: nodeConfig.icon.project
}
schemaDocument.updated = true
}
} else {
schemaDocument.definition.icon = {
name: nodeConfig.icon.name,
project: nodeConfig.icon.project
}
schemaDocument.updated = true
}
} else {
if (schemaDocument.definition.icon !== undefined) {
schemaDocument.definition.icon = undefined
schemaDocument.updated = true
}
}
}
function transformDocsInfoIntoTutorialInfo() {
if (schemaDocument === undefined) {
title = "Configuration Error"
@@ -1201,7 +1240,7 @@ function newSuperalgosTutorialSpace() {
if (fullscreenMode === false) {
if (schemaDocument.definition.icon === undefined || schemaDocument.definition.icon.name === '') {
/* When there is no image, we will render a Summary instead of a Table */
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(schemaDocument.definition)
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(schemaDocument.definition)
text = UI.projects.superalgos.utilities.docs.addKeyboard(text)
text = UI.projects.superalgos.utilities.docs.addCodeToCamelCase(text)
text = UI.projects.superalgos.utilities.docs.addCodeToWhiteList(text)
@@ -1219,7 +1258,7 @@ function newSuperalgosTutorialSpace() {
html = html + '</td>'
html = html + '<td>'
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(schemaDocument.definition)
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(schemaDocument.definition)
text = UI.projects.superalgos.utilities.docs.addKeyboard(text)
text = UI.projects.superalgos.utilities.docs.addCodeToCamelCase(text)
text = UI.projects.superalgos.utilities.docs.addCodeToWhiteList(text)
@@ -1237,7 +1276,7 @@ function newSuperalgosTutorialSpace() {
let paragraph = schemaDocument.paragraphs[i]
switch (paragraph.style) {
case 'Summary': {
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(paragraph)
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(paragraph)
text = UI.projects.superalgos.utilities.docs.addKeyboard(text)
text = UI.projects.superalgos.utilities.docs.addCodeToCamelCase(text)
text = UI.projects.superalgos.utilities.docs.addCodeToWhiteList(text)
@@ -1246,18 +1285,18 @@ function newSuperalgosTutorialSpace() {
break
}
case 'Title': {
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(paragraph)
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(paragraph)
html = html + '<h2 class="tutorial-font-medium">' + text + '</h2>'
break
}
case 'Gif': {
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(paragraph)
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(paragraph)
html = html + '<div id="tutorialGifDiv" width="200" width="290"/>'
newGifName = text
break
}
case 'Text': {
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(paragraph)
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(paragraph)
text = UI.projects.superalgos.utilities.docs.addKeyboard(text)
text = UI.projects.superalgos.utilities.docs.addCodeToCamelCase(text)
text = UI.projects.superalgos.utilities.docs.addCodeToWhiteList(text)
@@ -1266,17 +1305,17 @@ function newSuperalgosTutorialSpace() {
break
}
case 'Json': {
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(paragraph)
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(paragraph)
html = html + '<pre><code class="language-json">' + text + '</code></pre>'
break
}
case 'Javascript': {
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(paragraph)
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(paragraph)
html = html + '<pre><code class="language-javascript">' + text + '</code></pre>'
break
}
case 'List': {
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(paragraph)
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(paragraph)
text = UI.projects.superalgos.utilities.docs.addKeyboard(text)
text = UI.projects.superalgos.utilities.docs.addCodeToCamelCase(text)
text = UI.projects.superalgos.utilities.docs.addCodeToWhiteList(text)
@@ -1286,7 +1325,7 @@ function newSuperalgosTutorialSpace() {
break
}
case 'Callout': {
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(paragraph)
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(paragraph)
text = UI.projects.superalgos.utilities.docs.addKeyboard(text)
text = UI.projects.superalgos.utilities.docs.addCodeToCamelCase(text)
text = UI.projects.superalgos.utilities.docs.addCodeToWhiteList(text)
@@ -1295,13 +1334,13 @@ function newSuperalgosTutorialSpace() {
break
}
case 'Link': {
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(paragraph)
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(paragraph)
let splittedText = text.split('->')
html = html + '<a class="tutorial-font-small tutorial-external-link" href="' + splittedText[1] + '" target="_blank">' + splittedText[0] + '</a>'
break
}
case 'Note': {
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(paragraph)
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(paragraph)
text = UI.projects.superalgos.utilities.docs.addKeyboard(text)
text = UI.projects.superalgos.utilities.docs.addCodeToCamelCase(text)
text = UI.projects.superalgos.utilities.docs.addCodeToWhiteList(text)
@@ -1310,7 +1349,7 @@ function newSuperalgosTutorialSpace() {
break
}
case 'Success': {
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(paragraph)
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(paragraph)
text = UI.projects.superalgos.utilities.docs.addKeyboard(text)
text = UI.projects.superalgos.utilities.docs.addCodeToCamelCase(text)
text = UI.projects.superalgos.utilities.docs.addCodeToWhiteList(text)
@@ -1319,7 +1358,7 @@ function newSuperalgosTutorialSpace() {
break
}
case 'Important': {
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(paragraph)
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(paragraph)
text = UI.projects.superalgos.utilities.docs.addKeyboard(text)
text = UI.projects.superalgos.utilities.docs.addCodeToCamelCase(text)
text = UI.projects.superalgos.utilities.docs.addCodeToWhiteList(text)
@@ -1328,7 +1367,7 @@ function newSuperalgosTutorialSpace() {
break
}
case 'Warning': {
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(paragraph)
let text = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(paragraph)
text = UI.projects.superalgos.utilities.docs.addKeyboard(text)
text = UI.projects.superalgos.utilities.docs.addCodeToCamelCase(text)
text = UI.projects.superalgos.utilities.docs.addCodeToWhiteList(text)
+17 -14
View File
@@ -601,13 +601,18 @@ function newSuperalgosUtilitiesDocs() {
const MAX_NUMBER_OF_WORDS = 10
text = text.trim()
let cleanText = text.replace(/'/g, ' AMPERSAND ') // scaping ampersands, separating them from other words
.replaceAll('<', ' < ')
.replaceAll('>', ' > ')
.replaceAll(':', ' : ')
.replaceAll(',', ' , ')
.replaceAll('.', ' . ')
.replaceAll('!', ' ! ')
let words = cleanText.split(' ')
.replaceAll(':', ' :')
.replaceAll(',', ' ,')
.replaceAll('.', ' .')
.replaceAll('!', ' !')
let allWords = cleanText.split(' ')
let words = []
for (let i = 0; i < allWords.length; i++) {
let word = allWords[i]
if (word !== "") {
words.push(word)
}
}
let taggedText = ''
for (let i = 0; i < words.length; i++) {
@@ -617,7 +622,7 @@ function newSuperalgosUtilitiesDocs() {
for (let j = 0; j < MAX_NUMBER_OF_WORDS; j++) {
let word = words[i + j]
if (word === "" ) { word = " "}
if (word === "") { word = " " }
if (word !== undefined) {
if (phrase === '') {
phrase = word
@@ -666,12 +671,10 @@ function newSuperalgosUtilitiesDocs() {
}
}
taggedText = taggedText.replaceAll(' AMPERSAND ', '\'')
.replaceAll(' < ', '<')
.replaceAll(' > ', '>')
.replaceAll(' : ', ':')
.replaceAll(' . ', '.')
.replaceAll(' , ', ',')
.replaceAll(' ! ', '!')
.replaceAll(' :', ':')
.replaceAll(' .', '.')
.replaceAll(' ,', ',')
.replaceAll(' !', '!')
.replaceAll(' ', ' ')
return taggedText
}
@@ -20,6 +20,10 @@ function newSuperalgosUtilitiesLanguages() {
languageLabel = 'Russian'
break
}
case 'IT': {
languageLabel = 'Italian'
break
}
}
return languageLabel
}