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/partials/repo-subnav.php · 2.49 KB

raw
<?php
/** @var string $repoName @var string $curAction @var string $curRef
 *  @var string[] $branches  empty array to hide the branch pills
 *  The row above the content: branch pills, clone URL, feed links. */
?>
<div class="repo-subnav">
  <?php if (count($branches) > 1): ?>
    <span class="branches">
      <svg class="icon" width="14" height="14" 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>
      <?php foreach ($branches as $b): ?>
        <a class="pill<?= $b === $curRef ? ' on' : '' ?>" href="?r=<?= h($repoName) ?>&a=<?= h($curAction) ?>&ref=<?= h($b) ?>"><?= h($b) ?></a>
      <?php endforeach; ?>
    </span>
  <?php endif; ?>

  <?php if (CLONE_BASE !== ''): ?>
    <?php $cloneCmd = 'git clone ' . clone_url($repoName); ?>
    <button type="button" class="clone-box" data-copy="<?= h($cloneCmd) ?>"
            title="Kopiera klon-kommandot" aria-label="Kopiera klon-kommandot">
      <span class="copy-icon" aria-hidden="true"><svg class="icon" width="16" height="16" viewBox="0 0 16 16"><path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Z"></path></svg></span>
      <span class="done-icon" aria-hidden="true"><svg class="icon" width="16" height="16" viewBox="0 0 16 16"><path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path></svg></span>
      <code><?= h($cloneCmd) ?></code>
    </button>
  <?php endif; ?>

  <span class="feeds">
    <svg class="icon" width="14" height="14" viewBox="0 0 16 16" aria-hidden="true"><path d="M2.965 12.535a1.5 1.5 0 1 1 2.122 2.122 1.5 1.5 0 0 1-2.122-2.122ZM2 9.5a.75.75 0 0 1 .75-.75A4.5 4.5 0 0 1 7.25 13.25a.75.75 0 0 1-1.5 0A3 3 0 0 0 2.75 10.25.75.75 0 0 1 2 9.5Zm0-4a.75.75 0 0 1 .75-.75A8.5 8.5 0 0 1 11.25 13.25a.75.75 0 0 1-1.5 0A7 7 0 0 0 2.75 6.25.75.75 0 0 1 2 5.5Z"></path></svg>
    <a href="?r=<?= h($repoName) ?>&a=atom&ref=<?= h($curRef) ?>">commits</a>
    <a href="?r=<?= h($repoName) ?>&a=atom-tags">tags</a>
  </span>
</div>