Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/treetrek.git

Uses font-awesome icons

Author Dave Jarvis <email>
Date 2026-02-08 19:18:34 GMT-0800
Commit 4245298752831729515387562c4643be19f28a46
Parent 19a0389
new/FileRenderer.php
string $mediaType
): void {
- $icon = $isDir ? '[dir]' : '[file]';
-
- // Simple presentation logic for icons
- if (!$isDir && str_starts_with($mediaType, 'image/')) {
- $icon = '[img]';
- }
+ $iconClass = $this->getIconClass($isDir, $mediaType);
$url = '?repo=' . urlencode($this->repoSafeName) . '&hash=' . $sha;
echo '<a href="' . $url . '" class="file-item">';
echo '<span class="file-mode">' . $mode . '</span>';
echo '<span class="file-name">';
- echo '<span class="' . ($isDir ? 'dir' : 'file') . '-icon">' . $icon . '</span> ';
+
+ // Render the FontAwesome Icon
+ echo '<i class="fas ' . $iconClass . '" style="width: 20px; text-align: center; margin-right: 5px; color: #7a828e;"></i>';
+
echo htmlspecialchars($name);
echo '</span>';
if ($time) {
echo '<span class="file-date" style="color: #8b949e; font-size: 0.8em; margin-left: auto;">' . $time . '</span>';
}
echo '</a>';
+ }
+
+ /**
+ * Maps media types to FontAwesome 6 icon classes.
+ */
+ private function getIconClass(bool $isDir, string $mime): string {
+ if ($isDir) {
+ return 'fa-folder';
+ }
+
+ // Explicit Mime Matches
+ if ($mime === 'application/pdf') return 'fa-file-pdf';
+
+ // Archives
+ if (in_array($mime, [
+ 'application/zip', 'application/x-tar', 'application/gzip',
+ 'application/x-bzip2', 'application/vnd.rar', 'application/x-7z-compressed'
+ ])) {
+ return 'fa-file-archive';
+ }
+
+ // Broad Categories (based on prefix)
+ if (str_starts_with($mime, 'image/')) return 'fa-file-image';
+ if (str_starts_with($mime, 'audio/')) return 'fa-file-audio';
+ if (str_starts_with($mime, 'video/')) return 'fa-file-video';
+
+ // Code / Text
+ if (str_starts_with($mime, 'text/')) return 'fa-file-code';
+
+ // Common Application Types behaving like code/text
+ if (
+ str_contains($mime, 'javascript') ||
+ str_contains($mime, 'json') ||
+ str_contains($mime, 'xml') ||
+ str_contains($mime, 'php') ||
+ str_contains($mime, 'sh')
+ ) {
+ return 'fa-file-code';
+ }
+
+ // Default fallback
+ return 'fa-file';
}
}
new/Views.php
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo Config::SITE_TITLE . ($this->title ? ' - ' . htmlspecialchars($this->title) : ''); ?></title>
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link rel="stylesheet" href="repo.css">
<style>
Delta 48 lines added, 7 lines removed, 41-line increase