diff --git a/conf/app.ini b/conf/app.ini index 72c968b3e..acfea5ce1 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -14,7 +14,7 @@ DB_TYPE = mysql HOST = NAME = gogs USER = root -PASSWD = +PASSWD = fuxiaohei PASSWD_jiahua = root [security] diff --git a/public/css/gogs.css b/public/css/gogs.css index 6580d907a..9205178f4 100755 --- a/public/css/gogs.css +++ b/public/css/gogs.css @@ -28,6 +28,10 @@ body { margin: 0 .5em; } +.list-group .list-group-item { + background-color: transparent; +} + /* gogits nav header */ .gogs-masthead { background-color: #428bca; @@ -222,4 +226,74 @@ body { #gogs-repo-create textarea[name=desc] { height: 8em; +} + +/* gogits user setting */ + +#gogs-user-setting-nav > h4, #gogs-user-setting-container > h4 ,#gogs-ssh-keys > h4{ + padding-bottom: 18px; + margin-bottom: 18px; + border-bottom: 1px solid #CCC; +} + +#gogs-user-setting-nav .list-group .list-group-item a { + margin-left: 0; + padding: .6em; + font-size: 14px; + color: #3B73AF; +} + +#gogs-user-setting-nav .list-group .list-group-item { + background-color: transparent; +} + +#gogs-user-setting-nav .list-group .list-group-item-success a { + font-weight: bold; + color: #444; +} + +/* gogits user ssh keys */ + +#gogs-ssh-keys .list-group-item { + line-height: 48px; + border-bottom: 1px solid #DDD; +} + +#gogs-ssh-keys .list-group-item:after{ + clear: both; +} + +#gogs-ssh-keys .list-group-item:hover a.delete{ + display: block; +} + +#gogs-ssh-keys .name { + font-size: 14px; + font-weight: bold; +} + +#gogs-ssh-keys .list-group-item a.delete { + float: right; + color: white; + cursor: pointer; + margin-top: 10px; + border-radius: 3px; + display: none; +} + +#gogs-ssh-keys .print { + padding-left: 1em; + color: #888; +} + +#gogs-ssh-add { + display: inline-block; + color: white; + cursor: pointer; + margin-left: 0; + border-radius: 3px; +} + +#gogs-ssh-form textarea{ + height: 16em; } \ No newline at end of file diff --git a/public/js/app.js b/public/js/app.js index 6a4c72bd7..59d521090 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -3,12 +3,7 @@ var Gogits = { }; (function ($) { - Gogits.showTooltips = function () { - $("body").tooltip({ - selector: "[data-toggle=tooltip]" - //container: "body" - }); - }; + Gogits.showTab = function (selector, index) { if (!index) { index = 0; @@ -27,11 +22,29 @@ var Gogits = { }; $form.validate(options); }; + + // ----- init elements + Gogits.initModals = function () { + var modals = $("[data-toggle=modal]"); + if (modals.length < 1) { + return; + } + $.each(modals, function (i, item) { + $(item).modal("hide"); + }); + }; + Gogits.initTooltips = function () { + $("body").tooltip({ + selector: "[data-toggle=tooltip]" + //container: "body" + }); + }; })(jQuery); function initCore() { - Gogits.showTooltips(); + Gogits.initTooltips(); + Gogits.initModals(); } function initRegister() { diff --git a/routers/user/setting.go b/routers/user/setting.go new file mode 100644 index 000000000..84be13817 --- /dev/null +++ b/routers/user/setting.go @@ -0,0 +1,54 @@ +// Copyright 2014 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package user + +import ( + "github.com/gogits/gogs/models" + "github.com/gogits/gogs/modules/auth" + "github.com/gogits/gogs/modules/base" + "github.com/gogits/gogs/modules/log" + "github.com/martini-contrib/render" + "github.com/martini-contrib/sessions" + "net/http" +) + +func Setting(r render.Render, data base.TmplData, session sessions.Session) { + data["Title"] = "Setting" + data["PageIsUserSetting"] = true + r.HTML(200, "user/setting", data) +} + +func SettingSSHKeys(r render.Render, data base.TmplData, req *http.Request, session sessions.Session) { + // add ssh key + if req.Method == "POST" { + k := &models.PublicKey{OwnerId: auth.SignedInId(session), + Name: req.FormValue("keyname"), + Content: req.FormValue("key_content"), + } + err := models.AddPublicKey(k) + if err != nil { + data["ErrorMsg"] = err + log.Error("ssh.AddPublicKey: %v", err) + r.HTML(200, "base/error", data) + return + } else { + data["AddSSHKeySuccess"] = true + } + } + // get keys + keys, err := models.ListPublicKey(auth.SignedInId(session)) + if err != nil { + data["ErrorMsg"] = err + log.Error("ssh.ListPublicKey: %v", err) + r.HTML(200, "base/error", data) + return + } + + // set to template + data["Title"] = "SSH Keys" + data["PageIsUserSetting"] = true + data["Keys"] = keys + r.HTML(200, "user/publickey", data) +} diff --git a/templates/base/navbar.tmpl b/templates/base/navbar.tmpl index 12434dad2..e78f6bb22 100644 --- a/templates/base/navbar.tmpl +++ b/templates/base/navbar.tmpl @@ -10,7 +10,7 @@ - + {{else}}Sign in{{end}} diff --git a/templates/user/publickey.tmpl b/templates/user/publickey.tmpl new file mode 100644 index 000000000..fbd12adbd --- /dev/null +++ b/templates/user/publickey.tmpl @@ -0,0 +1,62 @@ +{{template "base/head" .}} +{{template "base/navbar" .}} +
New SSH Key is added !
{{end}} +Need help? Check out our guide to generating SSH keys or troubleshoot common SSH Problems
+