Browse Source

Restyle website/api.html. Now looks like the front page.

Made a few other little corrections too.
v0.7.4-release
Ryan 16 years ago
parent
commit
b5a1585470
  1. 9
      configure
  2. 54
      website/api.txt
  3. 47
      website/index.html
  4. 7
      website/pipe.css
  5. 4
      website/sh_main.min.js
  6. 69
      website/toc.js

9
configure

@ -109,7 +109,14 @@ benchmark: all
website: website/api.html website/index.html website: website/api.html website/index.html
website/api.html: website/api.txt 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 website-upload: website
scp website/* linode:~/tinyclouds/node/ scp website/* linode:~/tinyclouds/node/

54
website/api.txt

@ -4,13 +4,13 @@ Ryan Dahl <ry@tinyclouds.org>
Version, 0.1.6, 2009.08.22 Version, 0.1.6, 2009.08.22
== NAME == Name
node - purely event-based I/O for V8 javascript node - purely event-based I/O for V8 javascript
== SYNOPSIS == Synopsis
An example of a web server written with Node which responds with "Hello An example of a web server written with Node which responds with "Hello
World" after waiting two seconds: 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 == API

47
website/index.html

@ -9,7 +9,7 @@
</style> </style>
<script type="text/javascript" src="sh_main.js"></script> <script type="text/javascript" src="sh_main.js"></script>
<script type="text/javascript" src="sh_javascript.min.js"></script> <script type="text/javascript" src="sh_javascript.min.js"></script>
<link type="text/css" rel="stylesheet" href="style.css" /> <link type="text/css" rel="stylesheet" href="pipe.css" />
<link type="text/css" rel="stylesheet" href="sh_vim-dark.css" /> <link type="text/css" rel="stylesheet" href="sh_vim-dark.css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>node.js</title> <title>node.js</title>
@ -31,7 +31,7 @@
<h1><a href="http://tinyclouds.org/node">Node</a></h1> <h1><a href="http://tinyclouds.org/node">Node</a></h1>
<p id="introduction"> <p id="introduction">
Purely event-based I/O for Mostly event-based I/O for
<a href="http://code.google.com/p/v8/">V8 javascript</a>. <a href="http://code.google.com/p/v8/">V8 javascript</a>.
</p> </p>
@ -77,7 +77,7 @@ Server running at http://127.0.0.1:8000/</pre>
<p> <p>
Node's goal is to provide an easy way to build scalable network 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 prevent the server from handling new requests. Node tells the
operating system (through <code>epoll</code>, <code>kqueue</code>, operating system (through <code>epoll</code>, <code>kqueue</code>,
<code class="sh_none">/dev/poll</code>, or <code>select</code>) <code class="sh_none">/dev/poll</code>, or <code>select</code>)
@ -102,35 +102,34 @@ Server running at http://127.0.0.1:8000/</pre>
than systems which allocate 2mb thread stacks for each connection. than systems which allocate 2mb thread stacks for each connection.
Furthermore, users of Node are free from worries of dead-locking Furthermore, users of Node are free from worries of dead-locking
the process&mdash;there are no locks. No function in Node the process&mdash;there are no locks. Almost no function in Node
directly performs I/O, so the process never blocks. Because directly performs I/O, so the process never blocks. Because
nothing blocks, less-than-expert programmers are able to develop nothing blocks, less-than-expert programmers are able to develop
fast systems. fast systems.
</p> </p>
<p> <p>
Node is similar in design to systems like Ruby's Node is similar in design to systems like Ruby's <a
<a href="http://rubyeventmachine.com/">Event Machine</a> href="http://rubyeventmachine.com/">Event Machine</a> or Python's <a
or Python's <a href="http://twistedmatrix.com/">Twisted</a>. href="http://twistedmatrix.com/">Twisted</a>. Node takes the event
Node takes the event model a bit further. For example, in other model a bit further. For example, in other systems there is always
systems there is always a blocking call to start the event-loop. a blocking call to start the event-loop. Typically one defines
Typically one defines behavior through callbacks at the beginning behavior through callbacks at the beginning of a script and at the
of a script and at the end starts a server through a call like end starts a server through a call like
<code>EventMachine::run()</code>. In Node it works differently. <code>EventMachine::run()</code>. In Node there is no such
By default Node enters the event loop after executing the input start-the-event-loop call. Node simply enters the event loop after
script. Node exits the event loop when there are no more callbacks executing the input script. Node exits the event loop when there are
to perform. Like in traditional browser javascript, the event loop no more callbacks to perform. This behavior is like browser
is hidden from the user. javascript&mdash;the event loop is hidden from the user.
</p> </p>
<p> <p>
Node's HTTP API has grown out of my difficulties developing and Node's HTTP library has grown out of my difficulties developing and
working with web servers. For example, streaming data through working with web servers. For example, streaming data through most
most web frameworks is impossible. Or the oft-made false web frameworks is impossible. Node attempts to correct these
assumption that all message headers have unique fields. Node problems in its HTTP API. Coupled with Node's purely evented
attempts to correct these and other problems in its API. Coupled infrastructure, it makes a good foundation for web libraries or
with Node's purely evented infrastructure, it will make a more frameworks.
comprehensive foundation for future web libraries/frameworks.
</p> </p>
<p> <p>
@ -138,7 +137,7 @@ Server running at http://127.0.0.1:8000/</pre>
But what about multiple-processor concurrency? Threads are But what about multiple-processor concurrency? Threads are
necessary to scale programs to multi-core computers. necessary to scale programs to multi-core computers.
</i> </i>
The name <i>Node</i> should give some hint at how it is envisioned The name <i>Node</i> gives some hint at how it is envisioned
being used. Processes are necessary to scale to multi-core being used. Processes are necessary to scale to multi-core
computers, not memory-sharing threads. The fundamentals of scalable computers, not memory-sharing threads. The fundamentals of scalable
systems are fast networking and non-blocking design&mdash;the rest systems are fast networking and non-blocking design&mdash;the rest

7
website/style.css → website/pipe.css

@ -4,8 +4,6 @@ body {
font-size: 16pt; font-size: 16pt;
line-height: 150%; line-height: 150%;
font-family: times, Times New Roman, times-roman, georgia, serif; font-family: times, Times New Roman, times-roman, georgia, serif;
}
#content {
max-width: 30em; max-width: 30em;
margin: 0 0 5em 8em; margin: 0 0 5em 8em;
} }
@ -17,8 +15,13 @@ body {
font-size: 14pt; font-size: 14pt;
line-height: 120%; line-height: 120%;
} }
#toctitle {
display: none;
}
#toc ol { #toc ol {
list-style: none; list-style: none;
}
#toc ol, .toclevel2 {
margin: 0; margin: 0;
padding: 0; padding: 0;
padding-left: 1em; padding-left: 1em;

4
website/sh_main.min.js

File diff suppressed because one or more lines are too long

69
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);
}
Loading…
Cancel
Save