tkr/src/View/HomeView/HomeView.php
greg 9338332536 refactor-storage (#19)
Move ticks from filesystem into database.

I'm going to preserve the filesystem and just delete it manually. I'll add a login warning, but I'm pretty sure I'm the only person who'll ever be affected by this.

Co-authored-by: Greg Sarjeant <1686767+gsarjeant@users.noreply.github.com>
Reviewed-on: https://gitea.subcultureofone.org/greg/tkr/pulls/19
2025-07-24 02:12:31 +00:00

33 lines
1.4 KiB
PHP

<?php
class HomeView {
public function renderTicksSection(string $siteDescription, array $ticks, int $page, int $limit){
global $config;
ob_start();
?>
<ul class="tick-feed" aria-label="Recent updates">
<?php foreach ($ticks as $tick): ?>
<?php
$datetime = new DateTime($tick['timestamp'], new DateTimeZone('UTC'));
$relativeTime = Util::relative_time($tick['timestamp']);
?>
<li class="tick" tabindex="0">
<time datetime="<?php echo $datetime->format('c') ?>"><?php echo Util::escape_html($relativeTime) ?></time>
<span class="tick-text"><?php echo Util::linkify(Util::escape_html($tick['tick'])) ?></span>
</li>
<?php endforeach; ?>
</ul>
<div class="tick-pagination">
<?php if ($page > 1): ?>
<a <?php if($config->strictAccessibility): ?>tabindex="0"<?php endif; ?>
href="?page=<?php echo $page - 1 ?>">&laquo; Newer</a>
<?php endif; ?>
<?php if (count($ticks) === $limit): ?>
<a <?php if($config->strictAccessibility): ?>tabindex="0"<?php endif; ?>
href="?page=<?php echo $page + 1 ?>">Older &raquo;</a>
<?php endif; ?>
</div>
<?php return ob_get_clean();
}
}