Compare commits
7 Commits
da6a8f86c2
...
feature/fl
| Author | SHA1 | Date | |
|---|---|---|---|
| 5fbd555bb3 | |||
| de4915972c | |||
| 9c2405dd3f | |||
|
|
f772532309 | ||
|
|
17159e811f | ||
|
|
76d8b7d9cf | ||
|
|
f30304cbe9 |
@@ -1,3 +1,3 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
[ -z "$1" ] && echo "Please specify a Composer command (ex. install)" && exit
|
[ -z "$1" ] && bin/cli composer list && exit
|
||||||
bin/cli composer "$@"
|
bin/cli composer "$@"
|
||||||
@@ -21,15 +21,13 @@ class ScrapeWebsite extends Command
|
|||||||
{
|
{
|
||||||
private Client $client;
|
private Client $client;
|
||||||
|
|
||||||
|
public function __construct(protected Capsule $database)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
protected function configure(): void
|
protected function configure(): void
|
||||||
{
|
{
|
||||||
$capsule = new Capsule;
|
|
||||||
$capsule->addConnection([
|
|
||||||
'driver' => 'sqlite',
|
|
||||||
'database' => __DIR__ . '/../../database.sqlite',
|
|
||||||
]);
|
|
||||||
$capsule->setAsGlobal();
|
|
||||||
$capsule->bootEloquent();
|
|
||||||
$this->client = new Client();
|
$this->client = new Client();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,11 +11,7 @@ class BaseController extends AbstractController
|
|||||||
{
|
{
|
||||||
protected Environment $twig;
|
protected Environment $twig;
|
||||||
|
|
||||||
public function __construct(protected FilesystemAdapter $cache)
|
public function __construct(protected FilesystemAdapter $cache, protected Capsule $database)
|
||||||
{
|
{
|
||||||
$capsule = new Capsule;
|
|
||||||
$capsule->addConnection(['driver' => 'sqlite', 'database' => __DIR__ . '/../../database.sqlite']);
|
|
||||||
$capsule->setAsGlobal();
|
|
||||||
$capsule->bootEloquent();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14
src/DatabaseFactory.php
Normal file
14
src/DatabaseFactory.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Krzysiej\RyobiCrawler;
|
||||||
|
|
||||||
|
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||||
|
class DatabaseFactory
|
||||||
|
{
|
||||||
|
public static function create(Capsule $capsule): void
|
||||||
|
{
|
||||||
|
$capsule->addConnection(['driver' => 'sqlite', 'database' => __DIR__ . '/../database.sqlite']);
|
||||||
|
$capsule->setAsGlobal();
|
||||||
|
$capsule->bootEloquent();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Krzysiej\RyobiCrawler;
|
namespace Krzysiej\RyobiCrawler;
|
||||||
|
|
||||||
|
use Illuminate\Database\Capsule\Manager;
|
||||||
use Krzysiej\RyobiCrawler\Twig\AppExtension;
|
use Krzysiej\RyobiCrawler\Twig\AppExtension;
|
||||||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
||||||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
|
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
|
||||||
@@ -34,8 +35,9 @@ class Kernel extends BaseKernel
|
|||||||
'secret' => 'S0ME_SECRET'
|
'secret' => 'S0ME_SECRET'
|
||||||
]);
|
]);
|
||||||
$services = $container->services()->defaults()->autowire()->autoconfigure();
|
$services = $container->services()->defaults()->autowire()->autoconfigure();
|
||||||
|
$services->set(Manager::class)->configurator([DatabaseFactory::class, 'create']);
|
||||||
$services->load('Krzysiej\\RyobiCrawler\\', __DIR__ )
|
$services->load('Krzysiej\\RyobiCrawler\\', __DIR__ )
|
||||||
->exclude('../src/{Models,Twig,Kernel.php}');
|
->exclude('../src/{Models,Twig,DatabaseFactory.php,Kernel.php}');
|
||||||
$services->set('twig.extension.cache', AppExtension::class)->tag('twig.extension');
|
$services->set('twig.extension.cache', AppExtension::class)->tag('twig.extension');
|
||||||
$services->set(CacheExtension::class)->tag('twig.extension');
|
$services->set(CacheExtension::class)->tag('twig.extension');
|
||||||
$services->set(FilesystemAdapter::class)->args([
|
$services->set(FilesystemAdapter::class)->args([
|
||||||
|
|||||||
@@ -3,21 +3,22 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
{% cache 'list_' ~ listType %}
|
{% cache 'list_' ~ listType %}
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class='table table-hover'>
|
{# <table class='table table-hover'>#}
|
||||||
<thead>
|
{# <thead>#}
|
||||||
<tr>
|
{# <tr>#}
|
||||||
<th></th>
|
{# <th></th>#}
|
||||||
<th></th>
|
{# <th></th>#}
|
||||||
<th>Name</th>
|
{# <th>Name</th>#}
|
||||||
<th>Categories</th>
|
{# <th>Categories</th>#}
|
||||||
<th></th>
|
{# <th></th>#}
|
||||||
<th class="text-end">Lowest Price</th>
|
{# <th class="text-end">Lowest Price</th>#}
|
||||||
<th class="text-end">Current Price</th>
|
{# <th class="text-end">Current Price</th>#}
|
||||||
<th></th>
|
{# <th></th>#}
|
||||||
</tr>
|
{# </tr>#}
|
||||||
</thead>
|
{# </thead>#}
|
||||||
{% for product in products %}
|
{% for product in products %}
|
||||||
<tr>
|
<div class="d-inline-flex">
|
||||||
|
|
||||||
<td class="align-middle font-weight-bold h3"><a class="text-warning text-decoration-none"
|
<td class="align-middle font-weight-bold h3"><a class="text-warning text-decoration-none"
|
||||||
href="{{ path('app_star', {'productId': product.id}) }}">{% if product.starred == true %}★{% else %} ☆ {% endif %}</a></td>
|
href="{{ path('app_star', {'productId': product.id}) }}">{% if product.starred == true %}★{% else %} ☆ {% endif %}</a></td>
|
||||||
<td class="align-middle" style="width: 120px;"><img src='{{ product.image }}&width=70' class='img-thumbnail' alt='{{ product.name }}'/></td>
|
<td class="align-middle" style="width: 120px;"><img src='{{ product.image }}&width=70' class='img-thumbnail' alt='{{ product.name }}'/></td>
|
||||||
@@ -56,9 +57,9 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
{# </table>#}
|
||||||
</div>
|
</div>
|
||||||
{% endcache %}
|
{% endcache %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user