Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/treetrek.git

Adds tags

AuthorDave Jarvis <email>
Date2026-02-10 18:02:27 GMT-0800
Commit23f456bb2f7e91c16b689f12e7412ccf8f294314
Parentf152173
BasePage.php
<a href="?action=commits&repo=<?php echo $safeName; ?>">Commits</a>
<a href="?action=refs&repo=<?php echo $safeName; ?>">Branches</a>
+ <a href="?action=tags&repo=<?php echo $safeName; ?>">Tags</a>
<?php endif; ?>
Router.php
require_once 'GitDiff.php';
require_once 'DiffPage.php';
+require_once 'TagsPage.php';
class Router {
if ($action === 'commits') {
return new CommitsPage($this->repositories, $currentRepo, $this->git, $hash);
+ }
+
+ if ($action === 'tags') {
+ return new TagsPage($this->repositories, $currentRepo, $this->git);
}
TagsPage.php
+<?php
+class TagsPage extends BasePage {
+ private $currentRepo;
+ private $git;
+
+ public function __construct(array $repositories, array $currentRepo, Git $git) {
+ parent::__construct($repositories);
+ $this->currentRepo = $currentRepo;
+ $this->git = $git;
+ $this->title = $currentRepo['name'] . ' - Tags';
+ }
+
+ public function render() {
+ $this->renderLayout(function() {
+ $this->renderBreadcrumbs();
+
+ echo '<h2>Tags</h2>';
+ echo '<div class="refs-list">';
+
+ $hasTags = false;
+ $repoParam = '&repo=' . urlencode($this->currentRepo['safe_name']);
+
+ $this->git->eachTag(function($name, $sha) use ($repoParam, &$hasTags) {
+ $hasTags = true;
+ $url = '?hash=' . $sha . $repoParam;
+
+ echo '<div class="ref-item">';
+ echo '<span class="ref-type tag">Tag</span>';
+ echo '<a href="' . $url . '" class="ref-name">' . htmlspecialchars($name) . '</a>';
+ echo '<span class="commit-hash" style="margin-left: auto;">' . substr($sha, 0, 7) . '</span>';
+ echo '</div>';
+ });
+
+ if (!$hasTags) {
+ echo '<div class="empty-state"><p>No tags found.</p></div>';
+ }
+
+ echo '</div>'; // end refs-list
+ }, $this->currentRepo);
+ }
+
+ private function renderBreadcrumbs() {
+ $repoUrl = '?repo=' . urlencode($this->currentRepo['safe_name']);
+
+ $crumbs = [
+ '<a href="?">Repositories</a>',
+ '<a href="' . $repoUrl . '">' . htmlspecialchars($this->currentRepo['name']) . '</a>',
+ 'Tags'
+ ];
+
+ echo '<div class="breadcrumb">' . implode(' / ', $crumbs) . '</div>';
+ }
+}
Delta59 lines added, 0 lines removed, 59-line increase