"[ { \"project\" : \"tofgui\" ,\n \"version\" : \"1.0.0\" ,\n \"unit\" : \"struct\\nsystem_target\" ,\n \"info\" : \"This project provides a function `tofgui`, that starts a Graphical User Interfact in the browser that supports the management and editing of [TofJs](htttp://tofjs.org) projects.\\n\\n# Usage\\n\\nStart a [NodeJs](http://nodejs.org) REPL, load the required projects (see below) and then call `tofgui(port)`, e.g.\\n\\n > tofgui(55555)\\n Server started listening on port `55555` ...\\n `tofgui` is running now. Point your Firefox browser to `localhost:55555/?home` to get started.\\n undefined\\n > ...\\n\\nBy ending the REPL session (e.g. with `Ctrl+C`, `Ctrl+C`) you also terminate the GUI.\\n\\nAlternatively, you could also use the module\\n\\n > require ('./tofgui.tofm.js') . tofgui (55555);\\n\\n# Requirements\\n\\nThere are a couple of other projects that are required to run `tofgui`, namely:\\n`type`, `value`, `html`, `augment`, `global`, `system`, `utils`, `flatcode`, `session`, `unit`, `HttpTools`, `tofgui`.\\n\" } ,\n { \"unit\" : \"value\" ,\n \"name\" : \"tofgui\" ,\n \"type\" : \"$act (HttpServer.$HttpPortNumber)\" ,\n \"value\" : \"function (port) {\\n var httpServer = HttpServer.fileAndDocProducerServer (port) (TofGui.docProducer);\\n httpServer.start();\\n console.log ( '`tofgui` is running now. Point your Firefox browser to `localhost:%d/?home` to get started.', port );\\n}\" ,\n \"info\" : \"`tofgui(port)` creates a HTTP server that immediately starts to listen to the `$HttpPortNumber` value `port`.\\n\\nFor example,\\n\\nStart a [NodeJs](http://nodejs.org) REPL, load the required projects (see below) and then call `tofgui(port)`, e.g.\\n\\n > tofgui(55555)\\n Server started listening on port `55555` ...\\n `tofgui` is running now. Point your Firefox browser to `localhost:55555/?home` to get started.\\n undefined\\n > ...\\n\\nBy ending the REPL session (e.g. with `Ctrl+C`, `Ctrl+C`) you also terminate the GUI.\" ,\n \"comment\" : \"Recall, that the two lines\\n\\n var httpServer = HttpServer.fileAndDocProducerServer (port) (TofGui.docProducer);\\n httpServer.start();\\n\\nfirst create an instance of the `HttpServer` class (see the `HttpTools` project) and then starts it, so that the browser can point to `http://localhost:port` to use this GUI.\\n\\nRecall (see the info in the `HttpTools` project), that the `httpServer` created with `HttpServer.fileAndDocProducerServer(port)(dp)` works as a *file server* as well as a *document producer server*, depending on the URL requested by the browser:\\n\\n* If the URL query part (in fact, the combined query and data part from a GET as well as a POST request) of the URL is empty, the file from the URL path is returned.\\n For example,\\n\\n http://localhost:port/one/two/three.html\\n\\n displays `/one/two/three.html` in the browser window.\\n\\n* If the URL query part is not empty, say if it is `?key1=value1&key2=value2&key3=value3`, the query part is converted into a record `{key1: value1, key2: value2, key3: value3}` and the HTML document produced by `dp({key1: value1, key2: value2, key3: value3})` is shown in the browser window.\\n\\nThe second parameter `dp` is a **document producer**, i.e. a function that takes a record `r` and returns an HTML document `dp(r)`.\\nIn our case of `tofgui`, the document producer is the [`TofGui.docProducer`](#TofGui-docProducer).\" } ,\n { \"unit\" : \"struct\" ,\n \"name\" : \"TofGui\" } ,\n { \"unit\" : \"value\" ,\n \"name\" : \"TofGui.docProducer\" ,\n \"type\" : \"$prod ([$Rec, $HtmlDoc])\" ,\n \"value\" : \"function (rec) {\\n if ('home' in rec) {\\n return homePage();\\n } else {\\n if ('do' in rec) {\\n switch (rec.do) {\\n case 'list':\\n return listProjects ();\\n case 'edit':\\n if ('project' in rec) { return editProject (rec.project); }\\n else { return errorPage (\\\"Cannot edit: no `project` was submitted!\\\"); }\\n case 'compile':\\n if ('project' in rec) {\\n if ('flatcode' in rec) {\\n return compileProject (rec.project) (rec.flatcode);\\n } else {\\n return errorPage (\\\"Cannot compile `\\\" + rec.project + \\\"`, because no `flatcode` was submitted.\\\");\\n }\\n } else {\\n return errorPage (\\\"Cannot compile: no `project` was submitted!\\\");\\n }\\n case 'open':\\n return openProject (rec);\\n case 'delete':\\n if ('project' in rec) {\\n if ('confirmed' in rec) { return deleteProject ([rec.project, rec.confirmed]); }\\n else { return deleteProject (rec.project); }\\n } else {\\n return errorPage (\\\"do=delete
is called, but there is no project
specified.\\\");\\n }\\n case 'create':\\n return createProject (rec);\\n case 'move':\\n return moveProject (rec);\\n default:\\n return errorPage (\\\"Unknown `do` value `\\\" + rec.do + \\\"`!\\\");\\n }\\n } else {\\n return errorPage (\\\"Either a `home` or `do` value must be specified!\\\");\\n }\\n }\\n}\" ,\n \"info\" : \"`TofGui.docProducer(rec)` returns a HTML document, depending on the parameters provided in the record `rec`.\\nIn fact, this function works more like a router for a couple of other functions, namely:\\n\\n Parameter HTML document is created by\\n ------------- ---------------------------------------------------------------------------------------\\n `home=*` `homePage()`\\n `do=edit` `editProject(project)` or `editProject([project, log])`\\n `do=compile` `compileProject(project)`\\n `do=list` `listProjects ()`\\n `do=open` `openProject(rec)` where `rec` is the requested record\\n `do=delete` `deleteProject(project)` or `deleteProject([project,confirmed])`\\n `do=create` `createProject (rec)` where `rec` is the requested record\\n `do=move` `moveProject(rec)` where `rec` is the requested record\\n\\nNote, that it is possible to move a project. But you cannot delete a project, at least not with this GUI.\\n\\nIf `rec` does not neither have a `home` or `do` property, or if the `do` property does not have one of the defined values (`'edit'`, `'compile'`, etc.), an error is thrown.\" } ,\n { \"unit\" : \"doc\" ,\n \"name\" : \"TofGui\" ,\n \"header\" : \"The Single Page Generators\" } ,\n { \"unit\" : \"value\" ,\n \"name\" : \"TofGui.homePage\" ,\n \"type\" : \"$prod0 ($HtmlDoc)\" ,\n \"value\" : \"function () {\\n var html\\n = '
home of the TofJs GUI (= this page)
\\\\n'\\n + 'list all projects
\\\\n'\\n + 'open an existing project
\\\\n'\\n + 'create a new project
\\\\n'\\n + 'Server root: ' + process.cwd() + '
' + dir + '
Project | Project files | \\\\n';\\n for (var i = 0; i < branchL.length; i++) {\\n var pi = branchL[i];\\n body += '|
---|---|---|
' + pi + ' | \\\\n'\\n + '' + projectFileList(pi) + ' | \\\\n'\\n + ''\\n + ' move or copy '\\n + ' delete '\\n + ' | \\\\n'\\n + '
\\\" + dir + \\\"
.Something went wrong in TofGui.openProject(' + rec + ')
' + e + '' );\\n }\\n\\n var html = '\\\\n';\\n html += '
'\\n + clickablePathList ({\\\"do\\\":\\\"open\\\", \\\"projectDir\\\":projectDir}, 'projectDir')\\n + '
\\\\n';\\n html += '' + projectDir + '
' + pi + '
... ' + pi + ext + '
is deleted
' + pi + '
is deleted and ' + n + ' files were removed.
Something went wrong in deleting project \\\" + pi + \\\"
\\\\n\\\"\\n + \\\"
\\\" + e + \\\"\\\" );\\n }\\n } else {\\n html += '
' + pi + '
project?