| 
									
										
										
										
											2013-05-14 12:26:26 -04:00
										 |  |  | var categories = require('./src/categories.js'), | 
					
						
							| 
									
										
										
										
											2013-05-14 12:13:29 -04:00
										 |  |  |     templates = require('./src/templates.js'), | 
					
						
							|  |  |  |     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 = {}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | (function(config) { | 
					
						
							|  |  |  |     config['ROOT_DIRECTORY'] = __dirname; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-14 12:13:29 -04:00
										 |  |  | 	templates.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-14 12:13:29 -04:00
										 |  |  |         categories.get(function(data) { | 
					
						
							| 
									
										
										
										
											2013-05-06 22:05:42 +00:00
										 |  |  |             if (data.categories.length === 0) { | 
					
						
							|  |  |  |                 console.log('Setting up default categories...'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-14 12:13:29 -04:00
										 |  |  |                 fs.readFile(config.ROOT_DIRECTORY + '/install/data/categories.json', function(err, categories) { | 
					
						
							| 
									
										
										
										
											2013-05-07 20:49:27 +00:00
										 |  |  |                     categories = JSON.parse(categories); | 
					
						
							|  |  |  |                      | 
					
						
							|  |  |  |                     for (var category in categories) { | 
					
						
							| 
									
										
										
										
											2013-05-14 12:13:29 -04:00
										 |  |  |                         categories.create(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-04-22 16:51:32 +00:00
										 |  |  | }(global.configuration)); |