| | <?php |
| | - |
| | class FilePage extends BasePage { |
| | private $currentRepo; |
 |
| | $entries = []; |
| | |
| | - // Entries are now File objects |
| | $this->git->walk($target, function($file) use (&$entries) { |
| | $entries[] = $file; |
 |
| | private function renderTree($main, $targetHash, $entries) { |
| | $this->renderBreadcrumbs($targetHash, 'Tree'); |
| | - echo '<h2>' . htmlspecialchars($this->currentRepo['name']) . ' <span class="branch-badge">' . htmlspecialchars($main['name']) . '</span></h2>'; |
| | + echo '<h2>' . htmlspecialchars($this->currentRepo['name']) . |
| | + ' <span class="branch-badge">' . |
| | + htmlspecialchars($main['name']) . '</span></h2>'; |
| | |
| | - // Encapsulated sorting via File::compare |
| | usort($entries, function($a, $b) { |
| | return $a->compare($b); |
 |
| | } |
| | |
| | - $rawUrl = '?action=raw&hash=' . $targetHash . $repoParam . '&name=' . urlencode($filename); |
| | + $rawUrl = '?action=raw&hash=' . $targetHash . $repoParam . |
| | + '&name=' . urlencode($filename); |
| | |
| | if ($category === MediaTypeSniffer::CAT_IMAGE) { |
| | - echo '<div class="blob-content" style="text-align:center; padding: 20px; background: #f6f8fa;">'; |
| | - echo '<img src="' . $rawUrl . '" style="max-width: 100%; border: 1px solid #dfe2e5;">'; |
| | + echo '<div class="blob-content" style="text-align:center; ' . |
| | + 'padding: 20px; background: #f6f8fa;">'; |
| | + echo '<img src="' . $rawUrl . '" style="max-width: 100%; ' . |
| | + 'border: 1px solid #dfe2e5;">'; |
| | echo '</div>'; |
| | } elseif ($category === MediaTypeSniffer::CAT_VIDEO) { |
| | - echo '<div class="blob-content" style="text-align:center; padding: 20px; background: #000;">'; |
| | + echo '<div class="blob-content" style="text-align:center; ' . |
| | + 'padding: 20px; background: #000;">'; |
| | echo '<video controls style="max-width: 100%; max-height: 80vh;">'; |
| | echo '<source src="' . $rawUrl . '" type="' . $mediaType . '">'; |
| | echo '</video>'; |
| | echo '</div>'; |
| | } elseif ($category === MediaTypeSniffer::CAT_AUDIO) { |
| | - echo '<div class="blob-content" style="text-align:center; padding: 40px; background: #f6f8fa;">'; |
| | + echo '<div class="blob-content" style="text-align:center; ' . |
| | + 'padding: 40px; background: #f6f8fa;">'; |
| | echo '<audio controls style="width: 100%; max-width: 600px;">'; |
| | echo '<source src="' . $rawUrl . '" type="' . $mediaType . '">'; |
| | echo '</audio>'; |
| | echo '</div>'; |
| | } elseif ($category === MediaTypeSniffer::CAT_TEXT) { |
| | if ($size > 524288) { |
| | - $this->renderDownloadState($targetHash, "File is too large to display (" . $this->formatSize($size) . ")."); |
| | + $this->renderDownloadState($targetHash, "File is too large " . |
| | + "to display (" . $this->formatSize($size) . ")."); |
| | } else { |
| | $content = ''; |
| | - $this->git->stream($targetHash, function($d) use (&$content) { $content .= $d; }); |
| | - echo '<div class="blob-content"><pre class="blob-code">' . htmlspecialchars($content) . '</pre></div>'; |
| | + $this->git->stream($targetHash, function($d) use (&$content) { |
| | + $content .= $d; |
| | + }); |
| | + echo '<div class="blob-content"><pre class="blob-code">' . |
| | + htmlspecialchars($content) . '</pre></div>'; |
| | } |
| | } else { |
| | $this->renderDownloadState($targetHash, "This is a binary file."); |
| | } |
| | } |
| | |
| | private function renderDownloadState($hash, $reason) { |
| | - $url = '?action=raw&hash=' . $hash . '&repo=' . urlencode($this->currentRepo['safe_name']); |
| | - echo '<div class="empty-state" style="text-align: center; padding: 40px; border: 1px solid #e1e4e8; border-radius: 6px; margin-top: 10px;">'; |
| | - echo '<p style="margin-bottom: 20px; color: #586069;">' . htmlspecialchars($reason) . '</p>'; |
| | - echo '<a href="' . $url . '" style="display: inline-block; padding: 6px 16px; background: #0366d6; color: white; text-decoration: none; border-radius: 6px; font-weight: 600;">Download Raw File</a>'; |
| | + $url = '?action=raw&hash=' . $hash . '&repo=' . |
| | + urlencode($this->currentRepo['safe_name']); |
| | + echo '<div class="empty-state" style="text-align: center; ' . |
| | + 'padding: 40px; border: 1px solid #e1e4e8; border-radius: 6px; ' . |
| | + 'margin-top: 10px;">'; |
| | + echo '<p style="margin-bottom: 20px; color: #586069;">' . |
| | + htmlspecialchars($reason) . '</p>'; |
| | + echo '<a href="' . $url . '" style="display: inline-block; ' . |
| | + 'padding: 6px 16px; background: #0366d6; color: white; ' . |
| | + 'text-decoration: none; border-radius: 6px; ' . |
| | + 'font-weight: 600;">Download Raw File</a>'; |
| | echo '</div>'; |
| | } |
 |
| | echo '<div class="breadcrumb">'; |
| | echo '<a href="?">Repositories</a><span>/</span>'; |
| | - echo '<a href="?repo=' . urlencode($this->currentRepo['safe_name']) . '">' . htmlspecialchars($this->currentRepo['name']) . '</a>'; |
| | - if ($this->hash) echo '<span>/</span><span>' . $type . ' ' . substr($hash, 0, 7) . '</span>'; |
| | + echo '<a href="?repo=' . urlencode($this->currentRepo['safe_name']) . |
| | + '">' . htmlspecialchars($this->currentRepo['name']) . '</a>'; |
| | + if ($this->hash) { |
| | + echo '<span>/</span><span>' . $type . ' ' . |
| | + substr($hash, 0, 7) . '</span>'; |
| | + } |
| | echo '</div>'; |
| | } |
| | } |
| | + |
| | |