Restructured website folder
This commit is contained in:
parent
ca60e5e7f4
commit
f85e7f0825
|
@ -84,7 +84,8 @@ module.exports = function(logger){
|
||||||
|
|
||||||
var readPageFiles = function(){
|
var readPageFiles = function(){
|
||||||
async.each(Object.keys(pageFiles), function(fileName, callback){
|
async.each(Object.keys(pageFiles), function(fileName, callback){
|
||||||
fs.readFile('website/' + fileName, 'utf8', function(err, data){
|
var filePath = 'website/' + (fileName === 'index.html' ? '' : 'pages/') + fileName;
|
||||||
|
fs.readFile(filePath, 'utf8', function(err, data){
|
||||||
var pTemp = dot.template(data);
|
var pTemp = dot.template(data);
|
||||||
pageTemplates[pageFiles[fileName]] = pTemp
|
pageTemplates[pageFiles[fileName]] = pTemp
|
||||||
callback();
|
callback();
|
||||||
|
@ -100,7 +101,6 @@ module.exports = function(logger){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fs.watch('website', function(event, filename){
|
fs.watch('website', function(event, filename){
|
||||||
if (event === 'change' && filename in pageFiles)
|
if (event === 'change' && filename in pageFiles)
|
||||||
readPageFiles();
|
readPageFiles();
|
||||||
|
@ -191,7 +191,7 @@ module.exports = function(logger){
|
||||||
//res.send('you did api method ' + req.params.method);
|
//res.send('you did api method ' + req.params.method);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.use('/static', express.static('website'));
|
app.use('/static', express.static('website/static'));
|
||||||
|
|
||||||
app.use(function(err, req, res, next){
|
app.use(function(err, req, res, next){
|
||||||
console.error(err.stack);
|
console.error(err.stack);
|
||||||
|
|
|
@ -7,7 +7,6 @@ $(function(){
|
||||||
$('a[href="/' + page + '"]').parent().addClass('selected')
|
$('a[href="/' + page + '"]').parent().addClass('selected')
|
||||||
$.get("/api/get_page", {id: page}, function(data){
|
$.get("/api/get_page", {id: page}, function(data){
|
||||||
$('#page').html(data);
|
$('#page').html(data);
|
||||||
console.log('swapped to ' + page);
|
|
||||||
}, 'html')
|
}, 'html')
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -22,7 +21,7 @@ $(function(){
|
||||||
window.addEventListener('load', function() {
|
window.addEventListener('load', function() {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
window.addEventListener("popstate", function(e) {
|
window.addEventListener("popstate", function(e) {
|
||||||
hotSwap(location.pathname.slice(1))
|
hotSwap(location.pathname.slice(1));
|
||||||
});
|
});
|
||||||
}, 0);
|
}, 0);
|
||||||
});
|
});
|
Loading…
Reference in New Issue