From b5a1585470ba4df54a01121798d99264b70a006e Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 25 Aug 2009 16:23:01 +0200 Subject: [PATCH] Restyle website/api.html. Now looks like the front page. Made a few other little corrections too. --- configure | 9 ++++- website/api.txt | 54 +------------------------- website/index.html | 47 +++++++++++----------- website/{style.css => pipe.css} | 7 +++- website/sh_main.min.js | 4 -- website/toc.js | 69 +++++++++++++++++++++++++++++++++ 6 files changed, 107 insertions(+), 83 deletions(-) rename website/{style.css => pipe.css} (94%) delete mode 100644 website/sh_main.min.js create mode 100644 website/toc.js diff --git a/configure b/configure index 31a5f63560..87110b2dd7 100755 --- a/configure +++ b/configure @@ -109,7 +109,14 @@ benchmark: all website: website/api.html website/index.html website/api.html: website/api.txt - asciidoc -a toc -o website/api.html website/api.txt + asciidoc --unsafe \\ + -a theme=pipe \\ + -a toc \\ + -a linkcss \\ + -o website/api.html website/api.txt + +# -a stylesdir=website/ \\ +# -a scriptsdir=website/ \\ website-upload: website scp website/* linode:~/tinyclouds/node/ diff --git a/website/api.txt b/website/api.txt index 4c6d0f9c59..f8566ae054 100644 --- a/website/api.txt +++ b/website/api.txt @@ -4,13 +4,13 @@ Ryan Dahl Version, 0.1.6, 2009.08.22 -== NAME +== Name node - purely event-based I/O for V8 javascript -== SYNOPSIS +== Synopsis An example of a web server written with Node which responds with "Hello World" after waiting two seconds: @@ -35,56 +35,6 @@ Server running at http://127.0.0.1:8000/ ---------------------------------------- -== DESCRIPTION - -Node provides an easy way to build scalable network programs. In the above -example, the 2 second delay does not prevent the server from handling new -requests. Node tells the operating system (through +epoll+, +kqueue+, -+/dev/poll+, or +select+) that it should be notified when the 2 seconds are -up or if a new connection is made--then it goes to sleep. If someone new -connects, then it executes the callback, if the timeout expires, it executes -the inner callback. Each connection is only a small heap allocation. - -This is in contrast to today's more common model where OS threads are employed -for concurrency. Thread-based networking -http://www.sics.se/~joe/apachevsyaws.html[is] -http://www.kegel.com/c10k.html[relatively] -http://bulk.fefe.de/scalable-networking.pdf[inefficient] -and very difficult to use. Node will show much better memory efficiency -under high-loads than systems which allocate 2mb thread stacks for each -connection. Furthermore, users of Node are free from worries of -dead-locking the process--there are no locks. In fact, no function in Node -directly performs I/O. Because nothing blocks, less-than-expert programmers -are able to develop fast systems. - -Node is similar in design to systems like Ruby's -http://rubyeventmachine.com/[Event Machine] -or Python's http://twistedmatrix.com/[Twisted]. -Node takes the event model a bit further. For example, in other systems there -is always a blocking call to start the event-loop. Typically one defines -behavior through callbacks at the beginning of a script and at the end starts a -server through a call like +EventMachine::run()+. In Node it works differently. -By default Node enters the event loop after executing the input script. Node -exits the event loop when there are no more callbacks to perform. Like in -traditional browser javascript, the event loop is hidden from the user. - -Node's HTTP API has grown out of my difficulties developing and working with -web servers. For example, streaming data through most web frameworks is -impossible. Or the oft-made false assumption that all message headers have -unique fields. Node attempts to correct these and other problems in its API. -Coupled with Node's purely evented infrastructure, it will make a more -comprehensive foundation for future web libraries/frameworks. - -_But what about multiple-processor concurrency? Threads are necessary to scale -programs to multi-core computers._ The name _Node_ should give some hint at how -it is envisioned being used. Processes are necessary to scale to multi-core -computers, not memory-sharing threads. The fundamentals of scalable systems are -fast networking and non-blocking design--the rest is message passing. In the -future, I'd like Node to be able to spawn new processes (probably using the -http://www.whatwg.org/specs/web-workers/current-work/[Web Workers API]), -but this is something that fits well into the current design. - - == API diff --git a/website/index.html b/website/index.html index 196a702218..e4915a7c9c 100644 --- a/website/index.html +++ b/website/index.html @@ -9,7 +9,7 @@ - + node.js @@ -31,7 +31,7 @@

Node

- Purely event-based I/O for + Mostly event-based I/O for V8 javascript.

@@ -77,7 +77,7 @@ Server running at http://127.0.0.1:8000/

Node's goal is to provide an easy way to build scalable network - programs. In the above example, the 2 second delay does not + programs. In the above example, the two second delay does not prevent the server from handling new requests. Node tells the operating system (through epoll, kqueue, /dev/poll, or select) @@ -102,35 +102,34 @@ Server running at http://127.0.0.1:8000/ than systems which allocate 2mb thread stacks for each connection. Furthermore, users of Node are free from worries of dead-locking - the process—there are no locks. No function in Node + the process—there are no locks. Almost no function in Node directly performs I/O, so the process never blocks. Because nothing blocks, less-than-expert programmers are able to develop fast systems.

- Node is similar in design to systems like Ruby's - Event Machine - or Python's Twisted. - Node takes the event model a bit further. For example, in other - systems there is always a blocking call to start the event-loop. - Typically one defines behavior through callbacks at the beginning - of a script and at the end starts a server through a call like - EventMachine::run(). In Node it works differently. - By default Node enters the event loop after executing the input - script. Node exits the event loop when there are no more callbacks - to perform. Like in traditional browser javascript, the event loop - is hidden from the user. + Node is similar in design to systems like Ruby's Event Machine or Python's Twisted. Node takes the event + model a bit further. For example, in other systems there is always + a blocking call to start the event-loop. Typically one defines + behavior through callbacks at the beginning of a script and at the + end starts a server through a call like + EventMachine::run(). In Node there is no such + start-the-event-loop call. Node simply enters the event loop after + executing the input script. Node exits the event loop when there are + no more callbacks to perform. This behavior is like browser + javascript—the event loop is hidden from the user.

- Node's HTTP API has grown out of my difficulties developing and - working with web servers. For example, streaming data through - most web frameworks is impossible. Or the oft-made false - assumption that all message headers have unique fields. Node - attempts to correct these and other problems in its API. Coupled - with Node's purely evented infrastructure, it will make a more - comprehensive foundation for future web libraries/frameworks. + Node's HTTP library has grown out of my difficulties developing and + working with web servers. For example, streaming data through most + web frameworks is impossible. Node attempts to correct these + problems in its HTTP API. Coupled with Node's purely evented + infrastructure, it makes a good foundation for web libraries or + frameworks.

@@ -138,7 +137,7 @@ Server running at http://127.0.0.1:8000/ But what about multiple-processor concurrency? Threads are necessary to scale programs to multi-core computers. - The name Node should give some hint at how it is envisioned + The name Node gives some hint at how it is envisioned being used. Processes are necessary to scale to multi-core computers, not memory-sharing threads. The fundamentals of scalable systems are fast networking and non-blocking design—the rest diff --git a/website/style.css b/website/pipe.css similarity index 94% rename from website/style.css rename to website/pipe.css index 4e9eb333bc..1db5f020c4 100644 --- a/website/style.css +++ b/website/pipe.css @@ -4,8 +4,6 @@ body { font-size: 16pt; line-height: 150%; font-family: times, Times New Roman, times-roman, georgia, serif; -} -#content { max-width: 30em; margin: 0 0 5em 8em; } @@ -17,8 +15,13 @@ body { font-size: 14pt; line-height: 120%; } +#toctitle { + display: none; +} #toc ol { list-style: none; +} +#toc ol, .toclevel2 { margin: 0; padding: 0; padding-left: 1em; diff --git a/website/sh_main.min.js b/website/sh_main.min.js deleted file mode 100644 index 31d1ba09e0..0000000000 --- a/website/sh_main.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/* Copyright (C) 2007, 2008 gnombat@users.sourceforge.net */ -/* License: http://shjs.sourceforge.net/doc/gplv3.html */ - -if(!this.sh_languages){this.sh_languages={}}var sh_requests={};function sh_isEmailAddress(a){if(/^mailto:/.test(a)){return false}return a.indexOf("@")!==-1}function sh_setHref(b,c,d){var a=d.substring(b[c-2].pos,b[c-1].pos);if(a.length>=2&&a.charAt(0)==="<"&&a.charAt(a.length-1)===">"){a=a.substr(1,a.length-2)}if(sh_isEmailAddress(a)){a="mailto:"+a}b[c-2].node.href=a}function sh_konquerorExec(b){var a=[""];a.index=b.length;a.input=b;return a}function sh_highlightString(B,o){if(/Konqueror/.test(navigator.userAgent)){if(!o.konquered){for(var F=0;FI){x(g.substring(I,E.index),null)}var e=O[u];var J=e[1];var b;if(J instanceof Array){for(var L=0;L0){var e=b.split(" ");for(var c=0;c0){a.push(e[c])}}}return a}function sh_addClass(c,a){var d=sh_getClasses(c);for(var b=0;b element with class="'+h+'", but no such language exists'}}break}}}}; \ No newline at end of file diff --git a/website/toc.js b/website/toc.js new file mode 100644 index 0000000000..be6dabaed6 --- /dev/null +++ b/website/toc.js @@ -0,0 +1,69 @@ +/* Author: Mihai Bazon, September 2002 + * http://students.infoiasi.ro/~mishoo + * + * Table Of Content generator + * Version: 0.4 + * + * Feel free to use this script under the terms of the GNU General Public + * License, as long as you do not remove or alter this notice. + */ + + /* modified by Troy D. Hanson, September 2006. License: GPL */ + /* modified by Stuart Rackham, October 2006. License: GPL */ + +function getText(el) { + var text = ""; + for (var i = el.firstChild; i != null; i = i.nextSibling) { + if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants. + text += i.data; + else if (i.firstChild != null) + text += getText(i); + } + return text; +} + +function TocEntry(el, text, toclevel) { + this.element = el; + this.text = text; + this.toclevel = toclevel; +} + +function tocEntries(el, toclevels) { + var result = new Array; + var re = new RegExp('[hH]([2-'+(toclevels+1)+'])'); + // Function that scans the DOM tree for header elements (the DOM2 + // nodeIterator API would be a better technique but not supported by all + // browsers). + var iterate = function (el) { + for (var i = el.firstChild; i != null; i = i.nextSibling) { + if (i.nodeType == 1 /* Node.ELEMENT_NODE */) { + var mo = re.exec(i.tagName) + if (mo) + result[result.length] = new TocEntry(i, getText(i), mo[1]-1); + iterate(i); + } + } + } + iterate(el); + return result; +} + +// This function does the work. toclevels = 1..4. +function generateToc(toclevels) { + var toc = document.getElementById("toc"); + var entries = tocEntries(document.getElementsByTagName("body")[0], toclevels); + for (var i = 0; i < entries.length; ++i) { + var entry = entries[i]; + if (entry.element.id == "") + entry.element.id = "toc" + i; + var a = document.createElement("a"); + a.href = "#" + entry.element.id; + a.appendChild(document.createTextNode(entry.text)); + var div = document.createElement("div"); + div.appendChild(a); + div.className = "toclevel" + entry.toclevel; + toc.appendChild(div); + } + if (entries.length == 0) + document.getElementById("header").removeChild(toc); +}