diff --git a/public/css/gogs.css b/public/css/gogs.css index a8fa1daca..3d8dc3fdd 100755 --- a/public/css/gogs.css +++ b/public/css/gogs.css @@ -372,8 +372,89 @@ body { line-height: 32px; border-bottom: 1px solid #DDD; padding-left: 15px; + clear: both; +} + +#gogs-feed-right .repo-panel .list-group-item:last-child { + border-bottom: none; } #gogs-feed-right .repo-panel .list-group-item:hover { background-color: rgba(65, 131, 196, 0.1); +} + +#gogs-feed-right .repo-panel span.stars { + color: #666; + line-height: 44px; + margin-right: 1em; +} + +/* gogits repo single page */ + +.gogs-repo-nav h3 .fa { + color: #BBB; +} + +.gogs-repo-btns { + margin-top: 18px; +} + +.gogs-repo-btns .btn-group { + margin-left: 1em; +} + +.gogs-repo-btns .btn-group .btn { + padding-left: 6px; +} + +#gogs-repo-watching .dropdown-menu { + width: 280px; + padding: 0; +} + +#gogs-repo-watching .dropdown-menu .dropdown-item:hover .dropdown-header { + color: rgb(65, 131, 196); + cursor: pointer; +} + +#gogs-repo-watching .dropdown-menu .description { + padding: 0 20px; + color: #888; +} + +#gogs-repo-watching .dropdown-menu .dropdown-header { + color: #444; + font-weight: bold; + font-size: 14px; + margin-bottom: 4px; +} + + +#gogs-repo-toolbar{ + margin-top: 51px; + margin-bottom: -50px; + border-bottom: 1px solid #BBB; + background-color: #FFF; + height: 40px; +} + +#gogs-repo-toolbar .navbar-default{ + border: none; + height: 39px; +} + +#gogs-repo-toolbar .nav > li > a{ + height: 39px; +} + +#gogs-repo-toolbar .navbar-toolbar.navbar-default .navbar-nav>.active>a:after{ + border-bottom-color: #999; +} + +#gogs-repo-toolbar .navbar.nav-toolbar{ + margin-bottom: 0; +} + +#gogs-repo-toolbar .navbar-collapse{ + padding: 0; } \ No newline at end of file diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 644403452..5769aff7c 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -6,8 +6,6 @@ package repo import ( "net/http" - - "github.com/codegangsta/martini" "github.com/martini-contrib/render" "github.com/martini-contrib/sessions" @@ -87,20 +85,6 @@ func Delete(req *http.Request, r render.Render, data base.TmplData, session sess } } -func Repo(params martini.Params, req *http.Request, r render.Render, data base.TmplData, session sessions.Session) { - data["Title"] = "Repository" - files, err := models.GetReposFiles(params["username"], params["reponame"], "HEAD", "/") - if err != nil { - data["ErrorMsg"] = err - log.Error("repo.List: %v", err) - r.HTML(200, "base/error", data) - return - } - - data["Files"] = files - r.HTML(200, "repo/repo", data) -} - func List(req *http.Request, r render.Render, data base.TmplData, session sessions.Session) { u := auth.SignedInUser(session) if u != nil { diff --git a/routers/repo/single.go b/routers/repo/single.go new file mode 100644 index 000000000..811aed399 --- /dev/null +++ b/routers/repo/single.go @@ -0,0 +1,66 @@ +package repo + +import ( + "net/http" + + "github.com/codegangsta/martini" + "github.com/gogits/gogs/models" + "github.com/gogits/gogs/modules/auth" + "github.com/gogits/gogs/modules/base" + "github.com/martini-contrib/render" + "github.com/martini-contrib/sessions" + "github.com/qiniu/log" +) + +func Single(params martini.Params, req *http.Request, r render.Render, data base.TmplData, session sessions.Session) { + var ( + user *models.User + err error + ) + // get repository owner + isOwner := (data["SignedUserName"] == params["username"]) + if !isOwner { + user, err = models.GetUserByName(params["username"]) + if err != nil { + data["ErrorMsg"] = err + //log.Error("repo.Single: %v", err) + r.HTML(200, "base/error", data) + return + } + } else { + user = auth.SignedInUser(session) + } + if user == nil { + data["ErrorMsg"] = "invliad user account for single repository" + //log.Error("repo.Single: %v", err) + r.HTML(200, "base/error", data) + return + } + data["IsRepositoryOwner"] = isOwner + + // get repository + repo, err := models.GetRepositoryByName(user, params["reponame"]) + if err != nil { + data["ErrorMsg"] = err + //log.Error("repo.Single: %v", err) + r.HTML(200, "base/error", data) + return + } + + data["Repository"] = repo + data["Owner"] = user + data["Title"] = user.Name + "/" + repo.Name + data["RepositoryLink"] = data["Title"] + data["IsRepoToolbarSource"] = true + + files, err := models.GetReposFiles(params["username"], params["reponame"], "HEAD", "/") + if err != nil { + data["ErrorMsg"] = err + log.Error("repo.List: %v", err) + r.HTML(200, "base/error", data) + return + } + + data["Files"] = files + r.HTML(200, "repo/single", data) +} diff --git a/templates/repo/repo.tmpl b/templates/repo/repo.tmpl deleted file mode 100644 index 5ae3f25c1..000000000 --- a/templates/repo/repo.tmpl +++ /dev/null @@ -1,10 +0,0 @@ -{{template "base/head" .}} -{{template "base/navbar" .}} -