-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathfrontend.js
56 lines (49 loc) · 1.67 KB
/
frontend.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
"use strict";
var config = require( "./config" ),
Download = require( "./download" ),
fs = require( "node:fs" ),
Handlebars = require( "handlebars" ),
JqueryUi = require( "./lib/jquery-ui" ),
ThemeRoller = require( "./themeroller" );
var errorTemplate = Handlebars.compile( fs.readFileSync( __dirname + "/template/500.html", "utf-8" ) ),
rootTemplate = Handlebars.compile( fs.readFileSync( __dirname + "/template/root.html", "utf-8" ) );
/**
* Frontend( options )
* - options [ Object ]: key-value pairs detailed below.
*
* options
* - config [ Object ]: optional, if present used instead of the `config.json` file;
* - env [ String ]: optional, specify whether in development or production environment. Default: "development".
* - host [ String ]: optional, specify the host where download.jqueryui.com server is running. Default: "" (empty string).
*
*/
var Frontend = function( options ) {
this.options = options = Object.assign( {}, Frontend.defaults, options );
if ( options.config && typeof options.config === "object" ) {
require( "./lib/config" ).get = function() {
return options.config;
};
}
this.download = new Download( options );
this.themeroller = new ThemeRoller( options );
};
Frontend.defaults = {
env: "development",
host: "",
resources: {
jqueryVersion: config.jquery,
jqueryuiVersion: JqueryUi.getStable().pkg.version,
jqueryVersionForThemeRoller: config.themeroller.jquery,
jqueryuiVersionForThemeroller: config.themeroller.jqueryUi
}
};
Frontend.prototype = {
root: function() {
return rootTemplate();
},
error: function( response ) {
response.writeHead( 500 );
response.end( errorTemplate() );
}
};
module.exports = Frontend;