Skip to content

Commit 067329c

Browse files
committed
Added closure compiler, and made the client build using it.
1 parent 1c40e8b commit 067329c

12 files changed

+1112
-847
lines changed

Cakefile

+22-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{exec} = require 'child_process'
2+
closure = require './thirdparty/closure'
3+
fs = require 'fs'
24

35
task 'test', 'Run all tests', ->
46
require './tests'
@@ -12,6 +14,7 @@ lib = [
1214
]
1315

1416
client = [
17+
'client/web-prelude'
1518
'client/microevent'
1619
'types/text'
1720
'client/opstream'
@@ -26,9 +29,26 @@ e = (str, callback) ->
2629
console.log out if out != ''
2730
callback() if callback?
2831

29-
task 'webclient', 'Assemble the web client into one file', ->
32+
compile = (infile, outfile) ->
33+
# Closure compile the JS
34+
file = fs.readFileSync infile
35+
36+
closure.compile file, (err, code) ->
37+
throw err if err?
38+
39+
smaller = Math.round((1 - (code.length / file.length)) * 100)
40+
41+
output = outfile
42+
fs.writeFileSync output, code
43+
44+
console.log "Closure compiled: #{smaller}% smaller (#{code.length} bytes} written to #{output}"
45+
46+
47+
task 'webclient', 'Build the web client into one file', ->
3048
clientfiles = ("src/#{c}.coffee" for c in client).join ' '
3149
# I would really rather do this in pure JS.
3250
e "coffee -cj #{clientfiles}", ->
33-
e "cat #{lib.join ' '} concatenation.js >share.js", ->
51+
e "cat #{lib.join ' '} concatenation.js >share.uncompressed.js", ->
3452
e 'rm concatenation.js'
53+
compile 'share.uncompressed.js', 'share.js'
54+

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Licensed under the standard MIT license:
2+
3+
Copyright 2011 Joseph Gentle.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

examples/_wiki/wiki.html.mu

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<script src="/lib/ace/ace.js" type="text/javascript" charset="utf-8"></script>
1818
<script src="/socket.io/socket.io.js"></script>
1919
<script src="/share.js"></script>
20-
<script src="../lib/ace.js"></script>
20+
<script src="/lib/share.ace.js"></script>
2121
<script>
2222

2323
window.onload = function() {

examples/ace/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</div>
1313

1414
<div id="editor">Connecting...</div>
15-
<script src="/lib/ace/ace.js" type="text/javascript" charset="utf-8"></script>
15+
<script src="/lib/ace/ace-uncompressed.js" type="text/javascript" charset="utf-8"></script>
1616
<script src="/lib/ace/mode-coffee.js" type="text/javascript" charset="utf-8"></script>
1717
<script src="/socket.io/socket.io.js"></script>
1818
<script src="/share.js"></script>

0 commit comments

Comments
 (0)