-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
216 lines (160 loc) · 7.88 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<!doctype html>
<html>
<head>
<!-- Hook Test -->
<link rel="icon" type="image/png" href="favicon.png" />
<link rel="stylesheet" href="bootstrap-1.4.0.min.css" />
<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" href="google-code-prettify/sunburst.css" />
<script type="text/javascript" src="google-code-prettify/prettify.js"></script>
<script type="text/javascript" src="google-code-prettify/lang-lua.js"></script>
<title>Luvit</title>
</head>
<body onload="prettyPrint()">
<a href="http://github.com/luvit/luvit">
<img id="githubRibbon" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" />
</a>
<div class="container">
<header class="hero-unit">
<div class="row">
<img id="logo" src="logo.png" alt="Luvit logo" />
<div id="header">
<img src="title.png" alt="Luvit" />
<h2>asynchronous I/O for Lua</h2>
</div>
</div>
</header>
<article id="about" class="row">
<div class="span16">
<h1>About Luvit</h1>
<p>The original luvit (started 2011 by <a href="https://github.com/creationix">Tim Caswell</a>) was a node.js-like programming environment, but using Luajit instead of V8. Luvit 1.0 found it's niche in places like <a href="https://github.com/virgo-agent-toolkit">cloud monitoring</a> and scripting on slower devices like Raspberry PIs. It had nearly identical APIs to node and thus was easy to learn for developers looking for something like node, but less memory hungry.</p>
<p>Luvit 2.0 is a reboot of this idea but far more flexible and configurable. The new system consists of many parts that can be used with or without the new luvit framework.</p>
<p><a href="https://github.com/luvit/luvit">Read more</a> on luvit's project page over at Github.</p>
</div></article>
<article id="installation" class="row">
<div class="span16">
<h1>Getting Lit and Luvit</h1>
<p>
Assuming your platform is one of the supported platforms with pre-built luvi binaries, building lit and luvi is super easy and can be done on any computer without any tools required.
</p>
<h2>Get Lit</h2>
<p>If you're on a unix system, make sure you have <code>curl</code> and <code>sh</code> and run:</p>
<pre><code>curl -L https://github.com/luvit/lit/raw/master/get-lit.sh | sh</code></pre>
<p>If you're on a windows box, open a `cmd.exe` terminal and enter:</p>
<pre><code>PowerShell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://github.com/luvit/lit/raw/master/get-lit.ps1'))"</code></pre>
<p>Supported platforms include:</p>
<ul>
<li>Windows 64-bit</li>
<li>OSX 64-bit</li>
<li>Linux 64-bit</li>
<li>FreeBSD 64-bit</li>
<li>Raspberry Pi (Linux arm6l)</li>
<li>BeagleBone Black (Linux arm7l)</li>
</ul>
<p>If the lit installer doesn't work for you, <a href="https://github.com/luvit/luvi#building-from-source">compile luvi from source</a> and then <a href="https://github.com/luvit/lit#building-from-source">build lit using the custom luvi</a>.</p>
<h2>Building Luvit CLI</h2>
<p>Once you have lit installed, building luvit is super simple. To get the latest published release from the central lit package repository, simply run:</p>
<pre><code>lit make lit://luvit/luvit</code></pre>
<p>If you want the latest version from git, run:</p>
<pre><code>lit make github://luvit/luvit</code></pre>
<p>Either of these commands will build a luvit executable in your current working directory. Move it somewhere in your path to install.</p>
</div>
</article>
<article id="examples" class="row">
<div class="span16"><h1>Code samples</h1></div>
<div class="row">
<section class="span8">
<p id="httpServer">HTTP server</p>
<pre class="prettyprint"><code class="language-lua">local http = require("http")
http.createServer(function (req, res)
local body = "Hello world\n"
res:on("error", function(err)
print("Error while sending a response: " .. err)
end)
res:writeHead(200, {
["Content-Type"] = "text/plain",
["Content-Length"] = #body
})
res:finish(body)
end):listen(8080)
print("Server listening at http://localhost:8080/")
</code></pre>
</section>
<section class="span8">
<p id="httpClient">HTTP client</p>
<pre class="prettyprint"><code class="language-lua">local http = require('http')
local req = http.request({
host = "luvit.io",
port = 80,
path = "/"
}, function (res)
res:on("error", function(err)
print("Error while receiving a response: " .. err)
end)
res:on("data", function (chunk)
p("ondata", {chunk=chunk})
end)
end)
req:on("error", function(err)
print("Error while sending a request: " .. err)
end)
req:done()
</code></pre>
</section>
</div>
<div class="row">
<section class="span8">
<p id="tcpEchoServer">TCP echo server</p>
<pre class="prettyprint"><code class="language-lua">local net = require('net')
net.createServer(function (client)
-- Echo everything the client says back to itself
client:pipe(client)
-- Also log it to the server's stdout
client:pipe(process.stdout)
end):listen(8080)
print("TCP echo server listening on port 8080")
</code></pre>
</section>
<section class="span8">
<p id="tcpEchoClient">TCP echo client</p>
<pre class="prettyprint"><code class="language-lua">local net = require('net')
local client
client = net.createConnection(8080, '127.0.0.1', function (err)
if err then error(err) end
print("Connected...")
-- Send stdin to the server
process.stdin:pipe(client)
-- Send the server's response to stdout
client:pipe(process.stdout)
end)
</code></pre>
</section>
</div>
<p>
Do you have a question/want to learn more? Make sure to check out
the <a href="http://groups.google.com/group/luvit/">mailing list</a>
and drop by our IRC channel, #luvit on Freenode.
</p>
</article>
<article id="installation" class="row">
<div class="span16">
<h2>Luvi - Lua + LibUV Integrated</h2>
<p>Luvi is the C runtime of luvit and lit. It essentially consists of <a href="https://github.com/luvit/luv">fresh bindings to libuv</a>, embedded luajit, openssl, and asset bundling using zip files appended to itself.</p>
<p>Thanks to luvi, most development involving C compilers is kept at or below luvi and everything else including core luvit and lit development are done in pure lua with no required build step to test changes to core modules.</p>
<p><a href="https://github.com/luvit/luvi">Read more</a> on luvi's project page over at Github.</p>
<h2>Lit - Luvit Invention Toolkit</h2>
<p>Lit is a toolkit designed to make working in the new <a href="https://github.com/luvit/luvit/">luvit</a> 2.0 ecosystem
easy and even fun.</p>
<ul class="task-list">
<li>Lit powers the central repository at <code>wss://lit.luvit.io/</code>.</li>
<li>Lit is used to publish new packages to the central repository.</li>
<li>Lit is used to download and install dependencies into your local tree.</li>
<li>Lit can be used to compile <a href="https://github.com/luvit/luvi/">luvi</a> apps from folders or zip files into
self-executing binaries.</li>
</ul>
<p>Lit is also a luvi app and library itself and bootstraps fairly easily. It uses it's own copy of luvi when creating new apps so you don't have to provide a luvi build yourself.</p>
<p><a href="https://github.com/luvit/lit">Read more</a> on lit's project page over at Github.</p>
</div></article>
</div>
</body>
</html>