-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update dynapack, provide a real secret reward
- Loading branch information
Showing
10 changed files
with
56 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
node_modules/ | ||
chunks/ | ||
bundles/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
module.exports = 'You didn\'t find the secret. :('; | ||
module.exports = '<h1>You didn\'t find the secret. :(</h1>'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
var ensure = require('node-ensure'); | ||
|
||
var secret = './secret' /*js*/; | ||
var nope = './nope' /*js*/; | ||
|
||
function route(path, render) { | ||
var page = (path === '/secret') ? secret : nope; | ||
|
||
ensure([page], function(err) { | ||
var html; | ||
|
||
if (!err) { | ||
// 'page' is an html string. | ||
html = require(page); | ||
} | ||
|
||
render(err, html); | ||
}); | ||
} | ||
|
||
module.exports = route; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
module.exports = 'You found the secret page!'; | ||
module.exports = ( | ||
'<h1>You found the secret page!</h1>' + | ||
'<img src="/images/secret.png"></img>' | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,41 @@ | ||
var connect = require('connect'); | ||
var serveStatic = require('serve-static'); | ||
var fs = require('fs'); | ||
var router = require('./router'); | ||
var route = require('./route'); | ||
var parseurl = require('parseurl'); | ||
|
||
var words = 'hey do you want to know a secret'; | ||
var index = function(msg) { | ||
|
||
function renderString(content) { | ||
return ( | ||
'<html>' + | ||
'<head></head>' + | ||
'<head>' + | ||
'<style>li {cursor: pointer;} li:hover {color: #3366bb;}</style>' + | ||
'</head>' + | ||
'<body>' + | ||
'<h1 id="msg">' + msg + '</h1>' + | ||
'<h1>Find the secret</h1>' + | ||
'<ul>' + | ||
words.split(' ').map(function(word) { | ||
return '<li onclick="go(\'/' + word + '\')">secret</li>'; | ||
}).join('') + | ||
'</ul>' + | ||
'<div id="content">' + content + '</h1>' + | ||
'<script src="/entry.0.js"></script>' + | ||
'<script src="/1.js"></script>' + | ||
'</body>' + | ||
'</html>' | ||
); | ||
}; | ||
} | ||
|
||
var app = connect(); | ||
app.use(serveStatic(__dirname + '/dynapack-chunks')); | ||
app.use(serveStatic(__dirname + '/bundles')); | ||
app.use('/images', serveStatic(__dirname + '/images')); | ||
app.use(function(req, res) { | ||
router(parseurl(req).path, function(msg) { | ||
var html = index(msg); | ||
route(parseurl(req).path, function(err, content) { | ||
var html = renderString(err ? err.message : content); | ||
res.end(html); | ||
}); | ||
}); | ||
app.listen(3333); | ||
app.listen(3333, function(err) { | ||
if (err) throw err; | ||
console.log('Go to http://localhost:3333'); | ||
}); |