|
|
|
@ -70,25 +70,23 @@ var express = require('express'),
|
|
|
|
|
return '<script>templates.ready(function(){ajaxify.go("' + url + '", null, "' + tpl + '");});</script>';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Basic Routes (entirely client-side parsed, goal is to move the rest of the crap in this file into this one section)
|
|
|
|
|
(function() {
|
|
|
|
|
var routes = ['', 'login', 'register', 'account', 'latest', 'popular', 'active', '403', '404'];
|
|
|
|
|
var routes = ['', 'login', 'register', 'account', 'latest', 'popular', 'active', '403', '404'],
|
|
|
|
|
build_header = function() {
|
|
|
|
|
return templates['header'].parse({ cssSrc: global.config['theme:src'] || '/vendor/bootstrap/css/bootstrap.min.css' });
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
for (var i=0, ii=routes.length; i<ii; i++) {
|
|
|
|
|
(function(route) {
|
|
|
|
|
|
|
|
|
|
app.get('/' + route, function(req, res) {
|
|
|
|
|
|
|
|
|
|
if ((route === 'login' || route ==='register') && (req.user && req.user.uid > 0)) {
|
|
|
|
|
res.redirect('/account');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
res.send(
|
|
|
|
|
templates['header'].parse({ cssSrc: global.config['theme:src'] || '/vendor/bootstrap/css/bootstrap.min.css' }) +
|
|
|
|
|
app.create_route(route) + templates['footer']
|
|
|
|
|
);
|
|
|
|
|
res.send(build_header() + app.create_route(route) + templates['footer']);
|
|
|
|
|
});
|
|
|
|
|
}(routes[i]));
|
|
|
|
|
}
|
|
|
|
@ -97,16 +95,16 @@ var express = require('express'),
|
|
|
|
|
// Complex Routes
|
|
|
|
|
app.get('/topic/:topic_id/:slug?', function(req, res) {
|
|
|
|
|
var topic_url = req.params.topic_id + (req.params.slug ? '/' + req.params.slug : '');
|
|
|
|
|
res.send(templates['header'] + '<script>templates.ready(function(){ajaxify.go("topic/' + topic_url + '");});</script>' + templates['footer']);
|
|
|
|
|
res.send(build_header() + '<script>templates.ready(function(){ajaxify.go("topic/' + topic_url + '");});</script>' + templates['footer']);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
app.get('/category/:category_id/:slug?', function(req, res) {
|
|
|
|
|
var category_url = req.params.category_id + (req.params.slug ? '/' + req.params.slug : '');
|
|
|
|
|
res.send(templates['header'] + '<script>templates.ready(function(){ajaxify.go("category/' + category_url + '");});</script>' + templates['footer']);
|
|
|
|
|
res.send(build_header() + '<script>templates.ready(function(){ajaxify.go("category/' + category_url + '");});</script>' + templates['footer']);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
app.get('/confirm/:code', function(req, res) {
|
|
|
|
|
res.send(templates['header'] + '<script>templates.ready(function(){ajaxify.go("confirm/' + req.params.code + '");});</script>' + templates['footer']);
|
|
|
|
|
res.send(build_header() + '<script>templates.ready(function(){ajaxify.go("confirm/' + req.params.code + '");});</script>' + templates['footer']);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// These functions are called via ajax once the initial page is loaded to populate templates with data
|
|
|
|
|