]> source.dussan.org Git - gitea.git/commitdiff
workaround for reverse proxy, ssh, submodule
authorMatthias Pioch <likeit.mp@googlemail.com>
Sat, 24 Oct 2015 20:03:08 +0000 (22:03 +0200)
committerMatthias Pioch <likeit.mp@googlemail.com>
Sat, 24 Oct 2015 20:03:08 +0000 (22:03 +0200)
modules/base/template.go
modules/git/submodule.go
templates/repo/view_list.tmpl

index f5f567adede525f13e8c921082463fe30bd61880..a93d20ad86195c5574ec07eff01c127a44863b6d 100644 (file)
@@ -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
        },
index 0c7c2696c34c06ef1c853fb30e8e2cca300a35db..1291e112b97c47fa45f0d95eb45bdb242195f046 100644 (file)
@@ -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
 }
 
index d3303193f86c489ebc98423cd1c4abea26b7b0d3..bebac1ea4304856ef67cb5c7d7ce619f75816ca5 100644 (file)
@@ -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}}