From 4fff38856e784cb1c2c8115a7c7e013f42f7d8d8 Mon Sep 17 00:00:00 2001 From: FuXiaoHei Date: Thu, 13 Mar 2014 12:15:58 +0800 Subject: [PATCH] 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 a8fa1daca5..3d8dc3fddb 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 0000000000..be27db8e05 --- /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 0000000000..ef812f8249 --- /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 0000000000..57408e18e8 --- /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 6f2b4b371e..d422f8ffe4 100644 --- a/templates/user/dashboard.tmpl +++ b/templates/user/dashboard.tmpl @@ -22,7 +22,9 @@
diff --git a/web.go b/web.go index c7c704c168..c204131662 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"),