From 139a6f80dc258bba1e61aa9584787b86ac4addf3 Mon Sep 17 00:00:00 2001 From: skyblue Date: Sun, 23 Mar 2014 23:22:35 +0800 Subject: [PATCH 01/26] update my config --- conf/app.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/app.ini b/conf/app.ini index ab9f6dc4b..b9472b551 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -2,7 +2,7 @@ APP_NAME = Gogs: Go Git Service APP_LOGO = img/favicon.png ; !!MUST CHANGE TO YOUR USER NAME!! -RUN_USER = lunny +RUN_USER = skyblue ; Either "dev", "prod" or "test", default is "dev" RUN_MODE = dev @@ -164,4 +164,4 @@ RECEIVERS = [log.database] LEVEL = Driver = -CONN = \ No newline at end of file +CONN = From 7048ea45279cd96f88845d83fe7cef6fbb545fcf Mon Sep 17 00:00:00 2001 From: skyblue Date: Tue, 25 Mar 2014 18:34:57 +0800 Subject: [PATCH 02/26] update avatar, remove gzip request header --- modules/avatar/avatar.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/avatar/avatar.go b/modules/avatar/avatar.go index 0ba20294a..3b423a6d1 100644 --- a/modules/avatar/avatar.go +++ b/modules/avatar/avatar.go @@ -251,8 +251,8 @@ var client = &http.Client{} func (this *thunderTask) fetch() error { req, _ := http.NewRequest("GET", this.Url, nil) - req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8") - req.Header.Set("Accept-Encoding", "gzip,deflate,sdch") + req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/jpeg,image/png,*/*;q=0.8") + req.Header.Set("Accept-Encoding", "deflate,sdch") req.Header.Set("Accept-Language", "zh-CN,zh;q=0.8") req.Header.Set("Cache-Control", "no-cache") req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36") From 2a2f025388b2f47cff4162adc207af2ba68d64d9 Mon Sep 17 00:00:00 2001 From: FuXiaoHei Date: Tue, 25 Mar 2014 18:44:37 +0800 Subject: [PATCH 03/26] change css name style --- public/css/gogs.css | 202 ++++++++++++++++--------------- public/js/app.js | 10 +- templates/admin/config.tmpl | 4 +- templates/admin/dashboard.tmpl | 4 +- templates/admin/nav.tmpl | 2 +- templates/admin/repos.tmpl | 4 +- templates/admin/users.tmpl | 4 +- templates/admin/users/edit.tmpl | 4 +- templates/admin/users/new.tmpl | 4 +- templates/base/navbar.tmpl | 26 ++-- templates/help.tmpl | 4 +- templates/home.tmpl | 2 +- templates/install.tmpl | 4 +- templates/issue/create.tmpl | 4 +- templates/repo/branches.tmpl | 4 +- templates/repo/commits.tmpl | 4 +- templates/repo/create.tmpl | 4 +- templates/repo/diff.tmpl | 4 +- templates/repo/issues.tmpl | 4 +- templates/repo/list.tmpl | 2 +- templates/repo/nav.tmpl | 8 +- templates/repo/pulls.tmpl | 4 +- templates/repo/setting.tmpl | 6 +- templates/repo/single.tmpl | 4 +- templates/repo/toolbar.tmpl | 2 +- templates/status/200.tmpl | 2 +- templates/status/404.tmpl | 2 +- templates/status/500.tmpl | 2 +- templates/user/active.tmpl | 4 +- templates/user/dashboard.tmpl | 8 +- templates/user/delete.tmpl | 10 +- templates/user/issues.tmpl | 4 +- templates/user/notification.tmpl | 4 +- templates/user/password.tmpl | 8 +- templates/user/profile.tmpl | 12 +- templates/user/publickey.tmpl | 12 +- templates/user/pulls.tmpl | 4 +- templates/user/security.tmpl | 4 +- templates/user/setting.tmpl | 8 +- templates/user/setting_nav.tmpl | 2 +- templates/user/signin.tmpl | 6 +- templates/user/signup.tmpl | 4 +- templates/user/stars.tmpl | 4 +- 43 files changed, 214 insertions(+), 210 deletions(-) diff --git a/public/css/gogs.css b/public/css/gogs.css index 2254ef5a2..c8c5d87b8 100755 --- a/public/css/gogs.css +++ b/public/css/gogs.css @@ -52,14 +52,14 @@ html, body { } /* gogits nav header */ -.gogs-masthead { +.masthead { background-color: #428bca; box-shadow: inset 0 -2px 5px rgba(0, 0, 0, .1); margin: 0; } /* gogits nav item link */ -.gogs-nav-item { +.nav-item { position: relative; display: inline-block; padding: 10px; @@ -69,39 +69,39 @@ html, body { height: 46px; } -#gogs-nav-logo { +#nav-logo { padding-left: 0; padding-right: 0; margin-right: 10px; } -.gogs-nav-item:hover, -.gogs-nav-item:focus { +.nav-item:hover, +.nav-item:focus { color: #fff; text-decoration: none; } -.gogs-nav-item.navbar-right { +.nav-item.navbar-right { margin-top: 3px; } -.gogs-nav-item.navbar-btn { +.nav-item.navbar-btn { cursor: pointer; margin-top: 8px; padding: 5px 15px; height: 30px; } -.gogs-nav-item.navbar-right .fa { +.nav-item.navbar-right .fa { margin: 0; } /* gogits nav item active status */ -.gogs-nav .active { +.nav .active { color: #fff; } -.gogs-nav .active:after { +.nav .active:after { position: absolute; bottom: -1px; left: 50%; @@ -115,29 +115,29 @@ html, body { border-left: 5px solid transparent; } -#gogs-nav-logo:after { +#nav-logo:after { bottom: -4px !important; } -#gogs-nav-avatar:after { +#nav-avatar:after { bottom: -4px !important; } -.gogs-nav .tooltip { +.nav .tooltip { border: none; } /* gogits logo */ -#gogs-nav-avatar { +#nav-avatar { margin-top: 0; } -#gogs-logo, #gogs-nav-avatar img { +#logo, #nav-avatar img { width: 28px; height: 28px; } -#gogs-nav-out { +#nav-out { margin-top: 10px; padding: 5px 0; margin-left: 10px; @@ -145,56 +145,56 @@ html, body { float: right; } -#gogs-nav-signin, #gogs-nav-signup { +#nav-signin, #nav-signup { float: right; margin-left: 1em; } -#gogs-nav-out .fa { +#nav-out .fa { vertical-align: -10%; margin: 0 .5em; } /* gogits body */ -#gogs-body { +#body { padding-bottom: 60px; margin-top: 30px; } -#gogs-body .btn-default { +#body .btn-default { background-color: #FFF; background-image: linear-gradient(to bottom, #FFF 0, #FAFAFA 100%); } -#gogs-body-nav { +#body-nav { background-color: #FFF; border-bottom: 1px solid #DDD; height: 66px } -#gogs-body-nav .nav { +#body-nav .nav { font-size: 14px; margin-top: 12px; } -#gogs-body-nav .nav-pills li a { +#body-nav .nav-pills li a { color: #444; } -#gogs-body-nav .nav-pills li.active a { +#body-nav .nav-pills li.active a { font-weight: bold; border-bottom: 2px solid #d26911; background-color: transparent; color: #444; } -#gogs-body-nav .nav-pills li:hover a { +#body-nav .nav-pills li:hover a { background-color: transparent; text-decoration: underline; } /* gogits login card */ -.gogs-card { +.card { margin: auto; padding: 30px; background: #fff; @@ -203,87 +203,87 @@ html, body { box-sizing: border-box; } -.gogs-card h3 { +.card h3 { margin-top: 0; margin-bottom: 30px; padding-bottom: 20px; border-bottom: 1px solid #ccc; } -#gogs-login-card { +#login-card { width: 600px; } -#gogs-login-card .form-control { +#login-card .form-control { padding: 6px 12px; box-sizing: content-box; } -#gogs-login-card .control-label { +#login-card .control-label { height: 44px; line-height: 30px; } -#gogs-install-card{ +#install-card { width: 800px; } -#gogs-install-card .form-group { +#install-card .form-group { margin-left: 0; margin-right: 0; } -.gogs-card .btn { +.card .btn { cursor: pointer; margin-right: 1.2em; } -#gogs-social-login { +#social-login { margin-top: 30px; padding-top: 20px; border-top: 1px solid #ccc; } -#gogs-social-login .btn { +#social-login .btn { float: none; margin: auto; } /* gogs-user-profile */ -#gogs-user-avatar { +#user-avatar { width: 200px; height: 200px; border-radius: 6px; } -#gogs-user-avatar-commit { +#user-avatar-commit { width: 16px; height: 16px; border-radius: 2px; } -#gogs-user-name { +#user-name { margin-top: 20px; font-size: 1.6em; font-weight: bold; margin-bottom: 20px; } -#gogs-user-profile .profile-info .list-group-item { +#user-profile .profile-info .list-group-item { background-color: transparent; padding-top: 18px; color: #666; } -#gogs-user-profile .profile-info .list-group-item a { +#user-profile .profile-info .list-group-item a { margin: 0; padding: 0; display: inline; color: #0093c4; } -#gogs-user-profile .profile-info .list-group { +#user-profile .profile-info .list-group { border-top: 1px solid #ccc; padding-bottom: 18px; border-bottom: 1px solid #ccc; @@ -291,50 +291,50 @@ html, body { padding-right: 18px; } -#gogs-user-activity .tab-pane { +#user-activity .tab-pane { padding: 20px; } -#gogs-user-act-tabs li.active a { +#user-act-tabs li.active a { border-bottom-color: #ddd; } /* gogits repo create */ -#gogs-repo-create { +#repo-create { width: 800px; } -#gogs-repo-create textarea[name=desc] { +#repo-create textarea[name=desc] { height: 8em; } /* gogits user setting */ -#gogs-user-setting-nav > h4, #gogs-user-setting-container > h4, #gogs-user-setting-container > div > h4, -#gogs-ssh-keys > h4, #gogs-user-delete > h4, #gogs-repo-setting-container .tab-pane > h4 { +#user-setting-nav > h4, #user-setting-container > h4, #user-setting-container > div > h4, +#ssh-keys > h4, #user-delete > h4, #repo-setting-container .tab-pane > h4 { padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid #CCC; } -#gogs-user-setting-nav .list-group .list-group-item a { +#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 { +#user-setting-nav .list-group .list-group-item { background-color: transparent; } -#gogs-user-setting-nav .list-group .list-group-item-success a { +#user-setting-nav .list-group .list-group-item-success a { font-weight: bold; color: #444; } -.gogs-admin-nav { +.admin-nav { background-color: #FFF; padding-top: 10px; padding-left: 0; @@ -342,49 +342,49 @@ html, body { border: 1px solid #D8D8D8; } -.gogs-admin-nav li { +.admin-nav li { margin-bottom: 8px; border-left: 4px solid transparent; } -.gogs-admin-nav li:hover { +.admin-nav li:hover { border-left-color: #EEE; } -.gogs-admin-nav li.active:hover { +.admin-nav li.active:hover { border-left: 4px solid #DD4B39; } -#gogs-repo-setting-container .form-horizontal label { +#repo-setting-container .form-horizontal label { line-height: 30px; } /* gogits user ssh keys */ -#gogs-ssh-keys .list-group-item { +#ssh-keys .list-group-item { padding: 15px 0; border-bottom: 1px solid #DDD; } -#gogs-ssh-keys .list-group-item .delete { +#ssh-keys .list-group-item .delete { margin: -5px 50px 0; } -#gogs-ssh-keys .list-group-item:after { +#ssh-keys .list-group-item:after { clear: both; } -#gogs-ssh-keys .name { +#ssh-keys .name { font-size: 14px; font-weight: bold; } -#gogs-ssh-keys .print { +#ssh-keys .print { padding-left: 1em; color: #888; } -#gogs-ssh-add { +#ssh-add { display: inline-block; color: white; cursor: pointer; @@ -392,25 +392,25 @@ html, body { border-radius: 3px; } -#gogs-ssh-form textarea { +#ssh-form textarea { height: 16em; } -/* #gogs-feed */ +/* #feed */ -#gogs-feed-right .repo-panel .panel-heading .btn { +#feed-right .repo-panel .panel-heading .btn { margin-top: -4px; } -#gogs-feed-right .repo-panel .panel-body { +#feed-right .repo-panel .panel-body { padding: 0; } -#gogs-feed-right .repo-panel .list-group { +#feed-right .repo-panel .list-group { margin-bottom: 0; } -#gogs-feed-right .repo-panel .list-group-item a { +#feed-right .repo-panel .list-group-item a { display: block; margin-left: 0; background-color: transparent; @@ -418,11 +418,11 @@ html, body { font-weight: bold; } -#gogs-feed-right .repo-panel .list-group-item .fa { +#feed-right .repo-panel .list-group-item .fa { color: #666; } -#gogs-feed-right .repo-panel .list-group-item { +#feed-right .repo-panel .list-group-item { font-size: 14px; line-height: 32px; border-bottom: 1px solid #DDD; @@ -430,97 +430,101 @@ html, body { clear: both; } -#gogs-feed-right .repo-panel .list-group-item:last-child { +#feed-right .repo-panel .list-group-item:last-child { border-bottom: none; } -#gogs-feed-right .repo-panel .list-group-item:hover { +#feed-right .repo-panel .list-group-item:hover { background-color: #eafffd; background-color: rgba(65, 131, 196, 0.1); } -#gogs-feed-right .repo-panel span.stars { +#feed-right .repo-panel span.stars { color: #666; margin-right: 1em; } /* gogits repo single page */ -#gogs-body-nav.gogs-repo-nav { +#body-nav.repo-nav { padding-top: 16px; padding-bottom: 30px; height: auto; } -.gogs-repo-nav .name { +.repo-nav .name { margin-top: 15px; } -.gogs-repo-nav .desc { +.repo-nav .desc { color: #888; margin-bottom: 0; } -.gogs-repo-nav h3 .fa { +.repo-nav h3 .fa { color: #BBB; margin-left: 0; } -.gogs-repo-nav .actions { +.repo-nav .actions { padding-top: 20px; } -.gogs-repo-nav .btn-default { +.repo-nav .btn-default { font-family: Tahoma, Arial, sans-serif; } -#gogs-repo-watching .dropdown-menu { +#repo-watching .dropdown-menu { width: 280px; padding: 0; } -#gogs-repo-watching .dropdown-menu .dropdown-item:hover .dropdown-header, #gogs-repo-watching .dropdown-item .dropdown-header.text-primary { +#repo-watching .dropdown-menu .dropdown-item:hover .dropdown-header, #repo-watching .dropdown-item .dropdown-header.text-primary { color: rgb(65, 131, 196); cursor: pointer; } -#gogs-repo-watching .dropdown-menu .description { +#repo-watching .dropdown-menu .description { padding: 0 20px; color: #888; } -#gogs-repo-watching .dropdown-menu .dropdown-header { +#repo-watching .dropdown-menu .dropdown-header { color: #444; font-weight: bold; font-size: 14px; margin-bottom: 4px; } -#gogs-repo-toolbar { +#repo-toolbar { border-bottom: 1px solid #DDD; background-color: #FFF; height: 40px; font-size: 14px; } -#gogs-repo-toolbar .navbar-default { +#repo-toolbar .navbar-default { border: none; height: 39px; } -#gogs-repo-toolbar .nav > li > a { +#repo-toolbar .nav > li > a { height: 39px; } -#gogs-repo-toolbar .navbar-toolbar.navbar-default .navbar-nav > .active > a:after { +#repo-toolbar .nav .active { + color: #F6F6F6; +} + +#repo-toolbar .nav > .active > a:after { border-bottom-color: #999; } -#gogs-repo-toolbar .navbar.nav-toolbar { +#repo-toolbar .navbar.nav-toolbar { margin-bottom: 0; } -#gogs-repo-toolbar .navbar-collapse { +#repo-toolbar .navbar-collapse { padding: 0; } @@ -588,29 +592,29 @@ html, body { min-width: 200px; } -#gogs-repo-clone .dropdown-menu { +#repo-clone .dropdown-menu { width: 400px; padding: 20px; } -#gogs-repo-clone .input-group { +#repo-clone .input-group { margin-bottom: 15px; } -/* #gogs-source */ -#gogs-source { +/* #source */ +#source { margin-top: -20px; } -#gogs-source .source-toolbar:after { +#source .source-toolbar:after { clear: both; } -#gogs-source .source-toolbar .branch-switch { +#source .source-toolbar .branch-switch { display: inline-block; } -#gogs-source .source-toolbar .breadcrumb { +#source .source-toolbar .breadcrumb { margin: 0 .5em; padding: 6px 15px; font-size: 16px; @@ -619,9 +623,9 @@ html, body { background-color: transparent; } -#gogs-source .source-toolbar, -#gogs-source .info-box, -#gogs-source .file-content { +#source .source-toolbar, +#source .info-box, +#source .file-content { margin: 0 0 10px; } @@ -941,7 +945,7 @@ html, body { color: #888; } -#gogs-source .file-content.diff-file-box { +#source .file-content.diff-file-box { margin-bottom: 20px; } diff --git a/public/js/app.js b/public/js/app.js index f98fd03f8..0973398a5 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -243,7 +243,7 @@ function initCore() { function initRegister() { $.getScript("/js/jquery.validate.min.js", function () { - Gogits.validateForm("#gogs-login-card", { + Gogits.validateForm("#login-card", { rules: { "username": { required: true, @@ -268,7 +268,7 @@ function initRegister() { } function initUserSetting() { - $('#gogs-ssh-keys .delete').confirmation({ + $('#ssh-keys .delete').confirmation({ singleton: true, onConfirm: function (e, $this) { Gogits.ajaxDelete("", {"id": $this.data("del")}, function (json) { @@ -303,7 +303,7 @@ function initRepository() { // watching script (function () { - var $watch = $('#gogs-repo-watching'), + var $watch = $('#repo-watching'), watchLink = $watch.data("watch"), unwatchLink = $watch.data("unwatch"); $watch.on('click', '.to-watch',function () { @@ -354,14 +354,14 @@ function initRepository() { (function ($) { $(function () { initCore(); - var body = $("#gogs-body"); + var body = $("#body"); if (body.data("page") == "user-signup") { initRegister(); } if (body.data("page") == "user") { initUserSetting(); } - if ($('.gogs-repo-nav').length) { + if ($('.repo-nav').length) { initRepository(); } }); diff --git a/templates/admin/config.tmpl b/templates/admin/config.tmpl index 1e2630460..39895aa31 100644 --- a/templates/admin/config.tmpl +++ b/templates/admin/config.tmpl @@ -1,8 +1,8 @@ {{template "base/head" .}} {{template "base/navbar" .}} -
+
{{template "admin/nav" .}} -
+
Server Configuration diff --git a/templates/admin/dashboard.tmpl b/templates/admin/dashboard.tmpl index 2a5a161e0..e0b31817a 100644 --- a/templates/admin/dashboard.tmpl +++ b/templates/admin/dashboard.tmpl @@ -1,8 +1,8 @@ {{template "base/head" .}} {{template "base/navbar" .}} -
+
{{template "admin/nav" .}} -
+
Statistic diff --git a/templates/admin/nav.tmpl b/templates/admin/nav.tmpl index 72f008acc..8c2e33888 100644 --- a/templates/admin/nav.tmpl +++ b/templates/admin/nav.tmpl @@ -1,4 +1,4 @@ -
+
  • Dashboard
  • Users
  • diff --git a/templates/admin/repos.tmpl b/templates/admin/repos.tmpl index 2c91ccc09..8cc424db6 100644 --- a/templates/admin/repos.tmpl +++ b/templates/admin/repos.tmpl @@ -1,8 +1,8 @@ {{template "base/head" .}} {{template "base/navbar" .}} -
    +
    {{template "admin/nav" .}} -
    +
    Repository Management diff --git a/templates/admin/users.tmpl b/templates/admin/users.tmpl index dec5c1895..63da45174 100644 --- a/templates/admin/users.tmpl +++ b/templates/admin/users.tmpl @@ -1,8 +1,8 @@ {{template "base/head" .}} {{template "base/navbar" .}} -
    +
    {{template "admin/nav" .}} -
    +
    User Management diff --git a/templates/admin/users/edit.tmpl b/templates/admin/users/edit.tmpl index 08f11fcb1..5db2c7a95 100644 --- a/templates/admin/users/edit.tmpl +++ b/templates/admin/users/edit.tmpl @@ -1,8 +1,8 @@ {{template "base/head" .}} {{template "base/navbar" .}} -
    +
    {{template "admin/nav" .}} -
    +
    Edit Account diff --git a/templates/admin/users/new.tmpl b/templates/admin/users/new.tmpl index 7b41ae43a..7f441f32b 100644 --- a/templates/admin/users/new.tmpl +++ b/templates/admin/users/new.tmpl @@ -1,8 +1,8 @@ {{template "base/head" .}} {{template "base/navbar" .}} -
    +
    {{template "admin/nav" .}} -
    +
    New Account diff --git a/templates/base/navbar.tmpl b/templates/base/navbar.tmpl index 90e90f296..829ecba62 100644 --- a/templates/base/navbar.tmpl +++ b/templates/base/navbar.tmpl @@ -1,25 +1,25 @@ - -
    +
    {{if .IsRepositoryWatching}} {{else}} diff --git a/templates/repo/pulls.tmpl b/templates/repo/pulls.tmpl index daacc089c..8c5d9376c 100644 --- a/templates/repo/pulls.tmpl +++ b/templates/repo/pulls.tmpl @@ -2,8 +2,8 @@ {{template "base/navbar" .}} {{template "repo/nav" .}} {{template "repo/toolbar" .}} -
    -
    +
    +
    {{template "base/footer" .}} \ No newline at end of file diff --git a/templates/repo/setting.tmpl b/templates/repo/setting.tmpl index c826e55a7..d527dac3b 100644 --- a/templates/repo/setting.tmpl +++ b/templates/repo/setting.tmpl @@ -2,8 +2,8 @@ {{template "base/navbar" .}} {{template "repo/nav" .}} {{template "repo/toolbar" .}} -
    -
    +
    + From be69e74bc05b62deb6a5f9ae360af220cd5d5226 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 25 Mar 2014 07:06:56 -0400 Subject: [PATCH 05/26] Mirror fix --- modules/base/conf.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/base/conf.go b/modules/base/conf.go index d0f8ae2cc..3eb01bdd5 100644 --- a/modules/base/conf.go +++ b/modules/base/conf.go @@ -274,6 +274,9 @@ func NewConfigContext() { RunUser = Cfg.MustValue("", "RUN_USER") curUser := os.Getenv("USERNAME") + if len(curUser) == 0 { + curUser = os.Getenv("whoami") + } if RunUser != curUser { fmt.Printf("Expect user(%s) but current user is: %s\n", RunUser, curUser) os.Exit(2) From 7aa0a97d10a6810ab0b6fb482c7f8f179431104f Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 25 Mar 2014 07:10:23 -0400 Subject: [PATCH 06/26] Mirror fix --- modules/base/conf.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/base/conf.go b/modules/base/conf.go index 3eb01bdd5..1661681e7 100644 --- a/modules/base/conf.go +++ b/modules/base/conf.go @@ -275,7 +275,7 @@ func NewConfigContext() { RunUser = Cfg.MustValue("", "RUN_USER") curUser := os.Getenv("USERNAME") if len(curUser) == 0 { - curUser = os.Getenv("whoami") + curUser = os.Getenv("USER") } if RunUser != curUser { fmt.Printf("Expect user(%s) but current user is: %s\n", RunUser, curUser) From c3953a62fd874f035adf3c16a59dfd97f655c078 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 25 Mar 2014 07:30:18 -0400 Subject: [PATCH 07/26] Add more log to locate issue --- serve.go | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/serve.go b/serve.go index acdcb877f..962f87774 100644 --- a/serve.go +++ b/serve.go @@ -49,7 +49,7 @@ func init() { level := "0" os.MkdirAll("log", os.ModePerm) log.NewLogger(10000, "file", fmt.Sprintf(`{"level":%s,"filename":"%s"}`, level, "log/serv.log")) - log.Info("start logging...") + log.Trace("start logging...") } func parseCmd(cmd string) (string, string) { @@ -80,17 +80,20 @@ func runServ(k *cli.Context) { keys := strings.Split(os.Args[2], "-") if len(keys) != 2 { fmt.Println("auth file format error") + log.Error("auth file format error") return } keyId, err := strconv.ParseInt(keys[1], 10, 64) if err != nil { fmt.Println("auth file format error") + log.Error("auth file format error") return } user, err := models.GetUserByKeyId(keyId) if err != nil { fmt.Println("You have no right to access") + log.Error("You have no right to access") return } @@ -105,6 +108,7 @@ func runServ(k *cli.Context) { rr := strings.SplitN(rRepo, "/", 2) if len(rr) != 2 { println("Unavilable repository", args) + log.Error("Unavilable repository %v", args) return } repoName := rr[1] @@ -122,11 +126,12 @@ func runServ(k *cli.Context) { isExist = false if isRead { println("Repository", user.Name+"/"+repoName, "is not exist") + log.Error("Repository " + user.Name + "/" + repoName + " is not exist") return } } else { println("Get repository error:", err) - log.Error(err.Error()) + log.Error("Get repository error: " + err.Error()) return } } @@ -142,6 +147,7 @@ func runServ(k *cli.Context) { } if !has { println("You have no right to write this repository") + log.Error("You have no right to access this repository") return } case isRead: @@ -161,10 +167,12 @@ func runServ(k *cli.Context) { } if !has { println("You have no right to access this repository") + log.Error("You have no right to access this repository") return } default: println("Unknown command") + log.Error("Unknown command") return } @@ -175,23 +183,23 @@ func runServ(k *cli.Context) { _, err = models.CreateRepository(user, repoName, "", "", "", false, true) if err != nil { println("Create repository failed") - log.Error(err.Error()) + log.Error("Create repository failed: " + err.Error()) return } } } - rep, err = git.OpenRepository(repoPath) - if err != nil { - println("OpenRepository failed:", err.Error()) - log.Error(err.Error()) - return - } + rep, err = git.OpenRepository(repoPath) + if err != nil { + println("OpenRepository failed:", err.Error()) + log.Error("OpenRepository failed: " + err.Error()) + return + } refs, err := rep.AllReferencesMap() if err != nil { println("Get All References failed:", err.Error()) - log.Error(err.Error()) + log.Error("Get All References failed: " + err.Error()) return } @@ -208,7 +216,7 @@ func runServ(k *cli.Context) { if err = gitcmd.Run(); err != nil { println("execute command error:", err.Error()) - log.Error(err.Error()) + log.Error("execute command error: " + err.Error()) return } @@ -236,6 +244,7 @@ func runServ(k *cli.Context) { } if refname == "" { println("No find any reference name:", b.String()) + log.Error("No find any reference name: " + b.String()) return } @@ -248,17 +257,18 @@ func runServ(k *cli.Context) { refs, err = rep.AllReferencesMap() if err != nil { println("Get All References failed:", err.Error()) - log.Error(err.Error()) + log.Error("Get All References failed: " + err.Error()) return } if ref, ok = refs[refname]; !ok { + log.Error("unknow reference name -", refname, "-", b.String()) log.Error("unknow reference name -", refname, "-", b.String()) return } l, err = ref.AllCommits() if err != nil { println("Get All Commits failed:", err.Error()) - log.Error(err.Error()) + log.Error("Get All Commits failed: " + err.Error()) return } } else { @@ -268,14 +278,14 @@ func runServ(k *cli.Context) { last, err = ref.LastCommit() if err != nil { println("Get last commit failed:", err.Error()) - log.Error(err.Error()) + log.Error("Get last commit failed: " + err.Error()) return } ref2, err := rep.LookupReference(ref.Name) if err != nil { println("look up reference failed:", err.Error()) - log.Error(err.Error()) + log.Error("look up reference failed: " + err.Error()) return } @@ -283,7 +293,7 @@ func runServ(k *cli.Context) { before, err := ref2.LastCommit() if err != nil { println("Get last commit failed:", err.Error()) - log.Error(err.Error()) + log.Error("Get last commit failed: " + err.Error()) return } //log.Info("----", before.Id(), "-----", last.Id()) From 5d67960b1e812c2b455c93ec9c86d72c9c9a7f5b Mon Sep 17 00:00:00 2001 From: FuXiaoHei Date: Tue, 25 Mar 2014 19:38:07 +0800 Subject: [PATCH 08/26] fix style --- public/css/gogs.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/css/gogs.css b/public/css/gogs.css index c8c5d87b8..74dce472e 100755 --- a/public/css/gogs.css +++ b/public/css/gogs.css @@ -97,11 +97,11 @@ html, body { } /* gogits nav item active status */ -.nav .active { +#masthead .nav .active { color: #fff; } -.nav .active:after { +#masthead .nav .active:after { position: absolute; bottom: -1px; left: 50%; From ca49acfe67cee4b5d4be40519b83d9107833e60d Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 25 Mar 2014 07:38:48 -0400 Subject: [PATCH 09/26] Add more log to locate issue --- serve.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/serve.go b/serve.go index 962f87774..a4d5a727d 100644 --- a/serve.go +++ b/serve.go @@ -73,6 +73,8 @@ func In(b string, sl map[string]int) bool { } func runServ(k *cli.Context) { + log.Trace("new serv request") + base.NewConfigContext() models.LoadModelsConfig() models.NewEngine() From 4f6889bef2bea9992330860e8605d5d0d06df23f Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 25 Mar 2014 07:47:04 -0400 Subject: [PATCH 10/26] Add more log to locate issue --- modules/log/log.go | 6 +++++- serve.go | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/log/log.go b/modules/log/log.go index 0c07c7c62..e1bab8ae4 100644 --- a/modules/log/log.go +++ b/modules/log/log.go @@ -9,7 +9,10 @@ import ( "github.com/gogits/logs" ) -var logger *logs.BeeLogger +var ( + logger *logs.BeeLogger + Mode, Config string +) func init() { logger = logs.NewLogger(10000) @@ -17,6 +20,7 @@ func init() { } func NewLogger(bufLen int64, mode, config string) { + Mode, Config = mode, config logger = logs.NewLogger(bufLen) logger.SetLogger(mode, config) } diff --git a/serve.go b/serve.go index a4d5a727d..35adcaca3 100644 --- a/serve.go +++ b/serve.go @@ -73,6 +73,7 @@ func In(b string, sl map[string]int) bool { } func runServ(k *cli.Context) { + fmt.Println("new serv request", log.Mode, log.Config) log.Trace("new serv request") base.NewConfigContext() From 09e7e76204c694278972f3225040726d2ec687cd Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 25 Mar 2014 07:56:06 -0400 Subject: [PATCH 11/26] Add more log to locate issue --- serve.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/serve.go b/serve.go index 35adcaca3..89ef0d848 100644 --- a/serve.go +++ b/serve.go @@ -73,8 +73,7 @@ func In(b string, sl map[string]int) bool { } func runServ(k *cli.Context) { - fmt.Println("new serv request", log.Mode, log.Config) - log.Trace("new serv request") + log.Trace("new serv request " + log.Mode + ":" + log.Config) base.NewConfigContext() models.LoadModelsConfig() From 197c4d4a5ba8a9540c49879324194f5f6be4689c Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 25 Mar 2014 08:53:11 -0400 Subject: [PATCH 12/26] Fix wrong serve command log location and commit repo action --- models/action.go | 6 ++++-- modules/base/conf.go | 4 ++-- modules/middleware/repo.go | 2 +- serve.go | 6 ++++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/models/action.go b/models/action.go index 44d7aea8c..dffc0e537 100644 --- a/models/action.go +++ b/models/action.go @@ -59,7 +59,7 @@ func (a Action) GetContent() string { // CommitRepoAction records action for commit repository. func CommitRepoAction(userId int64, userName string, repoId int64, repoName string, refName string, commits *base.PushCommits) error { - log.Trace("action.CommitRepoAction: %d/%s", userId, repoName) + log.Trace("action.CommitRepoAction(start): %d/%s", userId, repoName) bs, err := json.Marshal(commits) if err != nil { @@ -92,8 +92,8 @@ func CommitRepoAction(userId int64, userName string, }) if err != nil { log.Error("action.CommitRepoAction(notify watches): %d/%s", userId, repoName) + return err } - return err } // Update repository last update time. @@ -107,6 +107,8 @@ func CommitRepoAction(userId int64, userName string, log.Error("action.CommitRepoAction(UpdateRepository): %d/%s", userId, repoName) return err } + + log.Trace("action.CommitRepoAction(end): %d/%s", userId, repoName) return nil } diff --git a/modules/base/conf.go b/modules/base/conf.go index 1661681e7..0fb1ccdcf 100644 --- a/modules/base/conf.go +++ b/modules/base/conf.go @@ -71,7 +71,7 @@ var Service struct { ResetPwdCodeLives int } -func exeDir() (string, error) { +func ExecDir() (string, error) { file, err := exec.LookPath(os.Args[0]) if err != nil { return "", err @@ -244,7 +244,7 @@ func newNotifyMailService() { func NewConfigContext() { //var err error - workDir, err := exeDir() + workDir, err := ExecDir() if err != nil { fmt.Printf("Fail to get work directory: %s\n", err) os.Exit(2) diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index eea2570ca..b23bccb10 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -73,7 +73,7 @@ func RepoAssignment(redirect bool) martini.Handler { if base.EnableHttpsClone { scheme = "https" } - ctx.Repo.CloneLink.SSH = fmt.Sprintf("git@%s:%s/%s.git", base.Domain, user.LowerName, repo.LowerName) + ctx.Repo.CloneLink.SSH = fmt.Sprintf("%s@%s:%s/%s.git", base.RunUser, base.Domain, user.LowerName, repo.LowerName) ctx.Repo.CloneLink.HTTPS = fmt.Sprintf("%s://%s/%s/%s.git", scheme, base.Domain, user.LowerName, repo.LowerName) ctx.Data["IsRepositoryValid"] = true diff --git a/serve.go b/serve.go index 89ef0d848..7e21fcae3 100644 --- a/serve.go +++ b/serve.go @@ -45,10 +45,10 @@ gogs serv provide access auth for repositories`, Flags: []cli.Flag{}, } -func init() { +func newLogger(execDir string) { level := "0" os.MkdirAll("log", os.ModePerm) - log.NewLogger(10000, "file", fmt.Sprintf(`{"level":%s,"filename":"%s"}`, level, "log/serv.log")) + log.NewLogger(10000, "file", fmt.Sprintf(`{"level":%s,"filename":"%s"}`, level, execDir+"/log/serv.log")) log.Trace("start logging...") } @@ -73,6 +73,8 @@ func In(b string, sl map[string]int) bool { } func runServ(k *cli.Context) { + execDir, _ := base.ExecDir() + newLogger(execDir) log.Trace("new serv request " + log.Mode + ":" + log.Config) base.NewConfigContext() From 9aba29dd8f067338025593b7c409b494d4b0ce32 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 25 Mar 2014 08:56:01 -0400 Subject: [PATCH 13/26] Fix wrong serve command log location and commit repo action --- serve.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/serve.go b/serve.go index 7e21fcae3..bfd2663fc 100644 --- a/serve.go +++ b/serve.go @@ -11,6 +11,7 @@ import ( "io" "os" "os/exec" + "path" "strconv" "strings" "time" @@ -47,8 +48,9 @@ gogs serv provide access auth for repositories`, func newLogger(execDir string) { level := "0" - os.MkdirAll("log", os.ModePerm) - log.NewLogger(10000, "file", fmt.Sprintf(`{"level":%s,"filename":"%s"}`, level, execDir+"/log/serv.log")) + logPath := execDir + "/log/serv.log" + os.MkdirAll(path.Dir(logPath), os.ModePerm) + log.NewLogger(10000, "file", fmt.Sprintf(`{"level":%s,"filename":"%s"}`, level, logPath)) log.Trace("start logging...") } From e5d8fe41c4fd8331352c77d8a17d5c035f0787a2 Mon Sep 17 00:00:00 2001 From: FuXiaoHei Date: Tue, 25 Mar 2014 21:14:05 +0800 Subject: [PATCH 14/26] issue create page ui --- public/css/gogs.css | 30 ++++++++++++++++++++++++++++-- public/js/app.js | 1 + templates/issue/create.tmpl | 36 ++++++++++++++++++++++++++++++++++-- templates/repo/toolbar.tmpl | 5 +++++ 4 files changed, 68 insertions(+), 4 deletions(-) diff --git a/public/css/gogs.css b/public/css/gogs.css index 74dce472e..eeead844a 100755 --- a/public/css/gogs.css +++ b/public/css/gogs.css @@ -512,6 +512,14 @@ html, body { height: 39px; } +#repo-toolbar .nav .tmp a:hover { + text-decoration: none; +} + +#repo-toolbar .nav .tmp .btn { + margin-top: -2px; +} + #repo-toolbar .nav .active { color: #F6F6F6; } @@ -602,7 +610,7 @@ html, body { } /* #source */ -#source { +#source, #commits { margin-top: -20px; } @@ -857,7 +865,7 @@ html, body { } .guide-box, .diff-head-box { - margin-top: 20px; + margin-top: 4px; } .diff-head-box h4 { @@ -991,6 +999,24 @@ html, body { color: #AAA; } +/* issue */ + +#issue-create-form .panel-body { + padding: 15px 0 0 0; +} + +#issue-create-form .panel-body.form-group, #issue-create-form .tab-pane .form-group { + margin-bottom: 0; +} + +#issue-create-form .nav-tabs { + margin-bottom: 10px; +} + +#issue-create-form .md-help{ + margin-top: 6px; +} + /* wrapper and footer */ #wrapper { diff --git a/public/js/app.js b/public/js/app.js index 0973398a5..8b0e5cd62 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -111,6 +111,7 @@ var Gogits = { }; Gogits.initTabs = function () { var $tabs = $('[data-init=tabs]'); + $tabs.tab("show"); $tabs.find("li:eq(0) a").tab("show"); }; // fix dropdown inside click diff --git a/templates/issue/create.tmpl b/templates/issue/create.tmpl index 2fb29d1b8..34c7f40aa 100644 --- a/templates/issue/create.tmpl +++ b/templates/issue/create.tmpl @@ -3,8 +3,40 @@ {{template "repo/nav" .}} {{template "repo/toolbar" .}}
    -
    - new-issues +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + Content with Markdown +
    + +
    +
    +
    + +
    +
    +
    preview
    +
    +
    +
    +
    + + +
    +
    +
    +
    {{template "base/footer" .}} \ No newline at end of file diff --git a/templates/repo/toolbar.tmpl b/templates/repo/toolbar.tmpl index 1f8a70984..17d4e5b1a 100644 --- a/templates/repo/toolbar.tmpl +++ b/templates/repo/toolbar.tmpl @@ -9,6 +9,11 @@
  • Issues
  • + {{if .IsRepoToolbarIssues}} +
  • + +
  • + {{end}} +
+

Your Issues

+
+
+ +{{template "base/footer" .}} \ No newline at end of file diff --git a/templates/repo/issues.tmpl b/templates/repo/issues.tmpl deleted file mode 100644 index df53197c3..000000000 --- a/templates/repo/issues.tmpl +++ /dev/null @@ -1,10 +0,0 @@ -{{template "base/head" .}} -{{template "base/navbar" .}} -{{template "repo/nav" .}} -{{template "repo/toolbar" .}} -
-
- issues -
-
-{{template "base/footer" .}} \ No newline at end of file diff --git a/templates/user/issues.tmpl b/templates/user/issues.tmpl deleted file mode 100644 index dd17b667d..000000000 --- a/templates/user/issues.tmpl +++ /dev/null @@ -1,17 +0,0 @@ -{{template "base/head" .}} -{{template "base/navbar" .}} -
-
- -

Issues

-
-
-
- {{if .HasInfo}}
{{.InfoMsg}}
{{end}} -
-{{template "base/footer" .}} \ No newline at end of file From 8ce9458d654c38d7e815d78a14b9f3daf599e284 Mon Sep 17 00:00:00 2001 From: FuXiaoHei Date: Tue, 25 Mar 2014 23:58:23 +0800 Subject: [PATCH 17/26] issue style change --- public/css/gogs.css | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/public/css/gogs.css b/public/css/gogs.css index 06f593191..69d8f7f49 100755 --- a/public/css/gogs.css +++ b/public/css/gogs.css @@ -1026,11 +1026,11 @@ html, body { color: #444; } -#issue .filter-list a.sm{ +#issue .filter-list a.sm { font-size: 13px; } -#issue .filter-list hr{ +#issue .filter-list hr { border-color: #CCC; } @@ -1052,7 +1052,7 @@ html, body { background-color: #FFF; } -#issue .issue-item:hover{ +#issue .issue-item:hover { background-color: rgba(19, 95, 215, 0.03); } @@ -1062,16 +1062,13 @@ html, body { #issue .issue-item .title { margin-bottom: 16px; + font-weight: bold; } #issue .issue-item h5.title a { color: #444; } -#issue .issue-item.unread h5 { - font-weight: bold; -} - #issue .issue-item .info span { margin-right: 12px; color: #888; From 84bec2842f6b926e5d287d6201560364771cd64c Mon Sep 17 00:00:00 2001 From: FuXiaoHei Date: Tue, 25 Mar 2014 23:59:50 +0800 Subject: [PATCH 18/26] issue style change --- public/css/gogs.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/public/css/gogs.css b/public/css/gogs.css index 69d8f7f49..6bf698e8b 100755 --- a/public/css/gogs.css +++ b/public/css/gogs.css @@ -1001,6 +1001,11 @@ html, body { /* issue */ +#issue-create-form .avatar { + width: 50px; + height: 50px; +} + #issue-create-form .panel-body { padding: 15px 0 0 0; } From 2fa8d0c8dd43f95e1659a266e84c7713cc8f2fcf Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 25 Mar 2014 12:12:27 -0400 Subject: [PATCH 19/26] Added create issue --- gogs.go | 2 +- modules/auth/issue.go | 9 +++------ modules/avatar/avatar.go | 3 ++- modules/base/tool.go | 5 ++++- modules/middleware/repo.go | 5 +++++ routers/repo/branch.go | 5 ----- routers/repo/issue.go | 11 +++-------- routers/repo/pull.go | 5 ----- routers/repo/repo.go | 14 -------------- serve.go | 5 ++--- templates/issue/create.tmpl | 9 +++++---- templates/issue/{repo.tmpl => list.tmpl} | 5 +++++ templates/repo/nav.tmpl | 2 +- web.go | 6 +++--- 14 files changed, 34 insertions(+), 52 deletions(-) rename templates/issue/{repo.tmpl => list.tmpl} (93%) diff --git a/gogs.go b/gogs.go index 7ac699cc6..b62580f8f 100644 --- a/gogs.go +++ b/gogs.go @@ -19,7 +19,7 @@ import ( // Test that go1.2 tag above is included in builds. main.go refers to this definition. const go12tag = true -const APP_VER = "0.1.7.0324" +const APP_VER = "0.1.7.0325" func init() { base.AppVer = APP_VER diff --git a/modules/auth/issue.go b/modules/auth/issue.go index e2b1f9f2a..8bf49684c 100644 --- a/modules/auth/issue.go +++ b/modules/auth/issue.go @@ -17,9 +17,8 @@ import ( ) type CreateIssueForm struct { - IssueName string `form:"name" binding:"Required;MaxSize(50)"` - RepoId int64 `form:"repoid" binding:"Required"` - MilestoneId int64 `form:"milestoneid" binding:"Required"` + IssueName string `form:"title" binding:"Required;MaxSize(50)"` + MilestoneId int64 `form:"milestoneid"` AssigneeId int64 `form:"assigneeid"` Labels string `form:"labels"` Content string `form:"content"` @@ -27,9 +26,7 @@ type CreateIssueForm struct { func (f *CreateIssueForm) Name(field string) string { names := map[string]string{ - "IssueName": "Issue name", - "RepoId": "Repository ID", - "MilestoneId": "Milestone ID", + "IssueName": "Issue name", } return names[field] } diff --git a/modules/avatar/avatar.go b/modules/avatar/avatar.go index 3b423a6d1..449c9656d 100644 --- a/modules/avatar/avatar.go +++ b/modules/avatar/avatar.go @@ -30,8 +30,9 @@ import ( "sync" "time" - "github.com/gogits/gogs/modules/log" "github.com/nfnt/resize" + + "github.com/gogits/gogs/modules/log" ) var ( diff --git a/modules/base/tool.go b/modules/base/tool.go index 0dec7aa8d..c23f5de6c 100644 --- a/modules/base/tool.go +++ b/modules/base/tool.go @@ -102,7 +102,10 @@ func CreateTimeLimitCode(data string, minutes int, startInf interface{}) string // AvatarLink returns avatar link by given e-mail. func AvatarLink(email string) string { - return "/avatar/" + EncodeMd5(email) + if Service.EnableCacheAvatar { + return "/avatar/" + EncodeMd5(email) + } + return "http://1.gravatar.com/avatar/" + EncodeMd5(email) } // Seconds-based time units diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index b23bccb10..bc90c05cc 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -76,6 +76,11 @@ func RepoAssignment(redirect bool) martini.Handler { ctx.Repo.CloneLink.SSH = fmt.Sprintf("%s@%s:%s/%s.git", base.RunUser, base.Domain, user.LowerName, repo.LowerName) ctx.Repo.CloneLink.HTTPS = fmt.Sprintf("%s://%s/%s/%s.git", scheme, base.Domain, user.LowerName, repo.LowerName) + if len(params["branchname"]) == 0 { + params["branchname"] = "master" + } + ctx.Data["Branchname"] = params["branchname"] + ctx.Data["IsRepositoryValid"] = true ctx.Data["Repository"] = repo ctx.Data["Owner"] = user diff --git a/routers/repo/branch.go b/routers/repo/branch.go index 8c953f2ed..aed77cfaa 100644 --- a/routers/repo/branch.go +++ b/routers/repo/branch.go @@ -26,11 +26,6 @@ func Branches(ctx *middleware.Context, params martini.Params) { ctx.Data["Username"] = params["username"] ctx.Data["Reponame"] = params["reponame"] - - if len(params["branchname"]) == 0 { - params["branchname"] = "master" - } - ctx.Data["Branchname"] = params["branchname"] ctx.Data["Branches"] = brs ctx.Data["IsRepoToolbarBranches"] = true diff --git a/routers/repo/issue.go b/routers/repo/issue.go index ab070d724..4e8324605 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -30,12 +30,7 @@ func Issues(ctx *middleware.Context, params martini.Params) { ctx.Handle(200, "issue.Issues: %v", err) return } - - if len(params["branchname"]) == 0 { - params["branchname"] = "master" - } - ctx.Data["Branchname"] = params["branchname"] - ctx.HTML(200, "issue/repo") + ctx.HTML(200, "issue/list") } func CreateIssue(ctx *middleware.Context, params martini.Params, form auth.CreateIssueForm) { @@ -57,10 +52,10 @@ func CreateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat return } - issue, err := models.CreateIssue(ctx.User.Id, form.RepoId, form.MilestoneId, form.AssigneeId, + issue, err := models.CreateIssue(ctx.User.Id, ctx.Repo.Repository.Id, form.MilestoneId, form.AssigneeId, form.IssueName, form.Labels, form.Content, false) if err == nil { - log.Trace("%s Issue created: %d", form.RepoId, issue.Id) + log.Trace("%d Issue created: %d", ctx.Repo.Repository.Id, issue.Id) ctx.Redirect(fmt.Sprintf("/%s/%s/issues/%d", params["username"], params["reponame"], issue.Index)) return } diff --git a/routers/repo/pull.go b/routers/repo/pull.go index 16c60389d..93b6a9f7c 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -12,10 +12,5 @@ import ( func Pulls(ctx *middleware.Context, params martini.Params) { ctx.Data["IsRepoToolbarPulls"] = true - if len(params["branchname"]) == 0 { - params["branchname"] = "master" - } - - ctx.Data["Branchname"] = params["branchname"] ctx.HTML(200, "repo/pulls") } diff --git a/routers/repo/repo.go b/routers/repo/repo.go index cd28d52ca..acf025a28 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -57,10 +57,6 @@ func Single(ctx *middleware.Context, params martini.Params) { return } - if len(params["branchname"]) == 0 { - params["branchname"] = "master" - } - // Get tree path treename := params["_1"] @@ -177,7 +173,6 @@ func Single(ctx *middleware.Context, params martini.Params) { ctx.Data["Username"] = params["username"] ctx.Data["Reponame"] = params["reponame"] - ctx.Data["Branchname"] = params["branchname"] var treenames []string Paths := make([]string, 0) @@ -216,10 +211,6 @@ func SingleDownload(ctx *middleware.Context, params martini.Params) { return } - if len(params["branchname"]) == 0 { - params["branchname"] = "master" - } - // Get tree path treename := params["_1"] @@ -290,11 +281,6 @@ func Setting(ctx *middleware.Context, params martini.Params) { title = t } - if len(params["branchname"]) == 0 { - params["branchname"] = "master" - } - - ctx.Data["Branchname"] = params["branchname"] ctx.Data["Title"] = title + " - settings" ctx.HTML(200, "repo/setting") } diff --git a/serve.go b/serve.go index bfd2663fc..25a34efba 100644 --- a/serve.go +++ b/serve.go @@ -249,8 +249,8 @@ func runServ(k *cli.Context) { } } if refname == "" { - println("No find any reference name:", b.String()) - log.Error("No find any reference name: " + b.String()) + println("Not found any reference name:", b.String()) + log.Error("Not found any reference name: " + b.String()) return } @@ -267,7 +267,6 @@ func runServ(k *cli.Context) { return } if ref, ok = refs[refname]; !ok { - log.Error("unknow reference name -", refname, "-", b.String()) log.Error("unknow reference name -", refname, "-", b.String()) return } diff --git a/templates/issue/create.tmpl b/templates/issue/create.tmpl index 34c7f40aa..cbc21f6ce 100644 --- a/templates/issue/create.tmpl +++ b/templates/issue/create.tmpl @@ -4,13 +4,14 @@ {{template "repo/toolbar" .}}
-
+ + {{.CsrfTokenHtml}}
- +
- +
@@ -23,7 +24,7 @@
- +
preview
diff --git a/templates/issue/repo.tmpl b/templates/issue/list.tmpl similarity index 93% rename from templates/issue/repo.tmpl rename to templates/issue/list.tmpl index c348f27ff..685eaeeb9 100644 --- a/templates/issue/repo.tmpl +++ b/templates/issue/list.tmpl @@ -18,6 +18,11 @@ Close 128
+
+ {{range .Issues}} +
+ {{end}} +
#123 diff --git a/templates/repo/nav.tmpl b/templates/repo/nav.tmpl index e1b22b1c9..02096c34c 100644 --- a/templates/repo/nav.tmpl +++ b/templates/repo/nav.tmpl @@ -2,7 +2,7 @@
-

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

+

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

{{.Repository.Description}}{{if .Repository.Website}} {{.Repository.Website}}{{end}}

diff --git a/web.go b/web.go index 6538c61f1..9b7b21639 100644 --- a/web.go +++ b/web.go @@ -90,7 +90,7 @@ func runWeb(*cli.Context) { // Routers. m.Get("/", ignSignIn, routers.Home) - m.Get("/install",routers.Install) + m.Get("/install", routers.Install) m.Get("/issues", reqSignIn, user.Issues) m.Get("/pulls", reqSignIn, user.Pulls) m.Get("/stars", reqSignIn, user.Stars) @@ -142,13 +142,13 @@ func runWeb(*cli.Context) { r.Post("/settings", repo.SettingPost) r.Get("/settings", repo.Setting) r.Get("/action/:action", repo.Action) + r.Any("/issues/new", binding.BindIgnErr(auth.CreateIssueForm{}), repo.CreateIssue) + r.Post("/issues/:index", binding.BindIgnErr(auth.CreateIssueForm{}), repo.UpdateIssue) }, reqSignIn, middleware.RepoAssignment(true)) m.Group("/:username/:reponame", func(r martini.Router) { r.Get("/commits/:branchname", repo.Commits) r.Get("/issues", repo.Issues) - r.Any("/issues/new", binding.BindIgnErr(auth.CreateIssueForm{}), repo.CreateIssue) r.Get("/issues/:index", repo.ViewIssue) - r.Post("/issues/:index", binding.BindIgnErr(auth.CreateIssueForm{}), repo.UpdateIssue) r.Get("/pulls", repo.Pulls) r.Get("/branches", repo.Branches) r.Get("/src/:branchname", repo.Single) From d3b8e9daa1a22501c03564f2739f9fa8198fbdf1 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 25 Mar 2014 14:04:57 -0400 Subject: [PATCH 20/26] Add notify watcher action --- README.md | 2 +- README_ZH.md | 2 +- models/action.go | 29 ++-------------- models/issue.go | 1 + models/repo.go | 71 ++++++++++++++++++++++++++++----------- modules/base/tool.go | 21 ++++++++---- routers/repo/issue.go | 40 ++++++++++++++++++---- templates/issue/list.tmpl | 48 +++++++------------------- 8 files changed, 119 insertions(+), 95 deletions(-) diff --git a/README.md b/README.md index a39a92a32..d99031c68 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ More importantly, Gogs only needs one binary to setup your own project hosting o - Create/delete/watch public repository. - User profile page. - Repository viewer. -- Gravatar support. +- Gravatar and cache support. - Mail service(register). - Administration panel. - Supports MySQL, PostgreSQL and SQLite3(binary release only). diff --git a/README_ZH.md b/README_ZH.md index 440f952f8..0a4d3bdc1 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -28,7 +28,7 @@ Gogs 完全使用 Go 语言来实现对 Git 数据的操作,实现 **零** 依 - 创建/删除/关注公开仓库 - 用户个人信息页面 - 仓库浏览器 -- Gravatar 支持 +- Gravatar 以及缓存支持 - 邮件服务(注册) - 管理员面板 - 支持 MySQL、PostgreSQL 以及 SQLite3(仅限二进制版本) diff --git a/models/action.go b/models/action.go index dffc0e537..edf1bf58f 100644 --- a/models/action.go +++ b/models/action.go @@ -19,6 +19,7 @@ const ( OP_STAR_REPO OP_FOLLOW_REPO OP_COMMIT_REPO + OP_CREATE_ISSUE OP_PULL_REQUEST ) @@ -67,34 +68,10 @@ func CommitRepoAction(userId int64, userName string, return err } - // Add feeds for user self and all watchers. - watches, err := GetWatches(repoId) - if err != nil { - log.Error("action.CommitRepoAction(get watches): %d/%s", userId, repoName) + if err = NotifyWatchers(userId, repoId, OP_COMMIT_REPO, userName, repoName, refName, string(bs)); err != nil { + log.Error("action.CommitRepoAction(notify watchers): %d/%s", userId, repoName) return err } - watches = append(watches, Watch{UserId: userId}) - - for i := range watches { - if userId == watches[i].UserId && i > 0 { - continue // Do not add twice in case author watches his/her repository. - } - - _, err = orm.InsertOne(&Action{ - UserId: watches[i].UserId, - ActUserId: userId, - ActUserName: userName, - OpType: OP_COMMIT_REPO, - Content: string(bs), - RepoId: repoId, - RepoName: repoName, - RefName: refName, - }) - if err != nil { - log.Error("action.CommitRepoAction(notify watches): %d/%s", userId, repoName) - return err - } - } // Update repository last update time. repo, err := GetRepositoryByName(userId, repoName) diff --git a/models/issue.go b/models/issue.go index fe43a94b5..2bdd083d9 100644 --- a/models/issue.go +++ b/models/issue.go @@ -23,6 +23,7 @@ type Issue struct { Name string RepoId int64 `xorm:"index"` PosterId int64 + Poster *User `xorm:"-"` MilestoneId int64 AssigneeId int64 IsPull bool // Indicates whether is a pull request or not. diff --git a/models/repo.go b/models/repo.go index d5f9be72a..824d5ba0c 100644 --- a/models/repo.go +++ b/models/repo.go @@ -262,27 +262,27 @@ func initRepository(f string, user *User, repo *Repository, initReadme bool, rep } /* - // hook/post-update - pu, err := os.OpenFile(filepath.Join(repoPath, "hooks", "post-update"), os.O_CREATE|os.O_WRONLY, 0777) - if err != nil { - return err - } - defer pu.Close() - // TODO: Windows .bat - if _, err = pu.WriteString(fmt.Sprintf("#!/usr/bin/env bash\n%s update\n", appPath)); err != nil { - return err - } + // hook/post-update + pu, err := os.OpenFile(filepath.Join(repoPath, "hooks", "post-update"), os.O_CREATE|os.O_WRONLY, 0777) + if err != nil { + return err + } + defer pu.Close() + // TODO: Windows .bat + if _, err = pu.WriteString(fmt.Sprintf("#!/usr/bin/env bash\n%s update\n", appPath)); err != nil { + return err + } - // hook/post-update - pu2, err := os.OpenFile(filepath.Join(repoPath, "hooks", "post-receive"), os.O_CREATE|os.O_WRONLY, 0777) - if err != nil { - return err - } - defer pu2.Close() - // TODO: Windows .bat - if _, err = pu2.WriteString("#!/usr/bin/env bash\ngit update-server-info\n"); err != nil { - return err - } + // hook/post-update + pu2, err := os.OpenFile(filepath.Join(repoPath, "hooks", "post-receive"), os.O_CREATE|os.O_WRONLY, 0777) + if err != nil { + return err + } + defer pu2.Close() + // TODO: Windows .bat + if _, err = pu2.WriteString("#!/usr/bin/env bash\ngit update-server-info\n"); err != nil { + return err + } */ // Initialize repository according to user's choice. @@ -506,6 +506,37 @@ func GetWatches(repoId int64) ([]Watch, error) { return watches, err } +// NotifyWatchers creates batch of actions for every watcher. +func NotifyWatchers(userId, repoId int64, opType int, userName, repoName, refName, content string) error { + // Add feeds for user self and all watchers. + watches, err := GetWatches(repoId) + if err != nil { + return errors.New("repo.NotifyWatchers(get watches): " + err.Error()) + } + watches = append(watches, Watch{UserId: userId}) + + for i := range watches { + if userId == watches[i].UserId && i > 0 { + continue // Do not add twice in case author watches his/her repository. + } + + _, err = orm.InsertOne(&Action{ + UserId: watches[i].UserId, + ActUserId: userId, + ActUserName: userName, + OpType: opType, + Content: content, + RepoId: repoId, + RepoName: repoName, + RefName: refName, + }) + if err != nil { + return errors.New("repo.NotifyWatchers(create action): " + err.Error()) + } + } + return nil +} + // IsWatching checks if user has watched given repository. func IsWatching(userId, repoId int64) bool { has, _ := orm.Get(&Watch{0, repoId, userId}) diff --git a/modules/base/tool.go b/modules/base/tool.go index c23f5de6c..8f38d492a 100644 --- a/modules/base/tool.go +++ b/modules/base/tool.go @@ -486,15 +486,19 @@ func ActionIcon(opType int) string { return "plus-circle" case 5: // Commit repository. return "arrow-circle-o-right" + case 6: // Create issue. + return "exclamation-circle" default: return "invalid type" } } const ( - TPL_CREATE_REPO = `%s created repository %s` - TPL_COMMIT_REPO = `%s pushed to %s at %s/%s%s` - TPL_COMMIT_REPO_LI = `
user-avatar %s %s
` + TPL_CREATE_REPO = `%s created repository %s` + TPL_COMMIT_REPO = `%s pushed to %s at %s%s` + TPL_COMMIT_REPO_LI = `
user-avatar %s %s
` + TPL_CREATE_Issue = `%s opened issue %s#%s +
user-avatar %s
` ) type PushCommits struct { @@ -507,11 +511,12 @@ type PushCommits struct { func ActionDesc(act Actioner, avatarLink string) string { actUserName := act.GetActUserName() repoName := act.GetRepoName() + repoLink := actUserName + "/" + repoName branch := act.GetBranch() content := act.GetContent() switch act.GetOpType() { case 1: // Create repository. - return fmt.Sprintf(TPL_CREATE_REPO, actUserName, actUserName, actUserName, repoName, repoName) + return fmt.Sprintf(TPL_CREATE_REPO, actUserName, actUserName, repoLink, repoName) case 5: // Commit repository. var push *PushCommits if err := json.Unmarshal([]byte(content), &push); err != nil { @@ -519,13 +524,17 @@ func ActionDesc(act Actioner, avatarLink string) string { } buf := bytes.NewBuffer([]byte("\n")) for _, commit := range push.Commits { - buf.WriteString(fmt.Sprintf(TPL_COMMIT_REPO_LI, avatarLink, actUserName, repoName, commit[0], commit[0][:7], commit[1]) + "\n") + buf.WriteString(fmt.Sprintf(TPL_COMMIT_REPO_LI, avatarLink, repoLink, commit[0], commit[0][:7], commit[1]) + "\n") } if push.Len > 3 { buf.WriteString(fmt.Sprintf(``, actUserName, repoName, branch, push.Len)) } - return fmt.Sprintf(TPL_COMMIT_REPO, actUserName, actUserName, actUserName, repoName, branch, branch, actUserName, repoName, actUserName, repoName, + return fmt.Sprintf(TPL_COMMIT_REPO, actUserName, actUserName, repoLink, branch, branch, repoLink, repoLink, buf.String()) + case 6: // Create issue. + infos := strings.SplitN(content, "|", 2) + return fmt.Sprintf(TPL_CREATE_Issue, actUserName, actUserName, repoLink, infos[0], repoLink, infos[0], + avatarLink, infos[1]) default: return "invalid type" } diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 4e8324605..fc5bb9864 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -23,13 +23,33 @@ func Issues(ctx *middleware.Context, params martini.Params) { milestoneId, _ := base.StrTo(params["milestone"]).Int() page, _ := base.StrTo(params["page"]).Int() - var err error - ctx.Data["Issues"], err = models.GetIssues(0, ctx.Repo.Repository.Id, 0, + // Get issues. + issues, err := models.GetIssues(0, ctx.Repo.Repository.Id, 0, int64(milestoneId), page, params["state"] == "closed", false, params["labels"], params["sortType"]) if err != nil { ctx.Handle(200, "issue.Issues: %v", err) return } + + var closedCount int + // Get posters. + for i := range issues { + u, err := models.GetUserById(issues[i].PosterId) + if err != nil { + ctx.Handle(200, "issue.Issues(get poster): %v", err) + return + } + + if issues[i].IsClosed { + closedCount++ + } + issues[i].Poster = u + } + + ctx.Data["Issues"] = issues + ctx.Data["IssueCount"] = len(issues) + ctx.Data["OpenCount"] = len(issues) - closedCount + ctx.Data["ClosedCount"] = closedCount ctx.HTML(200, "issue/list") } @@ -54,12 +74,20 @@ func CreateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat issue, err := models.CreateIssue(ctx.User.Id, ctx.Repo.Repository.Id, form.MilestoneId, form.AssigneeId, form.IssueName, form.Labels, form.Content, false) - if err == nil { - log.Trace("%d Issue created: %d", ctx.Repo.Repository.Id, issue.Id) - ctx.Redirect(fmt.Sprintf("/%s/%s/issues/%d", params["username"], params["reponame"], issue.Index)) + if err != nil { + ctx.Handle(200, "issue.CreateIssue", err) return } - ctx.Handle(200, "issue.CreateIssue", err) + + // Notify watchers. + if err = models.NotifyWatchers(ctx.User.Id, ctx.Repo.Repository.Id, models.OP_CREATE_ISSUE, + ctx.User.Name, ctx.Repo.Repository.Name, "", fmt.Sprintf("%d|%s", issue.Index, issue.Name)); err != nil { + ctx.Handle(200, "issue.CreateIssue", err) + return + } + + log.Trace("%d Issue created: %d", ctx.Repo.Repository.Id, issue.Id) + ctx.Redirect(fmt.Sprintf("/%s/%s/issues/%d", params["username"], params["reponame"], issue.Index)) } func ViewIssue(ctx *middleware.Context, params martini.Params) { diff --git a/templates/issue/list.tmpl b/templates/issue/list.tmpl index 685eaeeb9..0df688386 100644 --- a/templates/issue/list.tmpl +++ b/templates/issue/list.tmpl @@ -6,7 +6,7 @@
@@ -14,46 +14,24 @@
{{range .Issues}} -
+
+ #{{.Index}} +
{{.Name}}
+

+ + {{.Poster.Name}} + {{TimeSince .Created}} + {{.NumComments}} +

+
{{end}}
-
From 588a700257e982fda3fee66d38672e9598d350a7 Mon Sep 17 00:00:00 2001 From: Matthew Baird Date: Tue, 25 Mar 2014 12:12:23 -0700 Subject: [PATCH 21/26] fix typo s/Broad/Board --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d99031c68..5a57eb5f9 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ More importantly, Gogs only needs one binary to setup your own project hosting o ## Overview - Please see [Wiki](https://github.com/gogits/gogs/wiki) for project design, develop specification, change log and road map. -- See [Trello Broad](https://trello.com/b/uxAoeLUl/gogs-go-git-service) to follow the develop team. +- See [Trello Board](https://trello.com/b/uxAoeLUl/gogs-go-git-service) to follow the develop team. - Try it before anything? Do it [online](http://try.gogits.org/Unknown/gogs) or go down to **Installation -> Install from binary** section! - Having troubles? Get help from [Troubleshooting](https://github.com/gogits/gogs/wiki/Troubleshooting). @@ -57,4 +57,4 @@ There are two ways to install Gogs: ## Contributors -This project was launched by [Unknown](https://github.com/Unknwon) and [lunny](https://github.com/lunny); [fuxiaohei](https://github.com/fuxiaohei) and [slene](https://github.com/slene) joined the team soon after. See [contributors page](https://github.com/gogits/gogs/graphs/contributors) for full list of contributors. \ No newline at end of file +This project was launched by [Unknown](https://github.com/Unknwon) and [lunny](https://github.com/lunny); [fuxiaohei](https://github.com/fuxiaohei) and [slene](https://github.com/slene) joined the team soon after. See [contributors page](https://github.com/gogits/gogs/graphs/contributors) for full list of contributors. From 60b83ce0c670e2b96c19ff694301684500392838 Mon Sep 17 00:00:00 2001 From: Jake Scott Date: Wed, 26 Mar 2014 08:54:46 +1300 Subject: [PATCH 22/26] Fix up the spelling on the intro :) --- templates/home.tmpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/home.tmpl b/templates/home.tmpl index 381b6f1e8..8121a4e8c 100644 --- a/templates/home.tmpl +++ b/templates/home.tmpl @@ -1,6 +1,6 @@ {{template "base/head" .}} {{template "base/navbar" .}}
- Welcome to the land of Gogs! There will be some indroduction! + Welcome to the land of Gogs! We will add an introduction soon!
-{{template "base/footer" .}} \ No newline at end of file +{{template "base/footer" .}} From c1a3d4fefbbbf332cd1cedda66e93bf40cc9713d Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 25 Mar 2014 21:37:18 -0400 Subject: [PATCH 23/26] Add mail notify for creating issue --- gogs.go | 2 +- models/issue.go | 1 - modules/mailer/mail.go | 40 ++++++++++++++++++++++++++++++++++++++-- modules/mailer/mailer.go | 2 +- routers/repo/issue.go | 9 +++++++++ 5 files changed, 49 insertions(+), 5 deletions(-) diff --git a/gogs.go b/gogs.go index b62580f8f..f5a328add 100644 --- a/gogs.go +++ b/gogs.go @@ -19,7 +19,7 @@ import ( // Test that go1.2 tag above is included in builds. main.go refers to this definition. const go12tag = true -const APP_VER = "0.1.7.0325" +const APP_VER = "0.1.8.0325" func init() { base.AppVer = APP_VER diff --git a/models/issue.go b/models/issue.go index 2bdd083d9..2de656858 100644 --- a/models/issue.go +++ b/models/issue.go @@ -59,7 +59,6 @@ func CreateIssue(userId, repoId, milestoneId, assigneeId int64, name, labels, co Content: content, } _, err = orm.Insert(issue) - // TODO: newIssueAction return issue, err } diff --git a/modules/mailer/mail.go b/modules/mailer/mail.go index 92acd20ef..d0decbe06 100644 --- a/modules/mailer/mail.go +++ b/modules/mailer/mail.go @@ -6,6 +6,7 @@ package mailer import ( "encoding/hex" + "errors" "fmt" "github.com/gogits/gogs/models" @@ -15,12 +16,17 @@ import ( ) // Create New mail message use MailFrom and MailUser -func NewMailMessage(To []string, subject, body string) Message { - msg := NewHtmlMessage(To, base.MailService.User, subject, body) +func NewMailMessageFrom(To []string, from, subject, body string) Message { + msg := NewHtmlMessage(To, from, subject, body) msg.User = base.MailService.User return msg } +// Create New mail message use MailFrom and MailUser +func NewMailMessage(To []string, subject, body string) Message { + return NewMailMessageFrom(To, base.MailService.User, subject, body) +} + func GetMailTmplData(user *models.User) map[interface{}]interface{} { data := make(map[interface{}]interface{}, 10) data["AppName"] = base.AppName @@ -84,3 +90,33 @@ func SendActiveMail(r *middleware.Render, user *models.User) { SendAsync(&msg) } + +// SendNotifyMail sends mail notification of all watchers. +func SendNotifyMail(userId, repoId int64, userName, repoName, subject, content string) error { + watches, err := models.GetWatches(repoId) + if err != nil { + return errors.New("mail.NotifyWatchers(get watches): " + err.Error()) + } + + tos := make([]string, 0, len(watches)) + for i := range watches { + uid := watches[i].UserId + if userId == uid { + continue + } + u, err := models.GetUserById(uid) + if err != nil { + return errors.New("mail.NotifyWatchers(get user): " + err.Error()) + } + tos = append(tos, u.Email) + } + + if len(tos) == 0 { + return nil + } + + msg := NewMailMessageFrom(tos, userName, subject, content) + msg.Info = fmt.Sprintf("Subject: %s, send notify emails", subject) + SendAsync(&msg) + return nil +} diff --git a/modules/mailer/mailer.go b/modules/mailer/mailer.go index da63e01d2..63861d870 100644 --- a/modules/mailer/mailer.go +++ b/modules/mailer/mailer.go @@ -33,7 +33,7 @@ func (m Message) Content() string { } // create mail content - content := "From: " + m.User + "<" + m.From + + content := "From: " + m.From + "<" + m.User + ">\r\nSubject: " + m.Subject + "\r\nContent-Type: " + contentType + "\r\n\r\n" + m.Body return content } diff --git a/routers/repo/issue.go b/routers/repo/issue.go index fc5bb9864..242593ff2 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -13,6 +13,7 @@ import ( "github.com/gogits/gogs/modules/auth" "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/log" + "github.com/gogits/gogs/modules/mailer" "github.com/gogits/gogs/modules/middleware" ) @@ -86,6 +87,14 @@ func CreateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat return } + // Mail watchers. + if base.Service.NotifyMail { + if err = mailer.SendNotifyMail(ctx.User.Id, ctx.Repo.Repository.Id, ctx.User.Name, ctx.Repo.Repository.Name, issue.Name, issue.Content); err != nil { + ctx.Handle(200, "issue.CreateIssue", err) + return + } + } + log.Trace("%d Issue created: %d", ctx.Repo.Repository.Id, issue.Id) ctx.Redirect(fmt.Sprintf("/%s/%s/issues/%d", params["username"], params["reponame"], issue.Index)) } From a8623ec104c3759b53e39a41d0a571013677cea3 Mon Sep 17 00:00:00 2001 From: FuXiaoHei Date: Wed, 26 Mar 2014 10:49:18 +0800 Subject: [PATCH 24/26] fix init-tabs bug --- templates/admin/nav.tmpl | 2 +- templates/repo/setting.tmpl | 2 +- templates/user/profile.tmpl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/admin/nav.tmpl b/templates/admin/nav.tmpl index 8c2e33888..2ac646257 100644 --- a/templates/admin/nav.tmpl +++ b/templates/admin/nav.tmpl @@ -1,5 +1,5 @@
-
    +
    • Dashboard
    • Users
    • Repositories
    • diff --git a/templates/repo/setting.tmpl b/templates/repo/setting.tmpl index d527dac3b..ea7a5ddb6 100644 --- a/templates/repo/setting.tmpl +++ b/templates/repo/setting.tmpl @@ -4,7 +4,7 @@ {{template "repo/toolbar" .}}
      -
        +
        • Options
        • diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl index 7762ad2c6..3733736dd 100644 --- a/templates/user/profile.tmpl +++ b/templates/user/profile.tmpl @@ -24,7 +24,7 @@
      -
      {{template "base/footer" .}} \ No newline at end of file From 06cf878471af02376dfcd02b9781982a89c27a2a Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 26 Mar 2014 00:13:01 -0400 Subject: [PATCH 26/26] More on diff page --- models/git.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/models/git.go b/models/git.go index 6a4bd6106..b0b0dd2f8 100644 --- a/models/git.go +++ b/models/git.go @@ -246,25 +246,27 @@ func GetDiff(repoPath, commitid string) (*Diff, error) { } // Sperate parts by file. - parts := strings.Split(stdout, "diff --git ") + startIndex := strings.Index(stdout, "diff --git ") + 12 // First part is commit information. // Check if it's a merge. - mergeIndex := strings.Index(parts[0], "merge") + mergeIndex := strings.Index(stdout[:startIndex], "merge") if mergeIndex > -1 { - mergeCommit := strings.SplitN(strings.Split(parts[0], "\n")[1], "", 3)[2] + mergeCommit := strings.SplitN(strings.Split(stdout[:startIndex], "\n")[1], "", 3)[2] return GetDiff(repoPath, mergeCommit) } - diff := &Diff{NumFiles: len(parts[1:])} + parts := strings.Split(stdout[startIndex:], "diff --git ") + diff := &Diff{NumFiles: len(parts)} diff.Files = make([]*DiffFile, 0, diff.NumFiles) - for _, part := range parts[1:] { + for _, part := range parts { infos := strings.SplitN(part, "\n", 6) - infos[5] = strings.TrimSuffix(strings.TrimSuffix(infos[5], "\n"), "\n\\ No newline at end of file") + maxIndex := len(infos) - 1 + infos[maxIndex] = strings.TrimSuffix(strings.TrimSuffix(infos[maxIndex], "\n"), "\n\\ No newline at end of file") file := &DiffFile{ Name: strings.TrimPrefix(strings.Split(infos[0], " ")[0], "a/"), - Content: strings.Split(infos[5], "\n"), + Content: strings.Split(infos[maxIndex], "\n"), } diff.Files = append(diff.Files, file) }