diff --git a/core/core.js b/core/core.js index 131fa963..4c0d3bd7 100644 --- a/core/core.js +++ b/core/core.js @@ -312,7 +312,10 @@ function setGlobalSettings(settings) { } try { - gGlobalSettings = JSON.parse(readFileUtf8(kGlobalSettingsFile)); + var data = readFileUtf8(kGlobalSettingsFile); + if (data) { + gGlobalSettings = JSON.parse(data); + } } catch (error) { print("Error loading settings from " + kGlobalSettingsFile + ": " + error); } diff --git a/data/wiki/development b/data/wiki/development deleted file mode 100644 index 9836901f..00000000 --- a/data/wiki/development +++ /dev/null @@ -1,62 +0,0 @@ -= SandboxOS App Development Guide = -This is a brief introduction on developing SandboxOS apps targeted at people who are already familiar with web development. - -== Packages == -A package is a directory of files. '''package.json''' is the only file with special meaning. - -Here is an example package.json: -{{{ -#!json -{ - "name": "chat", - "start": "backend.js", - "imports": ["auth", "httpd", "filesystem"], - "href": "/chat", - "description": "A basic multi-user chat example." -} -}}} - - * '''name''': identifies the package. If it is not unique, any existing installed package of the same name will be replaced when installing the package. - * '''start''': specifies the JavaScript file which is the entry point of the task. When a new process is started for this package, this script is executed within it. - * '''imports''': list of package/task names which this package wants to be able to access. - * '''href''': link to the task's entry page used by [/tasks /tasks]. - * '''description''': human-readable description of the package, displayed by [/tasks /tasks]. - -== Promises == - -JavaScript promises are used heavily. Invoking any method on another task will return a Promise object. Execution will return immediately but go asynchronous. That usually looks like this: -{{{ -#!javascript -imports.email.sendMessage(message).then(function(result) { - // When sendMessage completes, result is the return value. -}).catch(function(error) { - // If sendMessage fails (or calling it somehow fails), error is the reason. -}); -// sendMessage returns immediately and execution continues on. -}}} - -This is a completely inadequate explanation of the nuances involved, but it's a starting point. Promises can be created and chained and combined in interesting ways. - -== Inter-Task Communication == -Tasks have access to the exported functions on any task declared in their package imports. - -In addition, functions passed between tasks can be called by the receiving task or passed along further. - -Here is an untested, made-up example with two hypothetical tasks, '''math''' and '''test''': - -'''math.js''': -{{{ -#!javascript -exports = { - sum: function(a, b) { return a + b; }, - multiply: function(a, b) { return a * b; }, -}; -}}} - -'''test.js''': -{{{ -#!javascript -imports.math.sum(4, 5).then(function(result) { - // result === 9 -}); -}}} \ No newline at end of file diff --git a/data/wiki/index b/data/wiki/index deleted file mode 100644 index 59429615..00000000 --- a/data/wiki/index +++ /dev/null @@ -1,65 +0,0 @@ -= SandboxOS = - -I embedded a JavaScript engine in a C++ application and used it to make some webapps. I made a wiki with it. That is what you are looking at. It's not especially good, but the interesting part is that you, as a visitor to this web site, have the power to rewrite the wiki webapp itself into something better. - -== Goals == -I've tried writing lofty descriptions about why I think this is cool, but I'm bad at that part. - -Goals include: - -=== 1. Make it easy to run servers. === - * SandboxOS can be made to run on lots of platforms. - * SandboxOS can be made trivial to install. I want to put it in app stores. - * SandboxOS is an app store in itself, so think "installing blogging software == installing a mobile game". And then think of a webapp that is 10x better than that. -=== 2. Make a thing that is by default pretty secure. === - * Actual access to most system resources (filesystem + network, currently) is restricted to a few apps that hand it out in very limited ways. - * Apps will only get access to resources when granted by the user. Think iOS or Android. - * The idea is that it can be made as secure as Google Chrome. It currently uses V8 and process isolation, but there's a lot more to do. In the end I want to trust installing random apps as much as or more than I trust visiting shady web sites. - * But security is nothing if you can't do cool stuff. I want to make weird social music players and things to manipulate photos on my phone from my desktop. -=== 3. Free software idealism === - * This is Wikipedia but for apps? - * Make distributed versions of things that Google/Apple/Facebook dominate? - * Something about software architecture and making small tools that fit together to do neat things. -=== 4. Fun === - * I get a kick out of making all of this stuff from scratch. The stack is getting pretty high, and it's just getting started. - * This hopefully lowers the barrier to entry to making little webapps, since you can use my server and make something with ~2 files that you edited like something on Google Docs. - -== How to Get Started == - -{{{ -#!html -