From 0d4498429cd912f78a508a4f4bc6856b15c73ac4 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Mon, 9 Nov 2015 02:13:25 -0500 Subject: [PATCH] work on #1904 --- README.md | 2 +- gogs.go | 2 +- routers/repo/view.go | 15 ++++++++++----- templates/.VERSION | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index be6f5a8004..a8389038fb 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra ![](public/img/gogs-large-resize.png) -##### Current version: 0.7.1 Beta +##### Current version: 0.7.2 Beta diff --git a/gogs.go b/gogs.go index 407abe67c9..74e5bd64e6 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.7.1.1108 Beta" +const APP_VER = "0.7.2.1109 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/routers/repo/view.go b/routers/repo/view.go index bc05b68051..6a3e0cb3bc 100644 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -31,14 +31,19 @@ func Home(ctx *middleware.Context) { repoLink := ctx.Repo.RepoLink branchLink := ctx.Repo.RepoLink + "/src/" + branchName + treeLink := branchLink rawLink := ctx.Repo.RepoLink + "/raw/" + branchName // Get tree path treename := ctx.Repo.TreeName - if len(treename) > 0 && treename[len(treename)-1] == '/' { - ctx.Redirect(repoLink + "/src/" + branchName + "/" + treename[:len(treename)-1]) - return + if len(treename) > 0 { + if treename[len(treename)-1] == '/' { + ctx.Redirect(repoLink + "/src/" + branchName + "/" + treename[:len(treename)-1]) + return + } + + treeLink += "/" + treename } ctx.Data["IsRepoToolbarSource"] = true @@ -98,7 +103,7 @@ func Home(ctx *middleware.Context) { readmeExist := base.IsMarkdownFile(blob.Name()) || base.IsReadmeFile(blob.Name()) ctx.Data["ReadmeExist"] = readmeExist if readmeExist { - ctx.Data["FileContent"] = string(base.RenderMarkdown(buf, branchLink)) + ctx.Data["FileContent"] = string(base.RenderMarkdown(buf, path.Dir(treeLink))) } else { if err, content := base.ToUtf8WithErr(buf); err != nil { if err != nil { @@ -191,7 +196,7 @@ func Home(ctx *middleware.Context) { buf = append(buf, d...) switch { case base.IsMarkdownFile(readmeFile.Name()): - buf = base.RenderMarkdown(buf, branchLink) + buf = base.RenderMarkdown(buf, treeLink) default: buf = bytes.Replace(buf, []byte("\n"), []byte(`
`), -1) } diff --git a/templates/.VERSION b/templates/.VERSION index 21f4732c6a..c5c0c2eee9 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.7.1.1108 Beta \ No newline at end of file +0.7.2.1109 Beta \ No newline at end of file