foxygit / foxygit Log in
A tiny read-only git web frontend — browse bare repos with just PHP and git, no database, no framework.
commits tags

/views/refs.php · 1.75 KB

raw
<?php
/** @var string $repoName @var array $refs */
$branches = array_values(array_filter($refs, fn($r) => $r['kind'] === 'branch'));
$tags     = array_values(array_filter($refs, fn($r) => $r['kind'] === 'tag'));
$branchIcon = '<svg class="icon" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true"><path d="M9.5 3.25a2.25 2.25 0 1 1 3 2.122V6A2.5 2.5 0 0 1 10 8.5H6a1 1 0 0 0-1 1v1.128a2.251 2.251 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.5 0v1.836A2.492 2.492 0 0 1 6 7h4a1 1 0 0 0 1-1v-.628A2.25 2.25 0 0 1 9.5 3.25Z"></path></svg>';
$tagIcon    = '<svg class="icon" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true"><path d="M1 7.775V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 0 1 0 2.474l-5.026 5.026a1.75 1.75 0 0 1-2.474 0l-6.25-6.25A1.752 1.752 0 0 1 1 7.775Zm1.5 0c0 .066.026.13.073.177l6.25 6.25a.25.25 0 0 0 .354 0l5.025-5.025a.25.25 0 0 0 0-.354l-6.25-6.25a.25.25 0 0 0-.177-.073H2.75a.25.25 0 0 0-.25.25ZM6 5a1 1 0 1 1 0 2 1 1 0 0 1 0-2Z"></path></svg>';
?>
<div class="box">
  <div class="box-header"><?= $branchIcon ?> Branches</div>
  <?php if (!$branches): ?>
    <p style="margin:12px 16px" class="desc">No branches.</p>
  <?php else: ?>
  <table><tbody>
    <?php foreach ($branches as $r): ?>
      <tr><td><a href="?r=<?= h($repoName) ?>&a=log&ref=<?= h($r['short']) ?>"><?= h($r['short']) ?></a></td></tr>
    <?php endforeach; ?>
  </tbody></table>
  <?php endif; ?>
</div>

<div class="box">
  <div class="box-header"><?= $tagIcon ?> Tags</div>
  <?php if (!$tags): ?>
    <p style="margin:12px 16px" class="desc">No tags.</p>
  <?php else: ?>
  <table><tbody>
    <?php foreach ($tags as $r): ?>
      <tr><td><?= h($r['short']) ?></td></tr>
    <?php endforeach; ?>
  </tbody></table>
  <?php endif; ?>
</div>