v0.33.0 62a09f5

mime.go RawHistoryFolder

1package webutil
2
3import (
4	"mime"
5	"path/filepath"
6	"strings"
7)
8
9// GetMimeType determines the MIME type for a given file path.
10// It tries the standard library first, then falls back to common web asset types.
11func GetMimeType(filename string) string {
12	lowerName := strings.ToLower(filename)
13	ext := filepath.Ext(lowerName)
14	if ext == ".br" {
15		return GetMimeType(strings.TrimSuffix(lowerName, ext))
16	}
17
18	mt := mime.TypeByExtension(ext)
19	if mt != "" {
20		return mt
21	}
22
23	switch ext {
24	case ".js", ".mjs":
25		return "application/javascript"
26	case ".css":
27		return "text/css"
28	case ".svg":
29		return "image/svg+xml"
30	case ".ico":
31		return "image/x-icon"
32	case ".woff":
33		return "font/woff"
34	case ".woff2":
35		return "font/woff2"
36	case ".ttf":
37		return "font/ttf"
38	case ".otf":
39		return "font/otf"
40	case ".png":
41		return "image/png"
42	case ".jpg", ".jpeg":
43		return "image/jpeg"
44	case ".gif":
45		return "image/gif"
46	case ".webp":
47		return "image/webp"
48	case ".m3u8":
49		return "application/vnd.apple.mpegurl" // RFC 8216
50	case ".json":
51		return "application/json"
52	case ".xml":
53		return "application/xml"
54	case ".html", ".htm":
55		return "text/html; charset=utf-8"
56	default:
57		return "text/plain"
58	}
59}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close