summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Pioch <likeit.mp@googlemail.com>2015-10-24 22:03:08 +0200
committerMatthias Pioch <likeit.mp@googlemail.com>2015-10-24 22:03:08 +0200
commit78a4e7124507ad32ce43cd10b723224194b8e94d (patch)
treedc5cd0b5b262d0e4502f5b8eb91800627b0570a1
parent71d8ff247d35eb366c6ea417555bed15e8675a31 (diff)
downloadgitea-78a4e7124507ad32ce43cd10b723224194b8e94d.tar.gz
gitea-78a4e7124507ad32ce43cd10b723224194b8e94d.zip
workaround for reverse proxy, ssh, submodule
-rw-r--r--modules/base/template.go3
-rw-r--r--modules/git/submodule.go10
-rw-r--r--templates/repo/view_list.tmpl4
3 files changed, 13 insertions, 4 deletions
diff --git a/modules/base/template.go b/modules/base/template.go
index f5f567aded..a93d20ad86 100644
--- a/modules/base/template.go
+++ b/modules/base/template.go
@@ -141,6 +141,9 @@ var TemplateFuncs template.FuncMap = map[string]interface{}{
"AppName": func() string {
return setting.AppName
},
+ "AppUrl": func() string {
+ return setting.AppUrl
+ },
"AppSubUrl": func() string {
return setting.AppSubUrl
},
diff --git a/modules/git/submodule.go b/modules/git/submodule.go
index 0c7c2696c3..1291e112b9 100644
--- a/modules/git/submodule.go
+++ b/modules/git/submodule.go
@@ -30,7 +30,7 @@ func NewSubModuleFile(c *Commit, refUrl, refId string) *SubModuleFile {
}
// RefUrl guesses and returns reference URL.
-func (sf *SubModuleFile) RefUrl() string {
+func (sf *SubModuleFile) RefUrl(appUrl string) string {
if sf.refUrl == "" {
return ""
}
@@ -51,8 +51,14 @@ func (sf *SubModuleFile) RefUrl() string {
i := strings.Index(url, "@")
j := strings.LastIndex(url, ":")
if i > -1 && j > -1 {
- return "http://" + url[i+1:j] + "/" + url[j+1:]
+ // fix problem with reverse proxy works only with local server
+ if strings.Contains(appUrl,url[i+1:j]) {
+ return appUrl + url[j+1:]
+ } else {
+ return "http://" + url[i+1:j] + "/" + url[j+1:]
+ }
}
+
return url
}
diff --git a/templates/repo/view_list.tmpl b/templates/repo/view_list.tmpl
index d3303193f8..bebac1ea43 100644
--- a/templates/repo/view_list.tmpl
+++ b/templates/repo/view_list.tmpl
@@ -39,8 +39,8 @@
<span class="octicon octicon-file-submodule"></span>
</td>
<td class="name">
- {{if $commit.RefUrl}}
- <a href="{{$commit.RefUrl}}" class="text-truncate">{{$entry.Name}}</a> @ <a href="{{$commit.RefUrl}}/commit/{{$commit.RefId}}">{{ShortSha $commit.RefId}}</a>
+ {{if $commit.RefUrl AppUrl}}
+ <a href="{{$commit.RefUrl AppUrl}}" class="text-truncate">{{$entry.Name}}</a> @ <a href="{{$commit.RefUrl AppUrl}}/commit/{{$commit.RefId}}">{{ShortSha $commit.RefId}}</a>
{{else}}
{{$entry.Name}} @ {{ShortSha $commit.RefId}}
{{end}}