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-13 13:58:17 +01:00
commit 824f929906
12 files changed
+228 -28

No files matched your search

+2 -2
View File
@@ -56,8 +56,8 @@
onresize="onResize()">
<div id="contributors" class="credits">
<p id="credits-page-status-paragraph" class="credits-yellow">The UI is loading...</p>
<p><span class="credits-red">Superalgos is free, open-source, and is
constantly improving thanks to the involvement of contributors!</span></p>
<p>Superalgos is <span class="credits-red">free</span>, <span class="credits-red">open-source</span>, and is
<span class="credits-red">constantly improving</span> thanks to the involvement of contributors:</p>
<p>Luis Fernando Molina, Julian Molina, Andreja Cobeljic, Matías Benitez, Ira Miller, Eduardo Remis,
Jeff Braun, rico4dev, 9808us, Barry Low, Nikola Bjelogrlic, Hirajin Koizuko, Francisco J. Santillán, Norman,
Viktoria B., Guillermo V., Daniel J.,
+57 -8
View File
@@ -533,6 +533,8 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
const commitMessage = unescape(requestParameters[3])
const username = unescape(requestParameters[4])
const token = unescape(requestParameters[5])
const currentBranch = unescape(requestParameters[6])
const contributionsBranch = unescape(requestParameters[7])
contribute()
@@ -553,7 +555,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
await git.add('./*')
await git.commit(commitMessage)
await git.push('origin', 'in-app-documentation')
await git.push('origin', branch)
}
async function doGithub() {
@@ -567,8 +569,8 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
const repo = 'Superalgos'
const owner = 'Superalgos'
const head = username + ':in-app-documentation'
const base = 'in-app-documentation'
const head = username + ':' + contributionsBranch
const base = currentBranch
const title = 'Contribution: ' + commitMessage
try {
@@ -604,10 +606,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
}
case 'Update': {
try {
const message = unescape(requestParameters[3])
const username = unescape(requestParameters[4])
const token = unescape(requestParameters[5])
const currentBranch = unescape(requestParameters[3])
update()
async function update() {
@@ -629,7 +628,57 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
}
const git = simpleGit(options)
return await git.pull('upstream', 'in-app-documentation')
return await git.pull('upstream', currentBranch)
}
} catch (err) {
console.log('[ERROR] httpInterface -> App -> Update -> Method call produced an error.')
console.log('[ERROR] httpInterface -> App -> Update -> err.stack = ' + err.stack)
console.log('[ERROR] httpInterface -> App -> Update -> commitMessage = ' + commitMessage)
console.log('[ERROR] httpInterface -> App -> Update -> username = ' + username)
console.log('[ERROR] httpInterface -> App -> Update -> token = ' + token)
let error = {
result: 'Fail Because',
message: err.message,
stack: err.stack
}
respondWithContent(JSON.stringify(error), httpResponse)
}
break
}
case 'Checkout': {
try {
const currentBranch = unescape(requestParameters[3])
checkout()
async function checkout() {
let result = await doGit()
if (result === true) {
respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse)
} else {
respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), httpResponse)
}
}
async function doGit() {
const simpleGit = require('simple-git');
const options = {
baseDir: process.cwd(),
binary: 'git',
maxConcurrentProcesses: 6,
}
const git = simpleGit(options)
try {
await git.checkout(currentBranch)
} catch (err) {
console.log('[ERROR] Error changing current branch to ' + currentBranch)
console.log(err.stack)
return false
}
return true
}
} catch (err) {
+5
View File
@@ -208,6 +208,11 @@
"propertyName": "languages",
"functionName": "newSuperalgosUtilitiesLanguages"
},
{
"name": "Git Branches",
"propertyName": "gitBranches",
"functionName": "newSuperalgosUtilitiesGitBranches"
},
{
"name": "Docs",
"propertyName": "docs",
@@ -0,0 +1,14 @@
{
"topic": "Branches Management Messages",
"pageNumber": "1",
"type": "Switching Branches - Changing Current Branch",
"definition": {
"text": "Write here a summary for this topic 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."
}
]
}
@@ -0,0 +1,14 @@
{
"topic": "Branches Management Messages",
"pageNumber": "2",
"type": "Switching Branches - Current Branch Changed",
"definition": {
"text": "Write here a summary for this topic 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."
}
]
}
@@ -0,0 +1,14 @@
{
"topic": "Branches Management Messages",
"pageNumber": "3",
"type": "Switching Branches - Contributions Branch Changed",
"definition": {
"text": "Write here a summary for this topic 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."
}
]
}
@@ -0,0 +1,14 @@
{
"topic": "Branches Management Messages",
"pageNumber": "4",
"type": "Switching Branches - Current Branch Not Changed",
"definition": {
"text": "Write here a summary for this topic 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."
}
]
}
+2
View File
@@ -2,6 +2,8 @@ function newSuperalgosGlobalsDocs() {
thisObject = {
NEW_PARAGRAPH_TEXT: "Left click and Edit to enter edit mode and change this text. ENTER to write new paragraphs. ESC to exit edit mode.",
DEFAULT_LANGUAGE: 'EN',
DEFAULT_ACTIVE_BRANCH: 'master',
DEFAULT_CONTRIBUTIONS_BRANCH: 'develop',
DOCS_SPACE_WIDTH: 900
}
return thisObject
@@ -62,7 +62,16 @@ function newSuperalgosDocsCommmandInterface() {
return
}
httpRequest(undefined, 'App/Contribute/' + message + '/' + config.username + '/' + config.token, onResponse)
httpRequest(
undefined,
'App/Contribute/' +
message + '/' +
config.username + '/' +
config.token + '/' +
UI.projects.superalgos.spaces.docsSpace.currentBranch + '/' +
UI.projects.superalgos.spaces.docsSpace.contributionBranch
, onResponse)
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Message - Creating Pull Request')
return
@@ -112,7 +121,7 @@ function newSuperalgosDocsCommmandInterface() {
return
}
httpRequest(undefined, 'App/Update/' + message + '/' + config.username + '/' + config.token, onResponse)
httpRequest(undefined, 'App/Update/' + UI.projects.superalgos.spaces.docsSpace.currentBranch, onResponse)
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Message - Updating Your Local App')
return
@@ -12,6 +12,8 @@ function newSuperalgosDocSpace() {
commandInterface: undefined,
contextMenu: undefined,
language: undefined,
currentBranch: undefined,
contributionsBranch: undefined,
menuLabelsMap: undefined,
currentDocumentBeingRendered: undefined,
previousDocumentBeingRendered: undefined,
@@ -20,6 +22,8 @@ function newSuperalgosDocSpace() {
textArea: undefined,
setUpWorkspaceSchemas: setUpWorkspaceSchemas,
changeLanguage: changeLanguage,
changeActiveBranch: changeActiveBranch,
changeContributionsBranch: changeContributionsBranch,
enterEditMode: enterEditMode,
exitEditMode: exitEditMode,
openSpaceAreaAndNavigateTo: openSpaceAreaAndNavigateTo,
@@ -57,6 +61,8 @@ function newSuperalgosDocSpace() {
setupSidePanelTab()
setUpMenuItemsMap()
setupUserLanguage()
setupActiveBranch()
setupContributionsBranch()
thisObject.searchEngine = newSuperalgosDocsSearchEngine()
thisObject.mainSearchPage = newSuperalgosDocsMainSearchPage()
@@ -76,6 +82,30 @@ function newSuperalgosDocSpace() {
isInitialized = true
function setupActiveBranch() {
/*
Getting the used preferred languague
*/
if (window.localStorage.getItem('Current Branch') !== null && window.localStorage.getItem('Current Branch') !== undefined && window.localStorage.getItem('Current Branch') !== 'undefined') {
UI.projects.superalgos.spaces.docsSpace.currentBranch = window.localStorage.getItem('Current Branch')
} else {
window.localStorage.setItem('Current Branch', UI.projects.superalgos.globals.docs.DEFAULT_ACTIVE_BRANCH)
UI.projects.superalgos.spaces.docsSpace.currentBranch = UI.projects.superalgos.globals.docs.DEFAULT_ACTIVE_BRANCH
}
}
function setupContributionsBranch() {
/*
Getting the used preferred languague
*/
if (window.localStorage.getItem('Contributions Branch') !== null && window.localStorage.getItem('Contributions Branch') !== undefined && window.localStorage.getItem('Contributions Branch') !== 'undefined') {
UI.projects.superalgos.spaces.docsSpace.contributionsBranch = window.localStorage.getItem('Contributions Branch')
} else {
window.localStorage.setItem('Contributions Branch', UI.projects.superalgos.globals.docs.DEFAULT_CONTRIBUTIONS_BRANCH)
UI.projects.superalgos.spaces.docsSpace.contributionsBranch = UI.projects.superalgos.globals.docs.DEFAULT_CONTRIBUTIONS_BRANCH
}
}
function setupUserLanguage() {
/*
Getting the used preferred languague
@@ -86,7 +116,6 @@ function newSuperalgosDocSpace() {
window.localStorage.setItem('Docs Language', UI.projects.superalgos.globals.docs.DEFAULT_LANGUAGE)
UI.projects.superalgos.spaces.docsSpace.language = UI.projects.superalgos.globals.docs.DEFAULT_LANGUAGE
}
}
function setupSidePanelTab() {
@@ -155,6 +184,29 @@ function newSuperalgosDocSpace() {
initialize()
}
function changeActiveBranch(branch) {
window.localStorage.setItem('Current Branch', UI.projects.superalgos.spaces.docsSpace.currentBranch)
httpRequest(undefined, 'App/Checkout/' + branch, onResponse)
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Switching Branches - Changing Current Branch')
function onResponse(err, data) {
/* Lets check the result of the call through the http interface */
data = JSON.parse(data)
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result && data.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
UI.projects.superalgos.spaces.docsSpace.currentBranch = branch
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Switching Branches - Current Branch Changed')
} else {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Switching Branches - Current Branch Not Changed')
}
}
}
function changeContributionsBranch(branch) {
UI.projects.superalgos.spaces.docsSpace.contributionsBranch = branch
window.localStorage.setItem('Contributions Branch', UI.projects.superalgos.spaces.docsSpace.contributionsBranch)
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Switching Branches - Contributions Branch Changed')
}
function changeLanguage(pLanguage) {
UI.projects.superalgos.spaces.docsSpace.language = pLanguage
window.localStorage.setItem('Docs Language', UI.projects.superalgos.spaces.docsSpace.language)
@@ -1,6 +1,6 @@
function newSuperalgosDocsFooter() {
let thisObject = {
addFooter: addFooter,
addFooter: addFooter,
initialize: initialize,
finalize: finalize
}
@@ -16,7 +16,6 @@ function newSuperalgosDocsFooter() {
}
function addFooter() {
let languageLabel = UI.projects.superalgos.utilities.languages.getLaguageLabel(UI.projects.superalgos.spaces.docsSpace.language)
let HTML = ''
@@ -33,11 +32,11 @@ function newSuperalgosDocsFooter() {
HTML = HTML + '<div class="docs-footer-cell style="white-space: nowrap; overflow-x: auto;" >' // white-space: nowrap; overflow-x: auto; prevents line breaks when combined with display: inline-block;" in the child elements
HTML = HTML + '<span style="float: right; display: inline-block;" onClick="UI.projects.superalgos.spaces.docsSpace.scrollToElement(\'docs-space-div\')"><button>TO TOP</button></span>'
if (UI.projects.superalgos.spaces.docsSpace.previousDocumentBeingRendered !== undefined ) {
HTML = HTML + '<span style="float: right; display: inline-block;" onClick="UI.projects.superalgos.spaces.docsSpace.navigateTo(\'' + UI.projects.superalgos.spaces.docsSpace.previousDocumentBeingRendered.project + '\', \'' + UI.projects.superalgos.spaces.docsSpace.previousDocumentBeingRendered.category + '\', \'' + UI.projects.superalgos.spaces.docsSpace.previousDocumentBeingRendered.type + '\')"><button>BACK</button></span>'
if (UI.projects.superalgos.spaces.docsSpace.previousDocumentBeingRendered !== undefined) {
HTML = HTML + '<span style="float: right; display: inline-block;" onClick="UI.projects.superalgos.spaces.docsSpace.navigateTo(\'' + UI.projects.superalgos.spaces.docsSpace.previousDocumentBeingRendered.project + '\', \'' + UI.projects.superalgos.spaces.docsSpace.previousDocumentBeingRendered.category + '\', \'' + UI.projects.superalgos.spaces.docsSpace.previousDocumentBeingRendered.type + '\')"><button>BACK</button></span>'
}
if (UI.projects.superalgos.spaces.docsSpace.currentBookBeingRendered !== undefined ) {
HTML = HTML + '<span style="float: right; display: inline-block;" onClick="UI.projects.superalgos.spaces.docsSpace.navigateTo(\'' + UI.projects.superalgos.spaces.docsSpace.currentBookBeingRendered.project + '\', \'' + UI.projects.superalgos.spaces.docsSpace.currentBookBeingRendered.category + '\', \'' + UI.projects.superalgos.spaces.docsSpace.currentBookBeingRendered.type + '\')"><button>TO BOOK</button></span>'
if (UI.projects.superalgos.spaces.docsSpace.currentBookBeingRendered !== undefined) {
HTML = HTML + '<span style="float: right; display: inline-block;" onClick="UI.projects.superalgos.spaces.docsSpace.navigateTo(\'' + UI.projects.superalgos.spaces.docsSpace.currentBookBeingRendered.project + '\', \'' + UI.projects.superalgos.spaces.docsSpace.currentBookBeingRendered.category + '\', \'' + UI.projects.superalgos.spaces.docsSpace.currentBookBeingRendered.type + '\')"><button>TO BOOK</button></span>'
}
HTML = HTML + '</div>'
@@ -54,7 +53,7 @@ function newSuperalgosDocsFooter() {
HTML = HTML + '<div class="docs-footer-cell">'
HTML = HTML + '<h4>Choose Your Language</h4>'
HTML = HTML + 'The current preferred language is <strong>' + languageLabel + '</strong>. Switch to:'
HTML = HTML + 'The current preferred language is <strong>' + UI.projects.superalgos.utilities.languages.getLaguageLabel(UI.projects.superalgos.spaces.docsSpace.language) + '</strong>. Switch to:'
HTML = HTML + '<ul>'
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>'
@@ -91,24 +90,26 @@ function newSuperalgosDocsFooter() {
HTML = HTML + '<div class="docs-footer-row">'
HTML = HTML + '<div class="docs-footer-cell">'
HTML = HTML + '<h4>About Your Deployment</h4>'
HTML = HTML + 'Superalgos may run from different branches in the repository. The <code class="docs-footer-code">master</code> branch features the stable version, and the <code class="docs-footer-code">develop</code> branch the version in development.'
HTML = HTML + 'Superalgos may run from different branches in the repository. The <code class="docs-footer-code">Master</code> branch features the stable version, and the <code class="docs-footer-code">Develop</code> branch the version in development anyone can test. <code class="docs-footer-code">Bug Fixes</code> is where we fix bugs.'
HTML = HTML + '</div>'
HTML = HTML + '<div class="docs-footer-cell">'
HTML = HTML + '<h4>Choose the Active Branch</h4>'
HTML = HTML + 'You are currently running on the <code class="docs-footer-code">' + languageLabel + '</code> branch. Switch to:'
HTML = HTML + '<h4>Choose the Current Branch</h4>'
HTML = HTML + 'You are currently running on the <code class="docs-footer-code">' + UI.projects.superalgos.utilities.gitBranches.getBranchLabel(UI.projects.superalgos.spaces.docsSpace.currentBranch) + '</code> branch. Switch to:'
HTML = HTML + '<ul>'
HTML = HTML + '<li><a href="#" onClick="UI.projects.superalgos.spaces.docsSpace.changeLanguage(\'EN\')"><code class="docs-footer-code">English</code></a></li>'
HTML = HTML + '<li><a href="#" onClick="UI.projects.superalgos.spaces.docsSpace.changeLanguage(\'ES\')"><code class="docs-footer-code">Spanish</a></code></li>'
HTML = HTML + '<li><a href="#" onClick="UI.projects.superalgos.spaces.docsSpace.changeActiveBranch(\'master\')">Master</a></li>'
HTML = HTML + '<li><a href="#" onClick="UI.projects.superalgos.spaces.docsSpace.changeActiveBranch(\'develop\')">Develop</a></li>'
HTML = HTML + '<li><a href="#" onClick="UI.projects.superalgos.spaces.docsSpace.changeActiveBranch(\'bug-fixes\')">Bug Fixes</a></li>'
HTML = HTML + '</ul>'
HTML = HTML + '</div>'
HTML = HTML + '<div class="docs-footer-cell">'
HTML = HTML + '<h4>Contributions Branch</h4>'
HTML = HTML + 'You are currently contributing to the <code class="docs-footer-code">' + languageLabel + '</code> branch. Switch to:'
HTML = HTML + 'You are currently contributing to the <code class="docs-footer-code">' + UI.projects.superalgos.utilities.gitBranches.getBranchLabel(UI.projects.superalgos.spaces.docsSpace.contributionsBranch) + '</code> branch. Switch to:'
HTML = HTML + '<ul>'
HTML = HTML + '<li><a href="#" onClick="UI.projects.superalgos.spaces.docsSpace.changeLanguage(\'EN\')"><code class="docs-footer-code">English</code></a></li>'
HTML = HTML + '<li><a href="#" onClick="UI.projects.superalgos.spaces.docsSpace.changeLanguage(\'ES\')"><code class="docs-footer-code">Spanish</a></code></li>'
HTML = HTML + '<li><a href="#" onClick="UI.projects.superalgos.spaces.docsSpace.changeContributionsBranch(\'master\')">Master</code></li>'
HTML = HTML + '<li><a href="#" onClick="UI.projects.superalgos.spaces.docsSpace.changeContributionsBranch(\'develop\')">Develop</a></li>'
HTML = HTML + '<li><a href="#" onClick="UI.projects.superalgos.spaces.docsSpace.changeContributionsBranch(\'bug-fixes\')">Bug Fixes</a></li>'
HTML = HTML + '</ul>'
HTML = HTML + '</ul>'
HTML = HTML + '</div>'
@@ -0,0 +1,26 @@
function newSuperalgosUtilitiesGitBranches() {
thisObject = {
getBranchLabel: getBranchLabel
}
return thisObject
function getBranchLabel(branch) {
let branchLabel
switch (branch) {
case 'master': {
branchLabel = 'Master'
break
}
case 'develop': {
branchLabel = 'Develop'
break
}
case 'bug-fixes': {
branchLabel = 'Bug Fixes'
break
}
}
return branchLabel
}
}