| 
									
										
										
										
											2013-05-14 12:26:26 -04:00
										 |  |  | var categories = require('./src/categories.js'), | 
					
						
							| 
									
										
										
										
											2013-05-17 13:36:35 -04:00
										 |  |  |     templates = require('./public/src/templates.js'), | 
					
						
							| 
									
										
										
										
											2013-05-14 12:13:29 -04:00
										 |  |  |     webserver = require('./src/webserver.js'), | 
					
						
							|  |  |  |     websockets = require('./src/websockets.js'), | 
					
						
							|  |  |  |     fs = require('fs'); | 
					
						
							| 
									
										
										
										
											2013-04-22 16:51:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-14 12:13:29 -04:00
										 |  |  | DEVELOPMENT = true; | 
					
						
							| 
									
										
										
										
											2013-04-22 16:51:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | global.configuration = {}; | 
					
						
							| 
									
										
										
										
											2013-05-17 13:43:32 -04:00
										 |  |  | global.templates = {}; | 
					
						
							| 
									
										
										
										
											2013-04-22 16:51:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | (function(config) { | 
					
						
							|  |  |  |     config['ROOT_DIRECTORY'] = __dirname; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-17 15:20:08 -04:00
										 |  |  |     templates.init([ | 
					
						
							| 
									
										
										
										
											2013-05-21 10:57:45 -04:00
										 |  |  |         'header', 'footer', 'logout', 'admin/header', 'admin/footer', 'admin/index', | 
					
						
							| 
									
										
										
										
											2013-05-24 08:39:39 -04:00
										 |  |  |         'emails/reset', 'emails/reset_plaintext', 'emails/email_confirm', 'emails/email_confirm_plaintext', | 
					
						
							|  |  |  |         'emails/header.tpl', 'emails/footer.tpl' | 
					
						
							| 
									
										
										
										
											2013-05-17 15:20:08 -04:00
										 |  |  |     ]); | 
					
						
							|  |  |  |      | 
					
						
							| 
									
										
										
										
											2013-05-17 13:36:35 -04:00
										 |  |  |     templates.ready(function() { | 
					
						
							|  |  |  |         webserver.init(); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2013-05-06 22:05:42 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     //setup scripts to be moved outside of the app in future.
 | 
					
						
							|  |  |  |     function setup_categories() { | 
					
						
							|  |  |  |         console.log('Checking categories...'); | 
					
						
							| 
									
										
										
										
											2013-05-21 21:07:26 -04:00
										 |  |  |         categories.getAllCategories(function(data) { | 
					
						
							| 
									
										
										
										
											2013-05-06 22:05:42 +00:00
										 |  |  |             if (data.categories.length === 0) { | 
					
						
							|  |  |  |                 console.log('Setting up default categories...'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-15 15:39:29 -04:00
										 |  |  |                 fs.readFile(config.ROOT_DIRECTORY + '/install/data/categories.json', function(err, default_categories) { | 
					
						
							|  |  |  |                     default_categories = JSON.parse(default_categories); | 
					
						
							| 
									
										
										
										
											2013-05-07 20:49:27 +00:00
										 |  |  |                      | 
					
						
							| 
									
										
										
										
											2013-05-15 15:39:29 -04:00
										 |  |  |                     for (var category in default_categories) { | 
					
						
							|  |  |  |                         categories.create(default_categories[category]); | 
					
						
							| 
									
										
										
										
											2013-05-07 20:49:27 +00:00
										 |  |  |                     } | 
					
						
							| 
									
										
										
										
											2013-05-06 22:05:42 +00:00
										 |  |  |                 }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             } else console.log('Good.'); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     setup_categories(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-14 14:04:19 -04:00
										 |  |  |      | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-22 16:51:32 +00:00
										 |  |  | }(global.configuration)); |