| 
									
										
										
										
											2017-10-21 21:10:33 -04:00
										 |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-01 21:27:46 -04:00
										 |  |  | const sourceIdService = require('../services/source_id'); | 
					
						
							| 
									
										
										
										
											2017-12-19 23:22:21 -05:00
										 |  |  | const sql = require('../services/sql'); | 
					
						
							| 
									
										
										
										
											2018-04-01 21:27:46 -04:00
										 |  |  | const labelService = require('../services/labels'); | 
					
						
							| 
									
										
										
										
											2018-04-02 21:34:28 -04:00
										 |  |  | const config = require('../services/config'); | 
					
						
							| 
									
										
										
										
											2018-06-08 23:18:53 -04:00
										 |  |  | const optionService = require('../services/options'); | 
					
						
							| 
									
										
										
										
											2017-10-14 23:31:44 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-30 19:31:22 -04:00
										 |  |  | async function index(req, res) { | 
					
						
							| 
									
										
										
										
											2017-12-16 20:48:34 -05:00
										 |  |  |     res.render('index', { | 
					
						
							| 
									
										
										
										
											2018-06-08 23:18:53 -04:00
										 |  |  |         theme: await optionService.getOption('theme'), | 
					
						
							| 
									
										
										
										
											2018-04-01 21:27:46 -04:00
										 |  |  |         sourceId: await sourceIdService.generateSourceId(), | 
					
						
							| 
									
										
										
										
											2018-03-07 23:24:23 -05:00
										 |  |  |         maxSyncIdAtLoad: await sql.getValue("SELECT MAX(id) FROM sync"), | 
					
						
							| 
									
										
										
										
											2018-04-02 21:34:28 -04:00
										 |  |  |         instanceName: config.General ? config.General.instanceName : null, | 
					
						
							| 
									
										
										
										
											2018-03-31 09:07:58 -04:00
										 |  |  |         appCss: await getAppCss() | 
					
						
							| 
									
										
										
										
											2017-12-16 20:48:34 -05:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2018-03-30 19:31:22 -04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-10-14 23:31:44 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-31 09:07:58 -04:00
										 |  |  | async function getAppCss() { | 
					
						
							| 
									
										
										
										
											2018-03-07 23:24:23 -05:00
										 |  |  |     let css = ''; | 
					
						
							| 
									
										
										
										
											2018-04-02 21:56:55 -04:00
										 |  |  |     const notes = labelService.getNotesWithLabel('appCss'); | 
					
						
							| 
									
										
										
										
											2018-03-07 23:24:23 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     for (const note of await notes) { | 
					
						
							|  |  |  |         css += `/* ${note.noteId} */
 | 
					
						
							|  |  |  | ${note.content} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | `;
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return css; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-30 19:31:22 -04:00
										 |  |  | module.exports = { | 
					
						
							|  |  |  |     index | 
					
						
							|  |  |  | }; |