File tree 2 files changed +38
-1
lines changed 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -197,5 +197,9 @@ var Garden = Class(function(options) {
197
197
}
198
198
} ) ;
199
199
200
- new Garden ( { dir : 'doc' , template : 'garden.jade' , out : 'site' } ) ;
200
+ exports . build = function ( options ) {
201
+ options = options || { dir : 'doc' , template : 'garden.jade' , out : 'site' } ;
202
+ new Garden ( options ) ;
203
+ }
201
204
205
+ exports . build ( ) ;
Original file line number Diff line number Diff line change
1
+ // This server implements a post-receive hook handler for github that will build the site
2
+ var build = require ( './build' ) . build ,
3
+ qs = require ( 'querystring' ) ,
4
+ port = 9900 ,
5
+ repoURL = "https://github.com/cramerdev/JavaScript-Garden" ;
6
+
7
+ require ( 'http' ) . createServer ( function ( request , response ) {
8
+ var payload = '' ;
9
+ try {
10
+ if ( request . method === 'POST' ) {
11
+ request . setEncoding ( 'utf8' ) ;
12
+ request . on ( 'data' , function ( data ) {
13
+ payload += data ;
14
+ } ) ;
15
+ request . on ( 'end' , function ( ) {
16
+ console . log ( payload ) ;
17
+ payload = JSON . parse ( qs . parse ( payload ) . payload ) ;
18
+ if ( payload . repository . url === repoURL ) {
19
+ build ( ) ;
20
+ } else {
21
+ response . writeHead ( 400 ) ; // Bad Request
22
+ }
23
+ } ) ;
24
+ response . writeHead ( 200 ) ; // OK
25
+ } else {
26
+ response . writeHead ( 405 ) ; // Method Not Allowed
27
+ }
28
+ } catch ( e ) {
29
+ console . error ( "Error: " + e ) ;
30
+ response . writeHead ( 500 ) ; // Internal Server Error
31
+ }
32
+ response . end ( ) ;
33
+ } ) . listen ( port ) ;
You can’t perform that action at this time.
0 commit comments