Added app and PHP version displays to the footer
This commit is contained in:
		| @@ -127,6 +127,15 @@ select[multiple]{ | |||||||
|   border-radius: 10px; |   border-radius: 10px; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | #main-footer{ | ||||||
|  |   margin-top: 25px; | ||||||
|  |  | ||||||
|  |   p{ | ||||||
|  |     margin-bottom: 5px; | ||||||
|  |     text-align: center; | ||||||
|  |   } | ||||||
|  | } | ||||||
|  |  | ||||||
| #result-form{ | #result-form{ | ||||||
|   margin: 0; |   margin: 0; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,6 @@ | |||||||
| { | { | ||||||
|     "name": "bitgoblin/colossus", |     "name": "bitgoblin/colossus", | ||||||
|  |     "version": "0.1.0", | ||||||
|     "description": "Self-hosted database for organizing PC hardware benchmarking results", |     "description": "Self-hosted database for organizing PC hardware benchmarking results", | ||||||
|     "type": "project", |     "type": "project", | ||||||
|     "license": "BSD-2-Clause", |     "license": "BSD-2-Clause", | ||||||
|   | |||||||
							
								
								
									
										26
									
								
								src/Middleware/AppInfo.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								src/Middleware/AppInfo.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,26 @@ | |||||||
|  | <?php | ||||||
|  |  | ||||||
|  | namespace BitGoblin\Colossus\Middleware; | ||||||
|  |  | ||||||
|  | use Psr\Http\Message\ServerRequestInterface as Request; | ||||||
|  |  | ||||||
|  | class AppInfo { | ||||||
|  |  | ||||||
|  | 	protected $view; | ||||||
|  |  | ||||||
|  | 	public function __construct($view) { | ||||||
|  | 		$this->view = $view; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public function __invoke(Request $request, $handler) { | ||||||
|  | 		// add running app version | ||||||
|  | 		$composer = json_decode(file_get_contents(__DIR__ . '/../../composer.json'), true); | ||||||
|  | 		$this->view->getEnvironment()->addGlobal('APP_VERSION', $composer['version'] ?? 'unknown'); | ||||||
|  |  | ||||||
|  | 		// add running PHP version | ||||||
|  | 		$this->view->getEnvironment()->addGlobal('PHP_VERSION', PHP_VERSION); | ||||||
|  |  | ||||||
|  | 		return $handler->handle($request); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -9,6 +9,8 @@ use Slim\Factory\AppFactory; | |||||||
| use Slim\Views\Twig; | use Slim\Views\Twig; | ||||||
| use Slim\Views\TwigMiddleware; | use Slim\Views\TwigMiddleware; | ||||||
|  |  | ||||||
|  | use BitGoblin\Colossus\Middleware\AppInfo; | ||||||
|  |  | ||||||
| require __DIR__ . '/../vendor/autoload.php'; | require __DIR__ . '/../vendor/autoload.php'; | ||||||
|  |  | ||||||
| // Load app configuration | // Load app configuration | ||||||
| @@ -38,5 +40,8 @@ $twig = Twig::create(__DIR__ . '/../views', ['cache' => false]); | |||||||
| // Add Twig-View Middleware | // Add Twig-View Middleware | ||||||
| $app->add(TwigMiddleware::create($app, $twig)); | $app->add(TwigMiddleware::create($app, $twig)); | ||||||
|  |  | ||||||
|  | // Add middleware for injecting global vars for app's info | ||||||
|  | $app->add(new AppInfo($twig)); | ||||||
|  |  | ||||||
| // Register routes | // Register routes | ||||||
| require_once __DIR__ . '/routes.php'; | require_once __DIR__ . '/routes.php'; | ||||||
|   | |||||||
| @@ -16,5 +16,6 @@ | |||||||
|     {% block content %}{% endblock %} |     {% block content %}{% endblock %} | ||||||
|   </div> |   </div> | ||||||
|  |  | ||||||
|  |   {% include 'partials/footer.twig' %} | ||||||
| </body> | </body> | ||||||
| </html> | </html> | ||||||
|   | |||||||
							
								
								
									
										8
									
								
								views/partials/footer.twig
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								views/partials/footer.twig
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | |||||||
|  | <footer id="main-footer" class="container"> | ||||||
|  | 	<div class="row"> | ||||||
|  | 		<div class="twelve columns"> | ||||||
|  | 			<p>Colossus version {{ APP_VERSION }}.</p> | ||||||
|  | 			<p>Running PHP version {{ PHP_VERSION }}.</p> | ||||||
|  | 		</div> | ||||||
|  | 	</div> | ||||||
|  | </footer> | ||||||
		Reference in New Issue
	
	Block a user