Compare commits

..

5 Commits

Author SHA1 Message Date
jay 9c7235a192 add Datatable 2026-08-15 13:42:14 -04:00
jay d7e5a82e8a require datatables/datatables 2026-08-15 13:37:12 -04:00
jay 1198934b2b composer require 2026-08-15 13:35:21 -04:00
jay 52cb55e360 composer init 2026-08-15 13:34:06 -04:00
jay 24a8d0f876 add .gitignore 2026-08-15 13:33:12 -04:00
3 changed files with 67 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
composer.lock
/nbproject/
/vendor/
+25
View File
@@ -0,0 +1,25 @@
{
"name": "potter/datatable",
"type": "library",
"license": "MIT",
"autoload": {
"psr-4": {
"Potter\\": "src/Potter/"
}
},
"authors": [
{
"name": "Jay Potter",
"email": "j@ypotter.ca"
}
],
"minimum-stability": "stable",
"require": {
"datatables/datatables": "^1.10.21",
"potter/container": ">=0.0.1",
"potter/controller": ">=0.0.1",
"potter/response": ">=0.0.1",
"potter/router": ">=0.0.1",
"psr/http-message": "^1.1.0"
}
}
+39
View File
@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace Potter;
use \Potter\Response\Text;
use \Psr\Http\Message\{ResponseInterface, ServerRequestInterface};
final class Datatable extends Controller
{
public function getDatatableScript(ServerRequestInterface $request): ResponseInterface
{
return new Text(
text: file_get_contents(getcwd() . '/vendor/datatables/datatables/media/js/jquery.dataTables.js'),
headers: ['Content-Type' => ['application/javascript; charset=utf-8']]);
}
public function getDatatableStyle(ServerRequestInterface $request): ResponseInterface
{
return new Text(
text: file_get_contents(getcwd() . '/vendor/datatables/datatables/media/css/jquery.dataTables.css'),
headers: ['Content-Type' => ['text/css; charset=utf-8']]);
}
public function getJQueryScript(ServerRequestInterface $request): ResponseInterface
{
return new Text(
text: file_get_contents(getcwd() . '/vendor/datatables/datatables/media/js/jquery.js'),
headers: ['Content-Type' => ['application/javascript; charset=utf-8']]);
}
protected function mapRoutes(Container $container, \Potter\Router\Router $router): void
{
$router->map('GET', '/datatable.js', [$this, 'getDatatableScript']);
$router->map('GET', '/datatable.css', [$this, 'getDatatableStyle']);
$router->map('GET', '/jquery.js', [$this, 'getJQueryScript']);
}
}