mirror of
				https://github.com/Alamantus/Lexiconga.git
				synced 2025-10-31 16:36:45 +01:00 
			
		
		
		
	Move index to template-index.html; Use router to render index
Makes it possible to render announcements more easily
This commit is contained in:
		
							parent
							
								
									1b6247f457
								
							
						
					
					
						commit
						90464fd15c
					
				
					 5 changed files with 34 additions and 4 deletions
				
			
		|  | @ -2,17 +2,17 @@ | ||||||
|   "name": "lexiconga-lite", |   "name": "lexiconga-lite", | ||||||
|   "version": "1.0.0", |   "version": "1.0.0", | ||||||
|   "description": "A light-as-possible rewrite of Lexiconga", |   "description": "A light-as-possible rewrite of Lexiconga", | ||||||
|   "main": "index.html", |   "main": "template-index.html", | ||||||
|   "repository": "https://cybre.tech/Alamantus/lexiconga-lite.git", |   "repository": "https://cybre.tech/Alamantus/lexiconga-lite.git", | ||||||
|   "author": "Robbie Antenesse <dev@alamantus.com>", |   "author": "Robbie Antenesse <dev@alamantus.com>", | ||||||
|   "license": "UNLICENCED", |   "license": "UNLICENCED", | ||||||
|   "scripts": { |   "scripts": { | ||||||
|     "start": "concurrently \"npm run watch-js\" \"npm run watch-php\" \"npm run copy-files\"", |     "start": "concurrently \"npm run watch-js\" \"npm run watch-php\" \"npm run copy-files\"", | ||||||
|     "watch-js": "parcel watch index.html offline.html template-view.html template-passwordreset.html --no-hmr --public-url ./", |     "watch-js": "parcel watch template-index.html offline.html template-view.html template-passwordreset.html --no-hmr --public-url ./", | ||||||
|     "watch-php": "cpx \"src/php/**/{*,.*}\" dist -v -w", |     "watch-php": "cpx \"src/php/**/{*,.*}\" dist -v -w", | ||||||
|     "copy-files": "cpx \"node_modules/upup/dist/upup.sw.min.js\" dist -v", |     "copy-files": "cpx \"node_modules/upup/dist/upup.sw.min.js\" dist -v", | ||||||
|     "bundle": "parcel build index.html offline.html template-view.html template-passwordreset.html && npm run copy-files && cpx \"src/php/**/{*,.*}\" dist", |     "bundle": "parcel build template-index.html offline.html template-view.html template-passwordreset.html && npm run copy-files && cpx \"src/php/**/{*,.*}\" dist", | ||||||
|     "serve-frontend-only": "parcel index.html", |     "serve-frontend-only": "parcel template-index.html", | ||||||
|     "clear": "npm run clear-dist && npm run clear-cache", |     "clear": "npm run clear-dist && npm run clear-cache", | ||||||
|     "clear-dist": "rimraf dist/*", |     "clear-dist": "rimraf dist/*", | ||||||
|     "clear-cache": "rimraf .cache/*" |     "clear-cache": "rimraf .cache/*" | ||||||
|  |  | ||||||
|  | @ -8,6 +8,8 @@ RewriteRule    ^view/([0-9]+)/?$    router.php?view=dictionary&dict=$1    [NC,L] | ||||||
| 
 | 
 | ||||||
| RewriteRule    ^([0-9]+)/?$    router.php?view=dictionary&dict=$1    [NC,L]    # Handle dictionary ids. | RewriteRule    ^([0-9]+)/?$    router.php?view=dictionary&dict=$1    [NC,L]    # Handle dictionary ids. | ||||||
| 
 | 
 | ||||||
|  | RewriteRule    ^/?(index.html)?$    router.php    [NC,L]    # Handle dictionary ids. | ||||||
|  | 
 | ||||||
| #RewriteRule ^issues/?$ https://github.com/Alamantus/Lexiconga/issues [R=301,L] # Shorten issues url. | #RewriteRule ^issues/?$ https://github.com/Alamantus/Lexiconga/issues [R=301,L] # Shorten issues url. | ||||||
| 
 | 
 | ||||||
| #RewriteRule ^updates/?$ https://github.com/Alamantus/Lexiconga/releases [R=301,L] # Shorten updates url. | #RewriteRule ^updates/?$ https://github.com/Alamantus/Lexiconga/releases [R=301,L] # Shorten updates url. | ||||||
							
								
								
									
										7
									
								
								src/php/announcements.json
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/php/announcements.json
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,7 @@ | ||||||
|  | [ | ||||||
|  |   { | ||||||
|  |     "header": "Test", | ||||||
|  |     "body": "<p>Test</p>", | ||||||
|  |     "expire": "January 1, 2020" | ||||||
|  |   } | ||||||
|  | ] | ||||||
|  | @ -66,4 +66,24 @@ switch ($view) { | ||||||
|     } |     } | ||||||
|     break; |     break; | ||||||
|   } |   } | ||||||
|  | 
 | ||||||
|  |   default: { | ||||||
|  |     $html = file_get_contents(realpath(dirname(__FILE__) . '/./template-index.html')); | ||||||
|  |     $announcements = file_get_contents(realpath(dirname(__FILE__) . '/./announcements.json')); | ||||||
|  |     $announcements = json_decode($announcements, true); | ||||||
|  |     $announcements_html = ''; | ||||||
|  |     foreach ($announcements as $announcement) { | ||||||
|  |       $expire = strtotime($announcement['expire']); | ||||||
|  |       if (time() < $expire) { | ||||||
|  |         $announcements_html .= '<article class="announcement"> | ||||||
|  |         <a class="close-button" title="Close Announcement" onclick="this.parentElement.parentElement.removeChild(this.parentElement);">×︎</a>
 | ||||||
|  |         <h4>' . $announcement['header'] . '</h4> | ||||||
|  |         ' . $announcement['body'] . ' | ||||||
|  |       </article>'; | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |     $html = str_replace('{{announcements}}', $announcements_html, $html); | ||||||
|  |     return Response::html($html); | ||||||
|  |     break; | ||||||
|  |   } | ||||||
| } | } | ||||||
|  | @ -121,6 +121,7 @@ | ||||||
|     </aside> |     </aside> | ||||||
|      |      | ||||||
|     <section id="mainColumn"> |     <section id="mainColumn"> | ||||||
|  |       {{announcements}} | ||||||
|       <section id="detailsSection"> |       <section id="detailsSection"> | ||||||
|         <h2 id="dictionaryName">Dictionary Name</h2> |         <h2 id="dictionaryName">Dictionary Name</h2> | ||||||
|         <nav> |         <nav> | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue