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 $path
* @var array $entries parse_tree() rows plus annotate_last_commits()'s
* lastHash/lastSubject/lastAt (lastAt null if somehow no commit found)
* @var ?string $readmeName @var ?string $readmeHtml @var ?string $licenseName */
$folderIcon = '<svg class="icon" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true" style="color:var(--acc)"><path d="M1.75 1A1.75 1.75 0 0 0 0 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0 0 16 13.25v-8.5A1.75 1.75 0 0 0 14.25 3H7.5a.25.25 0 0 1-.2-.1l-.9-1.2C6.07 1.26 5.55 1 5 1H1.75Z"></path></svg>';
$fileIcon = '<svg class="icon" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true" style="color:var(--dim)"><path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg>';
$readmeIcon = '<svg class="icon" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true"><path d="M0 1.75A.75.75 0 0 1 .75 1h4.253c1.227 0 2.317.59 3 1.501A3.743 3.743 0 0 1 11.006 1h4.245a.75.75 0 0 1 .75.75v10.5a.75.75 0 0 1-.75.75h-4.507a2.25 2.25 0 0 0-1.591.659l-.622.621a.75.75 0 0 1-1.06 0l-.622-.621A2.25 2.25 0 0 0 5.258 13H.75a.75.75 0 0 1-.75-.75Zm7.251 10.324.004-5.073-.002-2.253A2.25 2.25 0 0 0 5.003 2.5H1.5v9h3.757a3.75 3.75 0 0 1 1.994.574ZM8.755 4.75l-.004 7.322a3.752 3.752 0 0 1 1.992-.572H14.5v-9h-3.495a2.25 2.25 0 0 0-2.25 2.25Z"></path></svg>';
?>
<?php if ($path !== ''): ?>
<p class="desc">/<?= h($path) ?></p>
<?php endif; ?>
<div class="box">
<table class="tree">
<thead><tr><th>Mode</th><th>Name</th><th>Last commit</th><th class="num">Updated</th><th class="num">Size</th></tr></thead>
<tbody>
<?php foreach ($entries as $e): ?>
<tr>
<td class="mode" title="<?= h($e['mode']) ?>"><?= $e['isTree'] ? $folderIcon : $fileIcon ?></td>
<td>
<?php if ($e['isTree']): ?>
<a href="?r=<?= h($repoName) ?>&a=tree&ref=<?= h($ref) ?>&path=<?= h($e['child']) ?>"><?= h($e['name']) ?></a>
<?php else: ?>
<a href="?r=<?= h($repoName) ?>&a=tree&ref=<?= h($ref) ?>&blob=<?= h($e['child']) ?>"><?= h($e['name']) ?></a>
<?php endif; ?>
</td>
<td class="commit-msg desc">
<?php if ($e['lastHash'] !== ''): ?>
<a href="?r=<?= h($repoName) ?>&a=commit&h=<?= h($e['lastHash']) ?>" title="<?= h($e['lastSubject']) ?>"><?= h(truncate($e['lastSubject'], 72)) ?></a>
<?php endif; ?>
</td>
<td class="num desc"><?= $e['lastAt'] !== null ? h(format_relative_time($e['lastAt'])) : '' ?></td>
<td class="num hash"><?= h(format_size($e['size'])) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php if ($licenseName !== null): ?>
<p class="license-line">license: <a href="?r=<?= h($repoName) ?>&a=tree&ref=<?= h($ref) ?>&blob=<?= h($licenseName) ?>"><?= h($licenseName) ?></a></p>
<?php endif; ?>
<?php if ($readmeName !== null): ?>
<div class="box readme">
<div class="box-header"><?= $readmeIcon ?> <?= h($readmeName) ?></div>
<div class="body"><?= $readmeHtml ?></div>
</div>
<?php endif; ?>