Compare commits
10
Commits
0372f86cd2
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e06d5587f | ||
|
|
cee4f9944e | ||
|
|
5c8892e12f | ||
|
|
2e07b29941 | ||
|
|
49ac6f34bc | ||
|
|
918e435c59 | ||
|
|
ab74bddf09 | ||
|
|
79b3de19b9 | ||
|
|
1fc58b8c0c | ||
|
|
dc76405ba9 |
No files matched your search
@@ -0,0 +1,34 @@
|
|||||||
|
# Include any files or directories that you don't want to be copied to your
|
||||||
|
# container here (e.g., local build artifacts, temporary files, etc.).
|
||||||
|
#
|
||||||
|
# For more help, visit the .dockerignore file reference guide at
|
||||||
|
# https://docs.docker.com/go/build-context-dockerignore/
|
||||||
|
|
||||||
|
**/.classpath
|
||||||
|
**/.dockerignore
|
||||||
|
**/.env
|
||||||
|
**/.git
|
||||||
|
**/.gitignore
|
||||||
|
**/.project
|
||||||
|
**/.settings
|
||||||
|
**/.toolstarget
|
||||||
|
**/.vs
|
||||||
|
**/.vscode
|
||||||
|
**/.next
|
||||||
|
**/.cache
|
||||||
|
**/*.*proj.user
|
||||||
|
**/*.dbmdl
|
||||||
|
**/*.jfm
|
||||||
|
**/charts
|
||||||
|
**/docker-compose*
|
||||||
|
**/compose.y*ml
|
||||||
|
!**/composer.json
|
||||||
|
!**/composer.lock
|
||||||
|
**/Dockerfile*
|
||||||
|
**/node_modules
|
||||||
|
**/npm-debug.log
|
||||||
|
**/obj
|
||||||
|
**/secrets.dev.yaml
|
||||||
|
**/values.dev.yaml
|
||||||
|
LICENSE
|
||||||
|
README.md
|
||||||
@@ -56,3 +56,5 @@
|
|||||||
|
|
||||||
.env
|
.env
|
||||||
/*.db
|
/*.db
|
||||||
|
|
||||||
|
.idea
|
||||||
Generated
-8
@@ -1,8 +0,0 @@
|
|||||||
# Default ignored files
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
||||||
# Editor-based HTTP Client requests
|
|
||||||
/httpRequests/
|
|
||||||
# Datasource local storage ignored files
|
|
||||||
/dataSources/
|
|
||||||
/dataSources.local.xml
|
|
||||||
Generated
-94
@@ -1,94 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="WEB_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager">
|
|
||||||
<content url="file://$MODULE_DIR$">
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="Lewisdale\App\" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/composer" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/masterminds/html5" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/lexer" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/deprecations" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/event-manager" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/collections" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/persistence" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/instantiator" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/inflector" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/fig/http-message-util" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/dbal" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/phpoption/phpoption" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/league/uri" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/cache" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/league/uri-interfaces" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/common" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/orm" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/http-server-handler" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/ralouphie/getallheaders" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/http-factory" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/container" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/http-message" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/http-server-middleware" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/cache" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/log" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/type" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/diff" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/lines-of-code" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/laravel/serializable-closure" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/object-enumerator" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/comparator" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/code-unit" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/exporter" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/cli-parser" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/version" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/complexity" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/recursion-context" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/graham-campbell/result-type" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/brick/math" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/environment" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/global-state" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/code-unit-reverse-lookup" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/object-reflector" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/ramsey/collection" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/ramsey/uuid" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/ramsey/uuid-doctrine" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/myclabs/deep-copy" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/php-di/php-di" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/php-di/invoker" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/nikic/fast-route" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/phpunit/php-timer" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/cache-contracts" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/nikic/php-parser" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/phpunit/php-file-iterator" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/console" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/phpunit/php-invoker" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/deprecation-contracts" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/phpunit/php-text-template" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-grapheme" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/phpunit/phpunit" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/http-client" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/phpunit/php-code-coverage" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/http-client-contracts" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/var-exporter" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/css-selector" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-normalizer" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/cache" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php80" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php81" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/dom-crawler" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/service-contracts" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/string" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-ctype" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php72" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-mbstring" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/slim/psr7" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/twig/twig" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/slim/slim" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/slim/twig-view" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/slim/csrf" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/phar-io/version" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/phar-io/manifest" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/vlucas/phpdotenv" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/theseer/tokenizer" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
||||||
Generated
-8
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectModuleManager">
|
|
||||||
<modules>
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/baleen.iml" filepath="$PROJECT_DIR$/.idea/baleen.iml" />
|
|
||||||
</modules>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
Generated
-113
@@ -1,113 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="MessDetectorOptionsConfiguration">
|
|
||||||
<option name="transferred" value="true" />
|
|
||||||
</component>
|
|
||||||
<component name="PHPCSFixerOptionsConfiguration">
|
|
||||||
<option name="transferred" value="true" />
|
|
||||||
</component>
|
|
||||||
<component name="PHPCodeSnifferOptionsConfiguration">
|
|
||||||
<option name="highlightLevel" value="WARNING" />
|
|
||||||
<option name="transferred" value="true" />
|
|
||||||
</component>
|
|
||||||
<component name="PhpIncludePathManager">
|
|
||||||
<include_path>
|
|
||||||
<path value="$PROJECT_DIR$/vendor/composer" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/masterminds/html5" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/doctrine/lexer" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/doctrine/deprecations" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/doctrine/event-manager" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/doctrine/collections" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/doctrine/persistence" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/doctrine/instantiator" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/doctrine/inflector" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/fig/http-message-util" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/doctrine/dbal" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/phpoption/phpoption" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/league/uri" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/doctrine/cache" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/league/uri-interfaces" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/doctrine/common" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/doctrine/orm" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/psr/http-server-handler" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/ralouphie/getallheaders" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/psr/http-factory" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/psr/container" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/psr/http-message" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/psr/http-server-middleware" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/psr/cache" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/psr/log" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/sebastian/type" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/sebastian/diff" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/sebastian/lines-of-code" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/laravel/serializable-closure" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/sebastian/object-enumerator" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/sebastian/comparator" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/sebastian/code-unit" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/sebastian/exporter" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/sebastian/cli-parser" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/sebastian/version" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/sebastian/complexity" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/sebastian/recursion-context" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/graham-campbell/result-type" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/brick/math" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/sebastian/environment" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/sebastian/global-state" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/sebastian/code-unit-reverse-lookup" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/sebastian/object-reflector" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/ramsey/collection" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/ramsey/uuid" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/ramsey/uuid-doctrine" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/myclabs/deep-copy" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/php-di/php-di" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/php-di/invoker" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/nikic/fast-route" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/phpunit/php-timer" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/symfony/cache-contracts" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/nikic/php-parser" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/phpunit/php-file-iterator" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/symfony/console" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/phpunit/php-invoker" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/symfony/deprecation-contracts" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/phpunit/php-text-template" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-grapheme" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/phpunit/phpunit" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/symfony/http-client" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/phpunit/php-code-coverage" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/symfony/http-client-contracts" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/symfony/var-exporter" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/symfony/css-selector" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-normalizer" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/symfony/cache" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php80" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php81" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/symfony/dom-crawler" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/symfony/service-contracts" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/symfony/string" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-ctype" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php72" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-mbstring" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/slim/psr7" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/twig/twig" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/slim/slim" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/slim/twig-view" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/slim/csrf" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/phar-io/version" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/phar-io/manifest" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/vlucas/phpdotenv" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/theseer/tokenizer" />
|
|
||||||
</include_path>
|
|
||||||
</component>
|
|
||||||
<component name="PhpProjectSharedConfiguration" php_language_level="8.2" />
|
|
||||||
<component name="PhpStanOptionsConfiguration">
|
|
||||||
<option name="transferred" value="true" />
|
|
||||||
</component>
|
|
||||||
<component name="PhpUnit">
|
|
||||||
<phpunit_settings>
|
|
||||||
<PhpUnitSettings custom_loader_path="$PROJECT_DIR$/vendor/autoload.php" />
|
|
||||||
</phpunit_settings>
|
|
||||||
</component>
|
|
||||||
<component name="PsalmOptionsConfiguration">
|
|
||||||
<option name="transferred" value="true" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
Generated
-6
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="Symfony2PluginSettings">
|
|
||||||
<option name="pluginEnabled" value="true" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
Generated
-6
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="" vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
@@ -25,3 +25,13 @@ It's called Baleen, because that's what whales use to filter out the krill from
|
|||||||
## Running tests
|
## Running tests
|
||||||
|
|
||||||
1. Run `php vendor/bin/phpunit` to run the tests
|
1. Run `php vendor/bin/phpunit` to run the tests
|
||||||
|
|
||||||
|
## Running in Docker
|
||||||
|
|
||||||
|
There is a supplied `compose.yml`, so you can run the entire application with `docker compose up -d`, which will create the database and schema, and run an Nginx server.
|
||||||
|
|
||||||
|
To add a feed, get the docker container ID of the PHP container using `docker ps`, and then use the `create feed` command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker exec fe0bae104040 sh -c 'php bin/doctrine test:feed --filter=include --target=title -a "[No Ads]" -- "<feed url>" "DnD: Just the eps"'
|
||||||
|
```
|
||||||
+3
-2
@@ -8,14 +8,15 @@ use Lewisdale\App\Models\Repositories\FeedRepository;
|
|||||||
use Lewisdale\App\Tools\Console\TestFeed;
|
use Lewisdale\App\Tools\Console\TestFeed;
|
||||||
|
|
||||||
$dotenv = Dotenv\Dotenv::createImmutable([__DIR__, __DIR__ . "/.."]);
|
$dotenv = Dotenv\Dotenv::createImmutable([__DIR__, __DIR__ . "/.."]);
|
||||||
$dotenv->load();
|
$dotenv->safeLoad();
|
||||||
|
|
||||||
|
|
||||||
require_once __DIR__ . '/../src/dependencies.php';
|
require_once __DIR__ . '/../src/dependencies.php';
|
||||||
global $container;
|
global $container;
|
||||||
|
|
||||||
$commands = [
|
$commands = [
|
||||||
$container->get(TestFeed::class),
|
$container->get(TestFeed::class),
|
||||||
|
$container->get(\Lewisdale\App\Tools\Console\CreateUser::class),
|
||||||
];
|
];
|
||||||
|
|
||||||
ConsoleRunner::run(
|
ConsoleRunner::run(
|
||||||
|
|||||||
+2
-1
@@ -24,7 +24,8 @@
|
|||||||
"ext-simplexml": "*",
|
"ext-simplexml": "*",
|
||||||
"ext-curl": "*",
|
"ext-curl": "*",
|
||||||
"ext-dom": "*",
|
"ext-dom": "*",
|
||||||
"php": ">=8.3"
|
"php": ">=8.3",
|
||||||
|
"doctrine/migrations": "^3.8"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^10.0"
|
"phpunit/phpunit": "^10.0"
|
||||||
|
|||||||
Generated
+800
-622
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,44 @@
|
|||||||
|
name: baleen
|
||||||
|
|
||||||
|
services:
|
||||||
|
nginx:
|
||||||
|
image: nginx:1.27-alpine
|
||||||
|
ports:
|
||||||
|
- "8080:80"
|
||||||
|
volumes:
|
||||||
|
- ./:/var/www/html
|
||||||
|
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
|
||||||
|
depends_on:
|
||||||
|
- php
|
||||||
|
postgres:
|
||||||
|
image: postgres:17-alpine
|
||||||
|
expose:
|
||||||
|
- 5432
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: ${SERVICE_USER_POSTGRES}
|
||||||
|
POSTGRES_PASSWORD: ${SERVICE_PASSWORD_POSTGRES}
|
||||||
|
POSTGRES_DB: baleen
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready", "-d", "baleen"]
|
||||||
|
start_period: 20s
|
||||||
|
retries: 5
|
||||||
|
interval: 10s
|
||||||
|
php:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: docker/php/Dockerfile
|
||||||
|
expose:
|
||||||
|
- 9000
|
||||||
|
volumes:
|
||||||
|
- ./src:/var/www/html/src
|
||||||
|
- ./public:/var/www/html/public
|
||||||
|
- ./views:/var/www/html/views
|
||||||
|
- ./bin:/var/www/html/bin
|
||||||
|
environment:
|
||||||
|
DB_CONNECTION: postgres://${SERVICE_USER_POSTGRES}:${SERVICE_PASSWORD_POSTGRES}@postgres:5432/baleen
|
||||||
|
entrypoint: sh -c "php bin/doctrine orm:schema-tool:update --complete --force && php-fpm"
|
||||||
|
depends_on:
|
||||||
|
postgres:
|
||||||
|
condition: service_healthy
|
||||||
|
links:
|
||||||
|
- postgres
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
server {
|
||||||
|
|
||||||
|
listen 80 default_server;
|
||||||
|
root /var/www/html/public;
|
||||||
|
index index.html index.php;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.php?$query_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
location = /favicon.ico { access_log off; log_not_found off; }
|
||||||
|
location = /robots.txt { access_log off; log_not_found off; }
|
||||||
|
|
||||||
|
access_log off;
|
||||||
|
error_log /var/log/nginx/error.log error;
|
||||||
|
|
||||||
|
sendfile off;
|
||||||
|
|
||||||
|
client_max_body_size 100m;
|
||||||
|
|
||||||
|
location ~ .php$ {
|
||||||
|
fastcgi_split_path_info ^(.+.php)(/.+)$;
|
||||||
|
fastcgi_pass php:9000;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
include fastcgi_params;
|
||||||
|
fastcgi_read_timeout 300;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
fastcgi_intercept_errors off;
|
||||||
|
fastcgi_buffer_size 16k;
|
||||||
|
fastcgi_buffers 4 16k;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ /.ht {
|
||||||
|
deny all;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
FROM composer:lts AS build
|
||||||
|
|
||||||
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
|
COPY composer.json .
|
||||||
|
COPY composer.lock .
|
||||||
|
|
||||||
|
RUN --mount=type=bind,source=composer.json,target=composer.json \
|
||||||
|
--mount=type=bind,source=composer.lock,target=composer.lock \
|
||||||
|
--mount=type=cache,target=/tmp/cache \
|
||||||
|
composer install --no-dev --no-interaction
|
||||||
|
|
||||||
|
FROM php:8.3-fpm AS run
|
||||||
|
|
||||||
|
ARG DB_CONNECTION
|
||||||
|
|
||||||
|
WORKDIR /var/www/html
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
libpq-dev
|
||||||
|
|
||||||
|
|
||||||
|
RUN docker-php-ext-install pdo_pgsql
|
||||||
|
|
||||||
|
COPY --from=build /var/www/html/vendor /var/www/html/vendor
|
||||||
@@ -5,6 +5,11 @@ declare(strict_types=1);
|
|||||||
namespace Lewisdale\App\Controllers;
|
namespace Lewisdale\App\Controllers;
|
||||||
|
|
||||||
use Doctrine\Persistence\ObjectRepository;
|
use Doctrine\Persistence\ObjectRepository;
|
||||||
|
use Lewisdale\App\Models\Data\Feed;
|
||||||
|
use Lewisdale\App\Models\Data\FeedFilter;
|
||||||
|
use Lewisdale\App\Models\Data\FilterTarget;
|
||||||
|
use Lewisdale\App\Models\Data\FilterType;
|
||||||
|
use Lewisdale\App\Models\Repositories\FeedFilterRepository;
|
||||||
use Lewisdale\App\Models\Repositories\FeedRepository;
|
use Lewisdale\App\Models\Repositories\FeedRepository;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
@@ -16,20 +21,26 @@ class FeedController
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly Twig $view,
|
private readonly Twig $view,
|
||||||
private readonly LoggerInterface $logger,
|
private readonly LoggerInterface $logger,
|
||||||
private readonly FeedRepository $feedRepository
|
private readonly FeedRepository $feedRepository,
|
||||||
|
private readonly FeedFilterRepository $feedFilterRepository,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function get(ServerRequestInterface $request, ResponseInterface $response)
|
public function get(ServerRequestInterface $request, ResponseInterface $response)
|
||||||
{
|
{
|
||||||
$this->logger->info("FeedController::get() called");
|
$this->logger->info("FeedController::get() called");
|
||||||
$feeds = $this->feedRepository->findBy([], ['title' => 'ASC']);
|
$feeds = $this->feedRepository->findBy([], ['title' => 'ASC']);
|
||||||
return $this->view->render($response, 'index.twig.html', ['feeds' => $feeds]);
|
return $this->view->render($response, 'feed/index.twig.html', ['feeds' => $feeds]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_feed(ServerRequestInterface $request, ResponseInterface $response)
|
public function get_feed(ServerRequestInterface $request, ResponseInterface $response)
|
||||||
{
|
{
|
||||||
$this->logger->info("FeedController::get_feed() called");
|
$this->logger->info("FeedController::get_feed() called");
|
||||||
$feed = $this->feedRepository->find($request->getAttribute('id'));
|
$feed = $this->feedRepository->find($request->getAttribute('id'));
|
||||||
|
|
||||||
|
if (empty($feed)) {
|
||||||
|
return $response->withStatus(404);
|
||||||
|
}
|
||||||
|
|
||||||
$filtered = $feed->get_filtered_feed();
|
$filtered = $feed->get_filtered_feed();
|
||||||
|
|
||||||
$body = $response->getBody();
|
$body = $response->getBody();
|
||||||
@@ -45,8 +56,58 @@ class FeedController
|
|||||||
public function create(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface
|
public function create(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface
|
||||||
{
|
{
|
||||||
$this->logger->info("FeedController::create() called");
|
$this->logger->info("FeedController::create() called");
|
||||||
|
|
||||||
|
$feed = $this->feedRepository->find($request->getAttribute('id'));
|
||||||
|
|
||||||
|
return $this->view->render($response, 'feed/edit.twig.html', ['FilterTypes' => FilterType::cases(), 'FilterTargets' => FilterTarget::cases(), 'feed' => $feed ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function save(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface
|
||||||
|
{
|
||||||
|
$this->logger->info("FeedController::save() called");
|
||||||
|
|
||||||
$body = $request->getParsedBody();
|
$body = $request->getParsedBody();
|
||||||
|
|
||||||
return $this->view->render($response, 'create.twig.html');
|
$id = $request->getAttribute('id');
|
||||||
|
|
||||||
|
$feed = $id ? $this->feedRepository->find($request->getAttribute('id')) : new Feed();
|
||||||
|
|
||||||
|
$feed->title = $body['title'];
|
||||||
|
$feed->url = $body['url'];
|
||||||
|
|
||||||
|
$this->feedRepository->save($feed);
|
||||||
|
|
||||||
|
foreach ($body['feedFilters'] as $filter) {
|
||||||
|
$this->logger->info("Creating filter", ['filter' => $filter, 'post' => $_POST]);
|
||||||
|
|
||||||
|
$f = $filter['id'] ? $this->feedFilterRepository->find($filter['id']) : new FeedFilter(
|
||||||
|
FilterTarget::from($filter['target']),
|
||||||
|
FilterType::from($filter['type']),
|
||||||
|
$filter['value'],
|
||||||
|
$feed
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($f !== null && $filter['id']) {
|
||||||
|
$f->filter = FilterType::from($filter['type']);
|
||||||
|
$f->target = FilterTarget::from($filter['target']);
|
||||||
|
$f->value = $filter['value'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->feedFilterRepository->save($f);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response->withStatus(302)->withHeader('Location', "/feed");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface
|
||||||
|
{
|
||||||
|
$this->logger->info("FeedController::delete() called");
|
||||||
|
$feed = $this->feedRepository->find($request->getAttribute('id'));
|
||||||
|
if (empty($feed)) {
|
||||||
|
return $response->withStatus(404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->feedRepository->delete($feed);
|
||||||
|
return $response->withStatus(302)->withHeader('Location', '/feed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,7 @@ use Psr\Http\Message\ServerRequestInterface;
|
|||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Slim\Views\Twig;
|
use Slim\Views\Twig;
|
||||||
|
|
||||||
class SampleController
|
class HomeController
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly Twig $view,
|
private readonly Twig $view,
|
||||||
@@ -17,7 +17,7 @@ class SampleController
|
|||||||
|
|
||||||
public function get(ServerRequestInterface $request, ResponseInterface $response)
|
public function get(ServerRequestInterface $request, ResponseInterface $response)
|
||||||
{
|
{
|
||||||
$this->logger->info("SampleController::get() called");
|
$this->logger->info("HomeController::get() called");
|
||||||
return $this->view->render($response, 'index.twig.html');
|
return $this->view->render($response, 'index.twig.html');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Lewisdale\App\Controllers;
|
||||||
|
|
||||||
|
use Lewisdale\App\Models\Repositories\UserRepository;
|
||||||
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
use Slim\Views\Twig;
|
||||||
|
|
||||||
|
class LoginController {
|
||||||
|
function __construct(
|
||||||
|
private readonly Twig $view,
|
||||||
|
private readonly UserRepository $users,
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface {
|
||||||
|
return $this->view->render($response, 'account/login.twig.html', []);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function login(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface {
|
||||||
|
$body = $request->getParsedBody();
|
||||||
|
$email = $body['email'];
|
||||||
|
$password = $body['password'];
|
||||||
|
|
||||||
|
$user = $this->users->validateCredentials($email, $password);
|
||||||
|
|
||||||
|
if (!$user) {
|
||||||
|
return $this->view->render($response, 'account/login.twig.html', ['error' => 'Invalid email or password']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$_SESSION['user'] = $user->id;
|
||||||
|
|
||||||
|
return $response->withStatus(302)->withHeader('Location', '/feed');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -48,6 +48,10 @@ class Feed
|
|||||||
#[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE, nullable: true)]
|
#[ORM\Column(type: Types::DATETIMETZ_IMMUTABLE, nullable: true)]
|
||||||
public \DateTimeInterface|null $lastFetched;
|
public \DateTimeInterface|null $lastFetched;
|
||||||
|
|
||||||
|
#[ORM\ManyToOne(targetEntity: User::class, cascade: ['persist', 'remove'], inversedBy: 'feeds')]
|
||||||
|
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id')]
|
||||||
|
public User|null $user;
|
||||||
|
|
||||||
public function fetch(): void
|
public function fetch(): void
|
||||||
{
|
{
|
||||||
if (Robots::allowed($this->url)) {
|
if (Robots::allowed($this->url)) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Lewisdale\App\Models\Data;
|
namespace Lewisdale\App\Models\Data;
|
||||||
|
|
||||||
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Lewisdale\App\Models\Traits\AutoUpdate;
|
use Lewisdale\App\Models\Traits\AutoUpdate;
|
||||||
use Lewisdale\App\Models\View;
|
use Lewisdale\App\Models\View;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
@@ -18,7 +19,7 @@ class User
|
|||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
#[ORM\Column(type: 'integer')]
|
#[ORM\Column(type: 'integer')]
|
||||||
#[ORM\GeneratedValue]
|
#[ORM\GeneratedValue]
|
||||||
private ?int $id;
|
public ?int $id;
|
||||||
#[ORM\Column(type: 'string')]
|
#[ORM\Column(type: 'string')]
|
||||||
private string $password;
|
private string $password;
|
||||||
#[ORM\Column(type: 'string')]
|
#[ORM\Column(type: 'string')]
|
||||||
@@ -26,6 +27,12 @@ class User
|
|||||||
#[ORM\Column(type: 'string')]
|
#[ORM\Column(type: 'string')]
|
||||||
private string $salt;
|
private string $salt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Collection<Feed>
|
||||||
|
*/
|
||||||
|
#[ORM\OneToMany(mappedBy: 'user', targetEntity: Feed::class, cascade: ['persist', 'remove'])]
|
||||||
|
public Collection $feeds;
|
||||||
|
|
||||||
function __construct(
|
function __construct(
|
||||||
string $password,
|
string $password,
|
||||||
string $email,
|
string $email,
|
||||||
|
|||||||
@@ -15,4 +15,10 @@ class FeedFilterRepository extends EntityRepository
|
|||||||
{
|
{
|
||||||
parent::__construct($em, $em->getClassMetadata(FeedFilter::class));
|
parent::__construct($em, $em->getClassMetadata(FeedFilter::class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function save(FeedFilter $filter): void
|
||||||
|
{
|
||||||
|
$this->getEntityManager()->persist($filter);
|
||||||
|
$this->getEntityManager()->flush();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -21,4 +21,10 @@ class FeedRepository extends EntityRepository
|
|||||||
$this->_em->persist($feed);
|
$this->_em->persist($feed);
|
||||||
$this->_em->flush();
|
$this->_em->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delete(Feed $feed): void
|
||||||
|
{
|
||||||
|
$this->_em->remove($feed);
|
||||||
|
$this->_em->flush();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
|
||||||
|
namespace Lewisdale\App\Models\Repositories;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityManager;
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
use Lewisdale\App\Models\Data\User;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
use function DI\string;
|
||||||
|
|
||||||
|
/** @extends EntityRepository<User> */
|
||||||
|
class UserRepository extends EntityRepository {
|
||||||
|
private readonly LoggerInterface $logger;
|
||||||
|
|
||||||
|
public function __construct(EntityManager $em, LoggerInterface $logger)
|
||||||
|
{
|
||||||
|
parent::__construct($em, $em->getClassMetadata(User::class));
|
||||||
|
$this->logger = $logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findByEmail(string $email): ?User {
|
||||||
|
return $this->findOneBy(['email' => $email]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function validateCredentials(string $email, string $password): ?User {
|
||||||
|
$user = $this->findByEmail($email);
|
||||||
|
if (!$user || !$user->validate($password)) {
|
||||||
|
$this->logger->warning('Invalid credentials.', ['email' => $email, 'password' => $password, 'user' => $user, 'valid' => $user?->validate($password)]);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function save(User $user): void {
|
||||||
|
$this->_em->persist($user);
|
||||||
|
$this->_em->flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Lewisdale\App\Session;
|
||||||
|
|
||||||
|
use Lewisdale\App\Models\Repositories\UserRepository;
|
||||||
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
use Psr\Http\Server\MiddlewareInterface;
|
||||||
|
use Psr\Http\Server\RequestHandlerInterface;
|
||||||
|
use Slim\Psr7\Response;
|
||||||
|
|
||||||
|
class LoginMiddleware implements MiddlewareInterface {
|
||||||
|
|
||||||
|
function __construct(
|
||||||
|
private readonly UserRepository $users,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
private function redirectToLogin(): ResponseInterface {
|
||||||
|
$response = new Response(302);
|
||||||
|
return $response->withHeader('Location', '/account/login');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||||
|
{
|
||||||
|
if (!isset($_SESSION['user'])) {
|
||||||
|
return $this->redirectToLogin();
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = $this->users->find($_SESSION['user']);
|
||||||
|
|
||||||
|
if (!$user) {
|
||||||
|
return $this->redirectToLogin();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $handler->handle($request->withAttribute('user', $user));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
|
||||||
|
namespace Lewisdale\App\Tools\Console;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityManager;
|
||||||
|
use Doctrine\ORM\Tools\Console\Command\SchemaTool\AbstractCommand;
|
||||||
|
use Lewisdale\App\Models\Data\User;
|
||||||
|
use Lewisdale\App\Models\Repositories\FeedRepository;
|
||||||
|
use Lewisdale\App\Models\Repositories\UserRepository;
|
||||||
|
use Symfony\Component\Console\Attribute\AsCommand;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
|
#[AsCommand(name: 'user:create', description: 'Create a user')]
|
||||||
|
class CreateUser extends Command {
|
||||||
|
public function __construct(private readonly EntityManager $em,
|
||||||
|
private readonly UserRepository $userRepository)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function configure(): void {
|
||||||
|
$this->addArgument('email', InputArgument::REQUIRED, "The user's email address")
|
||||||
|
->addArgument('password', InputArgument::REQUIRED, "The user's password");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(InputInterface $input, OutputInterface $output): int {
|
||||||
|
$email = $input->getArgument('email');
|
||||||
|
$password = $input->getArgument('password');
|
||||||
|
|
||||||
|
$user = $this->userRepository->findOneBy(['email' => $email]);
|
||||||
|
if ($user !== null) {
|
||||||
|
$output->writeln('<error>User with email ' . $email . ' already exists.</error>');
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = new User('', $email);
|
||||||
|
$user->updatePassword($password);
|
||||||
|
|
||||||
|
$this->userRepository->save($user);
|
||||||
|
$output->writeln("<info>User $email created!</info>");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
+25
-6
@@ -1,10 +1,15 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
use Lewisdale\App\Controllers\FeedController;
|
use Lewisdale\App\Controllers\FeedController;
|
||||||
use Lewisdale\App\Controllers\SampleController;
|
use Lewisdale\App\Controllers\HomeController;
|
||||||
|
use Lewisdale\App\Controllers\LoginController;
|
||||||
|
use Lewisdale\App\Session\LoginMiddleware;
|
||||||
|
use Slim\Routing\RouteCollectorProxy;
|
||||||
use Slim\Views\TwigMiddleware;
|
use Slim\Views\TwigMiddleware;
|
||||||
|
|
||||||
ini_set('user_agent', 'Baleen/1.0 (https://lewisdale.dev)');
|
ini_set('user_agent', 'Baleen/1.0 (https://baleen.lewisdale.dev)');
|
||||||
|
ini_set('session.name', 'sessid');
|
||||||
|
ini_set('session.cookie_samesite', 'Lax');
|
||||||
|
|
||||||
require_once __DIR__ . "/dependencies.php";
|
require_once __DIR__ . "/dependencies.php";
|
||||||
|
|
||||||
@@ -12,18 +17,32 @@ global $container;
|
|||||||
global $app;
|
global $app;
|
||||||
|
|
||||||
$dotenv = Dotenv\Dotenv::createImmutable([__DIR__, __DIR__ . "/.."]);
|
$dotenv = Dotenv\Dotenv::createImmutable([__DIR__, __DIR__ . "/.."]);
|
||||||
$dotenv->load();
|
$dotenv->safeLoad();
|
||||||
|
|
||||||
require_once __DIR__ . "/session.php";
|
require_once __DIR__ . "/session.php";
|
||||||
|
|
||||||
$app->add(TwigMiddleware::createFromContainer($app));
|
$app->add(TwigMiddleware::createFromContainer($app));
|
||||||
$app->add('csrf');
|
$app->add('csrf');
|
||||||
|
|
||||||
$app->get("/", [SampleController::class, 'get']);
|
$app->get("/", [HomeController::class, 'get']);
|
||||||
|
|
||||||
$app->get('/feed', [FeedController::class, 'get']);
|
$app->group('/feed', function (RouteCollectorProxy $group) use ($app) {
|
||||||
|
$group->get('[/]', [FeedController::class, 'get'])->add(LoginMiddleware::class);
|
||||||
|
$group->post('[/]', [FeedController::class, 'save'])->add(LoginMiddleware::class);
|
||||||
|
|
||||||
$app->get('/feed/{id}', [FeedController::class, 'get_feed']);
|
$group->get('/new', [FeedController::class, 'create'])->add(LoginMiddleware::class);
|
||||||
|
|
||||||
|
$group->get('/{id}', [FeedController::class, 'get_feed']);
|
||||||
|
$group->post('/{id}', [FeedController::class, 'save'])->add(LoginMiddleware::class);
|
||||||
|
|
||||||
|
$group->get('/{id}/delete', [FeedController::class, 'delete'])->add(LoginMiddleware::class);
|
||||||
|
$group->get('/{id}/edit', [FeedController::class, 'create'])->add(LoginMiddleware::class);
|
||||||
|
});
|
||||||
|
|
||||||
|
$app->group('/account', function (RouteCollectorProxy $group) use ($app, $container) {
|
||||||
|
$group->get('/login', [LoginController::class, 'index']);
|
||||||
|
$group->post('/login', [LoginController::class, 'login']);
|
||||||
|
});
|
||||||
|
|
||||||
$app->addErrorMiddleware(true, true, true);
|
$app->addErrorMiddleware(true, true, true);
|
||||||
|
|
||||||
|
|||||||
@@ -49,12 +49,14 @@ $container->set(EntityManager::class, static function() {
|
|||||||
isDevMode: true,
|
isDevMode: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
$dsnParser = new DsnParser();
|
$dsnParser = new DsnParser(['postgres' => 'pdo_pgsql']);
|
||||||
$params = $dsnParser->parse($_ENV["DB_CONNECTION"]);
|
$params = $dsnParser->parse($_ENV["DB_CONNECTION"]);
|
||||||
|
|
||||||
$connection = DriverManager::getConnection($params, $config);
|
$connection = DriverManager::getConnection($params, $config);
|
||||||
|
|
||||||
$connection->executeQuery("PRAGMA foreign_keys = ON");
|
if ($params['driver'] === 'sqlite3' || $params['driver'] === 'pdo_sqlite') {
|
||||||
|
$connection->executeQuery("PRAGMA foreign_keys = ON");
|
||||||
|
}
|
||||||
|
|
||||||
return new EntityManager($connection, $config);
|
return new EntityManager($connection, $config);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
{% macro filterBlock(ctx, idx, type, target, value, id) %}
|
||||||
|
<fieldset>
|
||||||
|
<legend>Filter</legend>
|
||||||
|
<input type="hidden" name="feedFilters[{{ idx }}][id]" value="{{ id }}"/>
|
||||||
|
|
||||||
|
<label for="target">Filter target:</label>
|
||||||
|
<select name="feedFilters[{{ idx }}][target]" id="target">
|
||||||
|
{% for filterTarget in ctx.FilterTargets %}
|
||||||
|
<option value="{{ filterTarget.value }}" {% if filterTarget.value is same as(target) %}selected{% endif %}>{{ filterTarget.name | capitalize }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<label for="type">Filter type: </label>
|
||||||
|
<select name="feedFilters[{{ idx }}][type]" id="type">
|
||||||
|
{% for filterType in ctx.FilterTypes %}
|
||||||
|
<option value="{{ filterType.value }}" {% if filterType is same as(type) %}selected{% endif %}>{{ filterType.name | capitalize }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<label for="value">Filter value:</label>
|
||||||
|
<input type="text" name="feedFilters[{{ idx }}][value]" id="value" value="{{ value }}" />
|
||||||
|
</fieldset>
|
||||||
|
{% endmacro %}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<h1>Login</h1>
|
||||||
|
|
||||||
|
<form method="post">
|
||||||
|
{{ csrf() | raw }}
|
||||||
|
|
||||||
|
{% if error %}
|
||||||
|
<div class="alert alert-danger">{{ error }}</div>
|
||||||
|
{% endif %}
|
||||||
|
<label for="email">Email address</label>
|
||||||
|
<input id="email" type="email" name="email" placeholder="Email" required />
|
||||||
|
|
||||||
|
<label for="password">Password</label>
|
||||||
|
<input id="password" type="password" name="password" placeholder="Password" required minlength="8" />
|
||||||
|
|
||||||
|
<button type="submit">Login</button>
|
||||||
|
</form>
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
{% from "_includes/filterBlock.twig.html" import filterBlock %}
|
||||||
|
|
||||||
|
<h1>Create feed</h1>
|
||||||
|
|
||||||
|
<form method="POST" action="/feed/{{ feed.id }}">
|
||||||
|
{{ csrf() | raw }}
|
||||||
|
|
||||||
|
<input type="hidden" name="id" value="{{ feed.id }}"/>
|
||||||
|
|
||||||
|
<label for="url">
|
||||||
|
Feed URL
|
||||||
|
</label>
|
||||||
|
<input type="text" inputmode="url" name="url" value="{{ feed.url }}" id="url"/>
|
||||||
|
|
||||||
|
<label for="title">
|
||||||
|
Title
|
||||||
|
</label>
|
||||||
|
<input type="text" inputmode="title" name="title" value="{{ feed.title }}" id="title"/>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<legend>Filters</legend>
|
||||||
|
|
||||||
|
{% for filter in feed.feedFilters %}
|
||||||
|
{{ filterBlock(_context, loop.index0, filter.filter, filter.target, filter.value, filter.id) }}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{{ filterBlock(_context, (feed.feedFilters | length)) }}
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<button type="submit">Save feed</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<h1>Your feeds</h1>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<th>Title</th>
|
||||||
|
<th>Actions</th>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for feed in feeds %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ feed.title }}</td>
|
||||||
|
<td>
|
||||||
|
<a href="/feed/{{ feed.id }}">Link to feed</a>
|
||||||
|
<a href="/feed/{{ feed.id }}/edit">Edit feed</a>
|
||||||
|
<a href="/feed/{{ feed.id }}/delete">Delete</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
<h1>Hello, world.</h1>
|
<h1>Baleen</h1>
|
||||||
|
|
||||||
<p>This is a boilerplate PHP app. You should start by adding some routes, controllers, and maybe making me look
|
<p>This is Baleen, an RSS and Podcast feed filtering application. If you're here because you've spotted the user agent in your logs, it's because someone is using this application to produce a filtered RSS feed.</p>
|
||||||
good.</p>
|
|
||||||
|
<p>Baleen will always use the user agent <code>Baleen/1.0 (https://baleen.lewisdale.dev)</code>, and should respect robots.txt.</p>
|
||||||
|
|
||||||
|
<p>If you're blocking Baleen, but we're still appearing in your logs, please get in touch with <a href="https://lewisdale.dev/links/">the developer</a>, as this is likely a bug in the software.</p>
|
||||||
Reference in new issue
Block a user