|
diff --git a/README.md b/README.md
|
| ... |
| 5 |
## Features |
5 |
## Features |
| 6 |
|
6 |
|
| 7 |
- **Repository Management**: Supports multiple repositories grouped by category in `config.yaml`. |
7 |
- **Repository Management**: Supports multiple repositories grouped by category in `config.yaml`. |
| 8 |
- **Browsing**: Navigate commit history, directory trees, and file contents. |
8 |
- **Browsing**: Navigate commit history, directory files, and file contents. |
| 9 |
- **Syntax Highlighting**: Automatic language detection and highlighting via [Chroma](https://github.com/alecthomas/chroma). |
9 |
- **Syntax Highlighting**: Automatic language detection and highlighting via [Chroma](https://github.com/alecthomas/chroma). |
| 10 |
- **Markdown Rendering**: Renders README files with GFM support and GitHub-style alerts via [Goldmark](https://github.com/yuin/goldmark). |
10 |
- **Markdown Rendering**: Renders README files with GFM support and GitHub-style alerts via [Goldmark](https://github.com/yuin/goldmark). |
| 11 |
- **Language Statistics**: Visual breakdown of programming languages used in each repository. |
11 |
- **Language Statistics**: Visual breakdown of programming languages used in each repository. |
| ... |
| 81 |
|----------|-------------| |
81 |
|----------|-------------| |
| 82 |
| `/` | Home page with grouped repository list. | |
82 |
| `/` | Home page with grouped repository list. | |
| 83 |
| `/r/{name}` | Commit history (log) for the repository. | |
83 |
| `/r/{name}` | Commit history (log) for the repository. | |
| 84 |
| `/r/{name}/tree/{path}` | Directory tree browser. | |
84 |
| `/r/{name}/files/{path}` | Directory file browser. | |
| 85 |
| `/r/{name}/blob/{path}` | File viewer with syntax highlighting. | |
85 |
| `/r/{name}/blob/{path}` | File viewer with syntax highlighting. | |
| 86 |
| `/r/{name}/raw/{path}` | Raw file download. | |
86 |
| `/r/{name}/raw/{path}` | Raw file download. | |
| 87 |
| `/r/{name}/markers` | Results of the `TODO:` and `FIXME:` scanner. | |
87 |
| `/r/{name}/markers` | Results of the `TODO:` and `FIXME:` scanner. | |
| ... |
|
diff --git a/hfiles.go b/hfiles.go
|
| ... |
| 16 |
"github.com/go-git/go-git/v5/plumbing/object" |
16 |
"github.com/go-git/go-git/v5/plumbing/object" |
| 17 |
) |
17 |
) |
| 18 |
|
18 |
|
| 19 |
func treeHandler(w http.ResponseWriter, r *http.Request) { |
19 |
func filesHandler(w http.ResponseWriter, r *http.Request) { |
| 20 |
ctx, err := getRepoContext(w, r) |
20 |
ctx, err := getRepoContext(w, r) |
| 21 |
if err != nil { |
21 |
if err != nil { |
| 22 |
http.Error(w, err.Error(), http.StatusInternalServerError) |
22 |
http.Error(w, err.Error(), http.StatusInternalServerError) |
| ... |
| 86 |
RepoContext: ctx, |
86 |
RepoContext: ctx, |
| 87 |
Entries: entries, |
87 |
Entries: entries, |
| 88 |
Path: pathValue, |
88 |
Path: pathValue, |
| 89 |
View: "tree", |
89 |
View: "files", |
| 90 |
} |
90 |
} |
| 91 |
|
91 |
|
| 92 |
err = templates.ExecuteTemplate(w, "tree.html", data) |
92 |
err = templates.ExecuteTemplate(w, "files.html", data) |
| 93 |
if err != nil { |
93 |
if err != nil { |
| 94 |
http.Error(w, err.Error(), http.StatusInternalServerError) |
94 |
http.Error(w, err.Error(), http.StatusInternalServerError) |
| 95 |
} |
95 |
} |
| ... |
|
diff --git a/main.go b/main.go
|
| ... |
| 68 |
mux.HandleFunc("GET /r/{name}/markers", markersHandler) |
68 |
mux.HandleFunc("GET /r/{name}/markers", markersHandler) |
| 69 |
mux.HandleFunc("GET /r/{name}/commits.rss", repoCommitsRSSHandler) |
69 |
mux.HandleFunc("GET /r/{name}/commits.rss", repoCommitsRSSHandler) |
| 70 |
mux.HandleFunc("GET /r/{name}/tags.rss", repoTagsRSSHandler) |
70 |
mux.HandleFunc("GET /r/{name}/tags.rss", repoTagsRSSHandler) |
| 71 |
mux.HandleFunc("GET /r/{name}/tree/{path...}", treeHandler) |
71 |
mux.HandleFunc("GET /r/{name}/files/{path...}", filesHandler) |
| 72 |
mux.HandleFunc("GET /r/{name}/blob/{path...}", blobHandler) |
72 |
mux.HandleFunc("GET /r/{name}/blob/{path...}", blobHandler) |
| 73 |
mux.HandleFunc("GET /r/{name}/raw/{path...}", rawHandler) |
73 |
mux.HandleFunc("GET /r/{name}/raw/{path...}", rawHandler) |
| 74 |
mux.HandleFunc("GET /r/{name}/archive/{path...}", archiveHandler) |
74 |
mux.HandleFunc("GET /r/{name}/archive/{path...}", archiveHandler) |
| ... |
|
diff --git a/views/blob.html b/views/blob.html
|
| ... |
| 13 |
|
13 |
|
| 14 |
<div class="breadcrumbs"> |
14 |
<div class="breadcrumbs"> |
| 15 |
<span>Path:</span> |
15 |
<span>Path:</span> |
| 16 |
<a href="/r/{{.Repo.Name}}/tree/?ref={{.CurrentRef}}">{{.Repo.Name}}</a> |
16 |
<a href="/r/{{.Repo.Name}}/files/?ref={{.CurrentRef}}">{{.Repo.Name}}</a> |
| 17 |
{{$parts := split .Path "/"}} |
17 |
{{$parts := split .Path "/"}} |
| 18 |
{{$path := ""}} |
18 |
{{$path := ""}} |
| 19 |
{{range $i, $part := $parts}} |
19 |
{{range $i, $part := $parts}} |
| ... |
| 23 |
{{$part}} |
23 |
{{$part}} |
| 24 |
(<a href="/r/{{$.Repo.Name}}/raw/{{$.Path}}?ref={{$.CurrentRef}}">raw</a>) |
24 |
(<a href="/r/{{$.Repo.Name}}/raw/{{$.Path}}?ref={{$.CurrentRef}}">raw</a>) |
| 25 |
{{else}} |
25 |
{{else}} |
| 26 |
<a href="/r/{{$.Repo.Name}}/tree/{{$path}}?ref={{$.CurrentRef}}">{{$part}}</a> |
26 |
<a href="/r/{{$.Repo.Name}}/files/{{$path}}?ref={{$.CurrentRef}}">{{$part}}</a> |
| 27 |
{{end}} |
27 |
{{end}} |
| 28 |
{{end}} |
28 |
{{end}} |
| 29 |
</div> |
29 |
</div> |
| ... |
|
diff --git a/views/nav-repository.html b/views/nav-repository.html
|
| 1 |
<div class="nav-repository"> |
1 |
<div class="nav-repository"> |
| 2 |
<nav class="repo-nav"> |
2 |
<nav class="repo-nav"> |
| 3 |
<a href="/r/{{.Repo.Name}}?ref={{.CurrentRef}}">Commits</a> |
3 |
<a href="/r/{{.Repo.Name}}?ref={{.CurrentRef}}">Commits</a> |
| 4 |
<a href="/r/{{.Repo.Name}}/tree/?ref={{.CurrentRef}}">Tree</a> |
4 |
<a href="/r/{{.Repo.Name}}/files/?ref={{.CurrentRef}}">Files</a> |
| 5 |
<a href="/r/{{.Repo.Name}}/markers?ref={{.CurrentRef}}">Markers</a> |
5 |
<a href="/r/{{.Repo.Name}}/markers?ref={{.CurrentRef}}">Markers</a> |
| 6 |
{{if .ReadmeName}} |
6 |
{{if .ReadmeName}} |
| 7 |
<a href="/r/{{.Repo.Name}}/readme?ref={{.CurrentRef}}">Readme</a> |
7 |
<a href="/r/{{.Repo.Name}}/readme?ref={{.CurrentRef}}">Readme</a> |
| ... |
|
diff --git a/views/files.html b/views/files.html
|
| 1 |
<!DOCTYPE html> |
1 |
<!DOCTYPE html> |
| 2 |
<html> |
2 |
<html> |
| 3 |
<head> |
3 |
<head> |
| 4 |
<title>{{.Repo.Name}} - Tree</title> |
4 |
<title>{{.Repo.Name}} - Files</title> |
| 5 |
<link rel="stylesheet" href="/static/style.css"> |
5 |
<link rel="stylesheet" href="/static/style.css"> |
| 6 |
<link rel="shortcut icon" href="/static/favicon.png"> |
6 |
<link rel="shortcut icon" href="/static/favicon.png"> |
| 7 |
</head> |
7 |
</head> |
| ... |
| 14 |
<div class="breadcrumbs"> |
14 |
<div class="breadcrumbs"> |
| 15 |
<span>Path:</span> |
15 |
<span>Path:</span> |
| 16 |
{{if .Path}} |
16 |
{{if .Path}} |
| 17 |
<a href="/r/{{.Repo.Name}}/tree/?ref={{.CurrentRef}}">{{.Repo.Name}}</a> |
17 |
<a href="/r/{{.Repo.Name}}/files/?ref={{.CurrentRef}}">{{.Repo.Name}}</a> |
| 18 |
{{$parts := split .Path "/"}} |
18 |
{{$parts := split .Path "/"}} |
| 19 |
{{$path := ""}} |
19 |
{{$path := ""}} |
| 20 |
{{range $i, $part := $parts}} |
20 |
{{range $i, $part := $parts}} |
| ... |
| 24 |
{{$part}} |
24 |
{{$part}} |
| 25 |
(<a href="/r/{{$.Repo.Name}}/archive/{{$.Path}}?ref={{$.CurrentRef}}">download</a>) |
25 |
(<a href="/r/{{$.Repo.Name}}/archive/{{$.Path}}?ref={{$.CurrentRef}}">download</a>) |
| 26 |
{{else}} |
26 |
{{else}} |
| 27 |
<a href="/r/{{$.Repo.Name}}/tree/{{$path}}?ref={{$.CurrentRef}}">{{$part}}</a> |
27 |
<a href="/r/{{$.Repo.Name}}/files/{{$path}}?ref={{$.CurrentRef}}">{{$part}}</a> |
| 28 |
{{end}} |
28 |
{{end}} |
| 29 |
{{end}} |
29 |
{{end}} |
| 30 |
{{else}} |
30 |
{{else}} |
| ... |
| 46 |
{{if .Path}} |
46 |
{{if .Path}} |
| 47 |
<tr> |
47 |
<tr> |
| 48 |
<td></td> |
48 |
<td></td> |
| 49 |
<td colspan="4"><a href="/r/{{.Repo.Name}}/tree/{{parent .Path}}?ref={{.CurrentRef}}">..</a></td> |
49 |
<td colspan="4"><a href="/r/{{.Repo.Name}}/files/{{parent .Path}}?ref={{.CurrentRef}}">..</a></td> |
| 50 |
</tr> |
50 |
</tr> |
| 51 |
{{end}} |
51 |
{{end}} |
| 52 |
{{range .Entries}} |
52 |
{{range .Entries}} |
| ... |
| 54 |
<td class="filetype text-center">{{if .IsDir}}d{{else}}f{{end}}</td> |
54 |
<td class="filetype text-center">{{if .IsDir}}d{{else}}f{{end}}</td> |
| 55 |
<td> |
55 |
<td> |
| 56 |
{{if .IsDir}} |
56 |
{{if .IsDir}} |
| 57 |
<a href="/r/{{$.Repo.Name}}/tree/{{.Path}}?ref={{$.CurrentRef}}">{{.Name}}/</a> |
57 |
<a href="/r/{{$.Repo.Name}}/files/{{.Path}}?ref={{$.CurrentRef}}">{{.Name}}/</a> |
| 58 |
{{else}} |
58 |
{{else}} |
| 59 |
<a href="/r/{{$.Repo.Name}}/blob/{{.Path}}?ref={{$.CurrentRef}}">{{.Name}}</a> |
59 |
<a href="/r/{{$.Repo.Name}}/blob/{{.Path}}?ref={{$.CurrentRef}}">{{.Name}}</a> |
| 60 |
{{end}} |
60 |
{{end}} |
| ... |