-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
137 lines (119 loc) · 3.58 KB
/
server.js
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
var http = require( 'http' );
var carton = require( './lib/index' );
var fs = require( 'fs' );
var reset = fs.readFileSync( 'reset.css' );
var css = {
root: {
color: '#ffffff',
fontSize: 12
},
body: {
backgroundColor: '#404040'
},
page: {
backgroundColor: '#A6A6A6',
marginTop: 20
},
carton: {
backgroundColor: '#404040',
padding: 20,
'_:hover': { color: 'pink' },
},
disrupter_following: {
backgroundColor: '#404040',
width: 150,
height: 50,
padding: 20
},
disrupter_not_following: {
backgroundColor: '#404040',
width: 320,
height: 25,
padding: 20,
marginLeft: -180
},
twoLines: {
backgroundColor: '#404040',
backgroundColor: '#404040',
padding: 20,
lineHeight: 52
},
fitter: {
backgroundColor: '#404040',
padding: 20,
margin: 5
}
}
carton(
{ selector: '.', showGrid: true, extend: { slim: css.root , stretch: css.root , sticker: css.root , chopped: css.root , fixed: css.root , fit: css.root } },
[ { minWidth: 320 }, { maxWidth: 320 } ]
).global()
with ( css )
var DOC = (
DOCUMENT(
HTML(
HEAD(
TITLE( 'jsCarton - node.js sample' )
,
META( { name: 'viewport', content: 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0' } )
,
META( { httpEquiv: 'Content-Type', content: 'text/html;charset=utf-8' } )
,
LINK( { href: 'reset.css', rel: 'stylesheet', type: 'text/css' } )
,
STYLE()
)
,
BODY( [ body, 'center' ]
,
SLIM( [ page, false ]
,
CELL( [ 600,'auto','auto','auto','auto', 500 ], [ 300, 'auto','auto','auto', 'auto', 500 ]
,
CELL( [ 'auto', 'auto', 300, 400 ]
,
CELL( [ 300, 200 ]
,
STRETCH( [ carton ], 'I am a carton stretched to my parent cells', BR(), '( top_left ) width' )
)
,
CELL( [ 300, 200 ]
,
STICKER( [ disrupter_following, -30, -10 ], 'I am a sticker' )
,
FIXED( [ disrupter_not_following, 'auto', 'auto', 15, '50%' ], 'I am fixed ' )
)
)
,
CELL( [ 300, 400, 'left' ]
,
SLIM( [ carton ], 'As', BR(), 'slim', BR(), 'cartons' )
,
SLIM( [ carton, 'center' ], 'we', BR(), 'stand', BR(), 'in' )
,
SLIM( [ carton, 'right' ], 'a', BR(), 'Line' )
,
CHOPPED( [ twoLines ], 'As a chopped styleable I can exist on more than one line' )
)
,
CELL( [ '100%', 100 ]
,
FIT( [ fitter ], 'I am a fit styleable.', 'I am always fitting to my parent cell' )
)
)
)
)
)
)
)
http.createServer( function( req, res ) {
if ( req.url === '/favicon.ico' ) res.end( '' );
if ( req.url === '/reset.css' ) {
res.writeHead( 200, { 'Content-Type': 'text/css' });
res.end( reset );
}
res.writeHead( 200, { 'Content-Type': 'text/html' });
res.end( DOC.outerHTML );
})
.listen( 8080 );
console.log( 'Hello :) :8080 !' );