@ -118,6 +118,8 @@ passport.deserializeUser(function(uid, done) {
res . send ( templates [ 'header' ] + templates [ '403' ] + templates [ 'footer' ] ) ;
} ) ;
// 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' ] ;
@ -131,17 +133,14 @@ passport.deserializeUser(function(uid, done) {
}
} ( ) ) ;
function generate _topic _body ( req , res ) {
global . modules . topics . generate _topic _body ( function ( topic _body ) {
res . send ( templates [ 'header' ] + topic _body + templates [ 'footer' ] ) ;
} , req . params . topic _id ) ;
}
app . get ( '/topic/:topic_id' , generate _topic _body ) ;
app . get ( '/topic/:topic_id*' , generate _topic _body ) ;
// Complex Routes
app . get ( '/topic/:topic_id/:slug?' , function ( req , res ) {
res . send ( templates [ 'header' ] + '<script>templates.ready(function(){ajaxify.go("' + 'topic/' + req . params . topic _id + '");});</script>' + templates [ 'footer' ] ) ;
} ) ;
// These functions are called via ajax once the initial page is loaded to populate templates with data
function api _method ( req , res ) {
switch ( req . params . method ) {
case 'home' :
@ -173,7 +172,7 @@ passport.deserializeUser(function(uid, done) {
case 'topic' :
global . modules . posts . get ( function ( data ) {
res . send ( JSON . stringify ( data ) ) ;
} , req . params . id , req . user . uid ) ;
} , req . params . id , req . user . uid || 0 ) ;
break ;
default :
res . send ( '{}' ) ;