Goit

Simple and lightweight Git web server
Mirror of https://github.com/Jamozed/Goit
git clone http://git.omkov.net/Goit
Log | Tree | Refs | README | Download

AuthorJakob Wakeling <[email protected]>
Date2023-12-18 11:53:59
Commitdb3692db87cf30f7d5914d7d7b94c5ef8778510f
Parentdabb96760f77cd64b2c2e9dceca979c7383c2a4b

Show an indicator on repository mirrors' pages

Diffstat

M res/repo/header.html | 2 +-
M src/repo/commit.go | 3 ++-
M src/repo/edit.go | 3 ++-
M src/repo/file.go | 3 ++-
M src/repo/log.go | 3 ++-
M src/repo/refs.go | 3 ++-
M src/repo/tree.go | 3 ++-

7 files changed, 13 insertions, 7 deletions

diff --git a/res/repo/header.html b/res/repo/header.html
index 9f7e1df..38b5c48 100644
--- a/res/repo/header.html
+++ b/res/repo/header.html
@@ -3,7 +3,7 @@
 		<td rowspan="2">
 			<a href="/"><img style="max-height: 24px;" src="/static/favicon.png"></a>
 		</td>
-		<td><h1>{{.Name}}</h1></td>
+		<td><h1 style="display: inline;">{{.Name}}</h1>{{if .IsMirror}} (mirror){{end}}</td>
 	</tr>
 	<tr>
 		<td>{{.Description}}</td>
diff --git a/src/repo/commit.go b/src/repo/commit.go
index f4dd8ca..d4f5986 100644
--- a/src/repo/commit.go
+++ b/src/repo/commit.go
@@ -52,11 +52,12 @@ func HandleCommit(w http.ResponseWriter, r *http.Request) {
 		Stats                         []stat
 		Summary                       string
 		Diff                          template.HTML
-		Editable                      bool
+		Editable, IsMirror            bool
 	}{
 		Title: repo.Name + " - Log", Name: repo.Name, Description: repo.Description,
 		Url:      util.If(goit.Conf.UsesHttps, "https://", "http://") + r.Host + "/" + repo.Name,
 		Editable: (auth && repo.OwnerId == user.Id),
+		IsMirror: repo.IsMirror,
 	}
 
 	gr, err := git.PlainOpen(goit.RepoPath(repo.Name, true))
diff --git a/src/repo/edit.go b/src/repo/edit.go
index f8d766c..3a6f34d 100644
--- a/src/repo/edit.go
+++ b/src/repo/edit.go
@@ -59,7 +59,7 @@ func HandleEdit(w http.ResponseWriter, r *http.Request) {
 	data := struct {
 		Title, Name, Description, Url string
 		Readme, Licence               string
-		Editable                      bool
+		Editable, IsMirror            bool
 
 		Edit struct {
 			Id, Owner, Name, Description, Upstream string
@@ -77,6 +77,7 @@ func HandleEdit(w http.ResponseWriter, r *http.Request) {
 		Description: repo.Description,
 		Url:         util.If(goit.Conf.UsesHttps, "https://", "http://") + r.Host + "/" + repo.Name,
 		Editable:    (auth && repo.OwnerId == user.Id),
+		IsMirror:    repo.IsMirror,
 
 		CsrfField: csrf.TemplateField(r),
 	}
diff --git a/src/repo/file.go b/src/repo/file.go
index 44f489a..38b0a78 100644
--- a/src/repo/file.go
+++ b/src/repo/file.go
@@ -46,12 +46,13 @@ func HandleFile(w http.ResponseWriter, r *http.Request) {
 		Path, LineC, Size, Mode       string
 		Lines                         []string
 		Body                          string
-		Editable                      bool
+		Editable, IsMirror            bool
 		HtmlPath                      template.HTML
 	}{
 		Title: repo.Name + " - File", Name: repo.Name, Description: repo.Description,
 		Url:      util.If(goit.Conf.UsesHttps, "https://", "http://") + r.Host + "/" + repo.Name,
 		Editable: (auth && repo.OwnerId == user.Id),
+		IsMirror: repo.IsMirror,
 	}
 
 	gr, err := git.PlainOpen(goit.RepoPath(repo.Name, true))
diff --git a/src/repo/log.go b/src/repo/log.go
index c2987d2..720b6f4 100644
--- a/src/repo/log.go
+++ b/src/repo/log.go
@@ -54,11 +54,12 @@ func HandleLog(w http.ResponseWriter, r *http.Request) {
 		Title, Name, Description, Url string
 		Readme, Licence               string
 		Commits                       []row
-		Editable                      bool
+		Editable, IsMirror            bool
 	}{
 		Title: repo.Name + " - Log", Name: repo.Name, Description: repo.Description,
 		Url:      util.If(goit.Conf.UsesHttps, "https://", "http://") + r.Host + "/" + repo.Name,
 		Editable: (auth && repo.OwnerId == user.Id),
+		IsMirror: repo.IsMirror,
 	}
 
 	gr, err := git.PlainOpen(goit.RepoPath(repo.Name, true))
diff --git a/src/repo/refs.go b/src/repo/refs.go
index eda65ee..2674034 100644
--- a/src/repo/refs.go
+++ b/src/repo/refs.go
@@ -39,11 +39,12 @@ func HandleRefs(w http.ResponseWriter, r *http.Request) {
 		Title, Name, Description, Url string
 		Readme, Licence               string
 		Branches, Tags                []row
-		Editable                      bool
+		Editable, IsMirror            bool
 	}{
 		Title: repo.Name + " - References", Name: repo.Name, Description: repo.Description,
 		Url:      util.If(goit.Conf.UsesHttps, "https://", "http://") + r.Host + "/" + repo.Name,
 		Editable: (auth && repo.OwnerId == user.Id),
+		IsMirror: repo.IsMirror,
 	}
 
 	gr, err := git.PlainOpen(goit.RepoPath(repo.Name, true))
diff --git a/src/repo/tree.go b/src/repo/tree.go
index f943d24..26455e3 100644
--- a/src/repo/tree.go
+++ b/src/repo/tree.go
@@ -48,12 +48,13 @@ func HandleTree(w http.ResponseWriter, r *http.Request) {
 		Readme, Licence               string
 		Path, Size                    string
 		Files                         []row
-		Editable                      bool
+		Editable, IsMirror            bool
 		HtmlPath                      template.HTML
 	}{
 		Title: repo.Name + " - Tree", Name: repo.Name, Description: repo.Description,
 		Url:      util.If(goit.Conf.UsesHttps, "https://", "http://") + r.Host + "/" + repo.Name,
 		Editable: (auth && repo.OwnerId == user.Id),
+		IsMirror: repo.IsMirror,
 	}
 
 	parts := strings.Split(tpath, "/")