Compare commits

..

9 Commits

Author SHA1 Message Date
jay 85a158c435 add Bootstrap 2026-08-14 18:16:40 -04:00
jay 83964eb9fd require twbs/bootstrap 2026-08-14 18:08:12 -04:00
jay 975ad14985 require potter/response and psr/http-message 2026-08-14 18:05:02 -04:00
jay 7942d87cbe require potter/router 2026-08-14 17:58:29 -04:00
jay 34786e7223 require potter/container 2026-08-14 17:56:52 -04:00
jay 960a6397dc delete README.md 2026-08-14 17:56:33 -04:00
jay c223b84445 require potter/controller 2026-08-14 17:55:22 -04:00
jay fcc3add34b composer init 2026-08-14 17:53:59 -04:00
jay 07bbf82d31 create .gitignore 2026-08-14 17:52:51 -04:00
4 changed files with 59 additions and 2 deletions
+3
View File
@@ -0,0 +1,3 @@
composer.lock
/nbproject/
/vendor/
-2
View File
@@ -1,2 +0,0 @@
# Bootstrap
+25
View File
@@ -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"
}
}
+31
View File
@@ -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']);
}
}