Refactor index.php to use absolute paths for logos; add logo existence check function
This commit is contained in:
parent
625945d88f
commit
6b43788556
142
index.php
142
index.php
@ -1,18 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Absolute Webpfade verwenden!
|
||||||
|
* Ordnerstruktur im Webroot:
|
||||||
|
* /icons/...
|
||||||
|
* /style.css
|
||||||
|
*/
|
||||||
|
|
||||||
$projects = [
|
$projects = [
|
||||||
"privat" => [
|
"privat" => [
|
||||||
[
|
[
|
||||||
"title" => "Gitea",
|
"title" => "Gitea",
|
||||||
"description" => "Mein privates Git-Repository – Quellcode, Projekte & mehr.",
|
"description" => "Mein privates Git-Repository – Quellcode, Projekte & mehr.",
|
||||||
"url" => "/git",
|
"url" => "/git",
|
||||||
"logo" => "icons/gitea.svg",
|
"logo" => "/icons/gitea.svg",
|
||||||
"color" => "#609926"
|
"color" => "#609926"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"title" => "Nextcloud",
|
"title" => "Nextcloud",
|
||||||
"description" => "Meine persönliche Cloud – Dateien, Kalender & Kontakte.",
|
"description" => "Meine persönliche Cloud – Dateien, Kalender & Kontakte.",
|
||||||
"url" => "/nextcloud",
|
"url" => "/nextcloud",
|
||||||
"logo" => "icons/nextcloud.svg",
|
"logo" => "/icons/nextcloud.svg",
|
||||||
"color" => "#0082c9"
|
"color" => "#0082c9"
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
@ -21,7 +30,7 @@ $projects = [
|
|||||||
"title" => "Geizkragen.store",
|
"title" => "Geizkragen.store",
|
||||||
"description" => "Schulprojekt – Ein Online-Shop für Schnäppchenjäger.",
|
"description" => "Schulprojekt – Ein Online-Shop für Schnäppchenjäger.",
|
||||||
"url" => "https://geizkragen.store",
|
"url" => "https://geizkragen.store",
|
||||||
"logo" => "icons/geizkragen.png",
|
"logo" => "/icons/geizkragen.png",
|
||||||
"color" => "#e8281e",
|
"color" => "#e8281e",
|
||||||
"external" => true
|
"external" => true
|
||||||
],
|
],
|
||||||
@ -31,7 +40,7 @@ $projects = [
|
|||||||
"title" => "Home Assistant",
|
"title" => "Home Assistant",
|
||||||
"description" => "Meine Smart-Home-Zentrale – Automatisierungen & Geräte.",
|
"description" => "Meine Smart-Home-Zentrale – Automatisierungen & Geräte.",
|
||||||
"url" => "http://homeassistant.fabianschieder.com",
|
"url" => "http://homeassistant.fabianschieder.com",
|
||||||
"logo" => "icons/homeassistant.svg",
|
"logo" => "/icons/homeassistant.svg",
|
||||||
"color" => "#18BCF2",
|
"color" => "#18BCF2",
|
||||||
"external" => true
|
"external" => true
|
||||||
],
|
],
|
||||||
@ -39,12 +48,22 @@ $projects = [
|
|||||||
"title" => "NAS",
|
"title" => "NAS",
|
||||||
"description" => "Mein Netzwerkspeicher – Daten & Backups.",
|
"description" => "Mein Netzwerkspeicher – Daten & Backups.",
|
||||||
"url" => "http://nas.fabianschieder.com",
|
"url" => "http://nas.fabianschieder.com",
|
||||||
"logo" => "icons/nas.svg",
|
"logo" => "/icons/nas.svg",
|
||||||
"color" => "#a855f7",
|
"color" => "#a855f7",
|
||||||
"external" => true
|
"external" => true
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optional: Prüft serverseitig, ob die Logo-Datei existiert.
|
||||||
|
* Verhindert Broken Images.
|
||||||
|
*/
|
||||||
|
function logoExists(string $webPath): bool {
|
||||||
|
$filePath = $_SERVER['DOCUMENT_ROOT'] . $webPath;
|
||||||
|
return is_file($filePath);
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="de">
|
<html lang="de">
|
||||||
@ -52,76 +71,77 @@ $projects = [
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Fabian Schieder</title>
|
<title>Fabian Schieder</title>
|
||||||
<link rel="stylesheet" href="style.css">
|
<link rel="stylesheet" href="/style.css">
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div class="background-blur"></div>
|
<div class="background-blur"></div>
|
||||||
|
|
||||||
<header>
|
<header>
|
||||||
<div class="avatar">FS</div>
|
<div class="avatar">FS</div>
|
||||||
<h1>Fabian Schieder</h1>
|
<h1>Fabian Schieder</h1>
|
||||||
<p class="tagline">Entwickler · Schüler · Macher</p>
|
<p class="tagline">Entwickler · Schüler · Macher</p>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<?php foreach ($projects as $category => $items): ?>
|
<?php foreach ($projects as $category => $items): ?>
|
||||||
<section>
|
<section>
|
||||||
<h2 class="category-title">
|
<h2 class="category-title">
|
||||||
<?php if ($category === "privat"): ?>
|
<?php
|
||||||
<i class="fas fa-lock"></i> Privat
|
switch ($category) {
|
||||||
<?php elseif ($category === "schule"): ?>
|
case "privat":
|
||||||
<i class="fas fa-graduation-cap"></i> Schule
|
echo '<i class="fas fa-lock"></i> Privat';
|
||||||
<?php elseif ($category === "dienste"): ?>
|
break;
|
||||||
<i class="fas fa-network-wired"></i> Dienste
|
case "schule":
|
||||||
<?php endif; ?>
|
echo '<i class="fas fa-graduation-cap"></i> Schule';
|
||||||
|
break;
|
||||||
|
case "dienste":
|
||||||
|
echo '<i class="fas fa-network-wired"></i> Dienste';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
?>
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<div class="cards">
|
<div class="cards">
|
||||||
<?php foreach ($items as $project): ?>
|
<?php foreach ($items as $project): ?>
|
||||||
<a
|
<a
|
||||||
href="<?= htmlspecialchars($project['url']) ?>"
|
href="<?= htmlspecialchars($project['url'], ENT_QUOTES) ?>"
|
||||||
class="card"
|
class="card"
|
||||||
<?= !empty($project['external']) ? 'target="_blank" rel="noopener noreferrer"' : '' ?>
|
<?= !empty($project['external']) ? 'target="_blank" rel="noopener noreferrer"' : '' ?>
|
||||||
style="--accent: <?= htmlspecialchars($project['color']) ?>;"
|
style="--accent: <?= htmlspecialchars($project['color'], ENT_QUOTES) ?>;"
|
||||||
>
|
>
|
||||||
<div class="card-icon">
|
|
||||||
<?php if (!empty($project['logo'])): ?>
|
<div class="card-icon">
|
||||||
<img
|
<?php if (!empty($project['logo']) && logoExists($project['logo'])): ?>
|
||||||
src="<?= htmlspecialchars($project['logo']) ?>"
|
<img
|
||||||
alt="<?= htmlspecialchars($project['title']) ?> Logo"
|
src="<?= htmlspecialchars($project['logo'], ENT_QUOTES) ?>"
|
||||||
class="card-logo<?= !empty($project['logo_invert']) ? ' card-logo--invert' : '' ?><?= !empty($project['logo_bg']) ? ' card-logo--bg' : '' ?>"
|
alt="<?= htmlspecialchars($project['title'], ENT_QUOTES) ?> Logo"
|
||||||
>
|
class="card-logo"
|
||||||
<?php else: ?>
|
>
|
||||||
<i class="<?= htmlspecialchars($project['icon']) ?>"></i>
|
<?php else: ?>
|
||||||
<?php endif; ?>
|
<i class="fas fa-folder"></i>
|
||||||
</div>
|
<?php endif; ?>
|
||||||
<div class="card-body">
|
</div>
|
||||||
<h3><?= htmlspecialchars($project['title']) ?></h3>
|
|
||||||
<p><?= htmlspecialchars($project['description']) ?></p>
|
<div class="card-body">
|
||||||
</div>
|
<h3><?= htmlspecialchars($project['title'], ENT_QUOTES) ?></h3>
|
||||||
<div class="card-arrow">
|
<p><?= htmlspecialchars($project['description'], ENT_QUOTES) ?></p>
|
||||||
<i class="fas fa-arrow-right"></i>
|
</div>
|
||||||
</div>
|
|
||||||
</a>
|
<div class="card-arrow">
|
||||||
|
<i class="fas fa-arrow-right"></i>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
<p>© <?= date('Y') ?> Fabian Schieder — Alle Rechte vorbehalten.</p>
|
<p>© <?= date('Y') ?> Fabian Schieder — Alle Rechte vorbehalten.</p>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user