diff --git a/_config.yml b/_config.yml index 932f0b0..c2842cb 100644 --- a/_config.yml +++ b/_config.yml @@ -7,12 +7,14 @@ baseurl: "" # the subpath of your site, e.g. /blog/ url: "http://runtimejs.org" # the base hostname & protocol for your site twitter_username: runtimejs github_username: runtimejs -footer_text: © 2014-2015 runtime.js open source project +footer_text: © 2014-2016 runtime.js open source project permalink: pretty # Build settings highlighter: pygments markdown: redcarpet +redcarpet: + extensions: ["no_intra_emphasis", "fenced_code_blocks", "autolink", "tables", "with_toc_data"] gems: - jemoji diff --git a/_includes/head.html b/_includes/head.html index 557e4cc..62a143b 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -3,7 +3,7 @@ - {% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %} + {% if page.title %}{{ page.title }}{% else %}{{ site.title }} – {{ site.description }}{% endif %} diff --git a/_includes/subheader.html b/_includes/subheader.html new file mode 100644 index 0000000..c3d5021 --- /dev/null +++ b/_includes/subheader.html @@ -0,0 +1,7 @@ +
+
+
+ {{ page.title }} +
+
+
diff --git a/_layouts/blog.html b/_layouts/blog.html new file mode 100644 index 0000000..c0aaec6 --- /dev/null +++ b/_layouts/blog.html @@ -0,0 +1,10 @@ +--- +layout: defaultPage +--- +
+ +
+ {{ content }} +
+ +
diff --git a/_layouts/defaultPage.html b/_layouts/defaultPage.html new file mode 100644 index 0000000..d641b8b --- /dev/null +++ b/_layouts/defaultPage.html @@ -0,0 +1,22 @@ + + + + {% include head.html %} + + + + {% include header.html %} + + {% include subheader.html %} + +
+
+ {{ content }} +
+
+ + {% include footer.html %} + + + + diff --git a/_layouts/index.html b/_layouts/index.html index eef438a..0cdd2e0 100644 --- a/_layouts/index.html +++ b/_layouts/index.html @@ -3,7 +3,7 @@ {% include head.html %} - + {% include header.html %} diff --git a/_layouts/page.html b/_layouts/page.html index 23191ef..3ab619d 100644 --- a/_layouts/page.html +++ b/_layouts/page.html @@ -1,24 +1,23 @@ --- -layout: default +layout: defaultPage ---
-
+ diff --git a/_sass/_base.scss b/_sass/_base.scss index 61fef44..74108f6 100644 --- a/_sass/_base.scss +++ b/_sass/_base.scss @@ -163,6 +163,11 @@ pre { padding-left: $spacing-unit; @extend %clearfix; + .homepage & { + max-width: -webkit-calc(#{$home-content-width} - (#{$spacing-unit} * 2)); + max-width: calc(#{$home-content-width} - (#{$spacing-unit} * 2)); + } + @include media-query($on-laptop) { max-width: -webkit-calc(#{$content-width} - (#{$spacing-unit})); max-width: calc(#{$content-width} - (#{$spacing-unit})); @@ -214,6 +219,12 @@ pre { box-shadow: 1px 2px 3px rgba(0,0,0,0.5); } -.button:visited { +.button:visited, .button:hover, .button:focus { color: #fafafa; } + +table, table th, table td { + border: 1px solid #e8e8e8; + border-collapse: collapse; + padding: 10px; +} diff --git a/_sass/_layout.scss b/_sass/_layout.scss index 3e4e45a..33eb7dd 100644 --- a/_sass/_layout.scss +++ b/_sass/_layout.scss @@ -25,7 +25,8 @@ $BigTitleColor: #8EB290; text-decoration: none; &, - &:visited { + &:visited, + &:hover { color: #ddd; } } @@ -102,7 +103,6 @@ $BigTitleColor: #8EB290; background: #2d2d2d; padding-top: 40px; color: #e9e9e9; - margin-bottom: 30px; .wrap { margin-left: auto; @@ -134,6 +134,13 @@ $BigTitleColor: #8EB290; white-space: nowrap; } } + + .subheader-text { + color: #98C09B; + font-size: 26px; + margin-top: -28px; + margin-bottom: 12px; + } } /** @@ -215,6 +222,7 @@ $BigTitleColor: #8EB290; */ .page-content { line-height: 1.35; + margin-top: 20px; } .page-heading { @@ -223,7 +231,6 @@ $BigTitleColor: #8EB290; .post { font-size: 15px; - padding-top: 25px; } .post-list { @@ -264,9 +271,12 @@ $BigTitleColor: #8EB290; } } +.post-sidebar { + margin-left: 200px; +} + .post-content { margin-bottom: $spacing-unit; - margin-left: 200px; @include media-query($on-palm) { margin-left: 0px; diff --git a/api-docs.md b/api-docs.md new file mode 100644 index 0000000..b49457e --- /dev/null +++ b/api-docs.md @@ -0,0 +1,99 @@ +--- +layout: page +permalink: /api-docs/ +--- + + +## net.TCPSocket + +Provides raw TCP protocol connection socket. + + +constructor() +=== + +Create new socket object in the closed state. + +```js +const socket = new runtime.net.TCPSocket(); +``` + +open(string ip, number port) +=== + +Open socket and connect to TCP server using `ip` address and `port`. + +Argument | Type | Description +--- | --- | --- +ip | string | Server IP address to connect to. +port | number | TCP server port. +-- + +```js +socket.open('127.0.0.1', 8080); +``` + +send(Uint8Array buffer) +=== + +Push data buffer into socket transmit queue. This does not copy data, buffer will be sent directly to network interface, data modifications made after `send()` call may affect transmitted data. + +Argument | Type | Description +--- | --- | --- +buffer | Uint8Array | Buffer to send. +return | bool | Hint to the caller that transmit queue is full. +-- + +```js +socket.send(new Uint8Array([1, 2, 3])); +``` + +halfclose() +=== + +Send stream ended notification, but keep receiving new data. + +```js +socket.halfclose(); +``` + +close() +=== + +Close the socket, stop transmitting and receiving new data. + +```js +socket.close(); +``` + +ondata +=== + +Handler for received data events. + +```js +socket.ondata = function(buffer) { + console.log(buffer); +}; +``` + +Example +========== + +```js +var socket = new runtime.net.TCPSocket(); + +socket.onopen = function() { + socket.send(new Uint8Array([1, 2, 3])); +}; + +socket.ondata = function(buf) { +}; + +socket.onend = function() { +}; + +socket.open('127.0.0.1', 8080); +``` + + diff --git a/blog.html b/blog.html index 94a1865..1f0798d 100644 --- a/blog.html +++ b/blog.html @@ -1,5 +1,5 @@ --- -layout: index +layout: blog --- diff --git a/css/main.scss b/css/main.scss index 27226b6..ec78f30 100755 --- a/css/main.scss +++ b/css/main.scss @@ -26,6 +26,7 @@ $grey-color-dark: darken($grey-color, 25%); // Width of the content area $content-width: 900px; +$home-content-width: 760px; $on-palm: 600px; $on-laptop: 800px; diff --git a/getting-started.md b/getting-started.md index e79e5f7..b964dc7 100644 --- a/getting-started.md +++ b/getting-started.md @@ -4,7 +4,7 @@ title: Getting Started permalink: /getting-started/ --- -## Getting Started +## Quick Start The easiest way to start playing with runtime.js is to clone [Hello World](https://github.com/runtimejs/helloworld) repository and run it in QEMU. First, make sure you have [Node.js](https://nodejs.org/download/) and [QEMU](http://wiki.qemu.org/Main_Page) installed. @@ -13,7 +13,7 @@ First, make sure you have [Node.js](https://nodejs.org/download/) and [QEMU](htt Install Node.js if you don't have it already installed. [https://nodejs.org/download/](https://nodejs.org/download/). -[npm](https://www.npmjs.com/) package manager will be also installed. +[npm](https://www.npmjs.com/) package manager will also be installed. #### Install QEMU @@ -40,7 +40,15 @@ set PATH=%PATH%;C:\Program Files\qemu See also: [http://wiki.qemu.org/Download](http://wiki.qemu.org/Download)
-[http://en.wikibooks.org/wiki/QEMU/Installing_QEMU](http://en.wikibooks.org/wiki/QEMU/Installing_QEMU) +[http://en.wikibooks.org/wiki/QEMU/Installing_QEMU](http://en.wikibooks.org/wiki/QEMU/Installing_QEMU) + +#### Install runtime.js command line tools + +``` +npm install runtime-cli -g +``` + +This adds global `runtime` command for easy access. #### Hello World repository @@ -58,54 +66,27 @@ Run: npm start ``` -## Developer tools - -Tools could be included into application as dev-dependencies (as in Hello World example) or installed globally. - -#### runtimeify - -[runtimeify](https://www.npmjs.com/package/runtimeify) creates code bundles and packages them into initrd (initial ramdisk) images. It's a wrapper around [Browserify](http://browserify.org/). - -```bash -npm install runtimeify -g -``` - -#### runtime-tools - -Adds `runtime-qemu` command to be able to easily run bundled up image in QEMU. - -```bash -npm install runtime-tools -g -``` +Done, project should load and print "Hello World!". -## Creating an application +## New application -The process is very similar to any other Node.js application managed by npm. +It's easy to create a new project and manage dependencies using npm package manager: ```bash npm init npm install runtimejs --save -npm install runtimeify --save-dev -npm install runtime-tools --save-dev ``` index.js ```js -var runtime = require('runtimejs'); console.log('It works!'); ``` -Create bundle: - -```bash -runtimeify index.js -o initrd -``` - -Run in QEMU locally: +Run in QEMU: ```bash -runtime-qemu ./initrd +runtime start ``` #### Next Steps diff --git a/index.md b/index.md index eba8f45..0952ecb 100644 --- a/index.md +++ b/index.md @@ -2,48 +2,53 @@ layout: index --- -## What is runtime.js? +## Overview -**runtime.js** is an open-source library operating system for the cloud that runs JavaScript, could be bundled up with an application and deployed as a lightweight and immutable VM image. +**runtime.js** is an open-source library operating system (unikernel) for the cloud that runs JavaScript, can be bundled up with an application and deployed as a lightweight and immutable VM image. It's built on [V8 JavaScript engine](https://code.google.com/p/v8/) and uses event-driven and non-blocking I/O model inspired by Node.js. At the moment [KVM](http://www.linux-kvm.org/page/Main_Page) is the only supported hypervisor. -Example **index.js**: +It tries to be compatible with npm module ecosystem and supports some of the Node.js API. -```js -var runtime = require('runtimejs') -console.log('Hello world!') -``` +_WARNING: project is in development and not ready for production use._ + +## Usage -Let's bundle up and run it! +Install command line tool `runtime-cli`, it will add `runtime` command to the shell: -```bash -# install dependencies -npm install runtimejs -npm install runtimeify -g -npm install runtime-tools -g +``` +npm install runtime-cli -g +``` -# bundle up ramdisk image -runtimeify index.js -o initrd +Make sure QEMU is installed, it enables running applications locally: -# make sure you have QEMU installed +``` brew install qemu # OSX sudo apt-get install qemu # Ubuntu +``` -# run it in QEMU -runtime-qemu ./initrd +Setup simple project using npm: + +``` +mkdir project +cd project +npm init +npm install runtimejs --save +echo "console.log('ok')" > index.js ``` -WARNING: project is in development and not ready for production use. +Run project locally in QEMU: -## How does it work? +``` +runtime start +``` -There are two main components: operating system (OS) kernel and a core JavaScript library. +That's it, QEMU should load and print `ok` to console. -The kernel is the C++ program that manages low-level resources like CPU and memory, runs applications using embedded V8 JavaScript engine, and exposes raw hardware to JavaScript. +## How does it work? -Application, its dependencies and the core library are bundled up using Browserify, then packed into ramdisk image for kernel to use. +There are two main components: operating system kernel and a JavaScript library. -runtime.js is a library operating system, because application uses it as its own dependency (library). Internal architecture is similar to [exokernels](https://en.wikipedia.org/wiki/Exokernel), where system exposes the hardware to application code and forces as few abstractions as possible. +The kernel is written in C++ and manages low-level resources like CPU and memory, runs JavaScript using embedded V8 engine. Library drives the entire system and manages hardware devices (usually virtualized by hypervisor). Get Started ≫