From 4fff38856e784cb1c2c8115a7c7e013f42f7d8d8 Mon Sep 17 00:00:00 2001 From: FuXiaoHei Date: Thu, 13 Mar 2014 12:15:58 +0800 Subject: [PATCH 1/2] single repository page ui preview --- public/css/gogs.css | 81 +++++++++++++++++++++++++++++++++++ routers/repo/single.go | 56 ++++++++++++++++++++++++ templates/repo/single.tmpl | 38 ++++++++++++++++ templates/repo/toolbar.tmpl | 41 ++++++++++++++++++ templates/user/dashboard.tmpl | 4 +- web.go | 1 + 6 files changed, 220 insertions(+), 1 deletion(-) create mode 100644 routers/repo/single.go create mode 100644 templates/repo/single.tmpl create mode 100644 templates/repo/toolbar.tmpl 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/single.go b/routers/repo/single.go new file mode 100644 index 000000000..be27db8e0 --- /dev/null +++ b/routers/repo/single.go @@ -0,0 +1,56 @@ +package repo + +import ( + "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" + "net/http" +) + + +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 + + r.HTML(200, "repo/single", data) +} diff --git a/templates/repo/single.tmpl b/templates/repo/single.tmpl new file mode 100644 index 000000000..ef812f824 --- /dev/null +++ b/templates/repo/single.tmpl @@ -0,0 +1,38 @@ +{{template "base/head" .}} +{{template "base/navbar" .}} +
+
+
+
+ + + +
+
+ +
+
+ +
+
+

{{.Owner.Name}} / {{.Repository.Name}}

+
+
+{{template "repo/toolbar" .}} +
+ repo single dashboard +
+{{template "base/footer" .}} \ No newline at end of file diff --git a/templates/repo/toolbar.tmpl b/templates/repo/toolbar.tmpl new file mode 100644 index 000000000..57408e18e --- /dev/null +++ b/templates/repo/toolbar.tmpl @@ -0,0 +1,41 @@ +
+
+ +
+
\ No newline at end of file diff --git a/templates/user/dashboard.tmpl b/templates/user/dashboard.tmpl index 6f2b4b371..d422f8ffe 100644 --- a/templates/user/dashboard.tmpl +++ b/templates/user/dashboard.tmpl @@ -22,7 +22,9 @@
diff --git a/web.go b/web.go index c7c704c16..c20413166 100644 --- a/web.go +++ b/web.go @@ -73,6 +73,7 @@ func runWeb(*cli.Context) { m.Any("/repo/create", auth.SignInRequire(true), binding.BindIgnErr(auth.CreateRepoForm{}), repo.Create) m.Any("/repo/delete", auth.SignInRequire(true), repo.Delete) m.Any("/repo/list", auth.SignInRequire(false), repo.List) + m.Get("/:username/:reponame", auth.SignInRequire(false), repo.Single) listenAddr := fmt.Sprintf("%s:%s", base.Cfg.MustValue("server", "HTTP_ADDR"), From fecafdca2ac5884a4dbcef2b937dfc3d2bf27ef2 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 13 Mar 2014 12:45:41 +0800 Subject: [PATCH 2/2] merge --- routers/repo/repo.go | 16 ---------------- routers/repo/single.go | 14 ++++++++++++-- templates/repo/repo.tmpl | 10 ---------- templates/repo/single.tmpl | 6 +++++- web.go | 2 -- 5 files changed, 17 insertions(+), 31 deletions(-) delete mode 100644 templates/repo/repo.tmpl 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 index be27db8e0..811aed399 100644 --- a/routers/repo/single.go +++ b/routers/repo/single.go @@ -1,16 +1,17 @@ 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" - "net/http" + "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 @@ -52,5 +53,14 @@ func Single(params martini.Params, req *http.Request, r render.Render, data base 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" .}} -
-
    - {{range .Files}} -
  • {{.Name}} - {{.Type}}
  • - {{end}} -
-
-{{template "base/footer" .}} \ No newline at end of file diff --git a/templates/repo/single.tmpl b/templates/repo/single.tmpl index ef812f824..9d4a24f85 100644 --- a/templates/repo/single.tmpl +++ b/templates/repo/single.tmpl @@ -33,6 +33,10 @@ {{template "repo/toolbar" .}}
- repo single dashboard +
    + {{range .Files}} +
  • {{.Name}} - {{.Type}}
  • + {{end}} +
{{template "base/footer" .}} \ No newline at end of file diff --git a/web.go b/web.go index c8b7ed0d4..c20413166 100644 --- a/web.go +++ b/web.go @@ -70,8 +70,6 @@ func runWeb(*cli.Context) { m.Get("/user/:username", auth.SignInRequire(false), user.Profile) - m.Get("/:username/:reponame", repo.Repo) - m.Any("/repo/create", auth.SignInRequire(true), binding.BindIgnErr(auth.CreateRepoForm{}), repo.Create) m.Any("/repo/delete", auth.SignInRequire(true), repo.Delete) m.Any("/repo/list", auth.SignInRequire(false), repo.List)