A tiny read-only git web frontend — browse bare repos with just PHP and git, no database, no framework.
<?php
/** @var string $repoName @var string $ref @var string $blob @var int $size
* @var bool $tooLarge @var bool $isBinary @var bool $isImage
* @var string $content @var ?string $renderedHtml */
$rawHref = '?r=' . $repoName . '&a=raw&ref=' . $ref . '&blob=' . $blob;
$dlHref = $rawHref . '&dl=1';
?>
<div class="blob-toolbar">
<p class="desc">/<?= h($blob) ?> · <?= h(format_size((string) $size)) ?></p>
<span class="spacer"></span>
<a class="desc" href="<?= h($rawHref) ?>">raw</a>
<a class="icon-btn" href="<?= h($dlHref) ?>" download title="Download" aria-label="Download <?= h(basename($blob)) ?>">
<svg class="icon" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true"><path d="M2.75 14A1.75 1.75 0 0 1 1 12.25v-2.5a.75.75 0 0 1 1.5 0v2.5c0 .138.112.25.25.25h10.5a.25.25 0 0 0 .25-.25v-2.5a.75.75 0 0 1 1.5 0v2.5A1.75 1.75 0 0 1 13.25 14Z"></path><path d="M7.25 7.689V2a.75.75 0 0 1 1.5 0v5.689l1.97-1.969a.749.749 0 1 1 1.06 1.06l-3.25 3.25a.749.749 0 0 1-1.06 0L4.22 6.78a.749.749 0 1 1 1.06-1.06l1.97 1.969Z"></path></svg>
</a>
</div>
<?php if ($isImage): ?>
<div class="box img-frame"><img src="<?= h($rawHref) ?>" alt="<?= h($blob) ?>"></div>
<?php elseif ($tooLarge): ?>
<p class="desc">File too large to display inline — use the raw link above.</p>
<?php elseif ($isBinary): ?>
<p class="desc">Binary file — use the raw link above.</p>
<?php elseif ($renderedHtml !== null): ?>
<div class="box readme"><div class="body"><?= $renderedHtml ?></div></div>
<?php else: ?>
<pre><?= h($content) ?></pre>
<?php endif; ?>