feat: student name popover preview on /repertoire via htmx

This commit is contained in:
Pontoporeia
2026-04-24 13:11:15 +02:00
parent d961f9533c
commit ede53746ba
18 changed files with 237 additions and 278 deletions

View File

@@ -203,6 +203,30 @@ class SearchController
* Render the repertoire index partial and exit (for HTMX swaps).
* Never returns.
*/
/**
* HTMX endpoint: returns a popover snippet for a student name.
* Renders directly and exits.
*/
public function handleStudentPreview(): never {
$name = trim($_GET['name'] ?? '');
header('Content-Type: text/html; charset=UTF-8');
if ($name === '') {
echo '';
exit();
}
$theses = $this->db->getThesesByAuthorName($name);
if (empty($theses)) {
echo '';
exit();
}
include APP_ROOT . '/templates/partials/student-preview.php';
exit();
}
private function renderRepertoirePartial(
array $repData,
array $activeFilters,

View File

@@ -455,6 +455,24 @@ class Database {
return $stmt->fetchAll();
}
/**
* Fetch all published theses for a given author name.
* Returns rows of [id => int, title => string].
*/
public function getThesesByAuthorName(string $name): array {
$stmt = $this->pdo->prepare(
"SELECT t.id, t.title
FROM theses t
JOIN thesis_authors ta ON ta.thesis_id = t.id
JOIN authors a ON a.id = ta.author_id
WHERE t.is_published = 1
AND a.name = ?
ORDER BY t.year DESC, t.title ASC"
);
$stmt->execute([$name]);
return $stmt->fetchAll();
}
public function getAvailableYears() {
$sql = "SELECT DISTINCT year FROM theses WHERE is_published = 1 ORDER BY year DESC";
$stmt = $this->pdo->query($sql);

View File

@@ -107,6 +107,17 @@ class Dispatcher {
};
}
// /repertoire/student-preview (HTMX popover)
if ($path === '/repertoire/student-preview') {
return function() {
require_once APP_ROOT . '/src/Database.php';
require_once APP_ROOT . '/src/RateLimit.php';
require_once APP_ROOT . '/src/Controllers/SearchController.php';
$controller = SearchController::create();
$controller->handleStudentPreview();
};
}
// /partage/*
if (preg_match('#^/partage(/.*)?$#', $path)) {
return function() {