1 | var Backbone = require('backbone')
|
2 |
|
3 | Backbone.register = function(config) {
|
4 | Lilo.Model.urlRoot = config.urlRoot
|
5 |
|
6 | if (!Backbone.View.config) {
|
7 | Backbone.View.config = {}
|
8 | }
|
9 |
|
10 | if (!config.package) {
|
11 | config.package = {}
|
12 | }
|
13 |
|
14 | if (config.layoutPath) {
|
15 | Backbone.View.config.layoutPath = config.layoutPath
|
16 | }
|
17 | if (config.layoutViews) {
|
18 | Backbone.View.config.layoutViews = config.layoutViews
|
19 | }
|
20 | if (config.templatePath) {
|
21 | Backbone.View.config.templatePath = config.templatePath
|
22 | }
|
23 | if (config.layout) {
|
24 | Backbone.View.config.layout = config.layout
|
25 | }
|
26 |
|
27 | var package = Lilo.packager.createPackage({
|
28 | dependencies: config.package.deps,
|
29 | paths: config.package.paths
|
30 | })
|
31 |
|
32 | config.app.locals.modelUrlRoot = config.urlRoot
|
33 | config.app.locals.layoutViews = config.layoutViews
|
34 |
|
35 | package.register({
|
36 | app: config.app,
|
37 | target: config.package.target
|
38 | })
|
39 |
|
40 | new Lilo.Router({ app: config.app, routes: config.routes })
|
41 | }
|
42 |
|
43 | Backbone.ajax = require('./lib/server/request')
|
44 | Backbone.packager = require('./lib/server/packager')
|
45 | Backbone.Router = require('./lib/server/router')
|
46 | Backbone.View = require('./lib/server/view')
|
47 |
|
48 | Lilo = module.exports = Backbone
|