Stuff
This commit is contained in:
parent
e6ad944f79
commit
657975324a
@ -2,9 +2,7 @@
|
|||||||
<module type="WEB_MODULE" version="4">
|
<module type="WEB_MODULE" version="4">
|
||||||
<component name="NewModuleRootManager">
|
<component name="NewModuleRootManager">
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="Lewisdale\App\" />
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="Lewisdale\App\" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/composer" />
|
<excludeFolder url="file://$MODULE_DIR$/vendor/composer" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/masterminds/html5" />
|
<excludeFolder url="file://$MODULE_DIR$/vendor/masterminds/html5" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/lexer" />
|
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/lexer" />
|
@ -2,7 +2,7 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<modules>
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/feacher.iml" filepath="$PROJECT_DIR$/.idea/feacher.iml" />
|
<module fileurl="file://$PROJECT_DIR$/.idea/baleen.iml" filepath="$PROJECT_DIR$/.idea/baleen.iml" />
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
6
.idea/symfony2.xml
Normal file
6
.idea/symfony2.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Symfony2PluginSettings">
|
||||||
|
<option name="pluginEnabled" value="true" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -8,6 +8,7 @@ use Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider;
|
|||||||
$dotenv = Dotenv\Dotenv::createImmutable([__DIR__, __DIR__ . "/.."]);
|
$dotenv = Dotenv\Dotenv::createImmutable([__DIR__, __DIR__ . "/.."]);
|
||||||
$dotenv->load();
|
$dotenv->load();
|
||||||
|
|
||||||
|
|
||||||
require_once __DIR__ . '/../src/dependencies.php';
|
require_once __DIR__ . '/../src/dependencies.php';
|
||||||
global $container;
|
global $container;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "lewisdale/app",
|
"name": "lewisdale/baleen",
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"require": {
|
"require": {
|
||||||
"slim/slim": "^4.11",
|
"slim/slim": "^4.11",
|
||||||
@ -15,7 +15,7 @@
|
|||||||
"ext-pdo": "*",
|
"ext-pdo": "*",
|
||||||
"ext-readline": "*",
|
"ext-readline": "*",
|
||||||
"slim/csrf": "^1.3",
|
"slim/csrf": "^1.3",
|
||||||
"ramsey/uuid-doctrine": "^2.0",
|
"ramsey/uuid-doctrine": "^2.1",
|
||||||
"ramsey/uuid": "^4.7",
|
"ramsey/uuid": "^4.7",
|
||||||
"symfony/dom-crawler": "^6.3",
|
"symfony/dom-crawler": "^6.3",
|
||||||
"symfony/css-selector": "^6.3",
|
"symfony/css-selector": "^6.3",
|
||||||
|
29
composer.lock
generated
29
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "b316cfe896d61acbd6be631afe77733f",
|
"content-hash": "c8354494b2a7c54a846acc27471f1b8a",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "brick/math",
|
"name": "brick/math",
|
||||||
@ -2288,26 +2288,26 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "ramsey/uuid-doctrine",
|
"name": "ramsey/uuid-doctrine",
|
||||||
"version": "2.0.0",
|
"version": "2.1.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/ramsey/uuid-doctrine.git",
|
"url": "https://github.com/ramsey/uuid-doctrine.git",
|
||||||
"reference": "b002676be0e5e342d857c47f1b68e24de6841d08"
|
"reference": "491e1bfa4d9d81e52a60470fa92c871f7eef919e"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/ramsey/uuid-doctrine/zipball/b002676be0e5e342d857c47f1b68e24de6841d08",
|
"url": "https://api.github.com/repos/ramsey/uuid-doctrine/zipball/491e1bfa4d9d81e52a60470fa92c871f7eef919e",
|
||||||
"reference": "b002676be0e5e342d857c47f1b68e24de6841d08",
|
"reference": "491e1bfa4d9d81e52a60470fa92c871f7eef919e",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"doctrine/dbal": "^2.8 || ^3.0",
|
"doctrine/dbal": "^2.8 || ^3.0 || ^4.0",
|
||||||
"php": "^7.4 || ^8.0",
|
"php": "^8.1",
|
||||||
"ramsey/uuid": "^3.9.7 || ^4.0"
|
"ramsey/uuid": "^3.9.7 || ^4.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"captainhook/plugin-composer": "^5.3",
|
"captainhook/plugin-composer": "^5.3",
|
||||||
"doctrine/orm": "^2.5",
|
"doctrine/orm": "^2.5 || ^3.0",
|
||||||
"ergebnis/composer-normalize": "^2.28.3",
|
"ergebnis/composer-normalize": "^2.28.3",
|
||||||
"mockery/mockery": "^1.5",
|
"mockery/mockery": "^1.5",
|
||||||
"php-parallel-lint/php-console-highlighter": "^1.0",
|
"php-parallel-lint/php-console-highlighter": "^1.0",
|
||||||
@ -2317,12 +2317,9 @@
|
|||||||
"phpstan/phpstan": "^1.9",
|
"phpstan/phpstan": "^1.9",
|
||||||
"phpstan/phpstan-mockery": "^1.1",
|
"phpstan/phpstan-mockery": "^1.1",
|
||||||
"phpstan/phpstan-phpunit": "^1.3",
|
"phpstan/phpstan-phpunit": "^1.3",
|
||||||
"phpunit/phpunit": "^9.5",
|
"phpunit/phpunit": "^10.5",
|
||||||
"psalm/plugin-mockery": "^1.1",
|
|
||||||
"psalm/plugin-phpunit": "^0.18.4",
|
|
||||||
"ramsey/coding-standard": "^2.0.3",
|
"ramsey/coding-standard": "^2.0.3",
|
||||||
"ramsey/conventional-commits": "^1.3",
|
"ramsey/conventional-commits": "^1.3"
|
||||||
"vimeo/psalm": "^5.4"
|
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
@ -2359,7 +2356,7 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/ramsey/uuid-doctrine/issues",
|
"issues": "https://github.com/ramsey/uuid-doctrine/issues",
|
||||||
"source": "https://github.com/ramsey/uuid-doctrine/tree/2.0.0"
|
"source": "https://github.com/ramsey/uuid-doctrine/tree/2.1.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@ -2371,7 +2368,7 @@
|
|||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2022-12-20T23:38:28+00:00"
|
"time": "2024-05-27T00:00:21+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "slim/csrf",
|
"name": "slim/csrf",
|
||||||
@ -5909,5 +5906,5 @@
|
|||||||
"ext-readline": "*"
|
"ext-readline": "*"
|
||||||
},
|
},
|
||||||
"platform-dev": [],
|
"platform-dev": [],
|
||||||
"plugin-api-version": "2.3.0"
|
"plugin-api-version": "2.6.0"
|
||||||
}
|
}
|
||||||
|
36
src/Controllers/FeedController.php
Normal file
36
src/Controllers/FeedController.php
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
|
||||||
|
namespace Lewisdale\App\Controllers;
|
||||||
|
|
||||||
|
use Doctrine\Persistence\ObjectRepository;
|
||||||
|
use Lewisdale\App\Models\Repositories\FeedRepository;
|
||||||
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
use Slim\Views\Twig;
|
||||||
|
|
||||||
|
class FeedController
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly Twig $view,
|
||||||
|
private readonly LoggerInterface $logger,
|
||||||
|
private readonly FeedRepository $feedRepository
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function get(ServerRequestInterface $request, ResponseInterface $response)
|
||||||
|
{
|
||||||
|
$this->logger->info("FeedController::get() called");
|
||||||
|
$feeds = $this->feedRepository->findBy([], ['title' => 'ASC']);
|
||||||
|
return $this->view->render($response, 'index.twig.html', ['feeds' => $feeds]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create(ServerRequestInterface $request, ResponseInterface $response)
|
||||||
|
{
|
||||||
|
$this->logger->info("FeedController::create() called");
|
||||||
|
$body = $request->getParsedBody();
|
||||||
|
|
||||||
|
return $this->view->render($response, 'create.twig.html');
|
||||||
|
}
|
||||||
|
}
|
27
src/Models/Data/Feed.php
Normal file
27
src/Models/Data/Feed.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
|
||||||
|
namespace Lewisdale\App\Models\Data;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Ramsey\Uuid\Doctrine\UuidGenerator;
|
||||||
|
use Ramsey\Uuid\UuidInterface;
|
||||||
|
|
||||||
|
#[ORM\Entity]
|
||||||
|
#[ORM\Table(name: 'feeds')]
|
||||||
|
#[ORM\HasLifecycleCallbacks]
|
||||||
|
class Feed
|
||||||
|
{
|
||||||
|
#[ORM\Id]
|
||||||
|
#[ORM\Column(type: "uuid", unique: true)]
|
||||||
|
#[ORM\GeneratedValue(strategy: "CUSTOM")]
|
||||||
|
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||||
|
public UuidInterface $id;
|
||||||
|
|
||||||
|
#[ORM\Column(type: 'string')]
|
||||||
|
public string $url;
|
||||||
|
|
||||||
|
#[ORM\Column(type: 'string')]
|
||||||
|
public string $title;
|
||||||
|
}
|
39
src/Models/Data/FeedFilter.php
Normal file
39
src/Models/Data/FeedFilter.php
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
|
||||||
|
namespace Lewisdale\App\Models\Data;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Ramsey\Uuid\Doctrine\UuidGenerator;
|
||||||
|
use Ramsey\Uuid\UuidInterface;
|
||||||
|
|
||||||
|
#[ORM\Entity]
|
||||||
|
#[ORM\Table(name: 'feed_filters')]
|
||||||
|
#[ORM\HasLifecycleCallbacks]
|
||||||
|
class FeedFilter
|
||||||
|
{
|
||||||
|
#[ORM\Id]
|
||||||
|
#[ORM\Column(type: "uuid", unique: true)]
|
||||||
|
#[ORM\GeneratedValue(strategy: "CUSTOM")]
|
||||||
|
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
|
||||||
|
public UuidInterface $id;
|
||||||
|
|
||||||
|
public function getId(): UuidInterface
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[ORM\Column(type: 'string', enumType: FilterTarget::class)]
|
||||||
|
public FilterTarget $target;
|
||||||
|
|
||||||
|
#[ORM\Column(type: 'string', enumType: FilterType::class)]
|
||||||
|
public FilterType $filter;
|
||||||
|
|
||||||
|
#[ORM\Column(type: 'string')]
|
||||||
|
public string $value;
|
||||||
|
|
||||||
|
#[ORM\ManyToOne(targetEntity: Feed::class)]
|
||||||
|
#[ORM\JoinColumn(name: 'feed_id', referencedColumnName: 'id')]
|
||||||
|
public Feed $feed;
|
||||||
|
}
|
12
src/Models/Data/FilterTarget.php
Normal file
12
src/Models/Data/FilterTarget.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Lewisdale\App\Models\Data;
|
||||||
|
|
||||||
|
enum FilterTarget: string
|
||||||
|
{
|
||||||
|
case TITLE = 'title';
|
||||||
|
case DESCRIPTION = 'description';
|
||||||
|
case LINK = 'link';
|
||||||
|
case AUTHOR = 'author';
|
||||||
|
}
|
12
src/Models/Data/FilterType.php
Normal file
12
src/Models/Data/FilterType.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Lewisdale\App\Models\Data;
|
||||||
|
|
||||||
|
enum FilterType: string
|
||||||
|
{
|
||||||
|
case INCLUDE = 'include';
|
||||||
|
case EXCLUDE = 'exclude';
|
||||||
|
case REGEX = 'regex';
|
||||||
|
case EXACT = 'exact';
|
||||||
|
}
|
18
src/Models/Repositories/FeedFilterRepository.php
Normal file
18
src/Models/Repositories/FeedFilterRepository.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
|
||||||
|
namespace Lewisdale\App\Models\Repositories;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityManager;
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
use Lewisdale\App\Models\Data\FeedFilter;
|
||||||
|
|
||||||
|
/** @extends EntityRepository<FeedFilter> */
|
||||||
|
class FeedFilterRepository extends EntityRepository
|
||||||
|
{
|
||||||
|
public function __construct(EntityManager $em)
|
||||||
|
{
|
||||||
|
parent::__construct($em, $em->getClassMetadata(FeedFilter::class));
|
||||||
|
}
|
||||||
|
}
|
18
src/Models/Repositories/FeedRepository.php
Normal file
18
src/Models/Repositories/FeedRepository.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
|
||||||
|
namespace Lewisdale\App\Models\Repositories;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityManager;
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
use Lewisdale\App\Models\Data\Feed;
|
||||||
|
|
||||||
|
/** @extends EntityRepository<Feed> */
|
||||||
|
class FeedRepository extends EntityRepository
|
||||||
|
{
|
||||||
|
public function __construct(EntityManager $em)
|
||||||
|
{
|
||||||
|
parent::__construct($em, $em->getClassMetadata(Feed::class));
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
use Lewisdale\App\Controllers\FeedController;
|
||||||
use Lewisdale\App\Controllers\SampleController;
|
use Lewisdale\App\Controllers\SampleController;
|
||||||
use Slim\Views\TwigMiddleware;
|
use Slim\Views\TwigMiddleware;
|
||||||
|
|
||||||
@ -18,6 +19,8 @@ $app->add('csrf');
|
|||||||
|
|
||||||
$app->get("/", [SampleController::class, 'get']);
|
$app->get("/", [SampleController::class, 'get']);
|
||||||
|
|
||||||
|
$app->get('/feed', [FeedController::class, 'get']);
|
||||||
|
|
||||||
$app->addErrorMiddleware(true, true, true);
|
$app->addErrorMiddleware(true, true, true);
|
||||||
|
|
||||||
$app->run();
|
$app->run();
|
@ -48,7 +48,7 @@ $container->set(EntityManager::class, static function() {
|
|||||||
|
|
||||||
$connection = DriverManager::getConnection([
|
$connection = DriverManager::getConnection([
|
||||||
'driver' => 'pdo_sqlite',
|
'driver' => 'pdo_sqlite',
|
||||||
'path' => __DIR__ . '/../' . $_ENV["SQLITE_DB_NAME"],
|
'path' => __DIR__ . '/../' . getenv("SQLITE_DB_NAME"),
|
||||||
], $config);
|
], $config);
|
||||||
|
|
||||||
return new EntityManager($connection, $config);
|
return new EntityManager($connection, $config);
|
||||||
|
Loading…
Reference in New Issue
Block a user