added frontend and made it usable

This commit is contained in:
Hendrik Behme committed 2026-08-15 14:50:42 +02:00
1 parent 96408f00d8
commit b9b15152bc
50 files changed
+7974 -1

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
###> symfony/framework-bundle ###
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/var/
/vendor/
###< symfony/framework-bundle ###
+16
View File
@@ -0,0 +1,16 @@
FROM php:8.3-cli
RUN apt-get update && apt-get install -y --no-install-recommends \
libpq-dev unzip git \
&& docker-php-ext-install pdo_pgsql \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
&& rm -rf /var/lib/apt/lists/*
# The imported event data and the site's audience are both German-local;
# default to that instead of the container's UTC so any future "now"/
# "today" computation doesn't quietly disagree with the data for the two
# hours after every UTC midnight.
ENV TZ=Europe/Berlin
RUN echo "date.timezone = Europe/Berlin" > /usr/local/etc/php/conf.d/timezone.ini
WORKDIR /app
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env php
<?php
use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
if (!in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.\PHP_SAPI.' SAPI'.\PHP_EOL;
}
set_time_limit(0);
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
return function (array $context) {
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
return new Application($kernel);
};
+72
View File
@@ -0,0 +1,72 @@
{
"type": "project",
"license": "proprietary",
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": ">=8.2",
"ext-ctype": "*",
"ext-iconv": "*",
"doctrine/dbal": "^4.4",
"doctrine/doctrine-bundle": "^2.19",
"doctrine/orm": "^3.6",
"symfony/asset": "7.4.*",
"symfony/console": "7.4.*",
"symfony/doctrine-bridge": "7.4.*",
"symfony/dotenv": "7.4.*",
"symfony/flex": "^2",
"symfony/framework-bundle": "7.4.*",
"symfony/runtime": "7.4.*",
"symfony/twig-bundle": "7.4.*",
"symfony/yaml": "7.4.*",
"twig/twig": "^3.28"
},
"config": {
"allow-plugins": {
"php-http/discovery": true,
"symfony/flex": true,
"symfony/runtime": true
},
"bump-after-update": true,
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php72": "*",
"symfony/polyfill-php73": "*",
"symfony/polyfill-php74": "*",
"symfony/polyfill-php80": "*",
"symfony/polyfill-php81": "*",
"symfony/polyfill-php82": "*"
},
"scripts": {
"auto-scripts": [
],
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "7.4.*"
}
}
}
+4122
View File
File diff suppressed because it is too large. Load diff
+7
View File
@@ -0,0 +1,7 @@
<?php
return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
];
+45
View File
@@ -0,0 +1,45 @@
doctrine:
dbal:
url: '%env(resolve:DATABASE_URL)%'
server_version: '14'
orm:
auto_generate_proxy_classes: true
enable_lazy_ghost_objects: true
report_fields_where_declared: true
validate_xml_mapping: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
App:
type: attribute
is_bundle: false
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
controller_resolver:
auto_mapping: true
when@test:
doctrine:
dbal:
dbname_suffix: '_test%env(default::TEST_TOKEN)%'
when@prod:
doctrine:
orm:
auto_generate_proxy_classes: false
proxy_dir: '%kernel.build_dir%/doctrine/orm/Proxies'
query_cache_driver:
type: pool
pool: doctrine.system_cache_pool
result_cache_driver:
type: pool
pool: doctrine.result_cache_pool
framework:
cache:
pools:
doctrine.result_cache_pool:
adapter: cache.app
doctrine.system_cache_pool:
adapter: cache.system
+7
View File
@@ -0,0 +1,7 @@
framework:
secret: '%env(APP_SECRET)%'
router:
utf8: true
php_errors:
log: true
assets: ~
+6
View File
@@ -0,0 +1,6 @@
twig:
default_path: '%kernel.project_dir%/templates'
when@test:
twig:
strict_variables: true
File diff suppressed because it is too large. Load diff
+5
View File
@@ -0,0 +1,5 @@
controllers:
resource:
path: ../src/Controller/
namespace: App\Controller
type: attribute
+13
View File
@@ -0,0 +1,13 @@
parameters:
services:
_defaults:
autowire: true
autoconfigure: true
App\:
resource: '../src/'
exclude:
- '../src/DependencyInjection/'
- '../src/Entity/'
- '../src/Kernel.php'
@@ -0,0 +1,52 @@
<?php
namespace App\Controller;
use App\Repository\CategoryRepository;
use App\Repository\EventRepository;
use App\Service\EventMapSerializer;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
class EventController extends AbstractController
{
private const PER_PAGE = 24;
#[Route('/events', name: 'event_list')]
public function list(Request $request, EventRepository $events, CategoryRepository $categories): Response
{
$page = max(1, $request->query->getInt('page', 1));
$category = $request->query->get('category') ?: null;
$offset = (($page ?: 1) - 1) * self::PER_PAGE;
$items = $events->findPage(self::PER_PAGE, $offset, $category);
$total = $events->countPage($category);
return $this->render('events/list.html.twig', [
'activeNav' => 'events',
'events' => $items,
'categories' => $categories->findUsedNames(),
'activeCategory' => $category,
'page' => $page,
'totalPages' => max(1, (int) ceil($total / self::PER_PAGE)),
'total' => $total,
]);
}
#[Route('/events/{id}', name: 'event_show', requirements: ['id' => '\d+'])]
public function show(int $id, EventRepository $events, EventMapSerializer $mapSerializer): Response
{
$event = $events->findOneNotDeleted($id);
if (!$event) {
throw $this->createNotFoundException('Event nicht gefunden.');
}
return $this->render('events/show.html.twig', [
'activeNav' => 'events',
'event' => $event,
'mapEventJson' => $event->hasCoordinates() ? $mapSerializer->toJson([$event]) : '[]',
]);
}
}
@@ -0,0 +1,43 @@
<?php
namespace App\Controller;
use App\Repository\CategoryRepository;
use App\Repository\EventRepository;
use App\Service\DefaultLocation;
use App\Service\EventMapSerializer;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
class HomeController extends AbstractController
{
// Matches /map's MAX_RANGE_KM/POOL_LIMIT: the light map only shows the
// nearest 20, but the candidate pool it picks from needs to actually
// cover that area, not just be an arbitrary unordered chunk of events.
private const POOL_RADIUS_KM = 100;
private const POOL_LIMIT = 3000;
#[Route('/', name: 'home')]
public function index(
EventRepository $events,
CategoryRepository $categories,
EventMapSerializer $mapSerializer
): Response {
// Same fallback as /map: default to Köln until real geolocation
// (checked client-side in map.js) says otherwise.
$lat = DefaultLocation::LAT;
$lon = DefaultLocation::LON;
$pool = $events->findWithinRadius($lat, $lon, self::POOL_RADIUS_KM, self::POOL_LIMIT);
return $this->render('home.html.twig', [
'activeNav' => 'home',
'upcomingEvents' => $events->findRecent(6),
'mapEventsJson' => $mapSerializer->toJson($pool),
'popularCategories' => $categories->findMostUsedNames(12),
'centerLat' => $lat,
'centerLon' => $lon,
]);
}
}
+53
View File
@@ -0,0 +1,53 @@
<?php
namespace App\Controller;
use App\Repository\CategoryRepository;
use App\Repository\EventRepository;
use App\Service\DefaultLocation;
use App\Service\EventMapSerializer;
use App\Service\RangeDefaults;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
class MapController extends AbstractController
{
// Safety cap on the pool shipped to the client, not a practical limit:
// even the densest 100km radius seen (NRW around Köln) comes in under
// 3000, so this should never actually truncate in normal use.
private const POOL_LIMIT = 3000;
#[Route('/map', name: 'map')]
public function index(
Request $request,
EventRepository $events,
CategoryRepository $categories,
EventMapSerializer $mapSerializer
): Response {
$lat = (float) ($request->query->get('lat') ?: DefaultLocation::LAT);
$lon = (float) ($request->query->get('lon') ?: DefaultLocation::LON);
$rangeKm = (int) $request->query->get('range', RangeDefaults::DEFAULT_KM);
if ($rangeKm <= 0 || $rangeKm > RangeDefaults::MAX_KM) {
$rangeKm = RangeDefaults::DEFAULT_KM;
}
// Ship the pool sized to the *max* selectable range so the range
// dropdown and small map clicks/drags can be handled entirely
// client-side, without another page load.
$pool = $events->findWithinRadius($lat, $lon, RangeDefaults::MAX_KM, self::POOL_LIMIT);
return $this->render('map.html.twig', [
'activeNav' => 'map',
'mapEventsJson' => $mapSerializer->toJson($pool),
'categories' => $categories->findUsedNames(),
'centerLat' => $lat,
'centerLon' => $lon,
'rangeKm' => $rangeKm,
'rangeOptions' => RangeDefaults::OPTIONS_KM,
'maxRangeKm' => RangeDefaults::MAX_KM,
]);
}
}
@@ -0,0 +1,68 @@
<?php
namespace App\Controller;
use App\Repository\CategoryRepository;
use App\Repository\EventRepository;
use App\Service\RangeDefaults;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
class SearchController extends AbstractController
{
private const PER_PAGE = 24;
#[Route('/search', name: 'search')]
public function index(Request $request, EventRepository $events, CategoryRepository $categories): Response
{
$q = trim((string) $request->query->get('q', ''));
$category = $request->query->get('category') ?: null;
$when = $request->query->get('when') ?: 'any';
$page = max(1, $request->query->getInt('page', 1));
// Location filtering is opt-in — plain text/category search behaves
// exactly as before unless a place/"use my location" actually set
// lat/lon, unlike /map which always has *some* center.
$latParam = $request->query->get('lat');
$lonParam = $request->query->get('lon');
$hasLocation = null !== $latParam && null !== $lonParam && '' !== $latParam && '' !== $lonParam;
$lat = $hasLocation ? (float) $latParam : null;
$lon = $hasLocation ? (float) $lonParam : null;
$rangeKm = (int) $request->query->get('range', RangeDefaults::DEFAULT_KM);
if ($rangeKm <= 0 || $rangeKm > RangeDefaults::MAX_KM) {
$rangeKm = RangeDefaults::DEFAULT_KM;
}
$distances = [];
$locationIds = null;
if ($hasLocation) {
$distances = $events->distancesWithinRadius($lat, $lon, $rangeKm, 3000);
$locationIds = array_keys($distances);
}
$offset = ($page - 1) * self::PER_PAGE;
$results = $events->search($q ?: null, $category, $when, self::PER_PAGE, $offset, $locationIds);
$total = $events->countSearch($q ?: null, $category, $when, $locationIds);
return $this->render('search.html.twig', [
'activeNav' => 'search',
'q' => $q,
'events' => $results,
'categories' => $categories->findUsedNames(),
'activeCategory' => $category,
'when' => $when,
'hasLocation' => $hasLocation,
'lat' => $lat,
'lon' => $lon,
'rangeKm' => $rangeKm,
'rangeOptions' => RangeDefaults::OPTIONS_KM,
'distances' => $distances,
'page' => $page,
'totalPages' => max(1, (int) ceil($total / self::PER_PAGE)),
'total' => $total,
]);
}
}
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace App\Entity;
use App\Repository\CategoryRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: CategoryRepository::class)]
#[ORM\Table(name: 'categories')]
class Category
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private ?int $id = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $name = null;
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
}
+250
View File
@@ -0,0 +1,250 @@
<?php
namespace App\Entity;
use App\Repository\EventRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: EventRepository::class)]
#[ORM\Table(name: 'events')]
class Event
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private ?int $id = null;
#[ORM\Column(name: 'external_id', type: 'string', length: 255, nullable: true)]
private ?string $externalId = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $title = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $city = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $street = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $country = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $type = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $zip = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $phone = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $web = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $email = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $author = null;
#[ORM\Column(type: 'float', nullable: true)]
private ?float $latitude = null;
#[ORM\Column(type: 'float', nullable: true)]
private ?float $longitude = null;
#[ORM\Column(type: 'text', nullable: true)]
private ?string $description = null;
#[ORM\Column(type: 'text', nullable: true)]
private ?string $teaser = null;
#[ORM\Column(name: 'start_date', type: 'string', length: 255, nullable: true)]
private ?string $startDate = null;
#[ORM\Column(name: 'end_date', type: 'string', length: 255, nullable: true)]
private ?string $endDate = null;
#[ORM\Column(name: 'deleted_at', type: 'datetime', nullable: true)]
private ?\DateTimeInterface $deletedAt = null;
#[ORM\ManyToMany(targetEntity: Category::class)]
#[ORM\JoinTable(name: 'event_categories')]
#[ORM\JoinColumn(name: 'event_id', referencedColumnName: 'id')]
#[ORM\InverseJoinColumn(name: 'category_id', referencedColumnName: 'id')]
private Collection $categories;
#[ORM\ManyToMany(targetEntity: MediaObject::class)]
#[ORM\JoinTable(name: 'event_media_objects')]
#[ORM\JoinColumn(name: 'event_id', referencedColumnName: 'id')]
#[ORM\InverseJoinColumn(name: 'media_object_id', referencedColumnName: 'id')]
private Collection $mediaObjects;
public function __construct()
{
$this->categories = new ArrayCollection();
$this->mediaObjects = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getExternalId(): ?string
{
return $this->externalId;
}
public function getTitle(): ?string
{
return $this->title;
}
public function getCity(): ?string
{
return $this->city;
}
public function getStreet(): ?string
{
return $this->street;
}
public function getCountry(): ?string
{
return $this->country;
}
public function getType(): ?string
{
return $this->type;
}
public function getZip(): ?string
{
return $this->zip;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function getWeb(): ?string
{
return $this->web;
}
public function getEmail(): ?string
{
return $this->email;
}
public function getAuthor(): ?string
{
return $this->author;
}
public function getLatitude(): ?float
{
return $this->latitude;
}
public function getLongitude(): ?float
{
return $this->longitude;
}
public function getDescription(): ?string
{
return $this->description;
}
public function getTeaser(): ?string
{
return $this->teaser;
}
public function getStartDate(): ?string
{
return $this->startDate;
}
public function getEndDate(): ?string
{
return $this->endDate;
}
public function getDeletedAt(): ?\DateTimeInterface
{
return $this->deletedAt;
}
/** @return Collection<int, Category> */
public function getCategories(): Collection
{
return $this->categories;
}
/** @return string[] */
public function getCategoryNames(): array
{
return array_values(array_filter(array_map(
static fn (Category $category) => $category->getName(),
$this->categories->toArray()
)));
}
/** @return Collection<int, MediaObject> */
public function getMediaObjects(): Collection
{
return $this->mediaObjects;
}
public function getPrimaryImage(): ?MediaObject
{
foreach ($this->mediaObjects as $mediaObject) {
if ($mediaObject->isImage()) {
return $mediaObject;
}
}
return null;
}
public function hasCoordinates(): bool
{
return null !== $this->latitude
&& null !== $this->longitude
&& (0.0 !== $this->latitude || 0.0 !== $this->longitude);
}
public function getStartDateTime(): ?\DateTimeImmutable
{
if (!$this->startDate) {
return null;
}
try {
return new \DateTimeImmutable($this->startDate);
} catch (\Exception) {
return null;
}
}
public function getEndDateTime(): ?\DateTimeImmutable
{
if (!$this->endDate) {
return null;
}
try {
return new \DateTimeImmutable($this->endDate);
} catch (\Exception) {
return null;
}
}
}
+124
View File
@@ -0,0 +1,124 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
#[ORM\Table(name: 'media_objects')]
class MediaObject
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private ?int $id = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $url = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $alt = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $rel = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $name = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $type = null;
#[ORM\Column(name: 'ref_id', type: 'string', length: 255, nullable: true)]
private ?string $refId = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $source = null;
#[ORM\Column(type: 'integer', nullable: true)]
private ?int $prio = null;
#[ORM\Column(type: 'text', nullable: true)]
private ?string $description = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $license = null;
#[ORM\Column(name: 'ai_optimized', type: 'boolean', nullable: true)]
private ?bool $aiOptimized = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $ext = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $hash = null;
public function getId(): ?int
{
return $this->id;
}
public function getUrl(): ?string
{
return $this->url;
}
public function getAlt(): ?string
{
return $this->alt;
}
public function getName(): ?string
{
return $this->name;
}
public function getType(): ?string
{
return $this->type;
}
public function getSource(): ?string
{
return $this->source;
}
public function getDescription(): ?string
{
return $this->description;
}
public function getLicense(): ?string
{
return $this->license;
}
public function getExt(): ?string
{
return $this->ext;
}
public function getHash(): ?string
{
return $this->hash;
}
public function isImage(): bool
{
return str_starts_with($this->type ?? '', 'image/');
}
/**
* Matches the path EventRepository.saveMediaFile writes to in the Go
* importer: ./public/storage/<mediatype>/<hash><ext>.
*/
public function getStoragePath(): ?string
{
if (!$this->hash) {
return null;
}
$mediaType = strtolower((string) (strstr($this->type ?? '', '/', true) ?: 'other'));
return sprintf('/storage/%s/%s%s', $mediaType, $this->hash, $this->ext);
}
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace App;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
class Kernel extends BaseKernel
{
use MicroKernelTrait;
}
@@ -0,0 +1,55 @@
<?php
namespace App\Repository;
use App\Entity\Category;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\DBAL\ParameterType;
use Doctrine\Persistence\ManagerRegistry;
class CategoryRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Category::class);
}
/**
* Category names actually attached to at least one non-deleted event —
* the plain categories table can contain names no current event uses.
*
* @return string[]
*/
public function findUsedNames(): array
{
$sql = 'SELECT DISTINCT c.name FROM categories c
INNER JOIN event_categories ec ON ec.category_id = c.id
INNER JOIN events e ON e.id = ec.event_id AND e.deleted_at IS NULL
WHERE c.name IS NOT NULL AND c.name <> \'\'
ORDER BY c.name ASC';
return $this->getEntityManager()->getConnection()->executeQuery($sql)->fetchFirstColumn();
}
/**
* Category names ordered by how many non-deleted events use them —
* for a curated "browse by category" section, where alphabetical order
* would surface obscure tags ahead of common ones.
*
* @return string[]
*/
public function findMostUsedNames(int $limit = 12): array
{
$sql = 'SELECT c.name FROM categories c
INNER JOIN event_categories ec ON ec.category_id = c.id
INNER JOIN events e ON e.id = ec.event_id AND e.deleted_at IS NULL
WHERE c.name IS NOT NULL AND c.name <> \'\'
GROUP BY c.name
ORDER BY COUNT(*) DESC, c.name ASC
LIMIT :limit';
return $this->getEntityManager()->getConnection()
->executeQuery($sql, ['limit' => $limit], ['limit' => ParameterType::INTEGER])
->fetchFirstColumn();
}
}
+291
View File
@@ -0,0 +1,291 @@
<?php
namespace App\Repository;
use App\Entity\Event;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\DBAL\ParameterType;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ManagerRegistry;
class EventRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Event::class);
}
public function findOneNotDeleted(int $id): ?Event
{
return $this->notDeleted()
->andWhere('e.id = :id')
->setParameter('id', $id)
->getQuery()
->getOneOrNullResult();
}
/** @return Event[] */
public function findRecent(int $limit): array
{
return $this->orderByStartDate($this->notDeleted())
->setMaxResults($limit)
->getQuery()
->getResult();
}
/** @return Event[] */
public function findPage(int $limit, int $offset, ?string $category = null): array
{
$qb = $this->orderByStartDate($this->notDeleted())
->setMaxResults($limit)
->setFirstResult($offset);
$this->filterByCategory($qb, $category);
return $qb->getQuery()->getResult();
}
public function countPage(?string $category = null): int
{
$qb = $this->notDeleted()->select('COUNT(DISTINCT e.id)');
$this->filterByCategory($qb, $category);
return (int) $qb->getQuery()->getSingleScalarResult();
}
/** @return Event[] */
public function findWithCoordinates(int $limit = 500): array
{
return $this->notDeleted()
->andWhere('e.latitude IS NOT NULL AND e.longitude IS NOT NULL')
->andWhere('e.latitude <> 0 OR e.longitude <> 0')
->setMaxResults($limit)
->getQuery()
->getResult();
}
/**
* Distance in km to every event within `radiusKm` of (lat, lon),
* nearest first, keyed by event id — the location+range based
* replacement for a flat "first N" cap. No PostGIS here, so distance
* is a plain Haversine formula in raw SQL (DQL has no trig
* functions); a computed column can't be filtered in WHERE directly,
* hence the subquery.
*
* @return array<int, float>
*/
public function distancesWithinRadius(float $lat, float $lon, float $radiusKm, int $limit = 500): array
{
$sql = 'SELECT id, distance_km FROM (
SELECT e.id,
(6371 * acos(least(1, greatest(-1,
cos(radians(:lat)) * cos(radians(e.latitude)) * cos(radians(e.longitude) - radians(:lon))
+ sin(radians(:lat)) * sin(radians(e.latitude))
)))) AS distance_km
FROM events e
WHERE e.deleted_at IS NULL
AND e.latitude IS NOT NULL AND e.longitude IS NOT NULL
AND (e.latitude <> 0 OR e.longitude <> 0)
) sub
WHERE distance_km <= :radius
ORDER BY distance_km ASC
LIMIT :limit';
$rows = $this->getEntityManager()->getConnection()->executeQuery(
$sql,
['lat' => $lat, 'lon' => $lon, 'radius' => $radiusKm, 'limit' => $limit],
['lat' => ParameterType::STRING, 'lon' => ParameterType::STRING, 'radius' => ParameterType::STRING, 'limit' => ParameterType::INTEGER]
)->fetchAllAssociative();
$distances = [];
foreach ($rows as $row) {
$distances[(int) $row['id']] = (float) $row['distance_km'];
}
return $distances;
}
/**
* Events within `radiusKm` of (lat, lon), nearest first.
*
* @return Event[]
*/
public function findWithinRadius(float $lat, float $lon, float $radiusKm, int $limit = 500): array
{
return $this->hydrateInOrder(array_keys($this->distancesWithinRadius($lat, $lon, $radiusKm, $limit)));
}
/**
* Text/category search, paginated, optionally restricted to (and
* ordered by) a pre-computed set of location-filtered ids — e.g. from
* distancesWithinRadius() — so "markets near Düsseldorf" combines a
* normal LIKE/category filter with the radius query rather than
* needing a second, separate search path. Without $locationIds this
* behaves like a plain text/category search, ordered chronologically.
*
* Distance order only exists in PHP (the $locationIds array), not as
* a sortable DB column, so paging has to slice that ordered id list
* *after* intersecting it with the text/category matches — pushing
* LIMIT/OFFSET into SQL here would paginate an arbitrary DB-ordered
* subset instead of the correct "25th-50th nearest" slice.
*
* @param int[]|null $locationIds
*
* @return Event[]
*/
public function search(?string $q, ?string $category, string $when, int $limit, int $offset, ?array $locationIds = null): array
{
if (null === $locationIds) {
return $this->orderByStartDate($this->baseSearchQb($q, $category, $when))
->setMaxResults($limit)
->setFirstResult($offset)
->getQuery()
->getResult();
}
if (!$locationIds) {
return [];
}
$matchingIds = array_map('intval', array_column(
$this->baseSearchQb($q, $category, $when)
->select('e.id')
->andWhere('e.id IN (:locationIds)')
->setParameter('locationIds', $locationIds)
->getQuery()
->getScalarResult(),
'id'
));
$matchingIdSet = array_flip($matchingIds);
$orderedIds = array_values(array_filter($locationIds, static fn ($id) => isset($matchingIdSet[$id])));
return $this->hydrateInOrder(array_slice($orderedIds, $offset, $limit));
}
/**
* Total count matching the same filters as search(), for pagination.
*
* @param int[]|null $locationIds
*/
public function countSearch(?string $q, ?string $category, string $when, ?array $locationIds = null): int
{
if (null !== $locationIds && !$locationIds) {
return 0;
}
$qb = $this->baseSearchQb($q, $category, $when)->select('COUNT(DISTINCT e.id)');
if (null !== $locationIds) {
$qb->andWhere('e.id IN (:locationIds)')->setParameter('locationIds', $locationIds);
}
return (int) $qb->getQuery()->getSingleScalarResult();
}
private function baseSearchQb(?string $q, ?string $category, string $when): QueryBuilder
{
$qb = $this->notDeleted();
if ($q) {
$qb->andWhere('LOWER(e.title) LIKE :q OR LOWER(e.city) LIKE :q OR LOWER(e.street) LIKE :q')
->setParameter('q', '%'.mb_strtolower($q).'%');
}
$this->filterByCategory($qb, $category);
$this->filterByWhen($qb, $when);
return $qb;
}
/**
* startDate is a raw ISO-8601-ish string ("2026-09-12T18:00:00+02:00"),
* consistently formatted across the imported dataset, so a plain
* lexicographic string comparison against a "Y-m-d" boundary sorts
* correctly without needing to parse it as a real date/time column.
* Applied in SQL (not PHP, post-fetch) so it composes correctly with
* pagination and COUNT — filtering after LIMIT/OFFSET would make the
* page size and total count lie.
*/
private function filterByWhen(QueryBuilder $qb, string $when): void
{
if ('any' === $when) {
return;
}
// Explicit timezone, not the container's (UTC): the imported dates
// and the site's audience are both German-local, so "today" needs
// to mean the German calendar day, not whatever day it happens to
// be in UTC — those disagree for two hours after every UTC
// midnight.
$start = new \DateTimeImmutable('today', new \DateTimeZone('Europe/Berlin'));
$end = match ($when) {
'today' => $start->modify('+1 day'),
'week' => $start->modify('+7 days'),
default => null,
};
if (!$end) {
return;
}
$qb->andWhere('e.startDate >= :whenStart AND e.startDate < :whenEnd')
->setParameter('whenStart', $start->format('Y-m-d'))
->setParameter('whenEnd', $end->format('Y-m-d'));
}
/**
* Hydrates entities for the given ids and returns them in that exact
* order — Doctrine's IN(...) doesn't preserve it.
*
* @param int[] $ids
*
* @return Event[]
*/
private function hydrateInOrder(array $ids): array
{
if (!$ids) {
return [];
}
$events = $this->createQueryBuilder('e')
->andWhere('e.id IN (:ids)')
->setParameter('ids', $ids)
->getQuery()
->getResult();
$order = array_flip($ids);
usort($events, static fn (Event $a, Event $b) => $order[$a->getId()] <=> $order[$b->getId()]);
return $events;
}
private function filterByCategory(QueryBuilder $qb, ?string $category): void
{
if (!$category) {
return;
}
$qb->join('e.categories', 'c')
->andWhere('c.name = :category')
->setParameter('category', $category);
}
private function notDeleted(): QueryBuilder
{
return $this->createQueryBuilder('e')
->andWhere('e.deletedAt IS NULL');
}
/**
* startDate is a raw ISO-ish string column (may be empty when the
* source had no time interval); push undated events to the end
* instead of letting '' sort first.
*/
private function orderByStartDate(QueryBuilder $qb): QueryBuilder
{
return $qb->addSelect("CASE WHEN e.startDate = '' THEN 1 ELSE 0 END AS HIDDEN has_no_date")
->orderBy('has_no_date', 'ASC')
->addOrderBy('e.startDate', 'ASC');
}
}
+15
View File
@@ -0,0 +1,15 @@
<?php
namespace App\Service;
/**
* Köln — the site-wide fallback map center used whenever no real location
* (browser geolocation, a place search, or a URL) is available yet. Shared
* by HomeController and MapController so the "nearest 20" light map and
* the full /map explorer agree on the same default.
*/
final class DefaultLocation
{
public const LAT = 50.9375;
public const LON = 6.9603;
}
@@ -0,0 +1,40 @@
<?php
namespace App\Service;
use App\Entity\Event;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
/**
* Serializes Event entities into the plain JSON array the Leaflet stage
* (public/js/map.js) reads — used by Home, Map, and Event::show, so pulled
* out once rather than duplicated per controller.
*/
class EventMapSerializer
{
public function __construct(private UrlGeneratorInterface $urlGenerator)
{
}
/** @param Event[] $events */
public function toJson(array $events): string
{
return json_encode(
array_map($this->toPoint(...), $events),
JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE
);
}
private function toPoint(Event $event): array
{
return [
'id' => $event->getId(),
'title' => $event->getTitle(),
'venue' => $event->getCity(),
'category' => $event->getCategoryNames()[0] ?? null,
'lat' => $event->getLatitude(),
'lon' => $event->getLongitude(),
'url' => $this->urlGenerator->generate('event_show', ['id' => $event->getId()]),
];
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace App\Service;
/**
* Shared radius options for every location-based filter (the /map
* explorer and /search's "near a location" filter) — one set of
* dropdown choices and bounds instead of each controller inventing its
* own.
*/
final class RangeDefaults
{
public const DEFAULT_KM = 25;
public const MAX_KM = 100;
public const OPTIONS_KM = [5, 10, 25, 50, 100];
}
@@ -0,0 +1,45 @@
<?php
namespace App\Twig;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
/**
* Real ODH category names are German tourism-taxonomy strings, not a fixed
* set of slugs, so colors are derived deterministically from the name
* instead of a hardcoded lookup table.
*/
class CategoryColorExtension extends AbstractExtension
{
public function getFilters(): array
{
return [
new TwigFilter('category_color', $this->categoryColor(...)),
new TwigFilter('category_bg', $this->categoryBg(...)),
];
}
public function categoryColor(?string $name): string
{
if (!$name) {
return 'hsl(220, 10%, 55%)';
}
return sprintf('hsl(%d, 62%%, 42%%)', $this->hue($name));
}
public function categoryBg(?string $name): string
{
if (!$name) {
return 'hsl(220, 15%, 92%)';
}
return sprintf('hsl(%d, 55%%, 92%%)', $this->hue($name));
}
private function hue(string $name): int
{
return crc32($name) % 360;
}
}
+38
View File
@@ -0,0 +1,38 @@
{
"doctrine/deprecations": {
"version": "1.1",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "1.0",
"ref": "87424683adc81d7dc305eefec1fced883084aab9"
}
},
"doctrine/doctrine-bundle": {
"version": "2.19.0"
},
"symfony/console": {
"version": "7.4",
"recipe": {
"version": "5.3"
}
},
"symfony/flex": {
"version": "2.11",
"recipe": {
"version": "2.4"
}
},
"symfony/framework-bundle": {
"version": "v7.4.16"
},
"symfony/routing": {
"version": "7.4",
"recipe": {
"version": "7.4"
}
},
"symfony/twig-bundle": {
"version": "v7.4.15"
}
}
@@ -0,0 +1,10 @@
{# Leaflet + plugin stylesheets, shared by every page that renders a map. #}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet.fullscreen/3.0.2/Control.FullScreen.min.css">
<link rel="stylesheet" href="https://unpkg.com/leaflet-gesture-handling@1.2.2/dist/leaflet-gesture-handling.min.css">
{# OpenFreeMap serves vector tiles only — MapLibre GL renders them, bridged into our Leaflet map via maplibre-gl-leaflet. #}
<link href="https://unpkg.com/maplibre-gl@5/dist/maplibre-gl.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/1.5.3/MarkerCluster.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/1.5.3/MarkerCluster.Default.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/leaflet.awesome-markers@2.0.5/dist/leaflet.awesome-markers.css">
@@ -0,0 +1,11 @@
{# Leaflet + plugins + our map.js wrapper, shared by every page that renders a map. #}
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.min.js"></script>
{# Requires a two-finger drag / Ctrl+scroll to pan/zoom on touch/trackpad, with an on-map hint, so the map doesn't trap page scroll. #}
<script src="https://unpkg.com/leaflet-gesture-handling@1.2.2/dist/leaflet-gesture-handling.min.js"></script>
{# OpenFreeMap vector tiles: MapLibre GL does the rendering, maplibre-gl-leaflet bridges it into our Leaflet map as an ordinary layer. #}
<script src="https://unpkg.com/maplibre-gl@5/dist/maplibre-gl.js"></script>
<script src="https://unpkg.com/@maplibre/maplibre-gl-leaflet/leaflet-maplibre-gl.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.fullscreen/3.0.2/Control.FullScreen.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/1.5.3/leaflet.markercluster.js"></script>
<script src="https://cdn.jsdelivr.net/npm/leaflet.awesome-markers@2.0.5/dist/leaflet.awesome-markers.min.js"></script>
<script src="{{ asset('js/map.js') }}"></script>
+69
View File
@@ -0,0 +1,69 @@
{#
Reusable interactive map stage: pin map, event search box, "use my
location" button, and a nearby-events panel. Include on any page that
has defined `mapEventsJson` and `categories` in scope, then call
Vindn.initMapStage() (home) or Vindn.initRadiusMapStage() (/map) from
that page's scripts block.
Pass `compact: true` for the lighter home-page hero variant: hides the
category chips/legend and the location-search/range controls, and uses
a contained card height instead of the full-viewport /map takeover.
#}
{% set compact = compact|default(false) %}
<section class="stage{{ compact ? ' stage-compact' : '' }}">
<div id="mapCanvas" role="application" aria-label="Map of events"></div>
<div class="map-overlay-top">
<div class="float-card search-card">
<form action="{{ path('search') }}">
<label for="mapSearch" style="display:none;">Search events</label>
<input id="mapSearch" name="q" type="text" placeholder="Search events…">
<button class="btn btn-primary btn-sm" type="submit">Search</button>
</form>
{% if not compact %}
<div class="chip-row-tight" id="catChips">
<button class="chip-sm is-active" data-cat="all">All</button>
{% for category in categories %}
<button class="chip-sm" data-cat="{{ category }}">{{ category }}</button>
{% endfor %}
</div>
{% endif %}
</div>
<div class="float-card locate-card">
{% if not compact %}
<form id="locationSearchForm">
<label for="locationSearch" style="display:none;">Search a place</label>
<input id="locationSearch" type="text" placeholder="Search a place…" autocomplete="off">
<button class="btn btn-ghost btn-sm" type="submit" aria-label="Center map on this place">Go</button>
</form>
{% endif %}
<button class="locate-btn" id="locateBtn" type="button">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="3"/><path d="M12 2v3M12 19v3M2 12h3M19 12h3"/></svg>
Use my location
</button>
{% if not compact %}
<label class="range-label">
Range
<select id="rangeSelect">
{% for km in rangeOptions %}
<option value="{{ km }}" {{ km == rangeKm ? 'selected' : '' }}>{{ km }} km</option>
{% endfor %}
</select>
</label>
{% endif %}
<p class="locate-status" id="locateStatus">{{ compact ? 'Showing events near Nordrhein-Westfalen' : 'Showing events within ' ~ rangeKm ~ ' km' }}</p>
</div>
</div>
{% if not compact %}
<div class="legend float-card" id="legend"></div>
{% endif %}
<aside class="panel board" aria-label="Events">
<div class="panel-head">
<span class="eyebrow" style="color:var(--board-muted);">{{ compact ? 'Nearest to you' : 'Events' }}</span>
<span class="count" id="resultCount">— events</span>
</div>
<div class="panel-list" id="panelList"></div>
</aside>
</section>
+24
View File
@@ -0,0 +1,24 @@
{#
Compact pager: first / previous / current / next / last — deliberately
not a full list of page numbers, since result sets here can run into
the hundreds of pages.
Params:
currentPage, totalPages: integers
routeName: the route to link back to
routeParams: all params to preserve *except* `page` (e.g. category,
q, when, lat, lon, range)
#}
{% if totalPages > 1 %}
<nav class="pager" aria-label="Pagination">
{% if currentPage > 1 %}
<a href="{{ path(routeName, routeParams|merge({page: 1})) }}" aria-label="First page">« First</a>
<a href="{{ path(routeName, routeParams|merge({page: currentPage - 1})) }}" aria-label="Previous page">‹ Prev</a>
{% endif %}
<span class="is-active">Page {{ currentPage }} of {{ totalPages }}</span>
{% if currentPage < totalPages %}
<a href="{{ path(routeName, routeParams|merge({page: currentPage + 1})) }}" aria-label="Next page">Next ›</a>
<a href="{{ path(routeName, routeParams|merge({page: totalPages})) }}" aria-label="Last page">Last »</a>
{% endif %}
</nav>
{% endif %}
+67
View File
@@ -0,0 +1,67 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}VINDN — Find what's on{% endblock %}</title>
<link rel="stylesheet" href="{{ asset('styles.css') }}">
{% block head_extra %}{% endblock %}
</head>
<body>
<a href="#main" class="skip-link">Skip to content</a>
<header class="site-header">
<div class="wrap">
<a href="{{ path('home') }}" class="brand" aria-label="VINDN home">
<img src="{{ asset('images/vindn_logo_adobe.svg') }}" alt="VINDN">
</a>
<nav class="main-nav" aria-label="Primary">
<a href="{{ path('home') }}" class="{{ activeNav == 'home' ? 'is-active' : '' }}">Home</a>
<a href="{{ path('event_list') }}" class="{{ activeNav == 'events' ? 'is-active' : '' }}">Browse events</a>
<a href="{{ path('map') }}" class="{{ activeNav == 'map' ? 'is-active' : '' }}">Map</a>
<a href="{{ path('search') }}" class="{{ activeNav == 'search' ? 'is-active' : '' }}">Search</a>
</nav>
<div class="nav-actions">
<form class="nav-search" action="{{ path('search') }}" role="search">
<button type="submit" aria-label="Search">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="7"/><path d="M21 21l-4.3-4.3"/></svg>
</button>
<label for="navSearchInput" style="display:none;">Search events</label>
<input id="navSearchInput" type="text" name="q" placeholder="Search events…" autocomplete="off" value="{{ app.request.query.get('q') }}">
</form>
<button class="nav-burger" aria-label="Open menu" aria-expanded="false" aria-controls="mobileMenu"><span></span><span></span><span></span></button>
</div>
</div>
<div class="mobile-menu" id="mobileMenu" hidden>
<nav aria-label="Primary">
<a href="{{ path('home') }}" class="{{ activeNav == 'home' ? 'is-active' : '' }}">Home</a>
<a href="{{ path('event_list') }}" class="{{ activeNav == 'events' ? 'is-active' : '' }}">Browse events</a>
<a href="{{ path('map') }}" class="{{ activeNav == 'map' ? 'is-active' : '' }}">Map</a>
<a href="{{ path('search') }}" class="{{ activeNav == 'search' ? 'is-active' : '' }}">Search</a>
</nav>
<form class="mobile-search" action="{{ path('search') }}" role="search">
<label for="mobileSearchInput" style="display:none;">Search events</label>
<input id="mobileSearchInput" type="text" name="q" placeholder="Search events…" autocomplete="off" value="{{ app.request.query.get('q') }}">
<button type="submit">Search</button>
</form>
</div>
</header>
<main id="main">
{% block body %}{% endblock %}
</main>
<footer class="site-footer">
<div class="wrap">
{% block footer %}
<div class="footer-bottom" style="border-top:none; margin-top:0; padding-top:0;">
<span>© 2026 VINDN</span>
</div>
{% endblock %}
</div>
</footer>
<script src="{{ asset('js/nav.js') }}"></script>
{% block scripts %}{% endblock %}
</body>
</html>
+21
View File
@@ -0,0 +1,21 @@
{% set category = event.categoryNames|first %}
{% set image = event.primaryImage %}
<a class="event-card" href="{{ path('event_show', {id: event.id}) }}">
{% if image %}
<div class="glyph-tile" style="padding:0;">
<img src="{{ image.storagePath }}" alt="" loading="lazy" style="position:absolute; inset:0; width:100%; height:100%; object-fit:cover;">
</div>
{% else %}
<div class="glyph-tile" style="background:{{ category|category_bg }}; color:{{ category|category_color }};">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6"><circle cx="12" cy="12" r="9"/><path d="M12 3v18M3 12h18"/></svg>
</div>
{% endif %}
<div class="body">
{% if category %}
<span class="tag" style="background:{{ category|category_bg }}; color:{{ category|category_color }};">{{ category }}</span>
{% endif %}
<h3>{{ event.title }}</h3>
<p class="when">{{ event.startDateTime ? event.startDateTime|date('D, M j · H:i') : 'Date TBD' }}</p>
<p class="place">{{ [event.street, event.city]|filter(v => v)|join(', ') ?: event.country }}</p>
</div>
</a>
+55
View File
@@ -0,0 +1,55 @@
{% extends 'base.html.twig' %}
{% block title %}Browse events — VINDN{% endblock %}
{% block head_extra %}
<style>
.toolbar{ display:flex; justify-content:space-between; align-items:center; gap:16px; flex-wrap:wrap; margin-bottom:20px; }
</style>
{% endblock %}
{% block body %}
<section class="section" style="padding-bottom:0;">
<div class="wrap">
<p class="eyebrow" style="margin-bottom:10px;">All events</p>
<div class="toolbar">
<h1 style="font-size:clamp(28px,4vw,40px);">What's on{{ activeCategory ? ' — ' ~ activeCategory : '' }}</h1>
<p class="mono" style="font-size:13px; color:var(--muted);">{{ total }} event{{ total == 1 ? '' : 's' }}</p>
</div>
<input type="checkbox" id="catsToggle" class="chip-toggle-checkbox">
<div class="chip-row chip-row-collapsible">
<a href="{{ path('event_list') }}" class="chip {{ activeCategory is null ? 'is-active' : '' }}">All</a>
{% for category in categories %}
<a href="{{ path('event_list', {category: category}) }}" class="chip {{ activeCategory == category ? 'is-active' : '' }}">{{ category }}</a>
{% endfor %}
</div>
<label for="catsToggle" class="chip-toggle-btn" style="margin-bottom:32px;">
<span class="show-more">Show all categories ↑</span>
<span class="show-less">Show fewer categories ↑</span>
</label>
</div>
</section>
<section class="section" style="padding-top:0;">
<div class="wrap">
<div class="card-grid">
{% for event in events %}
{% include 'events/_card.html.twig' with { event: event } %}
{% else %}
<div class="no-results" style="grid-column:1/-1; padding:60px 20px; text-align:center; color:var(--muted); border:1px dashed var(--line-strong); border-radius:var(--r-card);">
<p class="eyebrow" style="margin-bottom:8px;">No events</p>
<p>Nothing matches this filter yet — try "All" or check back once the importer has run.</p>
</div>
{% endfor %}
</div>
{% include '_pager.html.twig' with {
currentPage: page,
totalPages: totalPages,
routeName: 'event_list',
routeParams: { category: activeCategory }
} %}
</div>
</section>
{% endblock %}
+113
View File
@@ -0,0 +1,113 @@
{% extends 'base.html.twig' %}
{% set category = event.categoryNames|first %}
{% set image = event.primaryImage %}
{% block title %}{{ event.title }} — VINDN{% endblock %}
{% block head_extra %}
{% include '_leaflet_head.html.twig' %}
<style>
.breadcrumb{ font-family:var(--f-mono); font-size:12px; color:var(--muted); margin-bottom:18px; }
.breadcrumb a:hover{ color:var(--accent); }
.hero-tile{
aspect-ratio: 16/6; border-radius:var(--r-card); position:relative; overflow:hidden;
display:flex; align-items:center; justify-content:center;
}
.hero-tile img{ position:absolute; inset:0; width:100%; height:100%; object-fit:cover; }
.hero-tile svg{ width:18%; opacity:.9; }
.detail-grid{ display:grid; grid-template-columns: 1fr 360px; gap:44px; margin-top:36px; align-items:start; }
.detail-grid h2{ font-size:22px; margin-bottom:14px; }
.prose p{ color:var(--ink-soft); margin:0 0 16px; font-size:15.5px; line-height:1.7; }
.info-board{ background:var(--board-bg); border-radius:var(--r-card); color:var(--board-text); padding:24px; position:sticky; top:96px; }
.info-board .row{ display:flex; justify-content:space-between; gap:12px; padding:13px 0; border-bottom:1px solid #2B2B22; font-size:13px; }
.info-board .row:first-child{ padding-top:0; }
.info-board .row:last-child{ border-bottom:none; }
.info-board .row .k{ font-family:var(--f-mono); color:var(--board-muted); flex:none; }
.info-board .row .v{ font-family:var(--f-mono); text-align:right; }
.info-board .row .v a{ color:inherit; }
#eventMapCanvas{ aspect-ratio:16/8; border-radius:var(--r-card); }
@media (max-width:900px){ .detail-grid{ grid-template-columns:1fr; } .info-board{ position:static; } }
</style>
{% endblock %}
{% block body %}
<section class="section">
<div class="wrap">
<p class="breadcrumb">
<a href="{{ path('event_list') }}">Browse events</a>
{% if category %} / <a href="{{ path('event_list', {category: category}) }}">{{ category }}</a>{% endif %}
/ {{ event.title }}
</p>
<div class="hero-tile" style="background:{{ category|category_bg }};">
{% if image %}
<img src="{{ image.storagePath }}" alt="">
{% else %}
<svg viewBox="0 0 24 24" fill="none" stroke="{{ category|category_color }}" stroke-width="1.4"><circle cx="12" cy="12" r="9"/><path d="M12 3v18M3 12h18"/></svg>
{% endif %}
</div>
<div style="display:flex; align-items:flex-start; justify-content:space-between; gap:20px; margin-top:28px; flex-wrap:wrap;">
<div>
{% if category %}<span class="tag" style="background:{{ category|category_bg }}; color:{{ category|category_color }};">{{ category }}</span>{% endif %}
<h1 style="font-size:clamp(28px,4vw,42px); margin-top:14px; max-width:640px;">{{ event.title }}</h1>
<p class="mono" style="color:var(--muted); margin-top:10px; font-size:13px;">
{{ event.startDateTime ? event.startDateTime|date('D, M j · H:i')|upper : 'DATE TBD' }}
{% if event.city %} · {{ event.city|upper }}{% endif %}
</p>
</div>
</div>
<div class="detail-grid">
<div>
{% if event.description %}
<div class="prose">
<h2>About this event</h2>
<p>{{ event.description }}</p>
</div>
{% elseif event.teaser %}
<div class="prose">
<h2>About this event</h2>
<p>{{ event.teaser }}</p>
</div>
{% endif %}
{% if event.hasCoordinates %}
<h2 style="margin-top:36px;">Location</h2>
<div id="eventMapCanvas" role="application" aria-label="Map showing the event location"></div>
{% endif %}
<p style="margin-top:14px; font-size:14px; color:var(--muted);">
{{ [event.street, (event.zip ~ ' ' ~ event.city)|trim, event.country]|filter(v => v)|join(', ') }}
</p>
</div>
<!-- sticky info board -->
<aside class="info-board" aria-label="Event details">
<div class="row"><span class="k">Starts</span><span class="v">{{ event.startDateTime ? event.startDateTime|date('D, M j · H:i') : 'TBD' }}</span></div>
{% if event.endDateTime %}
<div class="row"><span class="k">Ends</span><span class="v">{{ event.endDateTime|date('D, M j · H:i') }}</span></div>
{% endif %}
{% if event.city %}<div class="row"><span class="k">City</span><span class="v">{{ event.city }}</span></div>{% endif %}
{% if event.type %}<div class="row"><span class="k">Type</span><span class="v">{{ event.type }}</span></div>{% endif %}
{% if event.phone %}<div class="row"><span class="k">Phone</span><span class="v"><a href="tel:{{ event.phone }}">{{ event.phone }}</a></span></div>{% endif %}
{% if event.email %}<div class="row"><span class="k">Email</span><span class="v"><a href="mailto:{{ event.email }}">{{ event.email }}</a></span></div>{% endif %}
{% if event.web %}
<div class="row" style="border-bottom:none;"><span class="k">Website</span><span class="v"><a href="{{ event.web }}" target="_blank" rel="noopener">Visit site →</a></span></div>
{% endif %}
</aside>
</div>
</div>
</section>
{% endblock %}
{% block scripts %}
{% if event.hasCoordinates %}
{% include '_leaflet_scripts.html.twig' %}
<script type="application/json" id="event-map-data">{{ mapEventJson|raw }}</script>
<script>
Vindn.renderPinMap('eventMapCanvas', Vindn.readEmbeddedJson('event-map-data'), { zoom: 14, zoomControl: true, attributionControl: true });
</script>
{% endif %}
{% endblock %}
+111
View File
@@ -0,0 +1,111 @@
{% extends 'base.html.twig' %}
{% block title %}VINDN — Find what's on{% endblock %}
{% block head_extra %}
{% include '_leaflet_head.html.twig' %}
{% endblock %}
{% block body %}
<!-- MAP HERO — light: nearest ~20 events, refines once you share your location -->
<section class="section" style="padding:0;">
<div class="wrap">
<p class="eyebrow" style="margin-bottom:8px;">Nordrhein-Westfalen — updated every hour</p>
<div class="section-head">
<h1 style="font-size:clamp(28px,4vw,40px);">What's on near you</h1>
<a href="{{ path('map') }}" class="btn btn-primary btn-sm">Open full map →</a>
</div>
</div>
</section>
<section class="section" style="padding:0;">
{% include '_map_stage.html.twig' with { compact: true } %}
</section>
<!-- BROWSE EVENTS -->
<section class="section">
<div class="wrap">
<div class="section-head">
<div>
<p class="eyebrow" style="margin-bottom:8px;">Browse</p>
<h2>Find events by category</h2>
</div>
<a href="{{ path('event_list') }}" class="section-link">Browse all events →</a>
</div>
<div class="chip-row">
{% for category in popularCategories %}
<a href="{{ path('event_list', {category: category}) }}" class="chip">{{ category }}</a>
{% endfor %}
</div>
</div>
</section>
<!-- THIS WEEK -->
<section class="section" style="background:var(--paper-dim);">
<div class="wrap">
<div class="section-head">
<div>
<p class="eyebrow" style="margin-bottom:8px;">Live from the importer</p>
<h2>Worth planning around</h2>
</div>
<a href="{{ path('event_list') }}" class="section-link">Browse all events →</a>
</div>
<div class="card-grid">
{% for event in upcomingEvents %}
{% include 'events/_card.html.twig' with { event: event } %}
{% else %}
<p style="color:var(--muted);">No events imported yet — check back once the backend's import job has run.</p>
{% endfor %}
</div>
</div>
</section>
{% endblock %}
{% block footer %}
<div class="footer-grid">
<div>
<img src="{{ asset('images/vindn_logo_adobe.svg') }}" alt="VINDN" style="height:24px; margin-bottom:14px;">
<p style="max-width:260px; font-size:14px; color:var(--muted);">The board for everything on, wherever you are.</p>
</div>
<div>
<h4>Explore</h4>
<ul>
<li><a href="{{ path('event_list') }}">Browse events</a></li>
<li><a href="{{ path('search') }}">Search</a></li>
<li><a href="{{ path('map') }}">Map</a></li>
</ul>
</div>
<div>
<h4>Organizers</h4>
<ul>
<li><a href="#">List an event</a></li>
<li><a href="#">Pricing</a></li>
<li><a href="#">Guidelines</a></li>
</ul>
</div>
<div>
<h4>Company</h4>
<ul>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">Privacy</a></li>
</ul>
</div>
</div>
<div class="footer-bottom">
<span>© 2026 VINDN</span>
</div>
{% endblock %}
{% block scripts %}
{% include '_leaflet_scripts.html.twig' %}
<script type="application/json" id="map-data">{{ mapEventsJson|raw }}</script>
<script>
Vindn.initMapStage({
events: Vindn.readEmbeddedJson('map-data'),
limit: 20,
defaultCenter: [{{ centerLat }}, {{ centerLon }}]
});
</script>
{% endblock %}
+24
View File
@@ -0,0 +1,24 @@
{% extends 'base.html.twig' %}
{% block title %}Map — VINDN{% endblock %}
{% block head_extra %}
{% include '_leaflet_head.html.twig' %}
{% endblock %}
{% block body %}
{% include '_map_stage.html.twig' %}
{% endblock %}
{% block scripts %}
{% include '_leaflet_scripts.html.twig' %}
<script type="application/json" id="map-data">{{ mapEventsJson|raw }}</script>
<script>
Vindn.initRadiusMapStage({
events: Vindn.readEmbeddedJson('map-data'),
center: [{{ centerLat }}, {{ centerLon }}],
rangeKm: {{ rangeKm }},
maxRangeKm: {{ maxRangeKm }}
});
</script>
{% endblock %}
+230
View File
@@ -0,0 +1,230 @@
{% extends 'base.html.twig' %}
{% block title %}Search — VINDN{% endblock %}
{% block head_extra %}
<style>
.search-shell{ display:grid; grid-template-columns: 260px 1fr; gap:36px; align-items:start; }
.filter-group{ padding-bottom:22px; margin-bottom:22px; border-bottom:1px solid var(--line); }
.filter-group:last-child{ border-bottom:none; }
.filter-group h4{ font-family:var(--f-mono); font-size:12px; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); margin:0 0 14px; }
.filter-option{ display:flex; align-items:center; gap:10px; font-size:14px; padding:6px 0; cursor:pointer; }
.filter-option input{ accent-color: var(--accent); width:16px; height:16px; }
.results-toolbar{ display:flex; justify-content:space-between; align-items:center; margin-bottom:18px; flex-wrap:wrap; gap:12px; }
.search-input-bar{ display:flex; gap:10px; margin-bottom:28px; }
.search-input-bar input{ flex:1; padding:16px 20px; border:1px solid var(--line-strong); border-radius: var(--r-pill); font-size:15px; }
.no-results{ padding:60px 20px; text-align:center; color:var(--muted); border:1px dashed var(--line-strong); border-radius:var(--r-card); }
#locationSearchForm{ display:flex; gap:6px; margin-bottom:10px; }
#locationSearchForm input{ flex:1; min-width:0; padding:9px 10px; border:1px solid var(--line-strong); border-radius:6px; font-size:13px; }
.range-row{ display:flex; align-items:center; justify-content:space-between; gap:8px; margin-top:10px; font-size:13px; }
.range-row select{ padding:6px 8px; border:1px solid var(--line-strong); border-radius:6px; font-family:var(--f-mono); font-size:12px; background:#fff; }
#locationStatus{ font-family:var(--f-mono); font-size:11px; color:var(--muted); margin-top:8px; }
@media (max-width: 860px){ .search-shell{ grid-template-columns:1fr; } }
</style>
{% endblock %}
{% block body %}
<section class="section" style="padding-bottom:0;">
<div class="wrap">
<p class="eyebrow" style="margin-bottom:10px;">Search</p>
<h1 style="font-size:clamp(28px,4vw,40px); margin-bottom:24px;">
{{ q ? 'Searching: "' ~ q ~ '"' : 'Search events' }}
</h1>
<form class="search-input-bar" method="get" action="{{ path('search') }}">
{% if activeCategory %}<input type="hidden" name="category" value="{{ activeCategory }}">{% endif %}
{% if hasLocation %}
<input type="hidden" name="lat" value="{{ lat }}">
<input type="hidden" name="lon" value="{{ lon }}">
<input type="hidden" name="range" value="{{ rangeKm }}">
{% endif %}
<label for="q" style="display:none;">Search events</label>
<input id="q" name="q" type="text" value="{{ q }}" placeholder="Search by event, venue or city…">
<button class="btn btn-primary" type="submit">Search</button>
</form>
</div>
</section>
<section class="section" style="padding-top:0;">
<div class="wrap">
<div class="search-shell">
<!-- FILTERS -->
<aside aria-label="Filters">
<div class="filter-group">
<h4>Near a location</h4>
<form id="locationSearchForm">
<label for="locationSearchInput" style="display:none;">Search a place</label>
<input id="locationSearchInput" type="text" placeholder="Search a place…" autocomplete="off">
<button class="btn btn-ghost btn-sm" type="submit" aria-label="Search near this place">Go</button>
</form>
<button type="button" class="btn btn-ghost btn-sm" id="useMyLocationBtn" style="width:100%; justify-content:center;">Use my location</button>
{% if hasLocation %}
<div class="range-row">
<span>Within</span>
<select id="rangeSelect">
{% for km in rangeOptions %}
<option value="{{ km }}" {{ km == rangeKm ? 'selected' : '' }}>{{ km }} km</option>
{% endfor %}
</select>
</div>
<p id="locationStatus">
Near {{ lat|number_format(3) }}, {{ lon|number_format(3) }} —
<a href="{{ path('search', {q: q ?: null, category: activeCategory, when: when != 'any' ? when : null}) }}" style="color:var(--accent); text-decoration:underline;">clear</a>
</p>
{% else %}
<p id="locationStatus"></p>
{% endif %}
</div>
<form method="get" action="{{ path('search') }}" id="filterForm">
<input type="hidden" name="q" value="{{ q }}">
{% if hasLocation %}
<input type="hidden" name="lat" value="{{ lat }}">
<input type="hidden" name="lon" value="{{ lon }}">
<input type="hidden" name="range" value="{{ rangeKm }}">
{% endif %}
<div class="filter-group">
<h4>Category</h4>
<label class="filter-option">
<input type="radio" name="category" value="" {{ activeCategory ? '' : 'checked' }} onchange="this.form.submit()"> All
</label>
{% for category in categories %}
<label class="filter-option">
<input type="radio" name="category" value="{{ category }}" {{ activeCategory == category ? 'checked' : '' }} onchange="this.form.submit()"> {{ category }}
</label>
{% endfor %}
</div>
<div class="filter-group">
<h4>When</h4>
<label class="filter-option"><input type="radio" name="when" value="any" {{ when == 'any' ? 'checked' : '' }} onchange="this.form.submit()"> Any date</label>
<label class="filter-option"><input type="radio" name="when" value="today" {{ when == 'today' ? 'checked' : '' }} onchange="this.form.submit()"> Today</label>
<label class="filter-option"><input type="radio" name="when" value="week" {{ when == 'week' ? 'checked' : '' }} onchange="this.form.submit()"> Next 7 days</label>
</div>
<a href="{{ path('search') }}" class="btn btn-ghost btn-sm" style="width:100%; justify-content:center;">Clear filters</a>
</form>
</aside>
<!-- RESULTS -->
<div>
<div class="results-toolbar">
<p class="mono" style="font-size:13px; color:var(--muted);">
{{ total }} EVENT{{ total == 1 ? '' : 'S' }} MATCH{{ hasLocation ? ' · SORTED BY DISTANCE' : '' }}
</p>
</div>
{% if events|length %}
<div class="board" aria-label="Search results">
{% for event in events %}
<a class="board-row" href="{{ path('event_show', {id: event.id}) }}" aria-label="View {{ event.title }}">
<div class="board-date">
{{ event.startDateTime ? event.startDateTime|date('M j') : '—' }}
<span class="dow">{{ event.startDateTime ? event.startDateTime|date('D') : 'TBD' }}</span>
</div>
<div class="board-name">
{{ event.title }}
<span class="where">
{{ event.city }}{% if event.categoryNames|first %} · {{ event.categoryNames|first }}{% endif %}
{% if hasLocation and distances[event.id] is defined %}
{% set dist = distances[event.id] %}
· {{ dist < 1 ? (dist * 1000)|round ~ ' m' : (dist < 10 ? dist|round(1) : dist|round) ~ ' km' }} away
{% endif %}
</span>
</div>
<div class="board-status">{{ event.startDateTime ? event.startDateTime|date('H:i') : '' }}</div>
<div class="board-go">→</div>
</a>
{% endfor %}
</div>
{% else %}
<div class="no-results">
<p class="eyebrow" style="margin-bottom:8px;">No matches</p>
<p>Nothing fits those filters yet. Try clearing a filter or a different search term.</p>
</div>
{% endif %}
{% include '_pager.html.twig' with {
currentPage: page,
totalPages: totalPages,
routeName: 'search',
routeParams: {
q: q ?: null,
category: activeCategory,
when: when != 'any' ? when : null,
lat: hasLocation ? lat : null,
lon: hasLocation ? lon : null,
range: hasLocation ? rangeKm : null
}
} %}
</div>
</div>
</div>
</section>
{% endblock %}
{% block scripts %}
<script>
(function(){
var currentLat = {{ hasLocation ? lat : 'null' }};
var currentLon = {{ hasLocation ? lon : 'null' }};
function navigateWithLocation(lat, lon, rangeKm) {
var url = new URL(window.location.href);
url.searchParams.set('lat', lat.toFixed(5));
url.searchParams.set('lon', lon.toFixed(5));
url.searchParams.set('range', rangeKm || url.searchParams.get('range') || 25);
url.searchParams.delete('page'); // the result set changed, page N may no longer exist
window.location.href = url.toString();
}
var locationForm = document.getElementById('locationSearchForm');
if (locationForm) {
locationForm.addEventListener('submit', function (e) {
e.preventDefault();
var input = document.getElementById('locationSearchInput');
var query = (input.value || '').trim();
if (!query) return;
var statusEl = document.getElementById('locationStatus');
if (statusEl) statusEl.textContent = 'Looking up "' + query + '"…';
fetch('https://nominatim.openstreetmap.org/search?format=json&limit=1&q=' + encodeURIComponent(query))
.then(function (res) { return res.json(); })
.then(function (results) {
if (!results || !results.length) {
if (statusEl) statusEl.textContent = 'Could not find "' + query + '"';
return;
}
navigateWithLocation(parseFloat(results[0].lat), parseFloat(results[0].lon));
})
.catch(function () {
if (statusEl) statusEl.textContent = 'Location search failed';
});
});
}
var useMyLocationBtn = document.getElementById('useMyLocationBtn');
if (useMyLocationBtn) {
useMyLocationBtn.addEventListener('click', function () {
var statusEl = document.getElementById('locationStatus');
if (!navigator.geolocation) {
if (statusEl) statusEl.textContent = 'Location not supported by your browser';
return;
}
if (statusEl) statusEl.textContent = 'Finding you…';
navigator.geolocation.getCurrentPosition(function (pos) {
navigateWithLocation(pos.coords.latitude, pos.coords.longitude);
}, function () {
if (statusEl) statusEl.textContent = "Couldn't get your location";
}, { timeout: 8000 });
});
}
var rangeSelect = document.getElementById('rangeSelect');
if (rangeSelect) {
rangeSelect.addEventListener('change', function () {
if (currentLat === null || currentLon === null) return;
navigateWithLocation(currentLat, currentLon, parseInt(rangeSelect.value, 10));
});
}
})();
</script>
{% endblock %}