Compare commits
9 Commits
30cb4edfa6
...
85a158c435
| Author | SHA1 | Date | |
|---|---|---|---|
| 85a158c435 | |||
| 83964eb9fd | |||
| 975ad14985 | |||
| 7942d87cbe | |||
| 34786e7223 | |||
| 960a6397dc | |||
| c223b84445 | |||
| fcc3add34b | |||
| 07bbf82d31 |
@@ -0,0 +1,3 @@
|
||||
composer.lock
|
||||
/nbproject/
|
||||
/vendor/
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "potter/bootstrap",
|
||||
"type": "library",
|
||||
"license": "MIT",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Potter\\": "src/Potter/"
|
||||
}
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jay Potter",
|
||||
"email": "j@ypotter.ca"
|
||||
}
|
||||
],
|
||||
"minimum-stability": "stable",
|
||||
"require": {
|
||||
"potter/container": ">=0.0.1",
|
||||
"potter/controller": ">=0.0.1",
|
||||
"potter/response": ">=0.0.1",
|
||||
"potter/router": ">=0.0.1",
|
||||
"psr/http-message": "^2.0.0",
|
||||
"twbs/bootstrap": "^5.3.8"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Potter;
|
||||
|
||||
use \Potter\Response\Text,
|
||||
\Psr\Http\Message\{ResponseInterface, ServerRequestInterface};
|
||||
|
||||
final class Bootstrap extends Controller
|
||||
{
|
||||
static private function getBootstrapScript(ServerRequestInterface $request): ResponseInterface
|
||||
{
|
||||
return new Text(
|
||||
text: file_get_contents(getcwd() . '/vendor/twbs/bootstrap/dist/jss/bootstrap.js'),
|
||||
headers: ['Content-Type' => ['application/javascript; charset=utf-8']]);
|
||||
}
|
||||
|
||||
static private function getBootstrapStyle(ServerRequestInterface $request): ResponseInterface
|
||||
{
|
||||
return new Text(
|
||||
text: file_get_contents(getcwd() . '/vendor/twbs/bootstrap/dist/jss/bootstrap.js'),
|
||||
headers: ['Content-Type' => ['text/css; charset=utf-8']]);
|
||||
}
|
||||
|
||||
static private function mapRoutes(Container $container, \Potter\Router\Router $router): void
|
||||
{
|
||||
$router->map('GET', '/bootstrap.js', [self::class, 'getBootstrapScript']);
|
||||
$router->map('GET', '/bootstrap.css', [self::class, 'getBootstrapStyle']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user