main • app/views/repos/browse.php
<?php require __DIR__ . '/../layout/header.php'; ?>
<div class="d-flex justify-content-between align-items-center mb-3">
<div>
<h4 class="m-0"><?= e($repo['owner_username']) ?>/<?= e($repo['name']) ?></h4>
<div class="small text-muted">Browsing <b><?= e($branch) ?></b><?= $dir ? " • <span class='mono'>".e($dir)."</span>" : "" ?></div>
</div>
<div class="d-flex gap-2">
<form method="get" action="/r/<?= (int)$repo['id'] ?>/browse">
<input type="hidden" name="dir" value="<?= e($dir) ?>">
<select class="form-select form-select-sm" name="branch" onchange="this.form.submit()">
<?php foreach ($branches as $b): ?>
<option value="<?= e($b['name']) ?>" <?= $b['name']===$branch?'selected':'' ?>><?= e($b['name']) ?></option>
<?php endforeach; ?>
</select>
</form>
<?php if (repo_can_write($db, (int)$repo['id'], auth_user_id())): ?>
<a class="btn btn-dark btn-sm" href="/r/<?= (int)$repo['id'] ?>/commit-zip?branch=<?= e($branch) ?>">Commit ZIP</a>
<?php endif; ?>
</div>
</div>
<div class="card p-2">
<ul class="list-group list-group-flush">
<?php if ($dir !== ''): ?>
<?php $parent = preg_replace('#/[^/]+$#', '', $dir); $parent = trim($parent,'/'); ?>
<li class="list-group-item">
<a href="/r/<?= (int)$repo['id'] ?>/browse?branch=<?= e($branch) ?>&dir=<?= urlencode($parent) ?>">.. (parent)</a>
</li>
<?php endif; ?>
<?php foreach ($items as $it): ?>
<?php if ($it['type'] === 'dir'): ?>
<?php $newDir = trim($dir === '' ? $it['name'] : ($dir.'/'.$it['name']), '/'); ?>
<li class="list-group-item">
📁 <a href="/r/<?= (int)$repo['id'] ?>/browse?branch=<?= e($branch) ?>&dir=<?= urlencode($newDir) ?>"><?= e($it['name']) ?></a>
</li>
<?php else: ?>
<li class="list-group-item">
📄 <a href="/r/<?= (int)$repo['id'] ?>/file?branch=<?= e($branch) ?>&path=<?= urlencode($it['path']) ?>"><?= e($it['name']) ?></a>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
<?php require __DIR__ . '/../layout/footer.php'; ?>