From 4a6c56d2fdca7f3f7cbc6d03a6809796c0b5a56e Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 20 Mar 2014 09:49:06 -0400 Subject: [PATCH 1/2] Bug fix --- gogs.go | 2 +- models/repo.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/gogs.go b/gogs.go index 385b7421..d32e3908 100644 --- a/gogs.go +++ b/gogs.go @@ -20,7 +20,7 @@ import ( // Test that go1.1 tag above is included in builds. main.go refers to this definition. const go11tag = true -const APP_VER = "0.1.1.0320.1" +const APP_VER = "0.1.2.0320.1" func init() { base.AppVer = APP_VER diff --git a/models/repo.go b/models/repo.go index 4b6dedaf..052341ff 100644 --- a/models/repo.go +++ b/models/repo.go @@ -411,6 +411,10 @@ func DeleteRepository(userId, repoId int64, userName string) (err error) { session.Rollback() return err } + if _, err = session.Delete(&Watch{RepoId: repoId}); err != nil { + session.Rollback() + return err + } if err = session.Commit(); err != nil { session.Rollback() return err From 1a0d7c54a2abecbe5335ca374fd8a345c2e7d3fd Mon Sep 17 00:00:00 2001 From: FuXiaoHei Date: Thu, 20 Mar 2014 22:39:10 +0800 Subject: [PATCH 2/2] repo watching ajax --- public/css/gogs.css | 8 ++++++-- public/js/app.js | 35 +++++++++++++++++++++++++++++++++++ templates/repo/nav.tmpl | 14 +++++++++----- 3 files changed, 50 insertions(+), 7 deletions(-) diff --git a/public/css/gogs.css b/public/css/gogs.css index d1b1e155..f88b3963 100755 --- a/public/css/gogs.css +++ b/public/css/gogs.css @@ -445,7 +445,7 @@ html, body { padding: 0; } -#gogs-repo-watching .dropdown-menu .dropdown-item:hover .dropdown-header { +#gogs-repo-watching .dropdown-menu .dropdown-item:hover .dropdown-header, #gogs-repo-watching .dropdown-item .dropdown-header.text-primary { color: rgb(65, 131, 196); cursor: pointer; } @@ -678,7 +678,7 @@ html, body { } .file-content .file-body.file-code .lines-num span { - font-family: Menlo,Monaco,Consolas,"Courier New",monospace; + font-family: Menlo, Monaco, Consolas, "Courier New", monospace; line-height: 1.6; padding: 0 8px 0 10px; cursor: pointer; @@ -783,6 +783,10 @@ html, body { width: 120px; } +.commit-list .author { + min-width: 180px; +} + .guide-box pre, .guide-box .input-group { margin-top: 20px; margin-bottom: 30px; diff --git a/public/js/app.js b/public/js/app.js index 55541032..9a5a0d68 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -181,6 +181,7 @@ function initUserSetting() { } function initRepository() { + // guide box script (function () { var $guide = $('.guide-box'); if ($guide.length) { @@ -197,6 +198,40 @@ function initRepository() { // todo copy to clipboard } })(); + + // watching script + (function () { + var $watch = $('#gogs-repo-watching'), + watchLink = $watch.data("watch"), + unwatchLink = $watch.data("unwatch"); + $watch.on('click', '.to-watch',function () { + if ($watch.hasClass("watching")) { + return false; + } + $.get(watchLink, function (json) { + if (json.ok) { + $watch.find('.text-primary').removeClass('text-primary'); + $watch.find('.to-watch h4').addClass('text-primary'); + $watch.find('.fa-eye-slash').removeClass('fa-eye-slash').addClass('fa-eye'); + $watch.removeClass("no-watching").addClass("watching"); + } + }); + return false; + }).on('click', '.to-unwatch', function () { + if ($watch.hasClass("no-watching")) { + return false; + } + $.get(unwatchLink, function (json) { + if (json.ok) { + $watch.find('.text-primary').removeClass('text-primary'); + $watch.find('.to-unwatch h4').addClass('text-primary'); + $watch.find('.fa-eye').removeClass('fa-eye').addClass('fa-eye-slash'); + $watch.removeClass("watching").addClass("no-watching"); + } + }); + return false; + }); + })(); } (function ($) { diff --git a/templates/repo/nav.tmpl b/templates/repo/nav.tmpl index e8685b08..718c429a 100644 --- a/templates/repo/nav.tmpl +++ b/templates/repo/nav.tmpl @@ -13,20 +13,24 @@ -
+
+ {{if .IsRepositoryWatching}} + {{else}} + + {{end}}