From d8a24aff8c2a293bd13f306625d3ba401f182f64 Mon Sep 17 00:00:00 2001 From: FuXiaoHei Date: Mon, 3 Mar 2014 20:35:44 +0800 Subject: [PATCH 1/2] display login error message when login post error --- routers/user/user.go | 34 +++++++++++++++++++--------------- templates/user/signin.tmpl | 9 ++++++--- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/routers/user/user.go b/routers/user/user.go index cf1314086c..b7f9d148d1 100644 --- a/routers/user/user.go +++ b/routers/user/user.go @@ -24,22 +24,26 @@ func Profile(r render.Render) { } func SignIn(req *http.Request, r render.Render) { - if req.Method == "GET" { - r.HTML(200, "user/signin", map[string]interface{}{ - "Title": "Log In", - }) - return + var ( + errString string + account string + ) + if req.Method == "POST" { + account = req.FormValue("account") + _, err := models.LoginUserPlain(account, req.FormValue("passwd")) + if err == nil { + // login success + r.Redirect("/") + return + } + // login fail + errString = fmt.Sprintf("%v", err) } - - // todo sign in - _, err := models.LoginUserPlain(req.FormValue("account"), req.FormValue("passwd")) - if err != nil { - r.HTML(200, "base/error", map[string]interface{}{ - "Error": fmt.Sprintf("%v", err), - }) - return - } - r.Redirect("/") + r.HTML(200, "user/signin", map[string]interface{}{ + "Title": "Log In", + "Error": errString, + "Account": account, + }) } func SignUp(req *http.Request, r render.Render) { diff --git a/templates/user/signin.tmpl b/templates/user/signin.tmpl index 856e46d97b..6527ae53f2 100644 --- a/templates/user/signin.tmpl +++ b/templates/user/signin.tmpl @@ -2,17 +2,20 @@ {{template "base/navbar" .}}
-

Log in

+

Log in

{{if .Error}} +
+
{{.Error}}
+
{{end}}
- +
- +
From 39ac95e5a2f256a840dac6206623100a7688ac16 Mon Sep 17 00:00:00 2001 From: FuXiaoHei Date: Mon, 3 Mar 2014 22:40:22 +0800 Subject: [PATCH 2/2] nav ui for user logged --- public/css/gogs.css | 69 ++++++++++++++++++++++++++----------- public/js/app.js | 7 +++- templates/base/footer.tmpl | 7 +++- templates/base/navbar.tmpl | 11 ++++-- templates/user/profile.tmpl | 1 - 5 files changed, 69 insertions(+), 26 deletions(-) diff --git a/public/css/gogs.css b/public/css/gogs.css index 08dada0457..c08c1e3ba3 100755 --- a/public/css/gogs.css +++ b/public/css/gogs.css @@ -10,17 +10,17 @@ body { /* override bs3 */ -.tooltip-inner{ +.tooltip-inner { border-radius: 3px; background: #333; border: none; } -.tooltip-arrow{ +.tooltip-arrow { border-bottom-color: #333 !important; } -.fa{ +.fa { margin: 0 .5em; } @@ -28,8 +28,7 @@ body { .gogs-masthead { background-color: #428bca; box-shadow: inset 0 -2px 5px rgba(0, 0, 0, .1); - min-height: 45px; - padding: 2px 16px; + padding: 0 16px; } /* gogits nav item link */ @@ -54,6 +53,14 @@ body { padding: 5px 15px; } +.gogs-nav-item.navbar-right { + margin-top: 3px; +} + +.gogs-nav-item.navbar-right .fa{ + margin: 0; +} + /* gogits nav item active status */ .gogs-nav .active { color: #fff; @@ -73,19 +80,41 @@ body { border-left: 5px solid transparent; } +.gogs-nav .tooltip{ + border: none; +} + /* gogits logo */ -#gogs-logo { +#gogs-nav-avatar { + margin-top: 0; +} + +#gogs-logo, #gogs-nav-avatar img { width: 28px; + height: 28px; +} + +#gogs-nav-out { + margin-top: 10px; + padding: 5px 0; + margin-left: 10px; + height: 28px; +} + +#gogs-nav-out .fa { + vertical-align: -10%; + margin: 0 .5em; } /* gogits body */ #gogs-body { padding-top: 30px; padding-bottom: 60px; + margin-top: 50px; } /* gogits login card */ -.gogs-card{ +.gogs-card { margin: auto; padding: 30px; background: #fff; @@ -101,7 +130,7 @@ body { border-bottom: 1px solid #ccc; } -#gogs-login-card{ +#gogs-login-card { width: 600px; } @@ -115,51 +144,51 @@ body { line-height: 30px; } -.gogs-card .btn{ +.gogs-card .btn { cursor: pointer; margin-right: 1.2em; } -#gogs-social-login{ +#gogs-social-login { margin-top: 30px; padding-top: 20px; border-top: 1px solid #ccc; } -#gogs-social-login .btn{ +#gogs-social-login .btn { float: none; margin: auto; } /* gogs-user-profile */ -#gogs-user-avatar{ +#gogs-user-avatar { width: 200px; height: 200px; border-radius: 6px; } -#gogs-user-name{ +#gogs-user-name { margin-top: 20px; font-size: 1.6em; font-weight: bold; margin-bottom: 20px; } -#gogs-user-profile .profile-info .list-group-item{ +#gogs-user-profile .profile-info .list-group-item { background-color: transparent; padding-top: 18px; color: #666; } -#gogs-user-profile .profile-info .list-group-item a{ +#gogs-user-profile .profile-info .list-group-item a { margin: 0; padding: 0; display: inline; color: #0093c4; } -#gogs-user-profile .profile-info .list-group{ +#gogs-user-profile .profile-info .list-group { border-top: 1px solid #ccc; padding-bottom: 18px; border-bottom: 1px solid #ccc; @@ -167,20 +196,20 @@ body { padding-right: 18px; } -#gogs-user-activity .tab-pane{ +#gogs-user-activity .tab-pane { padding: 20px; } -#gogs-user-act-tabs li.active a{ +#gogs-user-act-tabs li.active a { border-bottom-color: #ddd; } /* gogits repo create */ -#gogs-repo-create{ +#gogs-repo-create { width: 800px; } -#gogs-repo-create textarea[name=desc]{ +#gogs-repo-create textarea[name=desc] { height: 8em; } \ No newline at end of file diff --git a/public/js/app.js b/public/js/app.js index a8220f46e1..414af13522 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -14,4 +14,9 @@ var Gogits = {}; $(selector).tab("show"); $(selector).find("li:eq(" + index + ") a").tab("show"); } -})(jQuery); \ No newline at end of file +})(jQuery); + + +function initCore(){ + Gogits.showTooltips(); +} \ No newline at end of file diff --git a/templates/base/footer.tmpl b/templates/base/footer.tmpl index 4d4a7e5285..eaf5bd626e 100644 --- a/templates/base/footer.tmpl +++ b/templates/base/footer.tmpl @@ -1,2 +1,7 @@ - + + \ No newline at end of file diff --git a/templates/base/navbar.tmpl b/templates/base/navbar.tmpl index ae908738a8..f47482f3b9 100644 --- a/templates/base/navbar.tmpl +++ b/templates/base/navbar.tmpl @@ -1,12 +1,17 @@ -
+ diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl index f32601001d..e7056aa869 100644 --- a/templates/user/profile.tmpl +++ b/templates/user/profile.tmpl @@ -30,7 +30,6 @@