Compare commits
4 Commits
feature/ta
...
feature/or
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2e4c79c87a | ||
|
|
c947e470af | ||
|
|
8eeba225ed | ||
|
|
9b6bcd22be |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,6 +1,5 @@
|
||||
/vendor/
|
||||
.idea
|
||||
*.sqlite
|
||||
database.sqlite
|
||||
var/cache/
|
||||
.env.local
|
||||
/node_modules/
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
FROM php:8.3-cli
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
ENV PHP_MEMORY_LIMIT=1500M
|
||||
RUN echo "memory_limit=1500M" > /usr/local/etc/php/conf.d/memory-limit.ini
|
||||
ENV PHP_MEMORY_LIMIT=512M
|
||||
RUN echo "memory_limit=512M" > /usr/local/etc/php/conf.d/memory-limit.ini
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git \
|
||||
unzip \
|
||||
libicu-dev \
|
||||
libzip-dev \
|
||||
nodejs \
|
||||
npm
|
||||
libzip-dev
|
||||
|
||||
RUN docker-php-ext-install zip intl
|
||||
|
||||
|
||||
11
README.md
11
README.md
@@ -4,7 +4,7 @@
|
||||
|
||||
1. Clone repository using `git clone https://git.techtube.pl/krzysiej/ryobi-crawler.git`
|
||||
2. Cd into project directory `cd ryobi-crawler`
|
||||
3. Build and start docker container `docker compose up -d --build --force-recreate`
|
||||
3. Build and start docker container `docker compose up -d`
|
||||
4. Run `docker compose exec php-app php console.php app:migrate` file to create `database.sqlite` and create tables.
|
||||
5. Run `docker compose exec php-app php console.php app:scrape` command to scrape all the products from the ryobi website.
|
||||
6. Access web interface using `localhost:9001` address in web browser.
|
||||
@@ -17,17 +17,10 @@
|
||||
3. Refresh cache on production by removing cache directory: `rm -rf var/cache`
|
||||
4. Start and build image in one go with command: `docker compose up -d --build --force-recreate`
|
||||
|
||||
## Bonus
|
||||
|
||||
### Install composer package
|
||||
|
||||
1. Run `bin/composer require vendor/package-name`
|
||||
|
||||
|
||||
## Running Cron
|
||||
|
||||
For now only way of running `app:scrape` command on schedule is to use host crontab.
|
||||
1. Run `crontab -e` command to edit a host crontab job file
|
||||
1. Run `crontab -e` command to edit host crontab job file
|
||||
2. Add a new line with e.g. line like this `0 1 * * * cd /var/project/directory/ && docker compose exec php-app php console.php app:scrape`
|
||||
3. Save and exit file editor. Cron will execute `app:scrape` once per day.
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
bin/cli rm -rf var/cache
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
[ -z "$1" ] && echo "Please specify a Composer command (ex. install)" && exit
|
||||
bin/cli composer "$@"
|
||||
@@ -11,9 +11,7 @@
|
||||
"symfony/twig-bundle": "^7.1",
|
||||
"symfony/dotenv": "^7.1",
|
||||
"twig/intl-extra": "^3.13",
|
||||
"twig/extra-bundle": "^3.13",
|
||||
"symfony/cache": "^7.2",
|
||||
"twig/cache-extra": "^3.21"
|
||||
"twig/extra-bundle": "^3.13"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
||||
803
composer.lock
generated
803
composer.lock
generated
File diff suppressed because it is too large
Load Diff
14
console.php
14
console.php
@@ -2,16 +2,18 @@
|
||||
|
||||
include_once 'vendor/autoload.php';
|
||||
|
||||
use Krzysiej\RyobiCrawler\Kernel;
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use Krzysiej\RyobiCrawler\Command\Migrate;
|
||||
use Krzysiej\RyobiCrawler\Command\ScrapeWebsite;
|
||||
|
||||
use Symfony\Component\Console\Application;
|
||||
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
header('Location: browser.php');
|
||||
echo 'Execute this script in cli only';
|
||||
exit;
|
||||
}
|
||||
$kernel = new Kernel('dev', true);
|
||||
$application = new Application($kernel);
|
||||
$application->setName('Ryobi website scraper application');
|
||||
$application->setVersion('1.2.0');
|
||||
|
||||
$application = new Application('Ryobi website scraper application', '1.1.1');
|
||||
$application->add(new ScrapeWebsite());
|
||||
$application->add(new Migrate());
|
||||
$application->run();
|
||||
|
||||
37
index.php
37
index.php
@@ -1,11 +1,46 @@
|
||||
<?php
|
||||
|
||||
use Krzysiej\RyobiCrawler\Kernel;
|
||||
use Krzysiej\RyobiCrawler\Twig\AppExtension;
|
||||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symfony\Component\Dotenv\Dotenv;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
|
||||
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
|
||||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
class Kernel extends BaseKernel
|
||||
{
|
||||
use MicroKernelTrait;
|
||||
|
||||
public function registerBundles(): iterable
|
||||
{
|
||||
return [
|
||||
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
|
||||
new Symfony\Bundle\TwigBundle\TwigBundle(),
|
||||
new Twig\Extra\TwigExtraBundle\TwigExtraBundle(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function configureContainer(ContainerConfigurator $container): void
|
||||
{
|
||||
$container->extension('framework', [
|
||||
'secret' => 'S0ME_SECRET'
|
||||
]);
|
||||
$container->services()
|
||||
->load('Krzysiej\\RyobiCrawler\\Controller\\', __DIR__.'/src/Controller/*')
|
||||
->autowire()
|
||||
->autoconfigure()
|
||||
;
|
||||
$container->services()->set(AppExtension::class)->tag('twig.extension');
|
||||
}
|
||||
|
||||
protected function configureRoutes(RoutingConfigurator $routes): void
|
||||
{
|
||||
$routes->import(__DIR__.'/src/Controller/', 'attribute');
|
||||
}
|
||||
}
|
||||
(new Dotenv())->bootEnv(__DIR__.'/.env');
|
||||
|
||||
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
|
||||
|
||||
1079
package-lock.json
generated
1079
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
20
package.json
20
package.json
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"name": "ryobi-crawler",
|
||||
"version": "1.0.0",
|
||||
"description": "## Project start",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"dev": "npx @tailwindcss/cli -i ./templates/input/style.css -o ./templates/output/style.css --watch"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.techtube.pl/krzysiej/ryobi-crawler.git"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@tailwindcss/cli": "^4.1.7",
|
||||
"tailwindcss": "^4.1.7"
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Krzysiej\RyobiCrawler\Command;
|
||||
|
||||
use Symfony\Component\Console\Helper\ProgressBar;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use Krzysiej\RyobiCrawler\Models\Product;
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Twig\Environment;
|
||||
|
||||
#[AsCommand(name: 'app:cache:warm-twig', description: '')]
|
||||
class CacheWarmCommand extends Command
|
||||
{
|
||||
public function __construct(
|
||||
private Environment $twig,
|
||||
private RequestStack $requestStack,
|
||||
private FilesystemAdapter $cache,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$this->cache->clear();
|
||||
|
||||
$capsule = new Capsule;
|
||||
$capsule->addConnection([
|
||||
'driver' => 'sqlite',
|
||||
'database' => __DIR__ . '/../../database.sqlite',
|
||||
]);
|
||||
$capsule->setAsGlobal();
|
||||
$capsule->bootEloquent();
|
||||
|
||||
$progress = new ProgressBar($output);
|
||||
$progress->start();
|
||||
$products = Product::with([
|
||||
'price' => fn($query) => $query->orderByDesc('created_at'),
|
||||
'stock' => fn($query) => $query->orderByDesc('created_at'),
|
||||
])->get();
|
||||
$progress->setMaxSteps(count($products));
|
||||
|
||||
$request = Request::create('/cache-warm');
|
||||
$this->requestStack->push($request);
|
||||
|
||||
foreach ($products as $product) {
|
||||
$priceList = $product->price()->pluck('price');
|
||||
$stockList = $product->stock()->pluck('stock');
|
||||
$priceDates = $product->price()->pluck('created_at')->map(fn($date) => $date->format('Y-m-d'))->toArray();
|
||||
$stockDates = $product->stock()->pluck('created_at')->map(fn($date) => $date->format('Y-m-d'))->toArray();
|
||||
$this->twig->render('product.html.twig', [
|
||||
'product' => $product,
|
||||
'price_list' => $this->prepareChartData($priceDates, $priceList),
|
||||
'stock_list' => $this->prepareChartData($stockDates, $stockList),
|
||||
'price_dates' => implode("','", $priceDates),
|
||||
]);
|
||||
$progress->advance();
|
||||
}
|
||||
|
||||
$progress->finish();
|
||||
$output->writeln('');
|
||||
$output->writeln('DONE');
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
private function prepareChartData($set1, $set2): string
|
||||
{
|
||||
$data = [];
|
||||
foreach ($set1 as $key => $value) {
|
||||
$data[] = ['x' => $value, 'y' => $set2[$key]];
|
||||
}
|
||||
$stringData = json_encode($data);
|
||||
|
||||
return str_replace(['"x"', '"y"'], ['x', 'y'], $stringData);
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,9 @@
|
||||
|
||||
namespace Krzysiej\RyobiCrawler\Controller;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Twig\Environment;
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
|
||||
@@ -11,11 +12,26 @@ class BaseController extends AbstractController
|
||||
{
|
||||
protected Environment $twig;
|
||||
|
||||
public function __construct(protected FilesystemAdapter $cache)
|
||||
public function __construct()
|
||||
{
|
||||
$capsule = new Capsule;
|
||||
$capsule->addConnection(['driver' => 'sqlite', 'database' => __DIR__ . '/../../database.sqlite']);
|
||||
$capsule->setAsGlobal();
|
||||
$capsule->bootEloquent();
|
||||
}
|
||||
|
||||
protected function handleOrderProducts(Builder $builder, Request $request): Builder
|
||||
{
|
||||
$builder->orderByDesc('starred')->orderByDesc('created_by');
|
||||
if ($request->query->get('order')) {
|
||||
$orderField = $request->query->get('order');
|
||||
$direction = 'desc';
|
||||
if (str_starts_with($orderField, '-')) {
|
||||
$direction = 'asc';
|
||||
}
|
||||
$builder->orderBy($request->query->get('order'), $direction);
|
||||
}
|
||||
|
||||
return $builder;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,11 +11,7 @@ final class CategoryController extends BaseController
|
||||
#[Route('/category/{category}', name: 'app_category')]
|
||||
public function __invoke(string $category): Response
|
||||
{
|
||||
if($this->cache->getItem('list_category_'.$category)->isHit()) {
|
||||
return $this->render('productList.html.twig', ['listType' => 'category_'.$category]);
|
||||
}
|
||||
|
||||
$products = Product::with(['price', 'lowestPrice'])
|
||||
$products = Product::with('price')
|
||||
->selectRaw('products.*')
|
||||
->distinct('products.id')
|
||||
->fromRaw('products, json_each(products.categories)')
|
||||
@@ -23,7 +19,6 @@ final class CategoryController extends BaseController
|
||||
->orderByDesc('starred')
|
||||
->orderByDesc('created_by')
|
||||
->get();
|
||||
|
||||
return $this->render('productList.html.twig', ['products' => $products, 'listType' => 'category_'.$category]);
|
||||
return $this->render('productList.html.twig', ['products' => $products]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,15 +13,12 @@ final class DiscontinuedController extends BaseController
|
||||
#[Route('/discontinued', name: 'app_discontinued')]
|
||||
public function __invoke(): Response
|
||||
{
|
||||
if($this->cache->getItem('list_discontinued')->isHit()) {
|
||||
return $this->render('productList.html.twig', ['listType' => 'discontinued']);
|
||||
}
|
||||
|
||||
$products = Product::where('updated_at', '<', now()->format('Y-m-d'))
|
||||
->orderByDesc('starred')
|
||||
->orderByDesc('created_by')
|
||||
->with(['currentPrice', 'lowestPrice'])
|
||||
->with(['currentPrice'])
|
||||
->get();
|
||||
return $this->render('productList.html.twig', ['products' => $products, 'listType' => 'discontinued']);
|
||||
return $this->render('productList.html.twig', ['products' => $products]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,22 +3,17 @@
|
||||
namespace Krzysiej\RyobiCrawler\Controller;
|
||||
|
||||
use Krzysiej\RyobiCrawler\Models\Product;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
final class IndexController extends BaseController
|
||||
{
|
||||
#[Route('/', name: 'app_home')]
|
||||
public function __invoke(): Response
|
||||
public function __invoke(Request $request): Response
|
||||
{
|
||||
if ($this->cache->getItem('list_all')->isHit()) {
|
||||
return $this->render('productList.html.twig', ['listType' => 'all']);
|
||||
}
|
||||
$products = Product::with(['currentStock', 'price', 'lowestPrice'])
|
||||
->orderByDesc('starred')
|
||||
->orderByDesc('created_by')
|
||||
->get();
|
||||
|
||||
return $this->render('productList.html.twig', ['products' => $products, 'listType' => 'all']);
|
||||
$products = Product::with(['currentStock', 'price', 'currentPrice']);
|
||||
$products = $this->handleOrderProducts($products, $request)->get();
|
||||
return $this->render('productList.html.twig', ['products' => $products]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,15 +14,12 @@ final class NewController extends BaseController
|
||||
#[Route('/new', name: 'app_new')]
|
||||
public function __invoke(): Response
|
||||
{
|
||||
if($this->cache->getItem('list_new')->isHit()) {
|
||||
return $this->render('productList.html.twig', ['listType' => 'new']);
|
||||
}
|
||||
|
||||
$products = Product::where('created_at', '>', now()->modify('-30 days')->format('Y-m-d'))
|
||||
->orderByDesc('starred')
|
||||
->orderByDesc('name')
|
||||
->orderByDesc('created_by')
|
||||
->with(['currentPrice', 'lowestPrice'])
|
||||
->with(['currentPrice'])
|
||||
->get();
|
||||
return $this->render('productList.html.twig', ['products' => $products, 'listType' => 'new']);
|
||||
return $this->render('productList.html.twig', ['products' => $products]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace Krzysiej\RyobiCrawler\Controller;
|
||||
|
||||
use Krzysiej\RyobiCrawler\Models\Product;
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Twig\Error\LoaderError;
|
||||
@@ -20,10 +19,6 @@ final class ProductController extends BaseController
|
||||
#[Route('/product/{productId<\d+>}', name: 'app_product')]
|
||||
public function __invoke(int $productId): Response
|
||||
{
|
||||
if($this->cache->getItem('product'.$productId)->isHit()) {
|
||||
return $this->render('product.html.twig', ['product' => ['id' => $productId]]);
|
||||
}
|
||||
|
||||
$product = Product::with([
|
||||
'price' => fn($query) => $query->orderBy('created_at', 'desc'),
|
||||
'stock' => fn($query) => $query->orderBy('created_at', 'desc'),
|
||||
|
||||
@@ -12,15 +12,11 @@ final class PromosController extends BaseController
|
||||
#[Route('/promos', name: 'app_promos')]
|
||||
public function __invoke(): Response
|
||||
{
|
||||
if($this->cache->getItem('list_promos')->isHit()) {
|
||||
return $this->render('productList.html.twig', ['listType' => 'promos']);
|
||||
}
|
||||
|
||||
$products = Product::whereHas('currentPrice', fn(Builder $query) => $query->whereColumn('price', '<', 'productStandardPrice'))
|
||||
->orderByDesc('starred')
|
||||
->orderByDesc('created_by')
|
||||
->with(['currentPrice', 'lowestPrice'])
|
||||
->with(['currentPrice'])
|
||||
->get();
|
||||
return $this->render('productList.html.twig', ['products' => $products, 'listType' => 'promos']);
|
||||
return $this->render('productList.html.twig', ['products' => $products]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Krzysiej\RyobiCrawler;
|
||||
|
||||
use Krzysiej\RyobiCrawler\Twig\AppExtension;
|
||||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
||||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
|
||||
use Symfony\Bundle\TwigBundle\TwigBundle;
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
|
||||
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
|
||||
use Twig\Extra\Cache\CacheExtension;
|
||||
use Twig\Extra\Cache\CacheRuntime;
|
||||
use Twig\Extra\TwigExtraBundle\TwigExtraBundle;
|
||||
|
||||
class Kernel extends BaseKernel
|
||||
{
|
||||
use MicroKernelTrait;
|
||||
|
||||
public function registerBundles(): iterable
|
||||
{
|
||||
return [
|
||||
new FrameworkBundle(),
|
||||
new TwigBundle(),
|
||||
new TwigExtraBundle(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function configureContainer(ContainerConfigurator $container): void
|
||||
{
|
||||
$container->extension('framework', [
|
||||
'secret' => 'S0ME_SECRET'
|
||||
]);
|
||||
$services = $container->services()->defaults()->autowire()->autoconfigure();
|
||||
$services->load('Krzysiej\\RyobiCrawler\\', __DIR__ )
|
||||
->exclude('../src/{Models,Twig,Kernel.php}');
|
||||
$services->set('twig.extension.cache', AppExtension::class)->tag('twig.extension');
|
||||
$services->set(CacheExtension::class)->tag('twig.extension');
|
||||
$services->set(FilesystemAdapter::class)->args([
|
||||
'$directory' => __DIR__ . '/../var/cache/twig_blocks'
|
||||
]);
|
||||
$services->set('twig.runtime.cache', CacheRuntime::class)->args([new Reference(FilesystemAdapter::class)])->tag('twig.runtime');
|
||||
}
|
||||
|
||||
protected function configureRoutes(RoutingConfigurator $routes): void
|
||||
{
|
||||
$routes->import(__DIR__ . '/Controller/', 'attribute');
|
||||
}
|
||||
}
|
||||
@@ -41,11 +41,6 @@ class Product extends Model
|
||||
return $this->hasOne(Price::class)->latestOfMany('created_at');
|
||||
}
|
||||
|
||||
public function lowestPrice(): HasOne
|
||||
{
|
||||
return $this->hasOne(Price::class)->ofMany('price', 'MIN');
|
||||
}
|
||||
|
||||
public function stock(): HasMany
|
||||
{
|
||||
return $this->hasMany(Stock::class);
|
||||
|
||||
@@ -19,7 +19,6 @@ class AppExtension extends AbstractExtension
|
||||
{
|
||||
return [
|
||||
new TwigFunction('promosCount', [$this, 'promosCount']),
|
||||
new TwigFunction('allCount', [$this, 'allCount']),
|
||||
new TwigFunction('newCount', [$this, 'newCount']),
|
||||
new TwigFunction('discontinuedCount', [$this, 'discontinuedCount']),
|
||||
];
|
||||
@@ -31,14 +30,10 @@ class AppExtension extends AbstractExtension
|
||||
new TwigFilter('findByCreatedAtDate', [$this, 'findByCreatedAtDate']),
|
||||
];
|
||||
}
|
||||
public function allCount(): int
|
||||
{
|
||||
return Product::count();
|
||||
}
|
||||
|
||||
public function promosCount(): int
|
||||
{
|
||||
return Product::whereHas('currentPrice', fn(Builder $query) => $query->whereColumn('price', '<', 'productStandardPrice'))->count();
|
||||
return Product::whereHas('currentPrice', fn(Builder $query) => $query->whereColumn('price', '<', 'productStandardPrice'))->with(['currentPrice'])->count();
|
||||
}
|
||||
|
||||
public function newCount(): int
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
@import "tailwindcss";
|
||||
@@ -1,340 +0,0 @@
|
||||
/*! tailwindcss v4.1.7 | MIT License | https://tailwindcss.com */
|
||||
@layer properties;
|
||||
@layer theme, base, components, utilities;
|
||||
@layer theme {
|
||||
:root, :host {
|
||||
--font-sans: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji",
|
||||
"Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
||||
--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
|
||||
"Courier New", monospace;
|
||||
--spacing: 0.25rem;
|
||||
--text-3xl: 1.875rem;
|
||||
--text-3xl--line-height: calc(2.25 / 1.875);
|
||||
--font-weight-bold: 700;
|
||||
--default-font-family: var(--font-sans);
|
||||
--default-mono-font-family: var(--font-mono);
|
||||
}
|
||||
}
|
||||
@layer base {
|
||||
*, ::after, ::before, ::backdrop, ::file-selector-button {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0 solid;
|
||||
}
|
||||
html, :host {
|
||||
line-height: 1.5;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
tab-size: 4;
|
||||
font-family: var(--default-font-family, ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");
|
||||
font-feature-settings: var(--default-font-feature-settings, normal);
|
||||
font-variation-settings: var(--default-font-variation-settings, normal);
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
hr {
|
||||
height: 0;
|
||||
color: inherit;
|
||||
border-top-width: 1px;
|
||||
}
|
||||
abbr:where([title]) {
|
||||
-webkit-text-decoration: underline dotted;
|
||||
text-decoration: underline dotted;
|
||||
}
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
font-size: inherit;
|
||||
font-weight: inherit;
|
||||
}
|
||||
a {
|
||||
color: inherit;
|
||||
-webkit-text-decoration: inherit;
|
||||
text-decoration: inherit;
|
||||
}
|
||||
b, strong {
|
||||
font-weight: bolder;
|
||||
}
|
||||
code, kbd, samp, pre {
|
||||
font-family: var(--default-mono-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);
|
||||
font-feature-settings: var(--default-mono-font-feature-settings, normal);
|
||||
font-variation-settings: var(--default-mono-font-variation-settings, normal);
|
||||
font-size: 1em;
|
||||
}
|
||||
small {
|
||||
font-size: 80%;
|
||||
}
|
||||
sub, sup {
|
||||
font-size: 75%;
|
||||
line-height: 0;
|
||||
position: relative;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
sub {
|
||||
bottom: -0.25em;
|
||||
}
|
||||
sup {
|
||||
top: -0.5em;
|
||||
}
|
||||
table {
|
||||
text-indent: 0;
|
||||
border-color: inherit;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
:-moz-focusring {
|
||||
outline: auto;
|
||||
}
|
||||
progress {
|
||||
vertical-align: baseline;
|
||||
}
|
||||
summary {
|
||||
display: list-item;
|
||||
}
|
||||
ol, ul, menu {
|
||||
list-style: none;
|
||||
}
|
||||
img, svg, video, canvas, audio, iframe, embed, object {
|
||||
display: block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
img, video {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
button, input, select, optgroup, textarea, ::file-selector-button {
|
||||
font: inherit;
|
||||
font-feature-settings: inherit;
|
||||
font-variation-settings: inherit;
|
||||
letter-spacing: inherit;
|
||||
color: inherit;
|
||||
border-radius: 0;
|
||||
background-color: transparent;
|
||||
opacity: 1;
|
||||
}
|
||||
:where(select:is([multiple], [size])) optgroup {
|
||||
font-weight: bolder;
|
||||
}
|
||||
:where(select:is([multiple], [size])) optgroup option {
|
||||
padding-inline-start: 20px;
|
||||
}
|
||||
::file-selector-button {
|
||||
margin-inline-end: 4px;
|
||||
}
|
||||
::placeholder {
|
||||
opacity: 1;
|
||||
}
|
||||
@supports (not (-webkit-appearance: -apple-pay-button)) or (contain-intrinsic-size: 1px) {
|
||||
::placeholder {
|
||||
color: currentcolor;
|
||||
@supports (color: color-mix(in lab, red, red)) {
|
||||
color: color-mix(in oklab, currentcolor 50%, transparent);
|
||||
}
|
||||
}
|
||||
}
|
||||
textarea {
|
||||
resize: vertical;
|
||||
}
|
||||
::-webkit-search-decoration {
|
||||
-webkit-appearance: none;
|
||||
}
|
||||
::-webkit-date-and-time-value {
|
||||
min-height: 1lh;
|
||||
text-align: inherit;
|
||||
}
|
||||
::-webkit-datetime-edit {
|
||||
display: inline-flex;
|
||||
}
|
||||
::-webkit-datetime-edit-fields-wrapper {
|
||||
padding: 0;
|
||||
}
|
||||
::-webkit-datetime-edit, ::-webkit-datetime-edit-year-field, ::-webkit-datetime-edit-month-field, ::-webkit-datetime-edit-day-field, ::-webkit-datetime-edit-hour-field, ::-webkit-datetime-edit-minute-field, ::-webkit-datetime-edit-second-field, ::-webkit-datetime-edit-millisecond-field, ::-webkit-datetime-edit-meridiem-field {
|
||||
padding-block: 0;
|
||||
}
|
||||
:-moz-ui-invalid {
|
||||
box-shadow: none;
|
||||
}
|
||||
button, input:where([type="button"], [type="reset"], [type="submit"]), ::file-selector-button {
|
||||
appearance: button;
|
||||
}
|
||||
::-webkit-inner-spin-button, ::-webkit-outer-spin-button {
|
||||
height: auto;
|
||||
}
|
||||
[hidden]:where(:not([hidden="until-found"])) {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
@layer utilities {
|
||||
.collapse {
|
||||
visibility: collapse;
|
||||
}
|
||||
.container {
|
||||
width: 100%;
|
||||
@media (width >= 40rem) {
|
||||
max-width: 40rem;
|
||||
}
|
||||
@media (width >= 48rem) {
|
||||
max-width: 48rem;
|
||||
}
|
||||
@media (width >= 64rem) {
|
||||
max-width: 64rem;
|
||||
}
|
||||
@media (width >= 80rem) {
|
||||
max-width: 80rem;
|
||||
}
|
||||
@media (width >= 96rem) {
|
||||
max-width: 96rem;
|
||||
}
|
||||
}
|
||||
.me-2 {
|
||||
margin-inline-end: calc(var(--spacing) * 2);
|
||||
}
|
||||
.me-auto {
|
||||
margin-inline-end: auto;
|
||||
}
|
||||
.mb-0 {
|
||||
margin-bottom: calc(var(--spacing) * 0);
|
||||
}
|
||||
.mb-2 {
|
||||
margin-bottom: calc(var(--spacing) * 2);
|
||||
}
|
||||
.block {
|
||||
display: block;
|
||||
}
|
||||
.grid {
|
||||
display: grid;
|
||||
}
|
||||
.table {
|
||||
display: table;
|
||||
}
|
||||
.flex-row {
|
||||
flex-direction: row;
|
||||
}
|
||||
.rounded {
|
||||
border-radius: 0.25rem;
|
||||
}
|
||||
.border {
|
||||
border-style: var(--tw-border-style);
|
||||
border-width: 1px;
|
||||
}
|
||||
.border-1 {
|
||||
border-style: var(--tw-border-style);
|
||||
border-width: 1px;
|
||||
}
|
||||
.p-1 {
|
||||
padding: calc(var(--spacing) * 1);
|
||||
}
|
||||
.text-end {
|
||||
text-align: end;
|
||||
}
|
||||
.align-middle {
|
||||
vertical-align: middle;
|
||||
}
|
||||
.text-3xl {
|
||||
font-size: var(--text-3xl);
|
||||
line-height: var(--tw-leading, var(--text-3xl--line-height));
|
||||
}
|
||||
.font-bold {
|
||||
--tw-font-weight: var(--font-weight-bold);
|
||||
font-weight: var(--font-weight-bold);
|
||||
}
|
||||
.underline {
|
||||
text-decoration-line: underline;
|
||||
}
|
||||
.shadow-sm {
|
||||
--tw-shadow: 0 1px 3px 0 var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 1px 2px -1px var(--tw-shadow-color, rgb(0 0 0 / 0.1));
|
||||
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
||||
}
|
||||
}
|
||||
@property --tw-border-style {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
initial-value: solid;
|
||||
}
|
||||
@property --tw-font-weight {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
}
|
||||
@property --tw-shadow {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
initial-value: 0 0 #0000;
|
||||
}
|
||||
@property --tw-shadow-color {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
}
|
||||
@property --tw-shadow-alpha {
|
||||
syntax: "<percentage>";
|
||||
inherits: false;
|
||||
initial-value: 100%;
|
||||
}
|
||||
@property --tw-inset-shadow {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
initial-value: 0 0 #0000;
|
||||
}
|
||||
@property --tw-inset-shadow-color {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
}
|
||||
@property --tw-inset-shadow-alpha {
|
||||
syntax: "<percentage>";
|
||||
inherits: false;
|
||||
initial-value: 100%;
|
||||
}
|
||||
@property --tw-ring-color {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
}
|
||||
@property --tw-ring-shadow {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
initial-value: 0 0 #0000;
|
||||
}
|
||||
@property --tw-inset-ring-color {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
}
|
||||
@property --tw-inset-ring-shadow {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
initial-value: 0 0 #0000;
|
||||
}
|
||||
@property --tw-ring-inset {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
}
|
||||
@property --tw-ring-offset-width {
|
||||
syntax: "<length>";
|
||||
inherits: false;
|
||||
initial-value: 0px;
|
||||
}
|
||||
@property --tw-ring-offset-color {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
initial-value: #fff;
|
||||
}
|
||||
@property --tw-ring-offset-shadow {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
initial-value: 0 0 #0000;
|
||||
}
|
||||
@layer properties {
|
||||
@supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
|
||||
*, ::before, ::after, ::backdrop {
|
||||
--tw-border-style: solid;
|
||||
--tw-font-weight: initial;
|
||||
--tw-shadow: 0 0 #0000;
|
||||
--tw-shadow-color: initial;
|
||||
--tw-shadow-alpha: 100%;
|
||||
--tw-inset-shadow: 0 0 #0000;
|
||||
--tw-inset-shadow-color: initial;
|
||||
--tw-inset-shadow-alpha: 100%;
|
||||
--tw-ring-color: initial;
|
||||
--tw-ring-shadow: 0 0 #0000;
|
||||
--tw-inset-ring-color: initial;
|
||||
--tw-inset-ring-shadow: 0 0 #0000;
|
||||
--tw-ring-inset: initial;
|
||||
--tw-ring-offset-width: 0px;
|
||||
--tw-ring-offset-color: #fff;
|
||||
--tw-ring-offset-shadow: 0 0 #0000;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
{% extends "template.html.twig" %}
|
||||
|
||||
{% block content %}
|
||||
{% cache 'product' ~ product.id %}
|
||||
<div class="table-responsive">
|
||||
<table class='table table-hover'>
|
||||
<tr>
|
||||
@@ -130,6 +129,5 @@
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endcache %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
{% extends "template.html.twig" %}
|
||||
|
||||
{% block content %}
|
||||
{% cache 'list_' ~ listType %}
|
||||
<div class="table-responsive">
|
||||
{{ app.request.get('order') }}
|
||||
<table class='table table-hover'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th>Name</th>
|
||||
<th><a href="{{ path( app.request.get('_route') , {'order': app.request.get('order') is same as('-name')?'name':'-name'|default('-name')}) }}">Name</a></th>
|
||||
<th>Categories</th>
|
||||
<th></th>
|
||||
<th class="text-end">Lowest Price</th>
|
||||
<th class="text-end">Current Price</th>
|
||||
<th><a href="{{ path( app.request.get('_route') , {'order': app.request.get('order') is same as('-price')?'price':'-price'|default('-price')}) }}">Price</a></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -46,8 +45,7 @@
|
||||
</nav>
|
||||
</td>
|
||||
<td class="align-middle"><a href='https://pl.ryobitools.eu/{{ product.url }}'>link</a></td>
|
||||
<td class="align-middle text-end">{% if product.lowestPrice.price != product.price.last.price %}{{ product.lowestPrice.price | format_currency('PLN', {}, 'pl') }}{% endif %}</td>
|
||||
<td class="align-middle text-end">{{ product.price.last.price | format_currency('PLN', {}, 'pl') }}</td>
|
||||
<td class="align-middle">{{ product.price.last.price | format_currency('PLN', {}, 'pl') }}</td>
|
||||
<td class="align-middle">
|
||||
<div class="d-flex flex-row">
|
||||
{% if product.price.last.price != product.price.last.productStandardPrice %}<span
|
||||
@@ -60,5 +58,4 @@
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
{% endcache %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -5,11 +5,10 @@
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Ryobi crawler</title>
|
||||
<link href="/templates/output/style.css" rel="stylesheet" />
|
||||
<link href="/templates/css/bootstrap.min.css" rel="stylesheet" />
|
||||
<script src="/templates/js/script.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 class="text-3xl font-bold underline">test header</h1>
|
||||
<nav class="navbar navbar-expand-lg sticky-top bg-body-tertiary border-bottom border-secondary border-1">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="{{ path('app_home') }}">Crawler</a>
|
||||
@@ -19,20 +18,15 @@
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
{% cache "menu_count" %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {% if app.request.pathinfo == path('app_home') %}active shadow-sm bg-body rounded{% endif %}" aria-current="page" href="{{ path('app_home') }}">All products <span class="badge text-bg-secondary">{{ allCount() }}</span></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {% if app.request.pathinfo == path('app_promos') %}active shadow-sm bg-body rounded{% endif %}" aria-current="page" href="{{ path('app_promos') }}">Promos <span class="badge text-bg-secondary">{{ promosCount() }}</span></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {% if app.request.pathinfo == path('app_new') %}active shadow-sm bg-body rounded{% endif %}" aria-current="page" href="{{ path('app_new') }}">New in last 30 days <span class="badge text-bg-secondary">{{ newCount() }}</span></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {% if app.request.pathinfo == path('app_discontinued') %}active shadow-sm bg-body rounded{% endif %}" aria-current="page" href="{{ path('app_discontinued') }}">Discontinued <span class="badge text-bg-secondary">{{ discontinuedCount() }}</span></a>
|
||||
</li>
|
||||
{% endcache %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {% if app.request.pathinfo == path('app_promos') %}active shadow-sm bg-body rounded{% endif %}" aria-current="page" href="{{ path('app_promos') }}">Promos <span class="badge text-bg-secondary">{{ promosCount() }}</span></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {% if app.request.pathinfo == path('app_new') %}active shadow-sm bg-body rounded{% endif %}" aria-current="page" href="{{ path('app_new') }}">New in last 30 days <span class="badge text-bg-secondary">{{ newCount() }}</span></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {% if app.request.pathinfo == path('app_discontinued') %}active shadow-sm bg-body rounded{% endif %}" aria-current="page" href="{{ path('app_discontinued') }}">Discontinued <span class="badge text-bg-secondary">{{ discontinuedCount() }}</span></a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<form class="form-floating d-flex col-lg-6 col-sm-8" role="search" action="{{ path('app_search') }}">
|
||||
|
||||
Reference in New Issue
Block a user