mirror of
https://codeberg.org/vlw/vlw.se.git
synced 2025-09-13 21:13:40 +02:00
153 lines
No EOL
4.7 KiB
PHP
153 lines
No EOL
4.7 KiB
PHP
<?php
|
|
|
|
use VLW\Database\Models\Work\Timeline;
|
|
use const VLW\{
|
|
ICONS_DIR,
|
|
DEFAULT_BUTTON_ICON,
|
|
TIMELINE_PREVIEW_LIMIT_PARAM
|
|
};
|
|
|
|
require_once VV::root("src/Consts.php");
|
|
require_once VV::root("src/Database/Models/Work/Timeline.php");
|
|
|
|
$timeline = new class extends Timeline {
|
|
public function __construct() {}
|
|
|
|
public static function ordered(): array {
|
|
// Get timeline list limit from search param if set
|
|
$limit = array_key_exists(TIMELINE_PREVIEW_LIMIT_PARAM, $_GET) ? (int) $_GET[TIMELINE_PREVIEW_LIMIT_PARAM] : null;
|
|
|
|
$timeline = [];
|
|
|
|
foreach (parent::all() as $idx => $item) {
|
|
// Use year as the first dimension
|
|
if (!array_key_exists($item->year(), $timeline)) {
|
|
$timeline[$item->year()] = [];
|
|
}
|
|
|
|
// And month as the second dimension
|
|
if (!array_key_exists($item->month(), $timeline[$item->year()])) {
|
|
$timeline[$item->year()][$item->month()] = [];
|
|
}
|
|
|
|
// Lastly, day as the third dimension
|
|
if (!array_key_exists($item->day(), $timeline[$item->year()][$item->month()])) {
|
|
$timeline[$item->year()][$item->month()][$item->day()] = [];
|
|
}
|
|
|
|
// Append Work instance on Timeline object to the output array by year->month->day
|
|
$timeline[$item->year()][$item->month()][$item->day()][] = $item->work();
|
|
|
|
// Bail out here if we've reached the theshold for items to display
|
|
if ($limit && $idx === $limit) {
|
|
return $timeline;
|
|
}
|
|
}
|
|
|
|
return $timeline;
|
|
}
|
|
}
|
|
|
|
?>
|
|
<style><?= VV::css("public/assets/css/pages/work/timeline") ?></style>
|
|
<section class="git">
|
|
<?= VV::embed("public/assets/media/icons/codeberg.svg") ?>
|
|
<p>This timeline has most but not all of my FOSS software. If you want to see a list of all things I've created for the free software world, check out my repos on Codeberg or Forgejo.</p>
|
|
<div class="buttons">
|
|
<a href="https://codeberg.org/vlw"><button class="inline solid">
|
|
<p>Codeberg</p>
|
|
<?= VV::embed("public/assets/media/icons/chevron.svg") ?>
|
|
</button></a>
|
|
<a href="https://git.vlw.se/explore/repos"><button class="inline">
|
|
<p>Forgejo</p>
|
|
<?= VV::embed("public/assets/media/icons/chevron.svg") ?>
|
|
</button></a>
|
|
</div>
|
|
</section>
|
|
<section class="timeline">
|
|
|
|
<?php // Get year int from key and array of months for current year ?>
|
|
<?php foreach ($timeline::ordered() as $year => $months): ?>
|
|
<div class="year">
|
|
<div class="track">
|
|
<p><?= $year ?></p>
|
|
</div>
|
|
|
|
<div class="months">
|
|
<?php // Get month int from key and array of days for current month ?>
|
|
<?php foreach ($months as $month => $days): ?>
|
|
<div class="month">
|
|
<div class="track">
|
|
<?php // Append leading zero to month ?>
|
|
<p><?= sprintf("%02d", $month) ?></p>
|
|
</div>
|
|
|
|
<div class="days">
|
|
<?php // Get day int from key and array of items for current day ?>
|
|
<?php foreach ($days as $day => $items): ?>
|
|
<div class="day">
|
|
<div class="track">
|
|
<?php // Append leading zero to day ?>
|
|
<p><?= sprintf("%02d", $day) ?></p>
|
|
</div>
|
|
|
|
<div class="items">
|
|
<?php foreach ($items as $work): ?>
|
|
<div class="item">
|
|
|
|
<?php // List tags if available ?>
|
|
<?php if ($work->tags()): ?>
|
|
<div class="tags">
|
|
|
|
<?php foreach ($work->tags() as $tag): ?>
|
|
<p class="tag <?= $tag->label()->name ?>"><?= $tag->label()->name ?></p>
|
|
<?php endforeach; ?>
|
|
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($work->title()): ?>
|
|
<h2><?= $work->title() ?></h2>
|
|
<?php endif; ?>
|
|
|
|
<p><?= $work->summary() ?></p>
|
|
|
|
<?php if ($work->actions()): ?>
|
|
<div class="actions">
|
|
|
|
<?php foreach ($work->actions() as $action): ?>
|
|
<a href="<?= $action->href() ?? "/work/{$work->id}" ?>"><button class="inline <?= implode(" ", $action->classes()) ?>">
|
|
<?php if ($action->icon_prepended()): ?>
|
|
<?= VV::embed(ICONS_DIR . $action->icon_prepended()) ?>
|
|
<?php endif; ?>
|
|
|
|
<p><?= $action->display_text() ?></p>
|
|
|
|
<?php if ($action->icon_appended()): ?>
|
|
<?= VV::embed(ICONS_DIR . $action->icon_appended()) ?>
|
|
<?php else: ?>
|
|
<?= VV::embed(DEFAULT_BUTTON_ICON) ?>
|
|
<?php endif; ?>
|
|
</button></a>
|
|
<?php endforeach; ?>
|
|
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
</div>
|
|
<?php endforeach; ?>
|
|
|
|
</section>
|
|
<script><?= VV::js("assets/js/pages/work/timeline") ?></script>
|