This repository was archived by the owner on May 8, 2021. It is now read-only.
File tree Expand file treeCollapse file tree 5 files changed+84
-24
lines changedFilter options
+84
-24
lines changed Original file line number Diff line number Diff line change
@@ -7,16 +7,6 @@ module.exports = function(grunt) {
7
7
grunt.file.mkdir(buildDir);
8
8
9
9
grunt.initConfig({
10
-
// create a static webserver
11
-
connect: {
12
-
server: {
13
-
options: {
14
-
hostname: hostname,
15
-
base: buildDir,
16
-
port: port
17
-
}
18
-
}
19
-
},
20
10
lumbar: {
21
11
// performs an initial build so when tests
22
12
// and initial open are run, code is built
@@ -34,6 +24,14 @@ module.exports = function(grunt) {
34
24
output: buildDir
35
25
}
36
26
},
27
+
'hapi-routes': {
28
+
map: {
29
+
options: {
30
+
package: 'web',
31
+
dest: buildDir + '/module-map.json'
32
+
}
33
+
}
34
+
},
37
35
// allows files to be opened when the
38
36
// Thorax Inspector Chrome extension
39
37
// is installed
@@ -50,7 +48,11 @@ module.exports = function(grunt) {
50
48
}
51
49
}
52
50
});
53
-
51
+
52
+
grunt.registerTask('hapi-server', function() {
53
+
// Self running.
54
+
require('./server');
55
+
});
54
56
grunt.registerTask('open-browser', function() {
55
57
var open = require('open');
56
58
open('http://' + hostname + ':' + port);
@@ -59,14 +61,16 @@ module.exports = function(grunt) {
59
61
grunt.loadTasks('tasks');
60
62
grunt.loadNpmTasks('thorax-inspector');
61
63
grunt.loadNpmTasks('lumbar');
64
+
grunt.loadNpmTasks('hula-hoop');
62
65
grunt.loadNpmTasks('grunt-contrib-connect');
63
66
64
67
grunt.registerTask('default', [
65
68
'ensure-installed',
66
69
'thorax:inspector',
70
+
'hapi-routes',
67
71
'lumbar:init',
68
-
'connect:server',
72
+
'hapi-server',
69
73
'open-browser',
70
74
'lumbar:watch'
71
75
]);
72
-
};
76
+
};
Original file line number Diff line number Diff line change
@@ -25,20 +25,25 @@ Application.initBackboneLoader(Application, function(type, module) {
25
25
// You have failed to load the module. Let the world know.
26
26
});
27
27
28
-
$(function() {
28
+
$(window).ready(function() {
29
+
// Check to see if we have rendered content that we can try to restore
30
+
var appEl = $('[data-view-name="application"]');
31
+
if (appEl.length) {
32
+
// Restore the application view explicitly
33
+
Application.restore(appEl);
34
+
} else {
35
+
// We are starting with a blank page, render a new element
36
+
$('body').append(Application.el);
37
+
Application.render();
38
+
}
39
+
29
40
// Application and other templates included by the base
30
41
// Application may want to use the link and url helpers
31
42
// which use hasPushstate, etc. so setup history, then
32
43
// render, then dispatch
33
44
Backbone.history.start({
34
-
pushState: false,
35
-
root: '/',
36
-
silent: true
45
+
pushState: true,
46
+
root: '/'
37
47
});
38
-
// TODO: can remove after this is fixed:
39
-
// https://github.com/walmartlabs/lumbar/issues/84
40
-
Application.template = Thorax.templates.application;
41
-
Application.appendTo('body');
42
-
Backbone.history.loadUrl();
43
48
});
44
49
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
12
12
"thorax-loading",
13
13
],
14
14
"scripts": [
15
-
{"src": "bower_components/bootstrap/js/bootstrap.js", "global": true},
15
+
{"src": "bower_components/bootstrap/js/bootstrap.js", "global": true, "server": false},
16
16
{"src": "lumbar-loader-backbone.js", "bower": "lumbar-loader"},
17
17
"js/init.js",
18
18
"js/model.js",
@@ -31,6 +31,9 @@
31
31
32
32
"templates": {
33
33
"root": "templates/",
34
+
"precompile": {
35
+
"data": true
36
+
},
34
37
"auto-include": {
35
38
"js/views/(.*)\\.(js|coffee)": [
36
39
"templates/$1.handlebars",
@@ -39,10 +42,12 @@
39
42
]
40
43
},
41
44
"knownHelpers": [
45
+
// Place any helpers created in the app here to optimize their use
42
46
],
43
47
"js/init.js": [
44
48
"templates/application.handlebars"
45
49
]
46
50
},
47
51
"loadPrefix": "/r/",
52
+
"server": true
48
53
}
Original file line number Diff line number Diff line change
@@ -17,6 +17,10 @@
17
17
"test": "node ./node_modules/grunt-cli/bin/grunt test"
18
18
},
19
19
"engines": {
20
-
"node" : ">=0.8.0"
20
+
"node": ">=0.8.0"
21
+
},
22
+
"dependencies": {
23
+
"hula-hoop": "0.0.1",
24
+
"hapi": "^5.0.0"
21
25
}
22
26
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
1
+
var Hapi = require('hapi'),
2
+
HulaHoop = require('hula-hoop');
3
+
4
+
var server = new Hapi.Server(8000);
5
+
6
+
var appName = 'throax-seed';
7
+
8
+
// Setup resource handling
9
+
HulaHoop.api.resourceLoader.register(appName, [
10
+
{name: 'main', version: '1.0.0', path: './build'}
11
+
]);
12
+
server.route([
13
+
{
14
+
path: '/r/{path*}',
15
+
method: 'GET',
16
+
handler: HulaHoop.endpoints.resources()
17
+
}
18
+
]);
19
+
20
+
// Setup the user endpoint routing
21
+
var pageHandler = HulaHoop.endpoints.page(appName, {
22
+
host: 'foo.com',
23
+
resourceRoot: '/r/'
24
+
});
25
+
26
+
server.route(
27
+
HulaHoop.api.resourceLoader.routes().map(function(route) {
28
+
return {
29
+
path: route,
30
+
method: 'GET',
31
+
handler: pageHandler,
32
+
config: {
33
+
cache: {
34
+
expiresIn: 5*60*1000,
35
+
privacy: 'private'
36
+
}
37
+
}
38
+
};
39
+
})
40
+
);
41
+
42
+
server.start();
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4