From 1bbf4c9768ac03b0c4fdac0993f7a864cea5faa1 Mon Sep 17 00:00:00 2001 From: Michael Dyrynda Date: Sun, 31 Aug 2014 21:06:50 +0930 Subject: [PATCH 001/153] Add missing 'new migration' link Addresses issue #399 --- templates/user/dashboard/dashboard.tmpl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/user/dashboard/dashboard.tmpl b/templates/user/dashboard/dashboard.tmpl index df4fc0b65..bf0aba097 100644 --- a/templates/user/dashboard/dashboard.tmpl +++ b/templates/user/dashboard/dashboard.tmpl @@ -58,6 +58,7 @@ @@ -165,4 +166,4 @@ -{{template "ng/base/footer" .}} \ No newline at end of file +{{template "ng/base/footer" .}} From 676bd764fa602048c1a81d94943f45dcb1a75c76 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sun, 31 Aug 2014 21:03:16 +0800 Subject: [PATCH 002/153] UI: SSH/HTTPS address switch and copy --- conf/locale/locale_en-US.ini | 6 ++++ conf/locale/locale_zh-CN.ini | 6 ++++ public/ng/js/gogs.js | 61 ++++++++++++++++++++++++++++++++++++ public/ng/js/lib/lib.js | 2 +- templates/repo/bare.tmpl | 18 +++++------ templates/repo/header.tmpl | 8 ++--- 6 files changed, 87 insertions(+), 14 deletions(-) diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini index 3dfbdc3aa..a99eb92e7 100644 --- a/conf/locale/locale_en-US.ini +++ b/conf/locale/locale_en-US.ini @@ -185,6 +185,7 @@ migrate_type = Migration Type migrate_type_helper = This repository will be a Mirror migrate_repo = Migrate Repository +copy_link = Copy clone_helper = Need help cloning? Visit Help! unwatch = Unwatch watch = Watch @@ -192,6 +193,11 @@ unstar = Unstar star = Star fork = Fork +quick_guide = Quick Guide +clone_this_repo = Clone this repository +create_new_repo_command = Create a new repository on the command line +push_exist_repo = Push an existing repository from the command line + settings = Settings settings.options = Options settings.collaboration = Collaboration diff --git a/conf/locale/locale_zh-CN.ini b/conf/locale/locale_zh-CN.ini index d498da9c1..21442539a 100644 --- a/conf/locale/locale_zh-CN.ini +++ b/conf/locale/locale_zh-CN.ini @@ -185,6 +185,7 @@ migrate_type = 迁移类型 migrate_type_helper = 本仓库将是 镜像 migrate_repo = 迁移仓库 +copy_link = 复制链接 clone_helper = 不知道如何操作?访问 此处 查看帮助! unwatch = 取消关注 watch = 关注 @@ -192,6 +193,11 @@ unstar = 取消点赞 star = 点赞 fork = 派生 +quick_guide = 快速帮助 +clone_this_repo = 克隆当前仓库 +create_new_repo_command = 从命令行创建一个新的仓库 +push_exist_repo = 从命令行推送已经创建的仓库 + settings = 仓库设置 settings.options = 基本设置 settings.collaboration = 管理协作者 diff --git a/public/ng/js/gogs.js b/public/ng/js/gogs.js index 9fe065552..bade9f342 100644 --- a/public/ng/js/gogs.js +++ b/public/ng/js/gogs.js @@ -238,6 +238,44 @@ var Gogs = {}; } }); } + + // Copy util. + Gogs.bindCopy = function (selector) { + if ($(selector).hasClass('js-copy-bind')) { + return; + } + $(selector).zclip({ + path: "/js/ZeroClipboard.swf", + copy: function () { + var t = $(this).data("copy-val"); + var to = $($(this).data("copy-from")); + var str = ""; + if (t == "txt") { + str = to.text(); + } + if (t == 'val') { + str = to.val(); + } + if (t == 'html') { + str = to.html(); + } + return str; + }, + afterCopy: function () { + alert("Clone URL has copied!"); +// var $this = $(this); +// $this.tooltip('hide') +// .attr('data-original-title', 'Copied OK'); +// setTimeout(function () { +// $this.tooltip("show"); +// }, 200); +// setTimeout(function () { +// $this.tooltip('hide') +// .attr('data-original-title', 'Copy to Clipboard'); +// }, 3000); + } + }).addClass("js-copy-bind"); + } })(jQuery); function initCore() { @@ -291,6 +329,26 @@ function initRepoCreate() { console.log('initRepoCreate'); } +function initRepo() { + // Clone link switch button. + $('#repo-clone-ssh').click(function () { + $(this).removeClass('btn-gray').addClass('btn-blue'); + $('#repo-clone-https').removeClass('btn-blue').addClass('btn-gray'); + $('#repo-clone-url').val($(this).data('link')); + $('.clone-url').text($(this).data('link')) + }); + $('#repo-clone-https').click(function () { + $(this).removeClass('btn-gray').addClass('btn-blue'); + $('#repo-clone-ssh').removeClass('btn-blue').addClass('btn-gray'); + $('#repo-clone-url').val($(this).data('link')); + $('.clone-url').text($(this).data('link')) + }); + // Copy URL. + $('#repo-clone-copy').hover(function () { + Gogs.bindCopy($(this)); + }) +} + function initRepoSetting() { // Options. // Confirmation of changing repository name. @@ -481,6 +539,9 @@ $(document).ready(function () { if ($('#repo-create-form').length || $('#repo-migrate-form').length) { initRepoCreate(); } + if ($('#repo-header').length) { + initRepo(); + } if ($('#repo-setting').length) { initRepoSetting(); } diff --git a/public/ng/js/lib/lib.js b/public/ng/js/lib/lib.js index 4264c66eb..5e95433d5 100644 --- a/public/ng/js/lib/lib.js +++ b/public/ng/js/lib/lib.js @@ -165,4 +165,4 @@ PR.registerLangHandler(PR.createSimpleLexer([["pun",/^[:>?|]+/,a,":|>?"],["dec", * Date: Wed Jun 01, 2011 */ -(function(a){a.fn.zclip=function(c){if(typeof c=="object"&&!c.length){var b=a.extend({path:"ZeroClipboard.swf",copy:null,beforeCopy:null,afterCopy:null,clickAfter:true,setHandCursor:true,setCSSEffects:true},c);return this.each(function(){var e=a(this);if(e.is(":visible")&&(typeof b.copy=="string"||a.isFunction(b.copy))){ZeroClipboard.setMoviePath(b.path);var d=new ZeroClipboard.Client();if(a.isFunction(b.copy)){e.bind("zClip_copy",b.copy)}if(a.isFunction(b.beforeCopy)){e.bind("zClip_beforeCopy",b.beforeCopy)}if(a.isFunction(b.afterCopy)){e.bind("zClip_afterCopy",b.afterCopy)}d.setHandCursor(b.setHandCursor);d.setCSSEffects(b.setCSSEffects);d.addEventListener("mouseOver",function(f){e.trigger("mouseenter")});d.addEventListener("mouseOut",function(f){e.trigger("mouseleave")});d.addEventListener("mouseDown",function(f){e.trigger("mousedown");if(!a.isFunction(b.copy)){d.setText(b.copy)}else{d.setText(e.triggerHandler("zClip_copy"))}if(a.isFunction(b.beforeCopy)){e.trigger("zClip_beforeCopy")}});d.addEventListener("complete",function(f,g){if(a.isFunction(b.afterCopy)){e.trigger("zClip_afterCopy")}else{if(g.length>500){g=g.substr(0,500)+"...\n\n("+(g.length-500)+" characters not shown)"}e.removeClass("hover");alert("Copied text to clipboard:\n\n "+g)}if(b.clickAfter){e.trigger("click")}});d.glue(e[0],e.parent()[0]);a(window).bind("load resize",function(){d.reposition()})}})}else{if(typeof c=="string"){return this.each(function(){var f=a(this);c=c.toLowerCase();var e=f.data("zclipId");var d=a("#"+e+".zclip");if(c=="remove"){d.remove();f.removeClass("active hover")}else{if(c=="hide"){d.hide();f.removeClass("active hover")}else{if(c=="show"){d.show()}}}})}}}})(jQuery);var ZeroClipboard={version:"1.0.7",clients:{},moviePath:"ZeroClipboard.swf",nextId:1,$:function(a){if(typeof(a)=="string"){a=document.getElementById(a)}if(!a.addClass){a.hide=function(){/*this.style.display="none"*/};a.show=function(){this.style.display=""};a.addClass=function(b){this.removeClass(b);this.className+=" "+b};a.removeClass=function(d){var e=this.className.split(/\s+/);var b=-1;for(var c=0;c-1){e.splice(b,1);this.className=e.join(" ")}return this};a.hasClass=function(b){return !!this.className.match(new RegExp("\\s*"+b+"\\s*"))}}return a},setMoviePath:function(a){this.moviePath=a},dispatch:function(d,b,c){var a=this.clients[d];if(a){a.receiveEvent(b,c)}},register:function(b,a){this.clients[b]=a},getDOMObjectPosition:function(c,a){var b={left:0,top:0,width:c.width?c.width:c.offsetWidth,height:c.height?c.height:c.offsetHeight};if(c&&(c!=a)){b.left+=c.offsetLeft;b.top+=c.offsetTop}return b},Client:function(a){this.handlers={};this.id=ZeroClipboard.nextId++;this.movieId="ZeroClipboardMovie_"+this.id;ZeroClipboard.register(this.id,this);if(a){this.glue(a)}}};ZeroClipboard.Client.prototype={id:0,ready:false,movie:null,clipText:"",handCursorEnabled:true,cssEffects:true,handlers:null,glue:function(d,b,e){this.domElement=ZeroClipboard.$(d);var f=99;if(this.domElement.style.zIndex){f=parseInt(this.domElement.style.zIndex,10)+1}if(typeof(b)=="string"){b=ZeroClipboard.$(b)}else{if(typeof(b)=="undefined"){b=document.getElementsByTagName("body")[0]}}var c=ZeroClipboard.getDOMObjectPosition(this.domElement,b);this.div=document.createElement("div");this.div.className="zclip";this.div.id="zclip-"+this.movieId;$(this.domElement).data("zclipId","zclip-"+this.movieId);var a=this.div.style;a.position="absolute";a.left=""+c.left+"px";a.top=""+c.top+"px";a.width=""+c.width+"px";a.height=""+c.height+"px";a.zIndex=f;if(typeof(e)=="object"){for(addedStyle in e){a[addedStyle]=e[addedStyle]}}b.appendChild(this.div);this.div.innerHTML=this.getHTML(c.width,c.height)},getHTML:function(d,a){var c="";var b="id="+this.id+"&width="+d+"&height="+a;if(navigator.userAgent.match(/MSIE/)){var e=location.href.match(/^https/i)?"https://":"http://";c+=''}else{c+=''}return c},hide:function(){if(this.div){this.div.style.left="-2000px"}},show:function(){this.reposition()},destroy:function(){if(this.domElement&&this.div){this.hide();this.div.innerHTML="";var a=document.getElementsByTagName("body")[0];try{a.removeChild(this.div)}catch(b){}this.domElement=null;this.div=null}},reposition:function(c){if(c){this.domElement=ZeroClipboard.$(c);if(!this.domElement){this.hide()}}if(this.domElement&&this.div){var b=ZeroClipboard.getDOMObjectPosition(this.domElement);var a=this.div.style;a.left=""+b.left+"px";a.top=""+b.top+"px"}},setText:function(a){this.clipText=a;if(this.ready){this.movie.setText(a)}},addEventListener:function(a,b){a=a.toString().toLowerCase().replace(/^on/,"");if(!this.handlers[a]){this.handlers[a]=[]}this.handlers[a].push(b)},setHandCursor:function(a){this.handCursorEnabled=a;if(this.ready){this.movie.setHandCursor(a)}},setCSSEffects:function(a){this.cssEffects=!!a},receiveEvent:function(d,f){d=d.toString().toLowerCase().replace(/^on/,"");switch(d){case"load":this.movie=document.getElementById(this.movieId);if(!this.movie){var c=this;setTimeout(function(){c.receiveEvent("load",null)},1);return}if(!this.ready&&navigator.userAgent.match(/Firefox/)&&navigator.userAgent.match(/Windows/)){var c=this;setTimeout(function(){c.receiveEvent("load",null)},100);this.ready=true;return}this.ready=true;try{this.movie.setText(this.clipText)}catch(h){}try{this.movie.setHandCursor(this.handCursorEnabled)}catch(h){}break;case"mouseover":if(this.domElement&&this.cssEffects){this.domElement.addClass("hover");if(this.recoverActive){this.domElement.addClass("active")}}break;case"mouseout":if(this.domElement&&this.cssEffects){this.recoverActive=false;if(this.domElement.hasClass("active")){this.domElement.removeClass("active");this.recoverActive=true}this.domElement.removeClass("hover")}break;case"mousedown":if(this.domElement&&this.cssEffects){this.domElement.addClass("active")}break;case"mouseup":if(this.domElement&&this.cssEffects){this.domElement.removeClass("active");this.recoverActive=false}break}if(this.handlers[d]){for(var b=0,a=this.handlers[d].length;b500){g=g.substr(0,500)+"...\n\n("+(g.length-500)+" characters not shown)"}e.removeClass("hover");alert("Copied text to clipboard:\n\n "+g)}if(b.clickAfter){e.trigger("click")}});d.glue(e[0],e.parent()[0]);a(window).bind("load resize",function(){d.reposition()})}})}else{if(typeof c=="string"){return this.each(function(){var f=a(this);c=c.toLowerCase();var e=f.data("zclipId");var d=a("#"+e+".zclip");if(c=="remove"){d.remove();f.removeClass("active hover")}else{if(c=="hide"){d.hide();f.removeClass("active hover")}else{if(c=="show"){d.show()}}}})}}}})(jQuery);var ZeroClipboard={version:"1.0.7",clients:{},moviePath:"ZeroClipboard.swf",nextId:1,$:function(a){if(typeof(a)=="string"){a=document.getElementById(a)}if(!a.addClass){a.hide=function(){/*this.style.display="none"*/};a.show=function(){this.style.display=""};a.addClass=function(b){this.removeClass(b);this.className+=" "+b};a.removeClass=function(d){var e=this.className.split(/\s+/);var b=-1;for(var c=0;c-1){e.splice(b,1);this.className=e.join(" ")}return this};a.hasClass=function(b){return !!this.className.match(new RegExp("\\s*"+b+"\\s*"))}}return a},setMoviePath:function(a){this.moviePath=a},dispatch:function(d,b,c){var a=this.clients[d];if(a){a.receiveEvent(b,c)}},register:function(b,a){this.clients[b]=a},getDOMObjectPosition:function(c,a){var b={left:0,top:0,width:c.width?c.width:c.offsetWidth,height:c.height?c.height:c.offsetHeight};if(c&&(c!=a)){b.left+=c.offsetLeft;b.top+=c.offsetTop}return b},Client:function(a){this.handlers={};this.id=ZeroClipboard.nextId++;this.movieId="ZeroClipboardMovie_"+this.id;ZeroClipboard.register(this.id,this);if(a){this.glue(a)}}};ZeroClipboard.Client.prototype={id:0,ready:false,movie:null,clipText:"",handCursorEnabled:true,cssEffects:true,handlers:null,glue:function(d,b,e){this.domElement=ZeroClipboard.$(d);var f=99;if(this.domElement.style.zIndex){f=parseInt(this.domElement.style.zIndex,10)+1}if(typeof(b)=="string"){b=ZeroClipboard.$(b)}else{if(typeof(b)=="undefined"){b=document.getElementsByTagName("body")[0]}}var c=ZeroClipboard.getDOMObjectPosition(this.domElement,b);this.div=document.createElement("div");this.div.className="zclip";this.div.id="zclip-"+this.movieId;$(this.domElement).data("zclipId","zclip-"+this.movieId);var a=this.div.style;a.position="absolute";a.left=""+c.left+"px";a.top=""+c.top+"px";a.width=""+c.width+"px";a.height=""+c.height+"px";a.zIndex=f;if(typeof(e)=="object"){for(addedStyle in e){a[addedStyle]=e[addedStyle]}}b.appendChild(this.div);this.div.innerHTML=this.getHTML(c.width,c.height)},getHTML:function(d,a){var c="";var b="id="+this.id+"&width="+d+"&height="+a;if(navigator.userAgent.match(/MSIE/)){var e=location.href.match(/^https/i)?"https://":"http://";c+=''}else{c+=''}return c},hide:function(){if(this.div){this.div.style.left="-2000px"}},show:function(){this.reposition()},destroy:function(){if(this.domElement&&this.div){this.hide();this.div.innerHTML="";var a=document.getElementsByTagName("body")[0];try{a.removeChild(this.div)}catch(b){}this.domElement=null;this.div=null}},reposition:function(c){if(c){this.domElement=ZeroClipboard.$(c);if(!this.domElement){this.hide()}}if(this.domElement&&this.div){var b=ZeroClipboard.getDOMObjectPosition(this.domElement);var a=this.div.style;a.left=""+b.left+"px";a.top=""+b.top+"px"}},setText:function(a){this.clipText=a;if(this.ready){this.movie.setText(a)}},addEventListener:function(a,b){a=a.toString().toLowerCase().replace(/^on/,"");if(!this.handlers[a]){this.handlers[a]=[]}this.handlers[a].push(b)},setHandCursor:function(a){this.handCursorEnabled=a;if(this.ready){this.movie.setHandCursor(a)}},setCSSEffects:function(a){this.cssEffects=!!a},receiveEvent:function(d,f){d=d.toString().toLowerCase().replace(/^on/,"");switch(d){case"load":this.movie=document.getElementById(this.movieId);if(!this.movie){var c=this;setTimeout(function(){c.receiveEvent("load",null)},1);return}if(!this.ready&&navigator.userAgent.match(/Firefox/)&&navigator.userAgent.match(/Windows/)){var c=this;setTimeout(function(){c.receiveEvent("load",null)},100);this.ready=true;return}this.ready=true;try{this.movie.setText(this.clipText)}catch(h){}try{this.movie.setHandCursor(this.handCursorEnabled)}catch(h){}break;case"mouseover":if(this.domElement&&this.cssEffects){this.domElement.addClass("hover");if(this.recoverActive){this.domElement.addClass("active")}}break;case"mouseout":if(this.domElement&&this.cssEffects){this.recoverActive=false;if(this.domElement.hasClass("active")){this.domElement.removeClass("active");this.recoverActive=true}this.domElement.removeClass("hover")}break;case"mousedown":if(this.domElement&&this.cssEffects){this.domElement.addClass("active")}break;case"mouseup":if(this.domElement&&this.cssEffects){this.domElement.removeClass("active");this.recoverActive=false}break}if(this.handlers[d]){for(var b=0,a=this.handlers[d].length;b
{{.i18n.Tr "repo.settings"}} - Quick Start + {{.i18n.Tr "repo.quick_guide"}}
-

Clone this repository

- - - - -

Need help cloning? Visit Help!

+

{{.i18n.Tr "repo.clone_this_repo"}}

+ + + + +

{{.i18n.Tr "repo.clone_helper" | Str2html}}


-

Create a new repository on the command line

+

{{.i18n.Tr "repo.create_new_repo_command"}}

touch README.md
 git init
 git add README.md
@@ -40,7 +40,7 @@ git push -u origin master

-

Push an existing repository from the command line

+

{{.i18n.Tr "repo.push_exist_repo"}}

git remote add origin {{.CloneLink.SSH}}
 git push -u origin master

diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index 31259f056..6f3d4c66c 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -16,10 +16,10 @@
-{{template "ng/base/footer" .}} \ No newline at end of file +{{template "ng/base/footer" .}} diff --git a/templates/repo/settings/hook_settings.tmpl b/templates/repo/settings/hook_settings.tmpl new file mode 100644 index 000000000..7bf4e2a36 --- /dev/null +++ b/templates/repo/settings/hook_settings.tmpl @@ -0,0 +1,15 @@ +
+

{{.i18n.Tr "repo.settings.event_desc"}}

+ + {{.i18n.Tr "repo.settings.event_push_only" | Str2html}} +
+
+ + +{{.i18n.Tr "repo.settings.active_helper"}} +
+
+ + + {{if .PageIsSettingsHooksEdit}}{{.i18n.Tr "repo.settings.delete_webhook"}}{{end}} +
diff --git a/templates/repo/settings/hook_types.tmpl b/templates/repo/settings/hook_types.tmpl new file mode 100644 index 000000000..782e2a4e7 --- /dev/null +++ b/templates/repo/settings/hook_types.tmpl @@ -0,0 +1,11 @@ +{{if .PageIsSettingsHooksNew}} +
+ + +
+{{end}} diff --git a/templates/repo/settings/slack_hook.tmpl b/templates/repo/settings/slack_hook.tmpl new file mode 100644 index 000000000..e68571a08 --- /dev/null +++ b/templates/repo/settings/slack_hook.tmpl @@ -0,0 +1,20 @@ +
+
+ {{.CsrfTokenHtml}} + +
{{.i18n.Tr "repo.settings.add_slack_hook_desc" | Str2html}}
+
+ + +
+
+ + +
+
+ + +
+ {{template "repo/settings/hook_settings" .}} +
+
From 72ec3e8da07be695a94935009077035c520ec142 Mon Sep 17 00:00:00 2001 From: fanningert Date: Sun, 31 Aug 2014 18:03:28 +0200 Subject: [PATCH 009/153] Update locale_de-DE.ini --- conf/locale/locale_de-DE.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/locale/locale_de-DE.ini b/conf/locale/locale_de-DE.ini index 80b2245cd..4a43bdba2 100644 --- a/conf/locale/locale_de-DE.ini +++ b/conf/locale/locale_de-DE.ini @@ -245,7 +245,7 @@ people = Personen invite_someone = Jemanden einladen teams = Teams lower_members = Mitglieder -lower_Repositorys = Repositorys +lower_Repositoryies = Repositorys create_new_team = Neues Team erstellen org_desc = Beschreibung team_name = Teamname @@ -297,7 +297,7 @@ teams.delete_team_success = Team gelöscht teams.read_permission_desc = Dieses Team erlaubt Lesezugriff: Mitglieder können Team-Repositorys einsehen und klonen. teams.write_permission_desc = Dieses Team erlaubt Schreibzugriff: Mitglieder können Team-Repositorys einsehen und hinein pushen. teams.admin_permission_desc = Diese Team erlaubt Adminzugriff: Mitglieder dieses Teams können pullen, pushen und dem Team Mitarbeiter hinzufügen. -teams.Repositorys = Team Repositorys +teams.Repositories = Team Repositorys teams.add_team_repository = Team-Repository hinzufügen teams.remove_repo = Entfernen @@ -305,7 +305,7 @@ teams.remove_repo = Entfernen dashboard = Dashboard users = Benutzer organizations = Organisationen -Repositorys = Repositorys +Repositories = Repositorys authentication = Authentifizierung config = Konfiguration monitor = Monitoring From 99e009665c732ea524e24580964902cb7f99f736 Mon Sep 17 00:00:00 2001 From: fanningert Date: Sun, 31 Aug 2014 18:04:15 +0200 Subject: [PATCH 010/153] Update locale_de-DE.ini --- conf/locale/locale_de-DE.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/locale/locale_de-DE.ini b/conf/locale/locale_de-DE.ini index 4a43bdba2..a3ce7b3d1 100644 --- a/conf/locale/locale_de-DE.ini +++ b/conf/locale/locale_de-DE.ini @@ -245,7 +245,7 @@ people = Personen invite_someone = Jemanden einladen teams = Teams lower_members = Mitglieder -lower_Repositoryies = Repositorys +lower_Repositories = Repositorys create_new_team = Neues Team erstellen org_desc = Beschreibung team_name = Teamname From 801fc536f2f4edf9b0381ea78833007c99fa30ca Mon Sep 17 00:00:00 2001 From: fanningert Date: Sun, 31 Aug 2014 18:05:26 +0200 Subject: [PATCH 011/153] Update locale_de-DE.ini --- conf/locale/locale_de-DE.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/locale/locale_de-DE.ini b/conf/locale/locale_de-DE.ini index a3ce7b3d1..97ca5efd0 100644 --- a/conf/locale/locale_de-DE.ini +++ b/conf/locale/locale_de-DE.ini @@ -245,7 +245,7 @@ people = Personen invite_someone = Jemanden einladen teams = Teams lower_members = Mitglieder -lower_Repositories = Repositorys +lower_repositories = Repositorys create_new_team = Neues Team erstellen org_desc = Beschreibung team_name = Teamname @@ -297,7 +297,7 @@ teams.delete_team_success = Team gelöscht teams.read_permission_desc = Dieses Team erlaubt Lesezugriff: Mitglieder können Team-Repositorys einsehen und klonen. teams.write_permission_desc = Dieses Team erlaubt Schreibzugriff: Mitglieder können Team-Repositorys einsehen und hinein pushen. teams.admin_permission_desc = Diese Team erlaubt Adminzugriff: Mitglieder dieses Teams können pullen, pushen und dem Team Mitarbeiter hinzufügen. -teams.Repositories = Team Repositorys +teams.repositories = Team Repositorys teams.add_team_repository = Team-Repository hinzufügen teams.remove_repo = Entfernen @@ -305,7 +305,7 @@ teams.remove_repo = Entfernen dashboard = Dashboard users = Benutzer organizations = Organisationen -Repositories = Repositorys +repositories = Repositorys authentication = Authentifizierung config = Konfiguration monitor = Monitoring From 36661f53e6cb7bd5fe202157f794255d4d6932af Mon Sep 17 00:00:00 2001 From: Unknwon Date: Mon, 1 Sep 2014 00:12:37 +0800 Subject: [PATCH 012/153] Update deps --- modules/setting/setting_memcache.go | 2 +- modules/setting/setting_redis.go | 4 ++-- public/ng/css/gogs.css | 1 + public/ng/less/gogs/base.less | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/setting/setting_memcache.go b/modules/setting/setting_memcache.go index e509f372d..26b1cc6f6 100644 --- a/modules/setting/setting_memcache.go +++ b/modules/setting/setting_memcache.go @@ -7,7 +7,7 @@ package setting import ( - _ "github.com/gogits/cache/memcache" + _ "github.com/macaron-contrib/cache/memcache" ) func init() { diff --git a/modules/setting/setting_redis.go b/modules/setting/setting_redis.go index 78b31d534..bfd1694de 100644 --- a/modules/setting/setting_redis.go +++ b/modules/setting/setting_redis.go @@ -7,8 +7,8 @@ package setting import ( - _ "github.com/gogits/cache/redis" - _ "github.com/gogits/session/redis" + _ "github.com/macaron-contrib/cache/redis" + _ "github.com/macaron-contrib/session/redis" ) func init() { diff --git a/public/ng/css/gogs.css b/public/ng/css/gogs.css index d81d6f314..6ff68a5b2 100644 --- a/public/ng/css/gogs.css +++ b/public/ng/css/gogs.css @@ -1,6 +1,7 @@ html, body { height: 100%; + overflow-y: scroll; } .octicon, .fa { diff --git a/public/ng/less/gogs/base.less b/public/ng/less/gogs/base.less index 241846dbb..8a8845074 100644 --- a/public/ng/less/gogs/base.less +++ b/public/ng/less/gogs/base.less @@ -11,6 +11,7 @@ html, body { height: 100%; + overflow-y: scroll; } .octicon, .fa { From da8dba53a7e238e55e36d520716f9a06af7e8317 Mon Sep 17 00:00:00 2001 From: fanningert Date: Sun, 31 Aug 2014 18:28:59 +0200 Subject: [PATCH 013/153] Removed not needed deps Removed * github.com/gogits/cache * github.com/gogits/session --- .gopmfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gopmfile b/.gopmfile index e06d0caaa..736205ae0 100644 --- a/.gopmfile +++ b/.gopmfile @@ -14,11 +14,9 @@ github.com/codegangsta/cli = github.com/go-sql-driver/mysql = github.com/go-xorm/core = github.com/go-xorm/xorm = -github.com/gogits/cache = github.com/gogits/gfm = github.com/gogits/git = github.com/gogits/oauth2 = -github.com/gogits/session = github.com/juju2013/goldap = github.com/johnweldon/asn1-ber = github.com/lib/pq = From c5ce33047e77b03b8d6e289d2b250e15c65ae3d2 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Mon, 1 Sep 2014 00:33:40 +0800 Subject: [PATCH 014/153] Mirror fix and hide missing pages for 0.5 release --- conf/locale/locale_zh-CN.ini | 5 +++++ templates/repo/header.tmpl | 4 ++-- templates/repo/home.tmpl | 18 +++++++++--------- .../{gogs_hook.tmpl => hook_gogs.tmpl} | 2 +- templates/repo/settings/hook_new.tmpl | 4 ++-- .../{slack_hook.tmpl => hook_slack.tmpl} | 2 +- templates/repo/settings/nav.tmpl | 2 +- templates/repo/sidebar.tmpl | 12 ++++++------ templates/user/dashboard/nav.tmpl | 10 ++++++---- 9 files changed, 33 insertions(+), 26 deletions(-) rename templates/repo/settings/{gogs_hook.tmpl => hook_gogs.tmpl} (97%) rename templates/repo/settings/{slack_hook.tmpl => hook_slack.tmpl} (95%) diff --git a/conf/locale/locale_zh-CN.ini b/conf/locale/locale_zh-CN.ini index 21442539a..55d22f23e 100644 --- a/conf/locale/locale_zh-CN.ini +++ b/conf/locale/locale_zh-CN.ini @@ -234,6 +234,11 @@ settings.update_webhook = 更新 Web 钩子 settings.update_hook_success = Web 钩子更新成功! settings.delete_webhook = 删除 Web 钩子 settings.recent_deliveries = 最近推送记录 +settings.hook_type = 钩子类型 +settings.add_slack_hook_desc = 为您的仓库增加 Slack 集成 +settings.slack_token = 令牌 +settings.slack_domain = 域名 +settings.slack_channel = 频道 [org] org_name_holder = 组织名称 diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index 6f3d4c66c..381250824 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -44,14 +44,14 @@ -
  • + \ No newline at end of file diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index 42b8bdd4b..094730847 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -9,11 +9,11 @@ {{.Repository.Website}}

    {{if .IsFile}} {{template "repo/view_file" .}} diff --git a/templates/repo/settings/gogs_hook.tmpl b/templates/repo/settings/hook_gogs.tmpl similarity index 97% rename from templates/repo/settings/gogs_hook.tmpl rename to templates/repo/settings/hook_gogs.tmpl index 678d640ba..35b589953 100644 --- a/templates/repo/settings/gogs_hook.tmpl +++ b/templates/repo/settings/hook_gogs.tmpl @@ -1,4 +1,4 @@ -
    +
    {{.CsrfTokenHtml}} diff --git a/templates/repo/settings/hook_new.tmpl b/templates/repo/settings/hook_new.tmpl index 7a450282b..2bce97a26 100644 --- a/templates/repo/settings/hook_new.tmpl +++ b/templates/repo/settings/hook_new.tmpl @@ -14,8 +14,8 @@ {{if .PageIsSettingsHooksNew}}{{.i18n.Tr "repo.settings.add_webhook"}}{{else}}{{.i18n.Tr "repo.settings.update_webhook"}}{{end}}
    {{template "repo/settings/hook_types" .}} - {{template "repo/settings/gogs_hook" .}} - {{template "repo/settings/slack_hook" .}} + {{template "repo/settings/hook_gogs" .}} + {{template "repo/settings/hook_slack" .}}
    {{if .PageIsSettingsHooksEdit}} diff --git a/templates/repo/settings/slack_hook.tmpl b/templates/repo/settings/hook_slack.tmpl similarity index 95% rename from templates/repo/settings/slack_hook.tmpl rename to templates/repo/settings/hook_slack.tmpl index e68571a08..50d28e2f5 100644 --- a/templates/repo/settings/slack_hook.tmpl +++ b/templates/repo/settings/hook_slack.tmpl @@ -1,4 +1,4 @@ -
    +
    {{.CsrfTokenHtml}} diff --git a/templates/repo/settings/nav.tmpl b/templates/repo/settings/nav.tmpl index 6288ca6cd..ef0765fea 100644 --- a/templates/repo/settings/nav.tmpl +++ b/templates/repo/settings/nav.tmpl @@ -5,7 +5,7 @@
  • {{.i18n.Tr "repo.settings.options"}}
  • {{.i18n.Tr "repo.settings.collaboration"}}
  • {{.i18n.Tr "repo.settings.hooks"}}
  • -
  • {{.i18n.Tr "repo.settings.deploy_keys"}}
  • + \ No newline at end of file diff --git a/templates/repo/sidebar.tmpl b/templates/repo/sidebar.tmpl index 39d999cab..f671bfc1b 100644 --- a/templates/repo/sidebar.tmpl +++ b/templates/repo/sidebar.tmpl @@ -3,23 +3,23 @@
  • Issues{{.Repository.NumOpenIssues}}
  • -
  • +
  • {{if .IsViewBranch}}{{.BranchName}}{{else}}{{ShortSha .BranchName}}{{end}}
  • Commits {{.CommitsCount}}
  • -
  • +
  • Releases {{.Repository.NumTags}}
  • -
  • +
  • settings diff --git a/templates/user/dashboard/nav.tmpl b/templates/user/dashboard/nav.tmpl index 6064f3569..c37447d3a 100644 --- a/templates/user/dashboard/nav.tmpl +++ b/templates/user/dashboard/nav.tmpl @@ -24,21 +24,23 @@
  • {{end}} -
  • +
  • {{.i18n.Tr "new_org"}}
  • + {{if not .ContextUser.IsOrganization}}
  • {{.i18n.Tr "issues"}}
  • -
  • + {{end}} +
  • {{.i18n.Tr "news_feed"}}
  • From 1858d2066bb0da2514463dc8cc2c825ed2a45ccd Mon Sep 17 00:00:00 2001 From: fanningert Date: Sun, 31 Aug 2014 18:48:24 +0200 Subject: [PATCH 015/153] Add new translation keys --- conf/locale/locale_de-DE.ini | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/conf/locale/locale_de-DE.ini b/conf/locale/locale_de-DE.ini index 97ca5efd0..2ac03c298 100644 --- a/conf/locale/locale_de-DE.ini +++ b/conf/locale/locale_de-DE.ini @@ -234,6 +234,11 @@ settings.update_webhook = Webhook aktualisieren settings.update_hook_success = Webhook wurde aktualisiert. settings.delete_webhook = Webhook löschen settings.recent_deliveries = letzte Zustellungen +settings.hook_type = Hook Type +settings.add_slack_hook_desc = Add Slack integration to your repository. +settings.slack_token = Token +settings.slack_domain = Domain +settings.slack_channel = Channel [org] org_name_holder = Name der Organisation From 7b310b1abb416c936e79d07523d6cd580a223cc6 Mon Sep 17 00:00:00 2001 From: Tristan Storch Date: Sun, 31 Aug 2014 19:25:26 +0200 Subject: [PATCH 016/153] German laguage update What has been done: - standardized expressions - shorter and clearer - minor corrections (orthography) --- conf/locale/locale_de-DE.ini | 172 ++++++++++++++++------------------- 1 file changed, 80 insertions(+), 92 deletions(-) diff --git a/conf/locale/locale_de-DE.ini b/conf/locale/locale_de-DE.ini index 2ac03c298..3e9936d6e 100644 --- a/conf/locale/locale_de-DE.ini +++ b/conf/locale/locale_de-DE.ini @@ -28,7 +28,7 @@ new_repo = Neues Repository new_migrate = Neue Migration new_org = Neue Organisation manage_org = Organisationen verwalten -admin_panel = Admin Panel +admin_panel = Admin-Panel account_settings = Kontoeinstellungen settings = Einstellungen @@ -50,20 +50,20 @@ my_mirrors = Meine Spiegel [auth] create_new_account = Neues Konto erstellen register_hepler_msg = Du hast schon ein Konto? Jetzt anmelden! -social_register_hepler_msg = Du hast schon ein Konto? Jetzt verknüpfen! +social_register_hepler_msg = Du hast schon ein soziales Konto? Jetzt verknüpfen! disable_register_prompt = Es tut uns leid, die Registrierung wurde deaktiviert. Bitte wende dich an den Administrator. disable_register_mail = Es tut uns leid, die Bestätigung der Registrierungs-E-Mail wurde deaktiviert. remember_me = angemeldet bleiben forgot_password= Passwort vergessen forget_password = Passwort vergessen? sign_up_now = Du willst ein Konto? Jetzt registrieren! -confirmation_mail_sent_prompt = A new confirmation e-mail has been sent to %s, please check your inbox within the next %d hours to complete your registration. +confirmation_mail_sent_prompt = Eine neu Bestätigungs-E-Mail wurde an %s gesendet. Kontrolliere dein Postfach innerhalb der nächsten %d Stunden um die Registrierung abzuschließen. sign_in_email = Melden dich mit deiner E-Mail-Adresse an active_your_account = Aktivieren dein Konto -resent_limit_prompt = Sorry, you are sending an activation e-mail too frequently. Please wait 3 minutes. -has_unconfirmed_mail = Hi %s, you have an unconfirmed email address(%s). If you haven't received a confirmation e-mail or need to resend a new one, please click on the button below. -resend_mail = Klicke hier, um deine Aktivierungs-E-Mail nochmal zu senden -email_not_associate = Diese E-Mail-Adresse ist mit keinen Konto verknüpft. +resent_limit_prompt = Es tut uns leid, du sendest zu häufig Aktivierungs-E-Mails. Bitte warte 3 Minuten. +has_unconfirmed_mail = Hallo %s, du hast eine unbestätigte E-Mail-Adresse (%s). Falls du noch keine Bestätigungs-E-Mail erhalten hast oder eine neue senden musst, klicke auf den unteren Button. +resend_mail = Hier klicken, um deine Aktivierungs-E-Mail erneut zu versenden +email_not_associate = Diese E-Mail-Adresse ist mit keinem Konto verknüpft. send_reset_mail = Hier klicken, um die E-Mail zum Passwort-zurücksetzen erneut zu versenden reset_password = Passwort zurücksetzen invalid_code = Es tut uns leid, der Bestätigungscode ist abgelaufen oder ungültig. @@ -72,13 +72,13 @@ password_too_short = Das Passwort muss mindenstens 6 Zeichen lang sein [form] UserName = Benutzername -RepoName = Repository Name +RepoName = Repository-Name Email = E-Mail-Adresse Password = Passwort Retype = Passwort erneut eingeben SSHTitle = SSH-Schlüsselname HttpsUrl = HTTPS-URL -PayloadUrl = Payload URL +PayloadUrl = Payload-URL TeamName = Teamname AuthName = Authentifizierungsname @@ -94,19 +94,19 @@ captcha_incorrect = Captcha stimmt nicht überein. password_not_match = Die Passwörter stimmen nicht überein. username_been_taken = Benutzername ist bereits vergeben. -repo_name_been_taken = Repository Name ist bereits vergeben. +repo_name_been_taken = Repository-Name ist bereits vergeben. org_name_been_taken = Organisationsname ist bereits vergeben. team_name_been_taken = Teamname ist bereits vergeben. email_been_used = E-Mail-Adresse wird bereits verwendet. ssh_key_been_used = SSH-Schlüsselname wird bereits verwendet. -illegal_username = Ihr Benutzername enthält ungültige Zeichen. +illegal_username = Benutzername enthält ungültige Zeichen. illegal_repo_name = Repository-Name enthält ungültige Zeichen. illegal_org_name = Organisationsname enthält ungültige Zeichen. illegal_team_name = Teamname enthält ungültige Zeichen. username_password_incorrect = Benutzername oder Passwort ist nicht korrekt. -enterred_invalid_repo_name = Bitte stellen Sie sicher, dass der eingegeben Repository-Name richtig ist. -enterred_invalid_owner_name = Bitte stellen Sie sicher, dass der eingegeben Besitzername richtig ist. -enterred_invalid_password = Bitte stellen Sie sicher, dass das eingegebene Passwort richtig ist. +enterred_invalid_repo_name = Bitte stelle sicher, dass der eingegeben Repository-Name richtig ist. +enterred_invalid_owner_name = Bitte stelle sicher, dass der eingegeben Besitzername richtig ist. +enterred_invalid_password = Bitte stelle sicher, dass das eingegebene Passwort richtig ist. user_not_exist = Angegebener Benutzer existiert nicht. last_org_owner = Der zu entfernende Benutzer ist der letzte Teambesitzer. Es muss einen anderen Besitzer geben. @@ -127,40 +127,40 @@ orgs = Organisationen delete = Konto löschen public_profile = Öffentliches Profil -profile_desc = Your Email address is public and will be used for any account related notifications, and any web based operations made via the site. +profile_desc = Deine E-Mail-Adresse wird nicht veröffentlicht und dient dazu, dir Benachrichtigungen bezüglich deines Kontos und deiner Repositorys zu schicken. full_name = Vollständiger Name website = Webseite location = Standort update_profile = Profil aktualisieren -update_profile_success = Dein Profil wurde aktualisiert. +update_profile_success = Profil aktualisiert change_password = Passwort ändern old_password = Aktuelles Passwort new_password = Neues Passwort password_incorrect = Aktuelles Passwort ist nicht korrekt. -change_password_success = Passwort erfolgreich geändert. Du kannst dich jetzt mit dem neuen Passwort anmelden. +change_password_success = Passwort geändert. Du kannst dich jetzt mit dem neuen Passwort anmelden. manage_ssh_keys = SSH-Schlüssel verwalten add_key = SSH-Schlüssel hinzufügen -ssh_desc = Dies ist eine Liste aller SSH-Schlüssel, die mit deinem Konto verküpft sind. Entferne alle Schlüssel, die du nicht kennst. -ssh_helper = Du brauchst Hilfe? Hier ist eine Anleitung zum Erzeugen von SSH-Schlüssel oder Problemlösung einfacher SSH-Probleme. +ssh_desc = Dies ist eine Liste aller SSH-Schlüssel, die mit deinem Konto verknüpft sind. Entferne alle Schlüssel, die du nicht kennst. +ssh_helper = Du brauchst Hilfe? Hier ist eine Anleitung zum Erzeugen von SSH-Schlüsseln oder Problemlösen einfacher SSH-Probleme. add_new_key = SSH-Schlüssel hinzufügen key_name = Schlüsselname key_content = Inhalt -add_key_success = SSH-Schlüssel wurde hinzugefügt! +add_key_success = SSH-Schlüssel hinzugefügt delete_key = SSH-Schlüssel löschen add_on = Hinzugefügt am last_used = Zuletzt verwendet auf no_activity = Keine neuen Aktivitäten -manage_social = Verküpfte soziale Konten verwalten -social_desc = Dies ist eine Liste verküpfter sozialer Konten. Entferne alle Verküpfungen, die du nicht kennst. +manage_social = Verknüpfte soziale Konten verwalten +social_desc = Dies ist eine Liste verknüpfter sozialer Konten. Entferne alle Verknüpfungen, die du nicht kennst. unbind = Verknüpfung entfernen unbind_success = Die Verknüpfung zum sozialen Konto wurde entfernt. delete_account = Konto löschen delete_prompt = Diese Aktion wird dein Konto dauerhaft löschen und kann NICHT rückgängig gemacht werden! -confirm_delete_account = Löschen bestätigen +confirm_delete_account = Löschen [repo] owner = Besitzer @@ -172,13 +172,14 @@ repo_desc = Beschreibung repo_lang = Sprache repo_lang_helper = Wähle eine .gitignore Datei license = Lizenz -license_helper = Wählen Sie eine Lizenz aus +license_helper = Wähle eine Lizenz aus init_readme = Repository mit README.md initialisieren create_repo = Repository erstellen default_branch = Standard-Branch mirror_interval = Spiegel-Intervall (in Stunden) goget_meta = Go-Get Meta goget_meta_helper = This repository will be Go-Getable +goget_meta_helper = Dieses Repository wird man mit go get klonen können. need_auth = Authorisierung benötigt migrate_type = Migrationstyp @@ -194,44 +195,44 @@ star = Markierung fork = Abspaltung quick_guide = Kurzanleitung -clone_this_repo = Dieses Repositorie klonen -create_new_repo_command = Erstellen Sie ein neues Repositorie mittels der Kommandozeile +clone_this_repo = Dieses Repository klonen +create_new_repo_command = Erstelle ein neues Repository mittels der Kommandozeile push_exist_repo = Push an existing repository from the command line settings = Einstellungen settings.options = Optionen settings.collaboration = Zusammenarbeit settings.hooks = Webhooks -settings.deploy_keys = Schlüssel bereitstellen +settings.deploy_keys = Deploy-Keys settings.basic_settings = Grundeinstellungen settings.danger_zone = Gefahrenzone -settings.site = Offizielle Website +settings.site = Offizielle Webseite settings.update_settings = Aktualisierungseinstellungen settings.transfer = Besitz übertragen settings.transfer_desc = Übertrage dieses Repository einem anderen Benutzer oder einer Organisation. settings.delete = Repository löschen settings.delete_desc = Wenn dieses Repository gelöschet ist, gibt es keinen Weg zurück. Sei dir sicher! -settings.update_settings_success = Repository-Optionen wurde erfolgreich aktualisiert. +settings.update_settings_success = Repository-Optionen aktualisiert settings.transfer_owner = Neuer Besitzer settings.make_transfer = übertragen -settings.confirm_delete = Löschen bestätigen -settings.add_collaborator = Neuen Mitarbeiter hinzufügen -settings.add_collaborator_success = Neuer Mitarbeiter wurde hinzugefügt. -settings.remove_collaborator_success = Mitarbeiter wurde entfernt. +settings.confirm_delete = Löschen +settings.add_collaborator = Mitarbeiter hinzufügen +settings.add_collaborator_success = Mitarbeiter hinzugefügt +settings.remove_collaborator_success = Mitarbeiter entfernt settings.add_webhook = Webhook hinzufügen settings.hooks_desc = Webhooks erlauben es externe Dienste zu informieren, wenn etwas bestimmtes in deinem Repository passiert. GoGS sendet dann eine POST-Request an alle angegebenen URLs. Erfahre mehr in unserem Webhooks Guide. -settings.remove_hook_success = Webhook wurde entfernt. +settings.remove_hook_success = Webhook entfernt settings.add_webhook_desc = GoGS sendet einen POST-Request an die unten stehende URL mit Details aller abonierten Ereignisse. Du kannst auch angeben, welches Datenformat du erhalten willst (JSON, x-www-form-urlencoded, etc). Mehr Informationen findest du im Webhooks Guide. -settings.payload_url = Payload URL +settings.payload_url = Payload-URL settings.content_type = Inhaltstyp -settings.secret = Geheimnis +settings.secret = Secret settings.event_desc = Welche Ereignisse sollen diesen Webhook auslösen? settings.event_push_only = Nur das push-Ereignis. settings.active = Aktiv settings.active_helper = Ereignisdetails werden ausgeliefert, wenn dieser Webhook ausgelöst wird. -settings.add_hook_success = Neuer Webhook wurde hinzugefügt. +settings.add_hook_success = Webhook hinzugefügt settings.update_webhook = Webhook aktualisieren -settings.update_hook_success = Webhook wurde aktualisiert. +settings.update_hook_success = Webhook aktualisiert settings.delete_webhook = Webhook löschen settings.recent_deliveries = letzte Zustellungen settings.hook_type = Hook Type @@ -247,7 +248,7 @@ org_email_helper = Das E-Mail-Konto der Organisation empfängt alle Benachrichti create_org = Organisation erstellen repo_updated = Aktualisiert people = Personen -invite_someone = Jemanden einladen +invite_someone = Benutzer einladen teams = Teams lower_members = Mitglieder lower_repositories = Repositorys @@ -255,8 +256,8 @@ create_new_team = Neues Team erstellen org_desc = Beschreibung team_name = Teamname team_desc = Beschreibung -team_name_helper = Sie werden diesen Namen verwenden, um dieses Team in Gesprächen zu erwähnen. -team_desc_helper = Was hat das Team auf sich? +team_name_helper = Verwende diesen Namen, um dich auf dieses Team zu beziehen. +team_desc_helper = Was hat es mit diesem Team auf sich? team_permission_desc = Welche Berechtigungsstufe soll das Team haben? settings = Einstellungen @@ -265,11 +266,11 @@ settings.full_name = Vollständiger Name settings.website = Webseite settings.location = Standort settings.update_settings = Aktualisierungseinstellungen -settings.update_setting_success = Einstellungen der Organisation wurden aktualisiert. +settings.update_setting_success = Organisationseinstellungen aktualisiert settings.delete = Organisation löschen settings.delete_account = Diese Organisation löschen settings.delete_prompt = Die Organisation wird dauerhaft gelöscht. Dies kann NICHT rückgängig gemacht werden! -settings.confirm_delete_account = Löschen bestätigen +settings.confirm_delete_account = Löschen members.public = Öffentlich members.public_helper = Privat machen @@ -302,7 +303,7 @@ teams.delete_team_success = Team gelöscht teams.read_permission_desc = Dieses Team erlaubt Lesezugriff: Mitglieder können Team-Repositorys einsehen und klonen. teams.write_permission_desc = Dieses Team erlaubt Schreibzugriff: Mitglieder können Team-Repositorys einsehen und hinein pushen. teams.admin_permission_desc = Diese Team erlaubt Adminzugriff: Mitglieder dieses Teams können pullen, pushen und dem Team Mitarbeiter hinzufügen. -teams.repositories = Team Repositorys +teams.repositories = Team-Repositorys teams.add_team_repository = Team-Repository hinzufügen teams.remove_repo = Entfernen @@ -324,8 +325,8 @@ dashboard.statistic_info = GoGS Datenbank hat %d Benutzer, %d Orga dashboard.operation_name = Operation Name dashboard.operation_switch = Switch dashboard.operation_run = Ausführen -dashboard.clean_unbind_oauth = ungebundene OAuthes bereinigen -dashboard.delete_inactivate_accounts = inaktiven Konten löschen +dashboard.clean_unbind_oauth = ungebundene OAuths bereinigen +dashboard.delete_inactivate_accounts = inaktive Konten löschen dashboard.server_uptime = Server-Uptime dashboard.current_goroutine = Aktuelle Goroutines dashboard.current_memory_usage = Aktuelle Speichernutzung @@ -337,7 +338,7 @@ dashboard.memory_free_times = Memory Free Times dashboard.current_heap_usage = Aktuelle Heap-Auslastung dashboard.heap_memory_obtained = erhaltener Heap-Memory dashboard.heap_memory_idle = unbenutzter Heap-Memory -dashboard.heap_memory_in_use = benutzer Heap-Memory +dashboard.heap_memory_in_use = benutzter Heap-Memory dashboard.heap_memory_released = freigegebener Heap-Memory dashboard.heap_objects = Heap-Objekte dashboard.bootstrap_stack_usage = Bootstrap-Stack-Auslastung @@ -348,26 +349,26 @@ dashboard.mcache_structures_usage = MCache-Structures-Auslastung dashboard.mcache_structures_obtained = erhaltene MCache-Structures dashboard.profiling_bucket_hash_table_obtained = Profiling Bucket Hash Table Obtained dashboard.gc_metadata_obtained = erhaltene GC-Metadata -dashboard.other_system_allocation_obtained = andere erhaltene Sustem-Allokatoren +dashboard.other_system_allocation_obtained = andere erhaltene System-Allokatoren dashboard.next_gc_recycle = nächster GC-Zyklus -dashboard.last_gc_time = seit leztem GC-Zyklus +dashboard.last_gc_time = seit letztem GC-Zyklus dashboard.total_gc_time = gesammte GC-Zeit dashboard.total_gc_pause = gesammte GC-Pause dashboard.last_gc_pause = letzte GC-Pause dashboard.gc_times = GC-Takt -users.user_manage_panel = Benutzerverwaltung +users.user_manage_panel = Benutzer users.new_account = Neues Konto erstellen users.name = Name users.activated = Aktiviert users.admin = Admin -users.repos = Repos +users.repos = Repositorys users.created = Erzeugt users.edit = Bearbeiten users.auth_source = Auth-Quelle users.local = Lokal users.auth_login_name = Auth-Login-Name -users.update_profile_success = Kontoprofil wurde erfolgreich aktualisiert. +users.update_profile_success = Kontoprofil aktualisiert users.edit_account = Konto bearbeiten users.is_activated = Dieses Konto ist aktiviert users.is_admin = Dieses Konto hat Administratorrechte @@ -380,7 +381,7 @@ orgs.name = Name orgs.teams = Teams orgs.members = Mitglieder -repos.repo_manage_panel = Repositoryverwaltung +repos.repo_manage_panel = Repositorys repos.owner = Besitzer repos.name = Name repos.private = Privat @@ -388,12 +389,12 @@ repos.watches = Watches repos.stars = Stars repos.issues = Issues -auths.auth_manage_panel = Authentifizierungsverwaltung +auths.auth_manage_panel = Authentifizierung auths.new = Neu Authentifizierungsquelle hinzufügen auths.name = Name auths.type = Typ -auths.enabled = Aktiviert -auths.updated = Aktualisiert +auths.enabled = aktiviert +auths.updated = aktualisiert auths.auth_type = Authentifizierungstyp auths.auth_name = Authentifizierungsname auths.domain = Domain @@ -403,15 +404,15 @@ auths.base_dn = Base DN auths.attributes = Suchattribute auths.filter = Suchfilter auths.ms_ad_sa = Ms Ad SA -auths.smtp_auth = SMTP Authentifizierungstyp -auths.smtphost = SMTP Host -auths.smtpport = SMTP Port +auths.smtp_auth = SMTP-Authentifizierungstyp +auths.smtphost = SMTP-Host +auths.smtpport = SMTP-Port auths.enable_tls = TLS-Verschlüsselung aktivieren auths.enable_auto_register = Automatische Registrierung aktivieren auths.tips = Tipps auths.edit = Authentifizierungseinstellungen bearbeiten auths.activated = Diese Authentifizierung ist aktiviert -auths.update_success = Authentifizierungseinstellungen wurde erfolgreich aktualisiert. +auths.update_success = Authentifizierungseinstellungen aktualisiert auths.update = Authentifizierungseinstellungen aktualisieren auths.delete = Authentifizierung löschen @@ -438,15 +439,15 @@ config.db_ssl_mode = SSL-Modus config.db_ssl_mode_helper = (nur für "postgres") config.db_path = Verzeichnis config.db_path_helper = (nur für "sqlite3") -config.service_config = Service Einstellungen -config.register_email_confirm = E-Mail Bestätigung bei Registrierung +config.service_config = Service-Einstellungen +config.register_email_confirm = E-Mail-Bestätigung bei Registrierung config.disable_register = Registrierung deaktivieren config.require_sign_in_view = Require Sign In View -config.mail_notify = E-Mail Benachrichtigung +config.mail_notify = E-Mail-Benachrichtigung config.enable_cache_avatar = Avatar-Cache aktivieren config.active_code_lives = Active Code Lives config.reset_password_code_lives = Reset Password Code Lives -config.webhook_config = Webhook Einstellungen +config.webhook_config = Webhook-Einstellungen config.task_interval = Task-Intervall config.deliver_timeout = Zeitlimit für Zustellung config.mailer_config = Mailer-Einstellungen @@ -454,28 +455,28 @@ config.mailer_enabled = Aktiviert config.mailer_name = Name config.mailer_host = Host config.mailer_user = Benutzer -config.oauth_config = OAuth Einstellungen +config.oauth_config = OAuth-Einstellungen config.oauth_enabled = Aktiviert -config.cache_config = Cache Einstellungen -config.cache_adapter = Cache Adapter -config.cache_interval = Cache Intervall -config.cache_conn = Cache Anbindung -config.session_config = Session Einstellungen -config.session_provider = Session Provider -config.provider_config = Provider Einstellungen -config.cookie_name = Cookie Name +config.cache_config = Cache-Einstellungen +config.cache_adapter = Cache-Adapter +config.cache_interval = Cache-Intervall +config.cache_conn = Cache-Anbindung +config.session_config = Session-Einstellungen +config.session_provider = Session-Provider +config.provider_config = Provider-Einstellungen +config.cookie_name = Cookie-Name config.enable_set_cookie = Enable Set Cookie config.gc_interval_time = GC-Intervallzeit -config.session_life_time = Session Lebensdauer +config.session_life_time = Session-Lebensdauer config.https_only = nur HTTPS -config.cookie_life_time = Cookie Lebensdauer -config.session_hash_function = Session-ID Hashfunktion -config.session_hash_key = Session-ID Hashschlüssel +config.cookie_life_time = Cookie-Lebensdauer +config.session_hash_function = Session-ID-Hashfunktion +config.session_hash_key = Session-ID-Hashschlüssel config.picture_config = Bildeinstellungen config.picture_service = Bildservice config.disable_gravatar = Gravatar deaktivieren -config.log_config = Log Einstellungen -config.log_mode = Log Modus +config.log_config = Log-Einstellungen +config.log_mode = Log-Modus monitor.cron = Cron-Tasks monitor.name = Name @@ -514,16 +515,3 @@ months = %d Monate %s years = %d Jahre %s raw_seconds = Sekunden raw_minutes = Minuten - - - - - - - - - - - - - From d1a2228f1cc1b0bec7023d226077e4002c07112a Mon Sep 17 00:00:00 2001 From: Tristan Storch Date: Fri, 29 Aug 2014 18:20:15 +0200 Subject: [PATCH 017/153] Docker mix and match setup Rewrite of the docker setup. Now uses fig to manage containers and container linkage. The base is a block based mix and match, which will give you the possibility to easily test all configurations. --- docker/README.md | 89 ++++++++++++++++++++++ docker/assemble_blocks.sh | 72 +++++++++++++++++ docker/blocks/docker_gogs/Dockerfile | 52 +++++++++++++ docker/blocks/docker_gogs_dev/Dockerfile | 52 +++++++++++++ docker/blocks/option_cache_memcache/config | 3 + docker/blocks/option_cache_memcache/fig | 2 + docker/blocks/option_cache_redis/config | 3 + docker/blocks/option_cache_redis/fig | 2 + docker/blocks/option_db_mysql/config | 6 ++ docker/blocks/option_db_mysql/fig | 7 ++ docker/blocks/option_db_postgresql/config | 6 ++ docker/blocks/option_db_postgresql/fig | 6 ++ docker/blocks/option_session_mysql/config | 3 + docker/blocks/option_session_mysql/fig | 7 ++ docker/blocks/w_cache/fig | 6 ++ docker/blocks/w_cache_session/fig | 7 ++ docker/blocks/w_db/fig | 6 ++ docker/blocks/w_db_cache/fig | 7 ++ docker/blocks/w_db_cache_session/fig | 8 ++ docker/blocks/w_db_session/fig | 7 ++ docker/blocks/w_none/fig | 4 + docker/blocks/w_session/fig | 6 ++ docker/docker/.gitkeep | 0 docker/templates/init_gogs.sh.tpl | 12 +++ dockerfiles/README.md | 40 ---------- 25 files changed, 373 insertions(+), 40 deletions(-) create mode 100644 docker/README.md create mode 100755 docker/assemble_blocks.sh create mode 100644 docker/blocks/docker_gogs/Dockerfile create mode 100644 docker/blocks/docker_gogs_dev/Dockerfile create mode 100644 docker/blocks/option_cache_memcache/config create mode 100644 docker/blocks/option_cache_memcache/fig create mode 100644 docker/blocks/option_cache_redis/config create mode 100644 docker/blocks/option_cache_redis/fig create mode 100644 docker/blocks/option_db_mysql/config create mode 100644 docker/blocks/option_db_mysql/fig create mode 100644 docker/blocks/option_db_postgresql/config create mode 100644 docker/blocks/option_db_postgresql/fig create mode 100644 docker/blocks/option_session_mysql/config create mode 100644 docker/blocks/option_session_mysql/fig create mode 100644 docker/blocks/w_cache/fig create mode 100644 docker/blocks/w_cache_session/fig create mode 100644 docker/blocks/w_db/fig create mode 100644 docker/blocks/w_db_cache/fig create mode 100644 docker/blocks/w_db_cache_session/fig create mode 100644 docker/blocks/w_db_session/fig create mode 100644 docker/blocks/w_none/fig create mode 100644 docker/blocks/w_session/fig create mode 100644 docker/docker/.gitkeep create mode 100644 docker/templates/init_gogs.sh.tpl delete mode 100644 dockerfiles/README.md diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 000000000..448912009 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,89 @@ +Docker +====== + +TOOLS ARE WRITTEN FOR TESTING AND TO SEE WHAT IT IS! + +For this to work you will need the nifty docker tool [fig]. + +The most simple setup will look like this: + +```sh +./assemble_blocks.sh docker_gogs w_db option_db_mysql +fig up + +``` + +That's it. You have GoGS running in docker linked to a MySQL docker container. + +Now visit http://localhost:3000/ and give details for the admin account an you're up and running. + + +How does it work +---------------- + +`./assemble_blocks.sh` will look in `blocks` for subdirectories. +In the subdirectories there are three relevant files: `Dockerfile`, `config` and `fig`. + +`Dockerfile` will be copied to `docker/` (also means last `Dockerfile` wins). + +The `config` file contains lines which will in the gogs docker container end up in `$GOGS_PATH/custom/config/app.ini` and by this gogs will be configured. +Here you can define things like the MySQL server for your database block. + +The `fig` file will just be added to `fig.yml`, which is used by fig to manage your containers. +This inculdes container linking! + +Just have a look at them and it will be clear how to write your own blocks. + +Just some things + + - all files (`Dockerfile`, `fig` and `config`) are optional + - the gogs block should always be the first block + +Currently the blocks are designed that, the blocks that start with `docker` pull in the base docker image. +Then one block starting with `w` defines, what containers should be linked to the gogs container. +For every option in the `w` block you need to add an `option` container. + +Example: + +```sh +./assemble_blocks.sh docker_gogs w_db_cache option_db_mysql option_cache_redis +``` + + +More sophisticated Example +-------------------------- + +Her is a more elaborated example + +```sh +./assemble_blocks.sh docker_gogs w_db_cache_session option_db_postgresql option_cache_redis option_session_mysql +fig up +``` + +This will set up four containters and link them proberly. One for each of + + - gogs + - database (postgresql) + - cache (redis) + - session (mysql) + +WARNING: This will not work at the Moment! MySQL session is broken! + + +Remark +------ + +After you execute `assemble_blocks.sh` you should always trigger `fig build` to inculde the the new init script `init_gogs.sh` in the docker image. + +If you want to use another GoGS docker file, but keep everything else the same, you can create a block, e.g. `docker_gogs_custom`, with only a `Dockerfile` and call + +```sh +./assemble_blocks.sh docker_gogs_custom w_db option_database_mysql +``` + +This will pull in the `Dockerfile` from `docker_gogs` instead of the one from `docker_gogs`. + +`Dockerfile`s for the `master` and `dev` branch are provided as `docker_gogs` and `docker_gogs_dev` + + +[fig]:http://www.fig.sh/ \ No newline at end of file diff --git a/docker/assemble_blocks.sh b/docker/assemble_blocks.sh new file mode 100755 index 000000000..852064de2 --- /dev/null +++ b/docker/assemble_blocks.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +blocks_dir=blocks +docker_dir=docker +template_dir=templates + +docker_file=Dockerfile + +gogs_config_file=conf.tmp +gogs_config=config +gogs_init_file=$docker_dir/init_gogs.sh + +fig_file=fig.yml +fig_config=fig + +gogs_init_template=$template_dir/init_gogs.sh.tpl + +if [ "$#" == 0 ]; then + blocks=`ls $blocks_dir` + if [ -z "$blocks" ]; then + echo "No Blocks available in $blocks_dir" + else + echo "Available Blocks:" + for block in $blocks; do + echo " $block" + done + fi + exit 0 +fi + +for file in $gogs_config_file $fig_file; do + if [ -e $file ]; then + echo "Deleting $file" + rm $file + fi +done + +for dir in $@; do + current_dir=$blocks_dir/$dir + if [ ! -d "$current_dir" ]; then + echo "$current_dir is not a directory" + exit 1 + fi + + if [ -e $current_dir/$docker_file ]; then + echo "Copying $current_dir/$docker_file to $docker_dir/$docker_file" + cp $current_dir/$docker_file $docker_dir/$docker_file + fi + + if [ -e $current_dir/$gogs_config ]; then + echo "Adding $current_dir/$gogs_config to $gogs_config_file" + cat $current_dir/$gogs_config >> $gogs_config_file + echo "" >> $gogs_config_file + fi + + if [ -e $current_dir/$fig_config ]; then + echo "Adding $current_dir/$fig_config to $fig_file" + cat $current_dir/fig >> $fig_file + echo "" >> $fig_file + fi +done + +echo "Creating $gogs_init_file" +sed "/{{ CONFIG }}/{ +r $gogs_config_file +d +}" $gogs_init_template > $gogs_init_file + +if [ -e $gogs_config_file ]; then + echo "Removing temporary GoGS config" + rm $gogs_config_file +fi \ No newline at end of file diff --git a/docker/blocks/docker_gogs/Dockerfile b/docker/blocks/docker_gogs/Dockerfile new file mode 100644 index 000000000..e2e056ae0 --- /dev/null +++ b/docker/blocks/docker_gogs/Dockerfile @@ -0,0 +1,52 @@ +FROM ubuntu:14.04 + +# This part is taken from the official docker image -------------------- + +RUN apt-get update && apt-get install -y \ + build-essential ca-certificates curl \ + bzr git mercurial \ + --no-install-recommends + +ENV GOLANG_VERSION 1.3 + +RUN curl -sSL http://golang.org/dl/go$GOLANG_VERSION.src.tar.gz \ + | tar -v -C /usr/src -xz +WORKDIR /usr/src/go + +RUN cd src && ./make.bash --no-clean 2>&1 + +ENV PATH /usr/src/go/bin:$PATH + +RUN mkdir -p /go/src +ENV GOPATH /go +ENV PATH /go/bin:$PATH +WORKDIR /go + +# ---------------------------------------------------------------------- + + +RUN useradd -m git + +ENV GOGS_PATH $GOPATH/src/github.com/gogits/gogs +ENV GOGS_CUSTOM_CONF_PATH $GOGS_PATH/custom/conf +ENV GOGS_CUSTOM_CONF $GOGS_CUSTOM_CONF_PATH/app.ini + +RUN go get -u -d github.com/gogits/gogs +# WORKDIR $GOGS_PATH +WORKDIR /go/src/github.com/gogits/gogs +RUN go build github.com/gogits/gogs +RUN chown -R git $GOGS_PATH + +ADD init_gogs.sh /tmp/ +RUN chown git /tmp/init_gogs.sh +RUN chmod +x /tmp/init_gogs.sh + +USER git +ENV HOME /home/git +ENV USER git +ENV PATH $GOGS_PATH:$PATH + +RUN git config --global user.name "GoGS" + +ENTRYPOINT ["/tmp/init_gogs.sh"] +CMD ["gogs", "web"] diff --git a/docker/blocks/docker_gogs_dev/Dockerfile b/docker/blocks/docker_gogs_dev/Dockerfile new file mode 100644 index 000000000..1c001e2c0 --- /dev/null +++ b/docker/blocks/docker_gogs_dev/Dockerfile @@ -0,0 +1,52 @@ +FROM ubuntu:14.04 + +# This part is taken from the official docker image -------------------- + +RUN apt-get update && apt-get install -y \ + build-essential ca-certificates curl \ + bzr git mercurial \ + --no-install-recommends + +ENV GOLANG_VERSION 1.3 + +RUN curl -sSL http://golang.org/dl/go$GOLANG_VERSION.src.tar.gz \ + | tar -v -C /usr/src -xz +WORKDIR /usr/src/go + +RUN cd src && ./make.bash --no-clean 2>&1 + +ENV PATH /usr/src/go/bin:$PATH + +RUN mkdir -p /go/src +ENV GOPATH /go +ENV PATH /go/bin:$PATH +WORKDIR /go + +# ---------------------------------------------------------------------- + + +RUN useradd -m git + +ENV GOGS_PATH $GOPATH/src/github.com/gogits/gogs +ENV GOGS_CUSTOM_CONF_PATH $GOGS_PATH/custom/conf +ENV GOGS_CUSTOM_CONF $GOGS_CUSTOM_CONF_PATH/app.ini + +RUN go get -u -d github.com/gogits/gogs +# WORKDIR $GOGS_PATH +WORKDIR /go/src/github.com/gogits/gogs +RUN git checkout dev; go get -u; git checkout dev; go build +RUN chown -R git $GOGS_PATH + +ADD init_gogs.sh /tmp/ +RUN chown git /tmp/init_gogs.sh +RUN chmod +x /tmp/init_gogs.sh + +USER git +ENV HOME /home/git +ENV USER git +ENV PATH $GOGS_PATH:$PATH + +RUN git config --global user.name "GoGS" + +ENTRYPOINT ["/tmp/init_gogs.sh"] +CMD ["gogs", "web"] diff --git a/docker/blocks/option_cache_memcache/config b/docker/blocks/option_cache_memcache/config new file mode 100644 index 000000000..daca6f3ef --- /dev/null +++ b/docker/blocks/option_cache_memcache/config @@ -0,0 +1,3 @@ +[cache] +DB_TYPE = memcache +HOST = HOST = ${CACHE_1_PORT_11211_TCP_ADDR}:${CACHE_1_PORT_11211_TCP_PORT} diff --git a/docker/blocks/option_cache_memcache/fig b/docker/blocks/option_cache_memcache/fig new file mode 100644 index 000000000..80d0215cc --- /dev/null +++ b/docker/blocks/option_cache_memcache/fig @@ -0,0 +1,2 @@ +cache: + image: sylvainlasnier/memcached:latest diff --git a/docker/blocks/option_cache_redis/config b/docker/blocks/option_cache_redis/config new file mode 100644 index 000000000..648f4f380 --- /dev/null +++ b/docker/blocks/option_cache_redis/config @@ -0,0 +1,3 @@ +[cache] +DB_TYPE = redis +HOST = ${CACHE_1_PORT_6379_TCP_ADDR}:${CACHE_1_PORT_6379_TCP_PORT} diff --git a/docker/blocks/option_cache_redis/fig b/docker/blocks/option_cache_redis/fig new file mode 100644 index 000000000..0e74bc4ae --- /dev/null +++ b/docker/blocks/option_cache_redis/fig @@ -0,0 +1,2 @@ +cache: + image: redis:latest diff --git a/docker/blocks/option_db_mysql/config b/docker/blocks/option_db_mysql/config new file mode 100644 index 000000000..53f8949d9 --- /dev/null +++ b/docker/blocks/option_db_mysql/config @@ -0,0 +1,6 @@ +[database] +DB_TYPE = mysql +HOST = ${DB_1_PORT_3306_TCP_ADDR}:${DB_1_PORT_3306_TCP_PORT} +NAME = ${DB_1_ENV_MYSQL_DATABASE} +USER = ${DB_1_ENV_MYSQL_USER} +PASSWD = ${DB_1_ENV_MYSQL_PASSWORD} diff --git a/docker/blocks/option_db_mysql/fig b/docker/blocks/option_db_mysql/fig new file mode 100644 index 000000000..a005a0593 --- /dev/null +++ b/docker/blocks/option_db_mysql/fig @@ -0,0 +1,7 @@ +db: + image: mysql:latest + environment: + MYSQL_ROOT_PASSWORD: rootpass + MYSQL_DATABASE: gogs + MYSQL_USER: gogs + MYSQL_PASSWORD: password diff --git a/docker/blocks/option_db_postgresql/config b/docker/blocks/option_db_postgresql/config new file mode 100644 index 000000000..e5946b06d --- /dev/null +++ b/docker/blocks/option_db_postgresql/config @@ -0,0 +1,6 @@ +[database] +DB_TYPE = postgres +HOST = ${DB_1_PORT_5432_TCP_ADDR}:${DB_1_PORT_5432_TCP_PORT} +NAME = ${DB_1_ENV_POSTGRESQL_DB} +USER = ${DB_1_ENV_POSTGRESQL_USER} +PASSWD = ${DB_1_ENV_POSTGRESQL_PASS} diff --git a/docker/blocks/option_db_postgresql/fig b/docker/blocks/option_db_postgresql/fig new file mode 100644 index 000000000..c839e9044 --- /dev/null +++ b/docker/blocks/option_db_postgresql/fig @@ -0,0 +1,6 @@ +db: + image: wyaeld/postgres:9.3 + environment: + POSTGRESQL_DB: gogs + POSTGRESQL_USER: gogs + POSTGRESQL_PASS: password diff --git a/docker/blocks/option_session_mysql/config b/docker/blocks/option_session_mysql/config new file mode 100644 index 000000000..b8bc2cc70 --- /dev/null +++ b/docker/blocks/option_session_mysql/config @@ -0,0 +1,3 @@ +[session] +PROVIDER = mysql +PROVIDER_CONFIG = ${SESSION_1_ENV_MYSQL_USER}:${SESSION_1_ENV_MYSQL_PASSWORD}@SESSION_1_PORT_3306_TCP_PROTO(${SESSION_1_PORT_3306_TCP_ADDR}:${SESSION_1_PORT_3306_TCP_PORT})/${SESSION_1_ENV_MYSQL_DATABASE} diff --git a/docker/blocks/option_session_mysql/fig b/docker/blocks/option_session_mysql/fig new file mode 100644 index 000000000..0e2dbf19c --- /dev/null +++ b/docker/blocks/option_session_mysql/fig @@ -0,0 +1,7 @@ +session: + image: mysql:latest + environment: + MYSQL_ROOT_PASSWORD: rootpass + MYSQL_DATABASE: gogs_session + MYSQL_USER: gogs + MYSQL_PASSWORD: password diff --git a/docker/blocks/w_cache/fig b/docker/blocks/w_cache/fig new file mode 100644 index 000000000..fd66c3578 --- /dev/null +++ b/docker/blocks/w_cache/fig @@ -0,0 +1,6 @@ +gogs: + build: docker + links: + - cache + ports: + - "3000:3000" diff --git a/docker/blocks/w_cache_session/fig b/docker/blocks/w_cache_session/fig new file mode 100644 index 000000000..0f9011406 --- /dev/null +++ b/docker/blocks/w_cache_session/fig @@ -0,0 +1,7 @@ +gogs: + build: docker + links: + - cache + - session + ports: + - "3000:3000" diff --git a/docker/blocks/w_db/fig b/docker/blocks/w_db/fig new file mode 100644 index 000000000..a7e9c1b69 --- /dev/null +++ b/docker/blocks/w_db/fig @@ -0,0 +1,6 @@ +gogs: + build: docker + links: + - db + ports: + - "3000:3000" diff --git a/docker/blocks/w_db_cache/fig b/docker/blocks/w_db_cache/fig new file mode 100644 index 000000000..42402e40f --- /dev/null +++ b/docker/blocks/w_db_cache/fig @@ -0,0 +1,7 @@ +gogs: + build: docker + links: + - db + - cache + ports: + - "3000:3000" diff --git a/docker/blocks/w_db_cache_session/fig b/docker/blocks/w_db_cache_session/fig new file mode 100644 index 000000000..42444405a --- /dev/null +++ b/docker/blocks/w_db_cache_session/fig @@ -0,0 +1,8 @@ +gogs: + build: docker + links: + - db + - cache + - session + ports: + - "3000:3000" diff --git a/docker/blocks/w_db_session/fig b/docker/blocks/w_db_session/fig new file mode 100644 index 000000000..3703c6ba3 --- /dev/null +++ b/docker/blocks/w_db_session/fig @@ -0,0 +1,7 @@ +gogs: + build: docker + links: + - db + - session + ports: + - "3000:3000" diff --git a/docker/blocks/w_none/fig b/docker/blocks/w_none/fig new file mode 100644 index 000000000..c0fed209d --- /dev/null +++ b/docker/blocks/w_none/fig @@ -0,0 +1,4 @@ +gogs: + build: docker + ports: + - "3000:3000" diff --git a/docker/blocks/w_session/fig b/docker/blocks/w_session/fig new file mode 100644 index 000000000..7dda0dde9 --- /dev/null +++ b/docker/blocks/w_session/fig @@ -0,0 +1,6 @@ +gogs: + build: docker + links: + - session + ports: + - "3000:3000" diff --git a/docker/docker/.gitkeep b/docker/docker/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/templates/init_gogs.sh.tpl b/docker/templates/init_gogs.sh.tpl new file mode 100644 index 000000000..26cff4e50 --- /dev/null +++ b/docker/templates/init_gogs.sh.tpl @@ -0,0 +1,12 @@ +#!/bin/sh + +if [ ! -d "$DIRECTORY" ]; then + mkdir -p $GOGS_CUSTOM_CONF_PATH + +echo " +{{ CONFIG }} +" >> $GOGS_CUSTOM_CONF + +fi + +exec "$@" diff --git a/dockerfiles/README.md b/dockerfiles/README.md deleted file mode 100644 index 11d28d0fc..000000000 --- a/dockerfiles/README.md +++ /dev/null @@ -1,40 +0,0 @@ -### Install Gogs With Docker - -Deploying gogs in [Docker](http://www.docker.io/) is just as easy as eating a pie, what you do is just open the `dockerfiles/build.sh` file, replace the configs: - -``` -DB_TYPE="YOUR_DB_TYPE" # type of database, support 'mysql' and 'postgres' -MEM_TYPE="YOUR_MEM_TYPE" # type of memory database, support 'redis' and 'memcache' -DB_PASSWORD="YOUR_DB_PASSWORD" # The database password. -DB_RUN_NAME="YOUR_DB_RUN_NAME" # The --name option value when run the database image. -MEM_RUN_NAME="YOUR_MEM_RUN_NAME" # The --name option value when run the mem database image. -HOST_PORT="YOUR_HOST_PORT" # The port on host, which will be redirected to the port 3000 inside gogs container. -``` - -And run: -``` -cd dockerfiles -./build.sh -``` - -The build might take some time, just be patient. After it finishes, you will receive the message: - -``` -Now we have the MySQL image(running) and gogs image, use the follow command to start gogs service( the content might be different, according to your own configs): - docker run -i -t --link YOUR_DB_RUN_NAME:db --link YOUR_MEM_RUN_NAME:mem -p YOUR_HOST_PORT:3000 gogits/gogs -``` - -Just follow the message, run: - -``` - docker run -i -t --link YOUR_DB_RUN_NAME:db --link YOUR_MEM_RUN_NAME:mem -p YOUR_HOST_PORT:3000 gogits/gogs -``` - -Now we have gogs running! Open the browser and navigate to: - -``` -http://YOUR_HOST_IP:YOUR_HOST_PORT -``` - -Let's 'gogs'! -Ouya~ From 00a864e693434bce687f3f5145d8369583197b78 Mon Sep 17 00:00:00 2001 From: Christopher Brickley Date: Tue, 26 Aug 2014 08:20:18 -0400 Subject: [PATCH 018/153] add commit compare functionality --- cmd/web.go | 1 + models/action.go | 6 ++- models/git_diff.go | 25 ++++++++---- models/slack.go | 14 +++++-- models/update.go | 4 +- models/webhook.go | 13 ++++--- public/css/gogs.css | 7 ++++ routers/repo/commit.go | 65 ++++++++++++++++++++++++++++++- templates/repo/commits.tmpl | 43 +------------------- templates/repo/commits_table.tmpl | 42 ++++++++++++++++++++ templates/repo/diff.tmpl | 15 ++++++- 11 files changed, 169 insertions(+), 66 deletions(-) create mode 100644 templates/repo/commits_table.tmpl diff --git a/cmd/web.go b/cmd/web.go index 275d3fb90..2199d4ca1 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -342,6 +342,7 @@ func runWeb(*cli.Context) { r.Get("/commit/:branchname/*", repo.Diff) r.Get("/releases", repo.Releases) r.Get("/archive/*.*", repo.Download) + r.Get("/compare/:before([a-z0-9]+)...:after([a-z0-9]+)", repo.CompareDiff) }, ignSignIn, middleware.RepoAssignment(true, true)) m.Group("/:username", func(r *macaron.Router) { diff --git a/models/action.go b/models/action.go index d536c84dd..5a8c31697 100644 --- a/models/action.go +++ b/models/action.go @@ -172,7 +172,7 @@ func updateIssuesCommit(userId, repoId int64, repoUserName, repoName string, com // CommitRepoAction adds new action for committing repository. func CommitRepoAction(userId, repoUserId int64, userName, actEmail string, - repoId int64, repoUserName, repoName string, refFullName string, commit *base.PushCommits) error { + repoId int64, repoUserName, repoName string, refFullName string, commit *base.PushCommits, oldCommitId string, newCommitId string) error { opType := COMMIT_REPO // Check it's tag push or branch. @@ -226,6 +226,7 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string, } repoLink := fmt.Sprintf("%s%s/%s", setting.AppUrl, repoUserName, repoName) + compareUrl := fmt.Sprintf("%s/compare/%s...%s", repoLink, oldCommitId, newCommitId) commits := make([]*PayloadCommit, len(commit.Commits)) for i, cmt := range commit.Commits { commits[i] = &PayloadCommit{ @@ -258,6 +259,9 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string, Name: repo.Owner.LowerName, Email: repo.Owner.Email, }, + Before: oldCommitId, + After: newCommitId, + CompareUrl: compareUrl, } for _, w := range ws { diff --git a/models/git_diff.go b/models/git_diff.go index 4b4d1234d..21a624de5 100644 --- a/models/git_diff.go +++ b/models/git_diff.go @@ -175,25 +175,30 @@ func ParsePatch(pid int64, cmd *exec.Cmd, reader io.Reader) (*Diff, error) { return diff, nil } -func GetDiff(repoPath, commitid string) (*Diff, error) { +func GetDiffRange(repoPath, beforeCommitId string, afterCommitId string) (*Diff, error) { repo, err := git.OpenRepository(repoPath) if err != nil { return nil, err } - commit, err := repo.GetCommit(commitid) + commit, err := repo.GetCommit(afterCommitId) if err != nil { return nil, err } rd, wr := io.Pipe() var cmd *exec.Cmd - // First commit of repository. - if commit.ParentCount() == 0 { - cmd = exec.Command("git", "show", commitid) + // if "after" commit given + if beforeCommitId == "" { + // First commit of repository. + if commit.ParentCount() == 0 { + cmd = exec.Command("git", "show", afterCommitId) + } else { + c, _ := commit.Parent(0) + cmd = exec.Command("git", "diff", c.Id.String(), afterCommitId) + } } else { - c, _ := commit.Parent(0) - cmd = exec.Command("git", "diff", c.Id.String(), commitid) + cmd = exec.Command("git", "diff", beforeCommitId, afterCommitId) } cmd.Dir = repoPath cmd.Stdout = wr @@ -208,7 +213,7 @@ func GetDiff(repoPath, commitid string) (*Diff, error) { }() defer rd.Close() - desc := fmt.Sprintf("GetDiff(%s)", repoPath) + desc := fmt.Sprintf("GetDiffRange(%s)", repoPath) pid := process.Add(desc, cmd) go func() { // In case process became zombie. @@ -226,3 +231,7 @@ func GetDiff(repoPath, commitid string) (*Diff, error) { return ParsePatch(pid, cmd, rd) } + +func GetDiffCommit(repoPath, commitId string) (*Diff, error) { + return GetDiffRange(repoPath, "", commitId) +} diff --git a/models/slack.go b/models/slack.go index 0a5574094..714b2f6ca 100644 --- a/models/slack.go +++ b/models/slack.go @@ -70,19 +70,21 @@ func getSlackPushPayload(p *Payload, slack *Slack) (*SlackPayload, error) { branchName := refSplit[len(refSplit)-1] var commitString string - // TODO: add commit compare before/after link when gogs adds it if len(p.Commits) == 1 { commitString = "1 new commit" } else { commitString = fmt.Sprintf("%d new commits", len(p.Commits)) + commitString = SlackLinkFormatter(p.CompareUrl, commitString) } - text := fmt.Sprintf("[%s:%s] %s pushed by %s", p.Repo.Name, branchName, commitString, p.Pusher.Name) + repoLink := SlackLinkFormatter(p.Repo.Url, p.Repo.Name) + branchLink := SlackLinkFormatter(p.Repo.Url+"/src/"+branchName, branchName) + text := fmt.Sprintf("[%s:%s] %s pushed by %s", repoLink, branchLink, commitString, p.Pusher.Name) var attachmentText string // for each commit, generate attachment text for i, commit := range p.Commits { - attachmentText += fmt.Sprintf("<%s|%s>: %s - %s", commit.Url, commit.Id[:7], SlackFormatter(commit.Message), commit.Author.Name) + attachmentText += fmt.Sprintf("%s: %s - %s", SlackLinkFormatter(commit.Url, commit.Id[:7]), SlackTextFormatter(commit.Message), SlackTextFormatter(commit.Author.Name)) // add linebreak to each commit but the last if i < len(p.Commits)-1 { attachmentText += "\n" @@ -103,7 +105,7 @@ func getSlackPushPayload(p *Payload, slack *Slack) (*SlackPayload, error) { } // see: https://api.slack.com/docs/formatting -func SlackFormatter(s string) string { +func SlackTextFormatter(s string) string { // take only first line of commit first := strings.Split(s, "\n")[0] // replace & < > @@ -112,3 +114,7 @@ func SlackFormatter(s string) string { first = strings.Replace(first, ">", ">", -1) return first } + +func SlackLinkFormatter(url string, text string) string { + return fmt.Sprintf("<%s|%s>", url, SlackTextFormatter(text)) +} diff --git a/models/update.go b/models/update.go index 68a92ada1..ec6a97901 100644 --- a/models/update.go +++ b/models/update.go @@ -101,7 +101,7 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName commit := &base.PushCommits{} if err = CommitRepoAction(userId, ru.Id, userName, actEmail, - repos.Id, repoUserName, repoName, refName, commit); err != nil { + repos.Id, repoUserName, repoName, refName, commit, oldCommitId, newCommitId); err != nil { log.GitLogger.Fatal(4, "runUpdate.models.CommitRepoAction: %s/%s:%v", repoUserName, repoName, err) } return err @@ -152,7 +152,7 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName //commits = append(commits, []string{lastCommit.Id().String(), lastCommit.Message()}) if err = CommitRepoAction(userId, ru.Id, userName, actEmail, - repos.Id, repoUserName, repoName, refName, &base.PushCommits{l.Len(), commits}); err != nil { + repos.Id, repoUserName, repoName, refName, &base.PushCommits{l.Len(), commits}, oldCommitId, newCommitId); err != nil { return fmt.Errorf("runUpdate.models.CommitRepoAction: %s/%s:%v", repoUserName, repoName, err) } return nil diff --git a/models/webhook.go b/models/webhook.go index 55ed4844e..0b7b3a994 100644 --- a/models/webhook.go +++ b/models/webhook.go @@ -169,11 +169,14 @@ type BasePayload interface { // Payload represents a payload information of hook. type Payload struct { - Secret string `json:"secret"` - Ref string `json:"ref"` - Commits []*PayloadCommit `json:"commits"` - Repo *PayloadRepo `json:"repository"` - Pusher *PayloadAuthor `json:"pusher"` + Secret string `json:"secret"` + Ref string `json:"ref"` + Commits []*PayloadCommit `json:"commits"` + Repo *PayloadRepo `json:"repository"` + Pusher *PayloadAuthor `json:"pusher"` + Before string `json:"before"` + After string `json:"after"` + CompareUrl string `json:"compare_url"` } func (p Payload) GetJSONPayload() ([]byte, error) { diff --git a/public/css/gogs.css b/public/css/gogs.css index 2d30d0628..0af09a3ec 100755 --- a/public/css/gogs.css +++ b/public/css/gogs.css @@ -968,6 +968,13 @@ body { .guide-box .zclip { left: auto !important; } +div.compare div#commits { + margin-top: 5px; +} +div.compare div#commits h4 { + margin: 10px 0; + line-height: 1.1; +} .diff-head-box h4 { margin-top: 0; margin-bottom: 0; diff --git a/routers/repo/commit.go b/routers/repo/commit.go index 6320123b4..54acc85b3 100644 --- a/routers/repo/commit.go +++ b/routers/repo/commit.go @@ -114,9 +114,9 @@ func Diff(ctx *middleware.Context) { commit := ctx.Repo.Commit - diff, err := models.GetDiff(models.RepoPath(userName, repoName), commitId) + diff, err := models.GetDiffCommit(models.RepoPath(userName, repoName), commitId) if err != nil { - ctx.Handle(404, "GetDiff", err) + ctx.Handle(404, "GetDiffCommit", err) return } @@ -162,6 +162,67 @@ func Diff(ctx *middleware.Context) { ctx.HTML(200, DIFF) } +func CompareDiff(ctx *middleware.Context) { + ctx.Data["IsRepoToolbarCommits"] = true + ctx.Data["IsDiffCompare"] = true + userName := ctx.Repo.Owner.Name + repoName := ctx.Repo.Repository.Name + beforeCommitId := ctx.Params(":before") + afterCommitId := ctx.Params(":after") + + commit, err := ctx.Repo.GitRepo.GetCommit(afterCommitId) + if err != nil { + ctx.Handle(404, "GetCommit", err) + return + } + + diff, err := models.GetDiffRange(models.RepoPath(userName, repoName), beforeCommitId, afterCommitId) + if err != nil { + ctx.Handle(404, "GetDiffRange", err) + return + } + + isImageFile := func(name string) bool { + blob, err := commit.GetBlobByPath(name) + if err != nil { + return false + } + + dataRc, err := blob.Data() + if err != nil { + return false + } + buf := make([]byte, 1024) + n, _ := dataRc.Read(buf) + if n > 0 { + buf = buf[:n] + } + _, isImage := base.IsImageFile(buf) + return isImage + } + + commits, err := commit.CommitsBeforeUntil(beforeCommitId) + if err != nil { + ctx.Handle(500, "CommitsBeforeUntil", err) + return + } + + ctx.Data["Commits"] = commits + ctx.Data["CommitCount"] = commits.Len() + ctx.Data["BeforeCommitId"] = beforeCommitId + ctx.Data["AfterCommitId"] = afterCommitId + ctx.Data["Username"] = userName + ctx.Data["Reponame"] = repoName + ctx.Data["IsImageFile"] = isImageFile + ctx.Data["Title"] = "Comparing " + base.ShortSha(beforeCommitId) + "..." + base.ShortSha(afterCommitId) + " · " + userName + "/" + repoName + ctx.Data["Commit"] = commit + ctx.Data["Diff"] = diff + ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0 + ctx.Data["SourcePath"] = "/" + path.Join(userName, repoName, "src", afterCommitId) + ctx.Data["RawPath"] = "/" + path.Join(userName, repoName, "raw", afterCommitId) + ctx.HTML(200, DIFF) +} + func FileHistory(ctx *middleware.Context) { ctx.Data["IsRepoToolbarCommits"] = true diff --git a/templates/repo/commits.tmpl b/templates/repo/commits.tmpl index 420e973a5..e7518e983 100644 --- a/templates/repo/commits.tmpl +++ b/templates/repo/commits.tmpl @@ -3,47 +3,6 @@ {{template "repo/nav" .}} {{template "repo/toolbar" .}}
    -
    -
    -
    - -
    - -
    - -
    -
    - -

    {{.CommitCount}} Commits

    -
    - - - - - - - - - - - {{ $username := .Username}} - {{ $reponame := .Reponame}} - {{$r := List .Commits}} - {{range $r}} - - - - - - - {{end}} - - -
    - {{if not .IsSearchPage}}{{end}} -
    + {{template "repo/commits_table" .}}
    {{template "base/footer" .}} diff --git a/templates/repo/commits_table.tmpl b/templates/repo/commits_table.tmpl new file mode 100644 index 000000000..4612398a5 --- /dev/null +++ b/templates/repo/commits_table.tmpl @@ -0,0 +1,42 @@ +
    +
    +
    + +

    {{.CommitCount}} Commits

    +
    + + + + + + + + + + + {{ $username := .Username}} + {{ $reponame := .Reponame}} + {{$r := List .Commits}} + {{range $r}} + + + + + + + {{end}} + + +
    + {{if not .IsSearchPage}}{{end}} +
    diff --git a/templates/repo/diff.tmpl b/templates/repo/diff.tmpl index 6adea0459..787334508 100644 --- a/templates/repo/diff.tmpl +++ b/templates/repo/diff.tmpl @@ -3,7 +3,18 @@ {{template "repo/nav" .}}
    + {{if .IsDiffCompare }}
    + +
    + {{template "repo/commits_table" .}} +
    +
    + {{else}} +
    Browse Source

    {{.Commit.Message}}

    @@ -22,9 +33,9 @@ {{.Commit.Author.Name}} {{TimeSince .Commit.Author.When $.Lang}}

    -
    +
    - + {{end}} {{if .DiffNotAvailable}}

    Diff Data Not Available.

    {{else}} From af0741da07ec190804fff2a84c3813fc62a1c3ba Mon Sep 17 00:00:00 2001 From: Christopher Brickley Date: Mon, 1 Sep 2014 19:19:56 -0400 Subject: [PATCH 019/153] handle initial commit for compareUrl --- models/action.go | 6 +++++- models/slack.go | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/models/action.go b/models/action.go index 5a8c31697..f739fc353 100644 --- a/models/action.go +++ b/models/action.go @@ -226,7 +226,11 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string, } repoLink := fmt.Sprintf("%s%s/%s", setting.AppUrl, repoUserName, repoName) - compareUrl := fmt.Sprintf("%s/compare/%s...%s", repoLink, oldCommitId, newCommitId) + compareUrl := "" + // if not the first commit, set the compareUrl + if !strings.HasPrefix(oldCommitId, "0000000") { + compareUrl = fmt.Sprintf("%s/compare/%s...%s", repoLink, oldCommitId, newCommitId) + } commits := make([]*PayloadCommit, len(commit.Commits)) for i, cmt := range commit.Commits { commits[i] = &PayloadCommit{ diff --git a/models/slack.go b/models/slack.go index 714b2f6ca..3dd40759a 100644 --- a/models/slack.go +++ b/models/slack.go @@ -72,9 +72,14 @@ func getSlackPushPayload(p *Payload, slack *Slack) (*SlackPayload, error) { if len(p.Commits) == 1 { commitString = "1 new commit" + if p.CompareUrl != "" { + commitString = SlackLinkFormatter(p.CompareUrl, commitString) + } } else { commitString = fmt.Sprintf("%d new commits", len(p.Commits)) - commitString = SlackLinkFormatter(p.CompareUrl, commitString) + if p.CompareUrl != "" { + commitString = SlackLinkFormatter(p.CompareUrl, commitString) + } } repoLink := SlackLinkFormatter(p.Repo.Url, p.Repo.Name) From 1240fef0ca252f03c8cd67ef84d6fd48cd3cb76d Mon Sep 17 00:00:00 2001 From: lunnyxiao Date: Tue, 2 Sep 2014 11:57:06 +0800 Subject: [PATCH 020/153] bug fixed for migrate and fixed #141 --- models/repo.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/models/repo.go b/models/repo.go index 470369667..105e8eecd 100644 --- a/models/repo.go +++ b/models/repo.go @@ -277,7 +277,7 @@ func MirrorUpdate() { // MigrateRepository migrates a existing repository from other project hosting. func MigrateRepository(u *User, name, desc string, private, mirror bool, url string) (*Repository, error) { - repo, err := CreateRepository(u, name, desc, "", "", private, mirror, false) + repo, err := CreateRepository(u, name, desc, "", "", private, true, false) if err != nil { return nil, err } @@ -307,8 +307,15 @@ func MigrateRepository(u *User, name, desc string, private, mirror bool, url str return repo, UpdateRepository(repo) } - // Clone from local repository. + // this command could for both migrate and mirror _, stderr, err := process.ExecTimeout(10*time.Minute, + fmt.Sprintf("MigrateRepository: %s", repoPath), + "git", "clone", "--mirror", "--bare", url, repoPath) + if err != nil { + return repo, errors.New("git clone: " + stderr) + } + // Clone from local repository. + /*_, stderr, err := process.ExecTimeout(10*time.Minute, fmt.Sprintf("MigrateRepository(git clone): %s", repoPath), "git", "clone", repoPath, tmpDir) if err != nil { @@ -327,7 +334,7 @@ func MigrateRepository(u *User, name, desc string, private, mirror bool, url str tmpDir, fmt.Sprintf("MigrateRepository(git push): %s", repoPath), "git", "push", "--tags", "origin", "refs/remotes/upstream/*:refs/heads/*"); err != nil { return repo, errors.New("git push: " + stderr) - } + }*/ return repo, UpdateRepository(repo) } From 8e0aeb4ad5183030a1e669713e8a053957742aaf Mon Sep 17 00:00:00 2001 From: Arpemedia Date: Tue, 2 Sep 2014 09:20:39 +0200 Subject: [PATCH 021/153] Fix a gramma error and translate two additional strings --- conf/locale/locale_de-DE.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/locale/locale_de-DE.ini b/conf/locale/locale_de-DE.ini index 97ca5efd0..5c7919aef 100644 --- a/conf/locale/locale_de-DE.ini +++ b/conf/locale/locale_de-DE.ini @@ -1,4 +1,4 @@ -app_desc = Ein einfacher, selbst gehostetes Git-Service, geschrieben in Go. +app_desc = Ein einfacher, selbst gehosteter Git-Service, geschrieben in Go. home = Home dashboard = Dashboard @@ -60,7 +60,7 @@ sign_up_now = Du willst ein Konto? Jetzt registrieren! confirmation_mail_sent_prompt = A new confirmation e-mail has been sent to %s, please check your inbox within the next %d hours to complete your registration. sign_in_email = Melden dich mit deiner E-Mail-Adresse an active_your_account = Aktivieren dein Konto -resent_limit_prompt = Sorry, you are sending an activation e-mail too frequently. Please wait 3 minutes. +resent_limit_prompt = Entschuldigung, du versuchst die Bestätigungs E-Mail zu häufig zu versenden. Bitte warte 3 Minuten. has_unconfirmed_mail = Hi %s, you have an unconfirmed email address(%s). If you haven't received a confirmation e-mail or need to resend a new one, please click on the button below. resend_mail = Klicke hier, um deine Aktivierungs-E-Mail nochmal zu senden email_not_associate = Diese E-Mail-Adresse ist mit keinen Konto verknüpft. @@ -127,7 +127,7 @@ orgs = Organisationen delete = Konto löschen public_profile = Öffentliches Profil -profile_desc = Your Email address is public and will be used for any account related notifications, and any web based operations made via the site. +profile_desc = Deine E-Mail Adresse ist öffentlich und wird für alle Meldungen im zusammenhang mit dem Benutzerkonto und für alle Operationen, die über die Weboberfläche gestartet werden, verwendet. full_name = Vollständiger Name website = Webseite location = Standort From 830efc90da2895d65c3a2df32e7ef79cf2a8d556 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 2 Sep 2014 07:11:39 -0400 Subject: [PATCH 022/153] update docs and mirror bug fix --- CONTRIBUTING.md | 66 +++++++++++++++++++++++++++++++++++++--------- README.md | 3 ++- README_ZH.md | 1 + gogs.go | 2 +- models/repo.go | 26 +++--------------- templates/.VERSION | 2 +- 6 files changed, 61 insertions(+), 39 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0a8b26f1c..1917ae885 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,14 +1,54 @@ # Contributing to Gogs -> Thanks [drone](https://github.com/drone/drone) because this guidelines sheet is forked from its [CONTRIBUTING.md](https://github.com/drone/drone/blob/master/CONTRIBUTING.md). +> This guidelines sheet is forked from [CONTRIBUTING.md](https://github.com/drone/drone/blob/master/CONTRIBUTING.md). -Want to hack on Gogs? Awesome! Here are instructions to get you started. They are probably not perfect, please let us know if anything feels wrong or incomplete. +Gogs is not perfect and it has bugs, or incomplete features for rare cases. You're welcome to tell us or contribute some code. This document describles details about how can you contribute to Gogs project. ## Contribution guidelines -### Pull requests are always welcome +Depends on the situation, you will: -**ALL PULL REQUESTS MUST SEND TO `DEV` BRANCH** +- Find bug, create an issue +- Need more functionality, make a feature request +- Want to contribute code, open a pull request +- Run into issue, need help + +### Bug Report + +If you find or consider something is a bug, please create a issue on [GitHub](https://github.com/gogits/gogs/issues). To reduce unnecessary time wasting of interacting and waiting with team members, please use following form as template in the first place: + +``` +- **Bug Description**: +- **Gogs Version**: +- **Git Version**: +- **System Type**: +- **Error Log**: +- **Other information**: +``` + +Please take a moment to check that an issue on [GitHub](https://github.com/gogits/gogs/issues) doesn't already exist documenting your bug report or improvement proposal. If it does, it never hurts to add a quick "+1" or "I have this problem too". This will help prioritize the most common problems and requests. + +#### Bug Report Example + +- **Bug Description**: Crash when create repository with license| +- **Gogs Version**: `v0.4.9.0901` +- **Git Version**: `1.9.0` +- **System Type**: `Ubuntu 12.04` +- **Error Log**: + +``` +2014/09/01 07:21:49 [E] nil pointer +``` + +- **Other information**: Use SQLite3 as database + +### Feature Request + +There is no standard form of making a feature request, just try to describle the feature as clear as possible because team members may not have experience with the functionality you're talking about. + +### Pull Request + +Pull requests are always welcome, but note that **ALL PULL REQUESTS MUST SEND TO `DEV` BRANCH**. We are always thrilled to receive pull requests, and do our best to process them as fast as possible. Not sure if that typo is worth a pull request? Do it! We will appreciate it. @@ -16,16 +56,16 @@ If your pull request is not accepted on the first try, don't be discouraged! If We're trying very hard to keep Gogs lean and focused. We don't want it to do everything for everybody. This means that we might decide against incorporating a new feature. +### Ask For Help + +Before open any new issue, please check your problem on [Troubleshooting](http://gogs.io/docs/intro/troubleshooting.md) and [FAQs](http://gogs.io/docs/intro/faqs.html) pages. + +## Things To Notice + +Please take a moment to check that an issue on [GitHub](https://github.com/gogits/gogs/issues) or card on [Trello](https://trello.com/b/uxAoeLUl/gogs-go-git-service) doesn't already exist documenting your bug report or improvement proposal. If it does, it never hurts to add a quick "+1" or "I have this problem too". This will help prioritize the most common problems and requests. + ### Discuss your design on the mailing list We recommend discussing your plans [on the mailing list](https://groups.google.com/forum/#!forum/gogits) before starting to code - especially for more ambitious contributions. This gives other contributors a chance to point you in the right direction, give feedback on your design, and maybe point out if someone else is working on the same thing. -We may close your pull request if not first discussed on the mailing list. We aren't doing this to be jerks. We are doing this to prevent people from spending large amounts of time on changes that may need to be designed or architected in a specific way, or may not align with the vision of the project. - -### Create issues... - -Any significant improvement should be documented as [a GitHub issue](https://github.com/gogits/gogs/issues) before anybody starts working on it. - -### ...but check for existing issues first! - -Please take a moment to check that an issue or card on [Trello](https://trello.com/b/uxAoeLUl/gogs-go-git-service) doesn't already exist documenting your bug report or improvement proposal. If it does, it never hurts to add a quick "+1" or "I have this problem too". This will help prioritize the most common problems and requests. \ No newline at end of file +We may close your pull request if not first discussed on the mailing list. We aren't doing this to be jerks. We are doing this to prevent people from spending large amounts of time on changes that may need to be designed or architected in a specific way, or may not align with the vision of the project. \ No newline at end of file diff --git a/README.md b/README.md index 38e081f46..ddb8367e9 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ The goal of this project is to make the easiest, fastest and most painless way t - Gravatar and cache support - Mail service(register, issue) - Administration panel +- Slack webhook integration - Supports MySQL, PostgreSQL and SQLite3 - Social account login(GitHub, Google, QQ, Weibo) - Multi-language support(English, Chinese, Germany etc.) @@ -69,7 +70,7 @@ There are 5 ways to install Gogs: - Usage and modification from [beego](http://beego.me) modules. - Thanks [lavachen](http://www.lavachen.cn/) and [Rocker](http://weibo.com/rocker1989) for designing Logo. - Thanks [gobuild.io](http://gobuild.io) for providing binary compile and download service. -- Great thanks to [Docker China](http://www.dockboard.org/) for providing [dockerfiles](https://github.com/gogits/gogs/tree/master/dockerfiles). +- Thanks [Docker China](http://www.dockboard.org/) for providing [dockerfiles](https://github.com/gogits/gogs/tree/master/dockerfiles). ## Contributors diff --git a/README_ZH.md b/README_ZH.md index b830d4164..de982baf3 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -31,6 +31,7 @@ Gogs 的目标是打造一个最简单、最快速和最轻松的方式搭建自 - Gravatar 以及缓存支持 - 邮件服务(注册、Issue) - 管理员面板 +- Slack Web 钩子集成 - 支持 MySQL、PostgreSQL 以及 SQLite3 数据库 - 社交帐号登录(GitHub、Google、QQ、微博) - 多语言支持(英文、简体中文、德语等等) diff --git a/gogs.go b/gogs.go index 1e2150b3c..a11601907 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.4.9.0831 Beta" +const APP_VER = "0.4.9.0902 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/models/repo.go b/models/repo.go index 105e8eecd..8f62fa17a 100644 --- a/models/repo.go +++ b/models/repo.go @@ -277,7 +277,7 @@ func MirrorUpdate() { // MigrateRepository migrates a existing repository from other project hosting. func MigrateRepository(u *User, name, desc string, private, mirror bool, url string) (*Repository, error) { - repo, err := CreateRepository(u, name, desc, "", "", private, true, false) + repo, err := CreateRepository(u, name, desc, "", "", private, mirror, false) if err != nil { return nil, err } @@ -305,6 +305,8 @@ func MigrateRepository(u *User, name, desc string, private, mirror bool, url str } repo.IsMirror = true return repo, UpdateRepository(repo) + } else { + os.RemoveAll(repoPath) } // this command could for both migrate and mirror @@ -314,28 +316,6 @@ func MigrateRepository(u *User, name, desc string, private, mirror bool, url str if err != nil { return repo, errors.New("git clone: " + stderr) } - // Clone from local repository. - /*_, stderr, err := process.ExecTimeout(10*time.Minute, - fmt.Sprintf("MigrateRepository(git clone): %s", repoPath), - "git", "clone", repoPath, tmpDir) - if err != nil { - return repo, errors.New("git clone: " + stderr) - } - - // Add remote and fetch data. - if _, stderr, err = process.ExecDir(3*time.Minute, - tmpDir, fmt.Sprintf("MigrateRepository(git pull): %s", repoPath), - "git", "remote", "add", "-f", "--tags", "upstream", url); err != nil { - return repo, errors.New("git remote: " + stderr) - } - - // Push data to local repository. - if _, stderr, err = process.ExecDir(3*time.Minute, - tmpDir, fmt.Sprintf("MigrateRepository(git push): %s", repoPath), - "git", "push", "--tags", "origin", "refs/remotes/upstream/*:refs/heads/*"); err != nil { - return repo, errors.New("git push: " + stderr) - }*/ - return repo, UpdateRepository(repo) } diff --git a/templates/.VERSION b/templates/.VERSION index fb2403adf..5f3c51819 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.4.9.0831 Beta \ No newline at end of file +0.4.9.0902 Beta \ No newline at end of file From 399887cc0e3788cdf2df418eb6b89c4b54da47e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=A0=E9=97=BB?= Date: Tue, 2 Sep 2014 07:13:13 -0400 Subject: [PATCH 023/153] Revert "Fix a gramma error and translate two additional strings (German translation)" --- conf/locale/locale_de-DE.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/locale/locale_de-DE.ini b/conf/locale/locale_de-DE.ini index 5c7919aef..97ca5efd0 100644 --- a/conf/locale/locale_de-DE.ini +++ b/conf/locale/locale_de-DE.ini @@ -1,4 +1,4 @@ -app_desc = Ein einfacher, selbst gehosteter Git-Service, geschrieben in Go. +app_desc = Ein einfacher, selbst gehostetes Git-Service, geschrieben in Go. home = Home dashboard = Dashboard @@ -60,7 +60,7 @@ sign_up_now = Du willst ein Konto? Jetzt registrieren! confirmation_mail_sent_prompt = A new confirmation e-mail has been sent to %s, please check your inbox within the next %d hours to complete your registration. sign_in_email = Melden dich mit deiner E-Mail-Adresse an active_your_account = Aktivieren dein Konto -resent_limit_prompt = Entschuldigung, du versuchst die Bestätigungs E-Mail zu häufig zu versenden. Bitte warte 3 Minuten. +resent_limit_prompt = Sorry, you are sending an activation e-mail too frequently. Please wait 3 minutes. has_unconfirmed_mail = Hi %s, you have an unconfirmed email address(%s). If you haven't received a confirmation e-mail or need to resend a new one, please click on the button below. resend_mail = Klicke hier, um deine Aktivierungs-E-Mail nochmal zu senden email_not_associate = Diese E-Mail-Adresse ist mit keinen Konto verknüpft. @@ -127,7 +127,7 @@ orgs = Organisationen delete = Konto löschen public_profile = Öffentliches Profil -profile_desc = Deine E-Mail Adresse ist öffentlich und wird für alle Meldungen im zusammenhang mit dem Benutzerkonto und für alle Operationen, die über die Weboberfläche gestartet werden, verwendet. +profile_desc = Your Email address is public and will be used for any account related notifications, and any web based operations made via the site. full_name = Vollständiger Name website = Webseite location = Standort From 0730ec408787f27c02d7f71d8e0cb713c0a95b57 Mon Sep 17 00:00:00 2001 From: Arpemedia Date: Tue, 2 Sep 2014 13:46:18 +0200 Subject: [PATCH 024/153] Fix grammar error in German translation --- conf/locale/locale_de-DE.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/locale/locale_de-DE.ini b/conf/locale/locale_de-DE.ini index 3e9936d6e..19b2b5d11 100644 --- a/conf/locale/locale_de-DE.ini +++ b/conf/locale/locale_de-DE.ini @@ -1,4 +1,4 @@ -app_desc = Ein einfacher, selbst gehostetes Git-Service, geschrieben in Go. +app_desc = Ein einfacher, selbst gehosteter Git-Service, geschrieben in Go. home = Home dashboard = Dashboard From 9476e58de941624912a3ceb89d52d36e79c03358 Mon Sep 17 00:00:00 2001 From: Vyacheslav Bakhmutov Date: Tue, 2 Sep 2014 22:48:40 +0700 Subject: [PATCH 025/153] Set headers in js and go files to X-Csrf-Token --- cmd/web.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/web.go b/cmd/web.go index 2199d4ca1..57164683a 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -95,6 +95,7 @@ func newMacaron() *macaron.Macaron { m.Use(csrf.Generate(csrf.Options{ Secret: setting.SecretKey, SetCookie: true, + Header: "X-Csrf-Token", })) m.Use(toolbox.Toolboxer(m, toolbox.Options{ HealthCheckFuncs: []*toolbox.HealthCheckFuncDesc{ From 8b0e815d98a02ed271410c5491e7a879818ca995 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 2 Sep 2014 13:01:02 -0400 Subject: [PATCH 026/153] Fix #425 --- modules/middleware/auth.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/middleware/auth.go b/modules/middleware/auth.go index 37e3aec45..51ce48c69 100644 --- a/modules/middleware/auth.go +++ b/modules/middleware/auth.go @@ -53,7 +53,7 @@ func Toggle(options *ToggleOptions) macaron.Handler { return } else if !ctx.User.IsActive && setting.Service.RegisterEmailConfirm { ctx.Data["Title"] = ctx.Tr("auth.active_your_account") - ctx.HTML(200, "user/activate") + ctx.HTML(200, "user/auth/activate") return } } From 2a7a03e5b3ca1f24b35003082902e7dda37991bc Mon Sep 17 00:00:00 2001 From: Vyacheslav Bakhmutov Date: Wed, 3 Sep 2014 00:04:22 +0700 Subject: [PATCH 027/153] take params for milestone and assignee from query instead of path args --- public/js/app.js | 2 +- routers/repo/issue.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/js/app.js b/public/js/app.js index a5bb9569e..2a7cf08ba 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -870,7 +870,7 @@ function initIssue() { $.post($m.data("ajax"), { issue: $('#issue').data("id"), - milestone: id + milestoneid: id }, function (json) { if (json.ok) { //window.location.reload(); diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 412d03c6e..59921d551 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -582,7 +582,7 @@ func UpdateIssueMilestone(ctx *middleware.Context) { } oldMid := issue.MilestoneId - mid := com.StrTo(ctx.Params(":milestone")).MustInt64() + mid := com.StrTo(ctx.Query("milestoneid")).MustInt64() if oldMid == mid { ctx.JSON(200, map[string]interface{}{ "ok": true, @@ -627,7 +627,7 @@ func UpdateAssignee(ctx *middleware.Context) { return } - aid := com.StrTo(ctx.Params(":assigneeid")).MustInt64() + aid := com.StrTo(ctx.Query("assigneeid")).MustInt64() // Not check for invalid assignne id and give responsibility to owners. issue.AssigneeId = aid if err = models.UpdateIssueUserPairByAssignee(aid, issue.Id); err != nil { From dcb10a41d4fa7abf2554955cdf3abbcea055adfd Mon Sep 17 00:00:00 2001 From: Michael Dyrynda Date: Wed, 3 Sep 2014 10:01:32 +0930 Subject: [PATCH 028/153] Add handling to branch switcher label to make label more consistent with GitHub behaviour Addresses #431 --- templates/repo/home.tmpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index 094730847..90633cd0c 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -17,7 +17,7 @@
  • @@ -75,4 +75,4 @@ {{template "repo/sidebar" .}}
  • -{{template "ng/base/footer" .}} \ No newline at end of file +{{template "ng/base/footer" .}} From 000b9062599d6138cb63775c61d1978283c195c1 Mon Sep 17 00:00:00 2001 From: Tristan Storch Date: Wed, 3 Sep 2014 16:58:23 +0200 Subject: [PATCH 029/153] Small German update Cleaning up a misunderstanding I had. --- conf/locale/locale_de-DE.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/locale/locale_de-DE.ini b/conf/locale/locale_de-DE.ini index 19b2b5d11..d8060f0b5 100644 --- a/conf/locale/locale_de-DE.ini +++ b/conf/locale/locale_de-DE.ini @@ -127,7 +127,7 @@ orgs = Organisationen delete = Konto löschen public_profile = Öffentliches Profil -profile_desc = Deine E-Mail-Adresse wird nicht veröffentlicht und dient dazu, dir Benachrichtigungen bezüglich deines Kontos und deiner Repositorys zu schicken. +profile_desc = Deine E-Mail-Adresse ist öffentlich und dient dazu, dir Benachrichtigungen bezüglich deines Kontos und deiner Repositorys zu schicken. full_name = Vollständiger Name website = Webseite location = Standort From 7df0794e14e713d359ee79d204d75cc574b02c1f Mon Sep 17 00:00:00 2001 From: Tristan Storch Date: Wed, 3 Sep 2014 17:12:38 +0200 Subject: [PATCH 030/153] docker dev block update The dev Dockerfile now works without superfluous go get calls. At this point the -u option is really not what we want. --- docker/blocks/docker_gogs_dev/Dockerfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docker/blocks/docker_gogs_dev/Dockerfile b/docker/blocks/docker_gogs_dev/Dockerfile index 1c001e2c0..a016409f5 100644 --- a/docker/blocks/docker_gogs_dev/Dockerfile +++ b/docker/blocks/docker_gogs_dev/Dockerfile @@ -1,8 +1,9 @@ FROM ubuntu:14.04 -# This part is taken from the official docker image -------------------- +# This part is derived from the official docker image ------------------ -RUN apt-get update && apt-get install -y \ +RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ + apt-get install -qy \ build-essential ca-certificates curl \ bzr git mercurial \ --no-install-recommends @@ -31,10 +32,10 @@ ENV GOGS_PATH $GOPATH/src/github.com/gogits/gogs ENV GOGS_CUSTOM_CONF_PATH $GOGS_PATH/custom/conf ENV GOGS_CUSTOM_CONF $GOGS_CUSTOM_CONF_PATH/app.ini -RUN go get -u -d github.com/gogits/gogs +RUN git clone -b dev https://github.com/gogits/gogs.git $GOPATH/src/github.com/gogits/gogs # WORKDIR $GOGS_PATH WORKDIR /go/src/github.com/gogits/gogs -RUN git checkout dev; go get -u; git checkout dev; go build +RUN go get -d && go build RUN chown -R git $GOGS_PATH ADD init_gogs.sh /tmp/ From 863a4d5bc4b1e1237e259325ac30c111755c9a02 Mon Sep 17 00:00:00 2001 From: Tristan Storch Date: Wed, 3 Sep 2014 18:41:20 +0200 Subject: [PATCH 031/153] Use variables, when the're there Why not use the environment variables, when they are there... --- docker/blocks/docker_gogs_dev/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/blocks/docker_gogs_dev/Dockerfile b/docker/blocks/docker_gogs_dev/Dockerfile index a016409f5..d1b96bf4a 100644 --- a/docker/blocks/docker_gogs_dev/Dockerfile +++ b/docker/blocks/docker_gogs_dev/Dockerfile @@ -32,7 +32,7 @@ ENV GOGS_PATH $GOPATH/src/github.com/gogits/gogs ENV GOGS_CUSTOM_CONF_PATH $GOGS_PATH/custom/conf ENV GOGS_CUSTOM_CONF $GOGS_CUSTOM_CONF_PATH/app.ini -RUN git clone -b dev https://github.com/gogits/gogs.git $GOPATH/src/github.com/gogits/gogs +RUN git clone -b dev https://github.com/gogits/gogs.git $GOGS_PATH # WORKDIR $GOGS_PATH WORKDIR /go/src/github.com/gogits/gogs RUN go get -d && go build From aee46bac0189de650d3444a34fc463a8c01a8aa8 Mon Sep 17 00:00:00 2001 From: Michael Dyrynda Date: Thu, 4 Sep 2014 09:12:51 +0930 Subject: [PATCH 032/153] add rel attribute such that font-awesome icons load correctly --- templates/ng/base/head.tmpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/ng/base/head.tmpl b/templates/ng/base/head.tmpl index 815453446..40c3899e9 100644 --- a/templates/ng/base/head.tmpl +++ b/templates/ng/base/head.tmpl @@ -12,7 +12,7 @@ {{if CdnMode}} - + {{else}} @@ -35,4 +35,4 @@
    - \ No newline at end of file + From 9fc4ded369a90140a63e064371479f2ef4e4bc4f Mon Sep 17 00:00:00 2001 From: Tristan Storch Date: Thu, 4 Sep 2014 12:03:29 +0200 Subject: [PATCH 033/153] Standard git user.name and user.email if not set Git user.name and user.email will now be set to the standard values - Gogs - gogitservice@gmail.com if user.name is not set or empty. If user.name is set and user.email not, it will leave it this way. --- models/repo.go | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/models/repo.go b/models/repo.go index 8f62fa17a..23d44a6b8 100644 --- a/models/repo.go +++ b/models/repo.go @@ -99,20 +99,26 @@ func NewRepoContext() { log.Fatal(4, "Gogs requires Git version greater or equal to 1.8.0") } - // Check if server has basic git setting. - stdout, stderr, err := process.Exec("NewRepoContext(get setting)", "git", "config", "--get", "user.name") - if err != nil { - log.Fatal(4, "Fail to get git user.name: %s", stderr) - } else if err != nil || len(strings.TrimSpace(stdout)) == 0 { - if _, stderr, err = process.Exec("NewRepoContext(set email)", "git", "config", "--global", "user.email", "gogitservice@gmail.com"); err != nil { - log.Fatal(4, "Fail to set git user.email: %s", stderr) - } else if _, stderr, err = process.Exec("NewRepoContext(set name)", "git", "config", "--global", "user.name", "Gogs"); err != nil { - log.Fatal(4, "Fail to set git user.name: %s", stderr) + // Check if server has basic git setting and set if not. + if stdout, stderr, err := process.Exec("NewRepoContext(get setting)", "git", "config", "--get", "user.name"); err != nil || strings.TrimSpace(stdout) == "" { + // ExitError indicates user.name is not set + if _, ok := err.(*exec.ExitError); ok || strings.TrimSpace(stdout) == "" { + stndrdUserName := "Gogs" + stndrdUserEmail := "gogitservice@gmail.com" + if _, stderr, gerr := process.Exec("NewRepoContext(set name)", "git", "config", "--global", "user.name", stndrdUserName); gerr != nil { + log.Fatal(4, "Fail to set git user.name(%s): %s", gerr, stderr) + } + if _, stderr, gerr := process.Exec("NewRepoContext(set email)", "git", "config", "--global", "user.email", stndrdUserEmail); gerr != nil { + log.Fatal(4, "Fail to set git user.email(%s): %s", gerr, stderr) + } + log.Info("Git user.name and user.email set to %s <%s>", stndrdUserName, stndrdUserEmail) + } else { + log.Fatal(4, "Fail to get git user.name(%s): %s", err, stderr) } } // Set git some configurations. - if _, stderr, err = process.Exec("NewRepoContext(git config --global core.quotepath false)", + if _, stderr, err := process.Exec("NewRepoContext(git config --global core.quotepath false)", "git", "config", "--global", "core.quotepath", "false"); err != nil { log.Fatal(4, "Fail to execute 'git config --global core.quotepath false': %s", stderr) } From bdfdf3cacba75fe1c36f7a05096748c26f25a2f9 Mon Sep 17 00:00:00 2001 From: Tristan Storch Date: Thu, 4 Sep 2014 17:19:26 +0200 Subject: [PATCH 034/153] Code dedoublication in models/models.go Just some code dedoublication in models/models.go --- models/models.go | 44 +++++++++++++++----------------------------- 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/models/models.go b/models/models.go index 4e2e08cf8..5558ec006 100644 --- a/models/models.go +++ b/models/models.go @@ -55,11 +55,12 @@ func LoadModelsConfig() { DbCfg.Path = setting.Cfg.MustValue("database", "PATH", "data/gogs.db") } -func NewTestEngine(x *xorm.Engine) (err error) { +func getEngine() (*xorm.Engine, error) { + cnnstr := "" switch DbCfg.Type { case "mysql": - x, err = xorm.NewEngine("mysql", fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8", - DbCfg.User, DbCfg.Pwd, DbCfg.Host, DbCfg.Name)) + cnnstr = fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8", + DbCfg.User, DbCfg.Pwd, DbCfg.Host, DbCfg.Name) case "postgres": var host, port = "127.0.0.1", "5432" fields := strings.Split(DbCfg.Host, ":") @@ -69,46 +70,31 @@ func NewTestEngine(x *xorm.Engine) (err error) { if len(fields) > 1 && len(strings.TrimSpace(fields[1])) > 0 { port = fields[1] } - cnnstr := fmt.Sprintf("user=%s password=%s host=%s port=%s dbname=%s sslmode=%s", + cnnstr = fmt.Sprintf("user=%s password=%s host=%s port=%s dbname=%s sslmode=%s", DbCfg.User, DbCfg.Pwd, host, port, DbCfg.Name, DbCfg.SslMode) - x, err = xorm.NewEngine("postgres", cnnstr) case "sqlite3": if !EnableSQLite3 { - return fmt.Errorf("Unknown database type: %s", DbCfg.Type) + return nil, fmt.Errorf("Unknown database type: %s", DbCfg.Type) } os.MkdirAll(path.Dir(DbCfg.Path), os.ModePerm) - x, err = xorm.NewEngine("sqlite3", DbCfg.Path) + cnnstr = DbCfg.Path default: - return fmt.Errorf("Unknown database type: %s", DbCfg.Type) + return nil, fmt.Errorf("Unknown database type: %s", DbCfg.Type) } + return xorm.NewEngine(DbCfg.Type, cnnstr) +} + +func NewTestEngine(x *xorm.Engine) (err error) { + x, err = getEngine() if err != nil { return fmt.Errorf("models.init(fail to conntect database): %v", err) } + return x.Sync(tables...) } func SetEngine() (err error) { - switch DbCfg.Type { - case "mysql": - x, err = xorm.NewEngine("mysql", fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8", - DbCfg.User, DbCfg.Pwd, DbCfg.Host, DbCfg.Name)) - case "postgres": - var host, port = "127.0.0.1", "5432" - fields := strings.Split(DbCfg.Host, ":") - if len(fields) > 0 && len(strings.TrimSpace(fields[0])) > 0 { - host = fields[0] - } - if len(fields) > 1 && len(strings.TrimSpace(fields[1])) > 0 { - port = fields[1] - } - x, err = xorm.NewEngine("postgres", fmt.Sprintf("user=%s password=%s host=%s port=%s dbname=%s sslmode=%s", - DbCfg.User, DbCfg.Pwd, host, port, DbCfg.Name, DbCfg.SslMode)) - case "sqlite3": - os.MkdirAll(path.Dir(DbCfg.Path), os.ModePerm) - x, err = xorm.NewEngine("sqlite3", DbCfg.Path) - default: - return fmt.Errorf("Unknown database type: %s", DbCfg.Type) - } + x, err = getEngine() if err != nil { return fmt.Errorf("models.init(fail to conntect database): %v", err) } From 31d80118438729119b40fd863e54ee7ca903b18b Mon Sep 17 00:00:00 2001 From: Vyacheslav Bakhmutov Date: Fri, 5 Sep 2014 08:10:41 +0700 Subject: [PATCH 035/153] Set milestone content field to TEXT orm type --- models/issue.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/issue.go b/models/issue.go index 307ace816..f16c2e256 100644 --- a/models/issue.go +++ b/models/issue.go @@ -612,7 +612,7 @@ type Milestone struct { RepoId int64 `xorm:"INDEX"` Index int64 Name string - Content string + Content string `xorm:"TEXT"` RenderedContent string `xorm:"-"` IsClosed bool NumIssues int From 6498fce04bdf4fb8503d226036c501901db56114 Mon Sep 17 00:00:00 2001 From: Vyacheslav Bakhmutov Date: Fri, 5 Sep 2014 09:10:58 +0700 Subject: [PATCH 036/153] Render milestone content as markdown --- routers/repo/issue.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 59921d551..934cf3c98 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -940,7 +940,7 @@ func Milestones(ctx *middleware.Context) { return } for _, m := range miles { - m.RenderedContent = string(base.RenderSpecialLink([]byte(m.Content), ctx.Repo.RepoLink)) + m.RenderedContent = string(base.RenderMarkdown([]byte(m.Content), ctx.Repo.RepoLink)) m.CalOpenIssues() } ctx.Data["Milestones"] = miles From 8d2fe064c5d3858d76ebd67d5597a0bfccce4ecc Mon Sep 17 00:00:00 2001 From: Christopher Brickley Date: Wed, 3 Sep 2014 22:13:09 -0400 Subject: [PATCH 037/153] modify grammar undo -> undone --- conf/locale/locale_en-US.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini index 946d56046..4f1acdcda 100644 --- a/conf/locale/locale_en-US.ini +++ b/conf/locale/locale_en-US.ini @@ -159,7 +159,7 @@ unbind = Unbind unbind_success = Social account has been unbound. delete_account = Delete Your Account -delete_prompt = The operation will delete your account permanently, and CANNOT be undo! +delete_prompt = The operation will delete your account permanently, and CANNOT be undone! confirm_delete_account = Confirm Deletion [repo] @@ -268,7 +268,7 @@ settings.update_settings = Update Settings settings.update_setting_success = Organization setting has been successfully updated. settings.delete = Delete Organization settings.delete_account = Delete This Organization -settings.delete_prompt = The operation will delete this organization permanently, and CANNOT be undo! +settings.delete_prompt = The operation will delete this organization permanently, and CANNOT be undone! settings.confirm_delete_account = Confirm Deletion members.public = Public From 7269b06fd5992776c07ae0303f85e0d05b1e62e9 Mon Sep 17 00:00:00 2001 From: Christopher Brickley Date: Wed, 3 Sep 2014 22:14:55 -0400 Subject: [PATCH 038/153] HookType is case-sensitive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update webhook wasn’t showing up because of the wrong case --- routers/repo/setting.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/repo/setting.go b/routers/repo/setting.go index fba9eed6a..745678122 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -354,11 +354,11 @@ func WebHooksEdit(ctx *middleware.Context) { case models.SLACK: { ctx.Data["SlackHook"] = w.GetSlackHook() - ctx.Data["HookType"] = "slack" + ctx.Data["HookType"] = "Slack" } default: { - ctx.Data["HookType"] = "gogs" + ctx.Data["HookType"] = "Gogs" } } w.GetEvent() From 85c35a6b8bb7430568d375d1e792e1417bbd7f4b Mon Sep 17 00:00:00 2001 From: Christopher Brickley Date: Thu, 4 Sep 2014 07:17:00 -0400 Subject: [PATCH 039/153] add organization-level webhooks --- cmd/web.go | 7 ++++ conf/locale/locale_en-US.ini | 1 + models/action.go | 16 ++++++- models/webhook.go | 13 ++++++ public/ng/js/gogs.js | 29 ++++++++----- routers/org/setting.go | 28 +++++++++++++ routers/repo/setting.go | 56 +++++++++++++++++++++---- templates/org/settings/hook_new.tmpl | 37 ++++++++++++++++ templates/org/settings/hooks.tmpl | 38 +++++++++++++++++ templates/org/settings/nav.tmpl | 3 +- templates/repo/settings/hook_gogs.tmpl | 2 +- templates/repo/settings/hook_slack.tmpl | 2 +- 12 files changed, 208 insertions(+), 24 deletions(-) create mode 100644 templates/org/settings/hook_new.tmpl create mode 100644 templates/org/settings/hooks.tmpl diff --git a/cmd/web.go b/cmd/web.go index 57164683a..f7b8d9212 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -260,6 +260,13 @@ func runWeb(*cli.Context) { m.Group("/settings", func(r *macaron.Router) { r.Get("", org.Settings) r.Post("", bindIgnErr(auth.UpdateOrgSettingForm{}), org.SettingsPost) + r.Get("/hooks", org.SettingsHooks) + r.Get("/hooks/new", repo.WebHooksNew) + r.Post("/hooks/gogs/new", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksNewPost) + r.Post("/hooks/slack/new", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksNewPost) + r.Get("/hooks/:id", repo.WebHooksEdit) + r.Post("/hooks/gogs/:id", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksEditPost) + r.Post("/hooks/slack/:id", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksEditPost) r.Route("/delete", "GET,POST", org.SettingsDelete) }) diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini index 4f1acdcda..3969074ee 100644 --- a/conf/locale/locale_en-US.ini +++ b/conf/locale/locale_en-US.ini @@ -270,6 +270,7 @@ settings.delete = Delete Organization settings.delete_account = Delete This Organization settings.delete_prompt = The operation will delete this organization permanently, and CANNOT be undone! settings.confirm_delete_account = Confirm Deletion +settings.hooks_desc = Add webhooks that will be triggered for all repositories under this organization. members.public = Public members.public_helper = make private diff --git a/models/action.go b/models/action.go index f739fc353..c0992dba6 100644 --- a/models/action.go +++ b/models/action.go @@ -220,8 +220,20 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string, ws, err := GetActiveWebhooksByRepoId(repoId) if err != nil { - return errors.New("action.CommitRepoAction(GetWebhooksByRepoId): " + err.Error()) - } else if len(ws) == 0 { + return errors.New("action.CommitRepoAction(GetActiveWebhooksByRepoId): " + err.Error()) + } + + // check if repo belongs to org and append additional webhooks + if repo.Owner.IsOrganization() { + // get hooks for org + orgws, err := GetActiveWebhooksByOrgId(repo.OwnerId) + if err != nil { + return errors.New("action.CommitRepoAction(GetActiveWebhooksByOrgId): " + err.Error()) + } + ws = append(ws, orgws...) + } + + if len(ws) == 0 { return nil } diff --git a/models/webhook.go b/models/webhook.go index 0b7b3a994..5acc83f59 100644 --- a/models/webhook.go +++ b/models/webhook.go @@ -45,6 +45,7 @@ type Webhook struct { IsActive bool HookTaskType HookTaskType Meta string `xorm:"TEXT"` // store hook-specific attributes + OrgId int64 } // GetEvent handles conversion from Events to HookEvent. @@ -120,6 +121,18 @@ func DeleteWebhook(hookId int64) error { return err } +// GetWebhooksByOrgId returns all webhooks for an organization. +func GetWebhooksByOrgId(orgId int64) (ws []*Webhook, err error) { + err = x.Find(&ws, &Webhook{OrgId: orgId}) + return ws, err +} + +// GetActiveWebhooksByOrgId returns all active webhooks for an organization. +func GetActiveWebhooksByOrgId(orgId int64) (ws []*Webhook, err error) { + err = x.Find(&ws, &Webhook{OrgId: orgId, IsActive: true}) + return ws, err +} + // ___ ___ __ ___________ __ // / | \ ____ ____ | | _\__ ___/____ _____| | __ // / ~ \/ _ \ / _ \| |/ / | | \__ \ / ___/ |/ / diff --git a/public/ng/js/gogs.js b/public/ng/js/gogs.js index c08a887a4..c60a5cf64 100644 --- a/public/ng/js/gogs.js +++ b/public/ng/js/gogs.js @@ -349,17 +349,8 @@ function initRepo() { }) } -function initRepoSetting() { - // Options. - // Confirmation of changing repository name. - $('#repo-setting-form').submit(function (e) { - var $reponame = $('#repo_name'); - if (($reponame.data('repo-name') != $reponame.val()) && !confirm('Repository name has been changed, do you want to continue?')) { - e.preventDefault(); - return true; - } - }); - +// when user changes hook type, hide/show proper divs +function initHookTypeChange() { // web hook type change $('select#hook-type').on("change", function () { hookTypes = ['Gogs','Slack']; @@ -374,6 +365,20 @@ function initRepoSetting() { } }); }); +} + +function initRepoSetting() { + // Options. + // Confirmation of changing repository name. + $('#repo-setting-form').submit(function (e) { + var $reponame = $('#repo_name'); + if (($reponame.data('repo-name') != $reponame.val()) && !confirm('Repository name has been changed, do you want to continue?')) { + e.preventDefault(); + return true; + } + }); + + initHookTypeChange(); $('#transfer-button').click(function () { $('#transfer-form').show(); @@ -421,6 +426,8 @@ function initOrgSetting() { return true; } }); + + initHookTypeChange(); } function initInvite() { diff --git a/routers/org/setting.go b/routers/org/setting.go index 0ddf0065c..f853ef0e8 100644 --- a/routers/org/setting.go +++ b/routers/org/setting.go @@ -5,6 +5,7 @@ package org import ( + "github.com/Unknwon/com" "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/auth" "github.com/gogits/gogs/modules/base" @@ -15,6 +16,7 @@ import ( const ( SETTINGS_OPTIONS base.TplName = "org/settings/options" SETTINGS_DELETE base.TplName = "org/settings/delete" + SETTINGS_HOOKS base.TplName = "org/settings/hooks" ) func Settings(ctx *middleware.Context) { @@ -97,3 +99,29 @@ func SettingsDelete(ctx *middleware.Context) { ctx.HTML(200, SETTINGS_DELETE) } + +func SettingsHooks(ctx *middleware.Context) { + ctx.Data["Title"] = ctx.Tr("org.settings") + ctx.Data["PageIsSettingsHooks"] = true + + // Delete web hook. + remove := com.StrTo(ctx.Query("remove")).MustInt64() + if remove > 0 { + if err := models.DeleteWebhook(remove); err != nil { + ctx.Handle(500, "DeleteWebhook", err) + return + } + ctx.Flash.Success(ctx.Tr("repo.settings.remove_hook_success")) + ctx.Redirect(ctx.Org.OrgLink + "/settings/hooks") + return + } + + ws, err := models.GetWebhooksByOrgId(ctx.Org.Organization.Id) + if err != nil { + ctx.Handle(500, "GetWebhooksByOrgId", err) + return + } + + ctx.Data["Webhooks"] = ws + ctx.HTML(200, SETTINGS_HOOKS) +} diff --git a/routers/repo/setting.go b/routers/repo/setting.go index 745678122..81747d43e 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -6,6 +6,7 @@ package repo import ( "encoding/json" + "errors" "fmt" "strings" "time" @@ -26,6 +27,7 @@ const ( COLLABORATION base.TplName = "repo/settings/collaboration" HOOKS base.TplName = "repo/settings/hooks" HOOK_NEW base.TplName = "repo/settings/hook_new" + ORG_HOOK_NEW base.TplName = "org/settings/hook_new" ) func Settings(ctx *middleware.Context) { @@ -284,7 +286,14 @@ func WebHooksNew(ctx *middleware.Context) { ctx.Data["PageIsSettingsHooksNew"] = true ctx.Data["Webhook"] = models.Webhook{HookEvent: &models.HookEvent{}} renderHookTypes(ctx) - ctx.HTML(200, HOOK_NEW) + orgId, repoId, _ := getOrgRepoCtx(ctx) + if repoId > 0 { + ctx.HTML(200, HOOK_NEW) + } else if orgId > 0 { + ctx.HTML(200, ORG_HOOK_NEW) + } else { + ctx.Handle(500, "WebHooksEdit(DetermineContext)", errors.New("Can't determine hook context")) + } } func WebHooksNewPost(ctx *middleware.Context, form auth.NewWebhookForm) { @@ -293,6 +302,8 @@ func WebHooksNewPost(ctx *middleware.Context, form auth.NewWebhookForm) { ctx.Data["PageIsSettingsHooksNew"] = true ctx.Data["Webhook"] = models.Webhook{HookEvent: &models.HookEvent{}} + orgId, repoId, link := getOrgRepoCtx(ctx) + if ctx.HasError() { ctx.HTML(200, HOOK_NEW) return @@ -304,7 +315,7 @@ func WebHooksNewPost(ctx *middleware.Context, form auth.NewWebhookForm) { } w := &models.Webhook{ - RepoId: ctx.Repo.Repository.Id, + RepoId: repoId, Url: form.PayloadUrl, ContentType: ct, Secret: form.Secret, @@ -314,6 +325,7 @@ func WebHooksNewPost(ctx *middleware.Context, form auth.NewWebhookForm) { IsActive: form.Active, HookTaskType: models.GOGS, Meta: "", + OrgId: orgId, } if err := w.UpdateEvent(); err != nil { @@ -325,7 +337,7 @@ func WebHooksNewPost(ctx *middleware.Context, form auth.NewWebhookForm) { } ctx.Flash.Success(ctx.Tr("repo.settings.add_hook_success")) - ctx.Redirect(ctx.Repo.RepoLink + "/settings/hooks") + ctx.Redirect(link + "/settings/hooks") } func WebHooksEdit(ctx *middleware.Context) { @@ -363,7 +375,14 @@ func WebHooksEdit(ctx *middleware.Context) { } w.GetEvent() ctx.Data["Webhook"] = w - ctx.HTML(200, HOOK_NEW) + orgId, repoId, _ := getOrgRepoCtx(ctx) + if repoId > 0 { + ctx.HTML(200, HOOK_NEW) + } else if orgId > 0 { + ctx.HTML(200, ORG_HOOK_NEW) + } else { + ctx.Handle(500, "WebHooksEdit(DetermineContext)", errors.New("Can't determine hook context")) + } } func WebHooksEditPost(ctx *middleware.Context, form auth.NewWebhookForm) { @@ -413,9 +432,10 @@ func WebHooksEditPost(ctx *middleware.Context, form auth.NewWebhookForm) { ctx.Handle(500, "WebHooksEditPost", err) return } + _, _, link := getOrgRepoCtx(ctx) ctx.Flash.Success(ctx.Tr("repo.settings.update_hook_success")) - ctx.Redirect(fmt.Sprintf("%s/settings/hooks/%d", ctx.Repo.RepoLink, hookId)) + ctx.Redirect(fmt.Sprintf("%s/settings/hooks/%d", link, hookId)) } func SlackHooksNewPost(ctx *middleware.Context, form auth.NewSlackHookForm) { @@ -428,6 +448,7 @@ func SlackHooksNewPost(ctx *middleware.Context, form auth.NewSlackHookForm) { ctx.HTML(200, HOOK_NEW) return } + orgId, repoId, link := getOrgRepoCtx(ctx) meta, err := json.Marshal(&models.Slack{ Domain: form.Domain, @@ -440,7 +461,7 @@ func SlackHooksNewPost(ctx *middleware.Context, form auth.NewSlackHookForm) { } w := &models.Webhook{ - RepoId: ctx.Repo.Repository.Id, + RepoId: repoId, Url: models.GetSlackURL(form.Domain, form.Token), ContentType: models.JSON, Secret: "", @@ -450,6 +471,7 @@ func SlackHooksNewPost(ctx *middleware.Context, form auth.NewSlackHookForm) { IsActive: form.Active, HookTaskType: models.SLACK, Meta: string(meta), + OrgId: orgId, } if err := w.UpdateEvent(); err != nil { ctx.Handle(500, "UpdateEvent", err) @@ -460,7 +482,7 @@ func SlackHooksNewPost(ctx *middleware.Context, form auth.NewSlackHookForm) { } ctx.Flash.Success(ctx.Tr("repo.settings.add_hook_success")) - ctx.Redirect(ctx.Repo.RepoLink + "/settings/hooks") + ctx.Redirect(link + "/settings/hooks") } func SlackHooksEditPost(ctx *middleware.Context, form auth.NewSlackHookForm) { @@ -514,7 +536,25 @@ func SlackHooksEditPost(ctx *middleware.Context, form auth.NewSlackHookForm) { ctx.Handle(500, "SlackHooksEditPost", err) return } + _, _, link := getOrgRepoCtx(ctx) ctx.Flash.Success(ctx.Tr("repo.settings.update_hook_success")) - ctx.Redirect(fmt.Sprintf("%s/settings/hooks/%d", ctx.Repo.RepoLink, hookId)) + ctx.Redirect(fmt.Sprintf("%s/settings/hooks/%d", link, hookId)) +} + +func getOrgRepoCtx(ctx *middleware.Context) (int64, int64, string) { + orgId := int64(0) + repoId := int64(0) + link := "" + if _, ok := ctx.Data["RepoLink"]; ok { + repoId = ctx.Repo.Repository.Id + link = ctx.Repo.RepoLink + } + + if _, ok := ctx.Data["OrgLink"]; ok { + orgId = ctx.Org.Organization.Id + link = ctx.Org.OrgLink + } + + return orgId, repoId, link } diff --git a/templates/org/settings/hook_new.tmpl b/templates/org/settings/hook_new.tmpl new file mode 100644 index 000000000..6e7ee5360 --- /dev/null +++ b/templates/org/settings/hook_new.tmpl @@ -0,0 +1,37 @@ +{{template "ng/base/head" .}} +{{template "ng/base/header" .}} +{{template "org/base/header" .}} +
    +
    + {{template "org/settings/nav" .}} +
    +
    + {{template "ng/base/alert" .}} +
    +
    +
    + {{if .PageIsSettingsHooksNew}}{{.i18n.Tr "repo.settings.add_webhook"}}{{else}}{{.i18n.Tr "repo.settings.update_webhook"}}{{end}} +
    + {{template "repo/settings/hook_types" .}} + {{template "repo/settings/hook_gogs" .}} + {{template "repo/settings/hook_slack" .}} +
    +
    + {{if .PageIsSettingsHooksEdit}} +
    +
    +
    +
    + {{.i18n.Tr "repo.settings.recent_deliveries"}} +
    +
      +
    • Coming soon!
    • +
    +
    +
    + {{end}} +
    +
    +
    +
    +{{template "ng/base/footer" .}} diff --git a/templates/org/settings/hooks.tmpl b/templates/org/settings/hooks.tmpl new file mode 100644 index 000000000..713cfeb45 --- /dev/null +++ b/templates/org/settings/hooks.tmpl @@ -0,0 +1,38 @@ +{{template "ng/base/head" .}} +{{template "ng/base/header" .}} +{{template "org/base/header" .}} +
    +
    + {{template "org/settings/nav" .}} +
    +
    + {{template "ng/base/alert" .}} +
    +
    +
    + {{.i18n.Tr "repo.settings.add_webhook"}} + {{.i18n.Tr "repo.settings.hooks"}} +
    +
      +
    • {{.i18n.Tr "org.settings.hooks_desc" | Str2html}}
    • + {{range .Webhooks}} +
    • + {{if .IsActive}} + + {{else}} + + {{end}} + {{.Url}} + + +
    • + {{end}} +
    +
    +
    +
    +
    +
    +
    +
    +{{template "ng/base/footer" .}} diff --git a/templates/org/settings/nav.tmpl b/templates/org/settings/nav.tmpl index 950569d68..954893c6c 100644 --- a/templates/org/settings/nav.tmpl +++ b/templates/org/settings/nav.tmpl @@ -5,7 +5,8 @@ - \ No newline at end of file + diff --git a/templates/repo/settings/hook_gogs.tmpl b/templates/repo/settings/hook_gogs.tmpl index 35b589953..31a04ce09 100644 --- a/templates/repo/settings/hook_gogs.tmpl +++ b/templates/repo/settings/hook_gogs.tmpl @@ -1,5 +1,5 @@
    -
    + {{.CsrfTokenHtml}}
    {{.i18n.Tr "repo.settings.add_webhook_desc" | Str2html}}
    diff --git a/templates/repo/settings/hook_slack.tmpl b/templates/repo/settings/hook_slack.tmpl index 50d28e2f5..ed7a42e6f 100644 --- a/templates/repo/settings/hook_slack.tmpl +++ b/templates/repo/settings/hook_slack.tmpl @@ -1,5 +1,5 @@
    - + {{.CsrfTokenHtml}}
    {{.i18n.Tr "repo.settings.add_slack_hook_desc" | Str2html}}
    From f7be61c81935a30c21797351db5da32183e3188d Mon Sep 17 00:00:00 2001 From: Christopher Brickley Date: Thu, 4 Sep 2014 19:05:21 -0400 Subject: [PATCH 040/153] getOrgRepoCtx returns values directly & err --- routers/repo/setting.go | 117 ++++++++++++++++++++++++---------------- 1 file changed, 71 insertions(+), 46 deletions(-) diff --git a/routers/repo/setting.go b/routers/repo/setting.go index 81747d43e..80a064492 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -286,14 +286,13 @@ func WebHooksNew(ctx *middleware.Context) { ctx.Data["PageIsSettingsHooksNew"] = true ctx.Data["Webhook"] = models.Webhook{HookEvent: &models.HookEvent{}} renderHookTypes(ctx) - orgId, repoId, _ := getOrgRepoCtx(ctx) - if repoId > 0 { - ctx.HTML(200, HOOK_NEW) - } else if orgId > 0 { - ctx.HTML(200, ORG_HOOK_NEW) - } else { - ctx.Handle(500, "WebHooksEdit(DetermineContext)", errors.New("Can't determine hook context")) + orCtx, err := getOrgRepoCtx(ctx) + if err != nil { + ctx.Handle(500, "WebHooksNew(getOrgRepoCtx)", err) + return } + + ctx.HTML(200, orCtx.NewTemplate) } func WebHooksNewPost(ctx *middleware.Context, form auth.NewWebhookForm) { @@ -302,10 +301,14 @@ func WebHooksNewPost(ctx *middleware.Context, form auth.NewWebhookForm) { ctx.Data["PageIsSettingsHooksNew"] = true ctx.Data["Webhook"] = models.Webhook{HookEvent: &models.HookEvent{}} - orgId, repoId, link := getOrgRepoCtx(ctx) + orCtx, err := getOrgRepoCtx(ctx) + if err != nil { + ctx.Handle(500, "WebHooksNewPost(getOrgRepoCtx)", err) + return + } if ctx.HasError() { - ctx.HTML(200, HOOK_NEW) + ctx.HTML(200, orCtx.NewTemplate) return } @@ -315,7 +318,7 @@ func WebHooksNewPost(ctx *middleware.Context, form auth.NewWebhookForm) { } w := &models.Webhook{ - RepoId: repoId, + RepoId: orCtx.RepoId, Url: form.PayloadUrl, ContentType: ct, Secret: form.Secret, @@ -325,7 +328,7 @@ func WebHooksNewPost(ctx *middleware.Context, form auth.NewWebhookForm) { IsActive: form.Active, HookTaskType: models.GOGS, Meta: "", - OrgId: orgId, + OrgId: orCtx.OrgId, } if err := w.UpdateEvent(); err != nil { @@ -337,7 +340,7 @@ func WebHooksNewPost(ctx *middleware.Context, form auth.NewWebhookForm) { } ctx.Flash.Success(ctx.Tr("repo.settings.add_hook_success")) - ctx.Redirect(link + "/settings/hooks") + ctx.Redirect(orCtx.Link + "/settings/hooks") } func WebHooksEdit(ctx *middleware.Context) { @@ -375,14 +378,12 @@ func WebHooksEdit(ctx *middleware.Context) { } w.GetEvent() ctx.Data["Webhook"] = w - orgId, repoId, _ := getOrgRepoCtx(ctx) - if repoId > 0 { - ctx.HTML(200, HOOK_NEW) - } else if orgId > 0 { - ctx.HTML(200, ORG_HOOK_NEW) - } else { - ctx.Handle(500, "WebHooksEdit(DetermineContext)", errors.New("Can't determine hook context")) + orCtx, err := getOrgRepoCtx(ctx) + if err != nil { + ctx.Handle(500, "WebHooksEdit(getOrgRepoCtx)", err) + return } + ctx.HTML(200, orCtx.NewTemplate) } func WebHooksEditPost(ctx *middleware.Context, form auth.NewWebhookForm) { @@ -408,8 +409,13 @@ func WebHooksEditPost(ctx *middleware.Context, form auth.NewWebhookForm) { w.GetEvent() ctx.Data["Webhook"] = w + orCtx, err := getOrgRepoCtx(ctx) + if err != nil { + ctx.Handle(500, "WebHooksEditPost(getOrgRepoCtx)", err) + return + } if ctx.HasError() { - ctx.HTML(200, HOOK_NEW) + ctx.HTML(200, orCtx.NewTemplate) return } @@ -432,10 +438,9 @@ func WebHooksEditPost(ctx *middleware.Context, form auth.NewWebhookForm) { ctx.Handle(500, "WebHooksEditPost", err) return } - _, _, link := getOrgRepoCtx(ctx) ctx.Flash.Success(ctx.Tr("repo.settings.update_hook_success")) - ctx.Redirect(fmt.Sprintf("%s/settings/hooks/%d", link, hookId)) + ctx.Redirect(fmt.Sprintf("%s/settings/hooks/%d", orCtx.Link, hookId)) } func SlackHooksNewPost(ctx *middleware.Context, form auth.NewSlackHookForm) { @@ -444,11 +449,16 @@ func SlackHooksNewPost(ctx *middleware.Context, form auth.NewSlackHookForm) { ctx.Data["PageIsSettingsHooksNew"] = true ctx.Data["Webhook"] = models.Webhook{HookEvent: &models.HookEvent{}} - if ctx.HasError() { - ctx.HTML(200, HOOK_NEW) + orCtx, err := getOrgRepoCtx(ctx) + if err != nil { + ctx.Handle(500, "SlackHooksNewPost(getOrgRepoCtx)", err) + return + } + + if ctx.HasError() { + ctx.HTML(200, orCtx.NewTemplate) return } - orgId, repoId, link := getOrgRepoCtx(ctx) meta, err := json.Marshal(&models.Slack{ Domain: form.Domain, @@ -461,7 +471,7 @@ func SlackHooksNewPost(ctx *middleware.Context, form auth.NewSlackHookForm) { } w := &models.Webhook{ - RepoId: repoId, + RepoId: orCtx.RepoId, Url: models.GetSlackURL(form.Domain, form.Token), ContentType: models.JSON, Secret: "", @@ -471,7 +481,7 @@ func SlackHooksNewPost(ctx *middleware.Context, form auth.NewSlackHookForm) { IsActive: form.Active, HookTaskType: models.SLACK, Meta: string(meta), - OrgId: orgId, + OrgId: orCtx.OrgId, } if err := w.UpdateEvent(); err != nil { ctx.Handle(500, "UpdateEvent", err) @@ -482,7 +492,7 @@ func SlackHooksNewPost(ctx *middleware.Context, form auth.NewSlackHookForm) { } ctx.Flash.Success(ctx.Tr("repo.settings.add_hook_success")) - ctx.Redirect(link + "/settings/hooks") + ctx.Redirect(orCtx.Link + "/settings/hooks") } func SlackHooksEditPost(ctx *middleware.Context, form auth.NewSlackHookForm) { @@ -491,9 +501,14 @@ func SlackHooksEditPost(ctx *middleware.Context, form auth.NewSlackHookForm) { ctx.Data["PageIsSettingsHooksEdit"] = true hookId := com.StrTo(ctx.Params(":id")).MustInt64() - fmt.Println("hookId slack=%d", hookId) if hookId == 0 { - ctx.Handle(404, "setting.WebHooksEditPost", nil) + ctx.Handle(404, "SlackHooksEditPost(hookId)", nil) + return + } + + orCtx, err := getOrgRepoCtx(ctx) + if err != nil { + ctx.Handle(500, "SlackHooksEditPost(getOrgRepoCtx)", err) return } @@ -510,7 +525,7 @@ func SlackHooksEditPost(ctx *middleware.Context, form auth.NewSlackHookForm) { ctx.Data["Webhook"] = w if ctx.HasError() { - ctx.HTML(200, HOOK_NEW) + ctx.HTML(200, orCtx.NewTemplate) return } meta, err := json.Marshal(&models.Slack{ @@ -536,25 +551,35 @@ func SlackHooksEditPost(ctx *middleware.Context, form auth.NewSlackHookForm) { ctx.Handle(500, "SlackHooksEditPost", err) return } - _, _, link := getOrgRepoCtx(ctx) ctx.Flash.Success(ctx.Tr("repo.settings.update_hook_success")) - ctx.Redirect(fmt.Sprintf("%s/settings/hooks/%d", link, hookId)) + ctx.Redirect(fmt.Sprintf("%s/settings/hooks/%d", orCtx.Link, hookId)) } -func getOrgRepoCtx(ctx *middleware.Context) (int64, int64, string) { - orgId := int64(0) - repoId := int64(0) - link := "" +type OrgRepoCtx struct { + OrgId int64 + RepoId int64 + Link string + NewTemplate base.TplName +} + +// determines whether this is a repo context or organization context +func getOrgRepoCtx(ctx *middleware.Context) (*OrgRepoCtx, error) { if _, ok := ctx.Data["RepoLink"]; ok { - repoId = ctx.Repo.Repository.Id - link = ctx.Repo.RepoLink + return &OrgRepoCtx{ + OrgId: int64(0), + RepoId: ctx.Repo.Repository.Id, + Link: ctx.Repo.RepoLink, + NewTemplate: HOOK_NEW, + }, nil + } else if _, ok := ctx.Data["OrgLink"]; ok { + return &OrgRepoCtx{ + OrgId: ctx.Org.Organization.Id, + RepoId: int64(0), + Link: ctx.Org.OrgLink, + NewTemplate: ORG_HOOK_NEW, + }, nil + } else { + return &OrgRepoCtx{}, errors.New("Unable to set OrgRepo context") } - - if _, ok := ctx.Data["OrgLink"]; ok { - orgId = ctx.Org.Organization.Id - link = ctx.Org.OrgLink - } - - return orgId, repoId, link } From ab7206d6b787645956b0279f729bd7b22cbed690 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 5 Sep 2014 17:28:09 -0400 Subject: [PATCH 041/153] Fix #348 --- README.md | 3 +- README_ZH.md | 3 +- cmd/web.go | 1 + conf/locale/locale_en-US.ini | 3 + conf/locale/locale_zh-CN.ini | 3 + gogs.go | 2 +- models/repo.go | 4 +- routers/home.go | 26 +++++++- templates/.VERSION | 2 +- templates/explore/nav.tmpl | 8 +++ templates/explore/repos.tmpl | 25 ++++++++ templates/org/settings/options.tmpl | 96 ++++++++++++++--------------- templates/status/404.tmpl | 4 +- 13 files changed, 121 insertions(+), 59 deletions(-) create mode 100644 templates/explore/nav.tmpl create mode 100644 templates/explore/repos.tmpl diff --git a/README.md b/README.md index ddb8367e9..689b0df4f 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ There are 5 ways to install Gogs: - [Install from binary](http://gogs.io/docs/installation/install_from_binary.md): **STRONGLY RECOMMENDED** - [Install from source](http://gogs.io/docs/installation/install_from_source.md) - [Install from packages](http://gogs.io/docs/installation/install_from_packages.md) -- [Ship with Docker](https://github.com/gogits/gogs/tree/master/dockerfiles) +- [Ship with Docker](https://github.com/gogits/gogs/tree/master/docker) - [Install with Vagrant](https://github.com/geerlingguy/ansible-vagrant-examples/tree/master/gogs) ## Acknowledgments @@ -70,7 +70,6 @@ There are 5 ways to install Gogs: - Usage and modification from [beego](http://beego.me) modules. - Thanks [lavachen](http://www.lavachen.cn/) and [Rocker](http://weibo.com/rocker1989) for designing Logo. - Thanks [gobuild.io](http://gobuild.io) for providing binary compile and download service. -- Thanks [Docker China](http://www.dockboard.org/) for providing [dockerfiles](https://github.com/gogits/gogs/tree/master/dockerfiles). ## Contributors diff --git a/README_ZH.md b/README_ZH.md index de982baf3..401c8186c 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -50,7 +50,7 @@ Gogs 的目标是打造一个最简单、最快速和最轻松的方式搭建自 - [二进制安装](http://gogs.io/docs/installation/install_from_binary.md): **强烈推荐** - [源码安装](http://gogs.io/docs/installation/install_from_source.md) - [包管理安装](http://gogs.io/docs/installation/install_from_packages.md) -- [采用 Docker 部署](https://github.com/gogits/gogs/tree/master/dockerfiles) +- [采用 Docker 部署](https://github.com/gogits/gogs/tree/master/docker) - [通过 Vagrant 安装](https://github.com/geerlingguy/ansible-vagrant-examples/tree/master/gogs) ## 特别鸣谢 @@ -61,7 +61,6 @@ Gogs 的目标是打造一个最简单、最快速和最轻松的方式搭建自 - [martini](http://martini.codegangsta.io/) 的路由与中间件机制。 - 感谢 [gobuild.io](http://gobuild.io) 提供二进制编译与下载服务。 - 感谢 [lavachen](http://www.lavachen.cn/) 和 [Rocker](http://weibo.com/rocker1989) 设计的 Logo。 -- 感谢 [Docker 中文社区](http://www.dockboard.org/) 提供的 [dockerfiles](https://github.com/gogits/gogs/tree/master/dockerfiles)。 ## 贡献成员 diff --git a/cmd/web.go b/cmd/web.go index 57164683a..cad1db336 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -124,6 +124,7 @@ func runWeb(*cli.Context) { // Routers. m.Get("/", ignSignIn, routers.Home) + m.Get("/explore", routers.Explore) m.Get("/install", bindIgnErr(auth.InstallForm{}), routers.Install) m.Post("/install", bindIgnErr(auth.InstallForm{}), routers.InstallPost) m.Group("", func(r *macaron.Router) { diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini index 946d56046..e8329933a 100644 --- a/conf/locale/locale_en-US.ini +++ b/conf/locale/locale_en-US.ini @@ -47,6 +47,9 @@ collaborative_repos = Collaborative Repositories my_orgs = My Organizations my_mirrors = My Mirrors +[explore] +repos = Repositories + [auth] create_new_account = Create New Account register_hepler_msg = Already have an account? Sign in now! diff --git a/conf/locale/locale_zh-CN.ini b/conf/locale/locale_zh-CN.ini index 55d22f23e..a61a54ceb 100644 --- a/conf/locale/locale_zh-CN.ini +++ b/conf/locale/locale_zh-CN.ini @@ -47,6 +47,9 @@ collaborative_repos = 参与协作的仓库 my_orgs = 我的组织 my_mirrors = 我的镜像 +[explore] +repos = 探索仓库 + [auth] create_new_account = 创建帐户 register_hepler_msg = 已经注册?立即登录! diff --git a/gogs.go b/gogs.go index a11601907..1c012d409 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.4.9.0902 Beta" +const APP_VER = "0.4.9.0905 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/models/repo.go b/models/repo.go index 23d44a6b8..341e7e47a 100644 --- a/models/repo.go +++ b/models/repo.go @@ -972,8 +972,8 @@ func GetRepositories(uid int64, private bool) ([]*Repository, error) { } // GetRecentUpdatedRepositories returns the list of repositories that are recently updated. -func GetRecentUpdatedRepositories() (repos []*Repository, err error) { - err = x.Where("is_private=?", false).Limit(5).Desc("updated").Find(&repos) +func GetRecentUpdatedRepositories(num int) (repos []*Repository, err error) { + err = x.Where("is_private=?", false).Limit(num).Desc("updated").Find(&repos) return repos, err } diff --git a/routers/home.go b/routers/home.go index 5ea3e2a02..36a4f50fd 100644 --- a/routers/home.go +++ b/routers/home.go @@ -5,6 +5,9 @@ package routers import ( + "fmt" + + "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/middleware" "github.com/gogits/gogs/modules/setting" @@ -12,7 +15,8 @@ import ( ) const ( - HOME base.TplName = "home" + HOME base.TplName = "home" + EXPLORE_REPOS base.TplName = "explore/repos" ) func Home(ctx *middleware.Context) { @@ -42,6 +46,26 @@ func Home(ctx *middleware.Context) { ctx.HTML(200, HOME) } +func Explore(ctx *middleware.Context) { + ctx.Data["Title"] = ctx.Tr("explore") + ctx.Data["PageIsExploreRepositories"] = true + + repos, err := models.GetRecentUpdatedRepositories(20) + if err != nil { + ctx.Handle(500, "GetRecentUpdatedRepositories", err) + return + } + for _, repo := range repos { + if err = repo.GetOwner(); err != nil { + ctx.Handle(500, "GetOwner", fmt.Errorf("%d: %v", repo.Id, err)) + return + } + } + ctx.Data["Repos"] = repos + + ctx.HTML(200, EXPLORE_REPOS) +} + func NotFound(ctx *middleware.Context) { ctx.Data["Title"] = "Page Not Found" ctx.Handle(404, "home.NotFound", nil) diff --git a/templates/.VERSION b/templates/.VERSION index 5f3c51819..6e361299e 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.4.9.0902 Beta \ No newline at end of file +0.4.9.0905 Beta \ No newline at end of file diff --git a/templates/explore/nav.tmpl b/templates/explore/nav.tmpl new file mode 100644 index 000000000..1310bccf0 --- /dev/null +++ b/templates/explore/nav.tmpl @@ -0,0 +1,8 @@ +
    +

    {{.i18n.Tr "explore"}}

    + +
    \ No newline at end of file diff --git a/templates/explore/repos.tmpl b/templates/explore/repos.tmpl new file mode 100644 index 000000000..a1e3d408e --- /dev/null +++ b/templates/explore/repos.tmpl @@ -0,0 +1,25 @@ +{{template "ng/base/head" .}} +{{template "ng/base/header" .}} +
    +
    + {{template "explore/nav" .}} +
    +
    +
    + {{range .Repos}} +
    +
      +
    • {{.NumStars}}
    • +
    • {{.NumForks}}
    • +
    +

    {{.Name}}

    +

    {{.Description}}

    +

    {{$.i18n.Tr "org.repo_updated"}} {{TimeSince .Updated $.i18n.Lang}}

    +
    + {{end}} +
    +
    +
    +
    +
    +{{template "ng/base/footer" .}} \ No newline at end of file diff --git a/templates/org/settings/options.tmpl b/templates/org/settings/options.tmpl index ae225a9ca..14ea1b349 100644 --- a/templates/org/settings/options.tmpl +++ b/templates/org/settings/options.tmpl @@ -3,54 +3,54 @@ {{template "org/base/header" .}}
    - {{template "org/settings/nav" .}} -
    -
    - {{template "ng/base/alert" .}} -
    -
    -
    - {{.i18n.Tr "org.settings.options"}} -
    - - {{.CsrfTokenHtml}} - -
    - - -
    -
    - - -
    -
    - - -
    -
    - - -
    -
    - - -
    -
    - - -
    -
    - - -
    -
    - - -
    - -
    -
    -
    + {{template "org/settings/nav" .}} +
    +
    + {{template "ng/base/alert" .}} +
    +
    +
    + {{.i18n.Tr "org.settings.options"}} +
    +
    + {{.CsrfTokenHtml}} + +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    +
    +
    +
    diff --git a/templates/status/404.tmpl b/templates/status/404.tmpl index 2d04b5591..e024715ed 100644 --- a/templates/status/404.tmpl +++ b/templates/status/404.tmpl @@ -1,11 +1,11 @@ {{template "ng/base/head" .}} {{template "ng/base/header" .}} -
    +

    404



    Application Version: {{AppVer}}

    If you think this is an error, please open an issue on GitHub.

    -

    We're currently working on 0.5 beta version, many pages may be missing at this time. Sorry for confusion!

    +
    {{template "ng/base/footer" .}} From 0ddb1eb769610f1d74997ad12d848ae5a0bdb4ab Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sun, 7 Sep 2014 19:02:58 -0400 Subject: [PATCH 042/153] Finish new install page, almost ready for 0.5 release --- conf/locale/locale_en-US.ini | 47 ++++- conf/locale/locale_zh-CN.ini | 45 ++++ gogs.go | 2 +- modules/auth/user_form.go | 21 +- public/ng/css/gogs.css | 13 ++ public/ng/js/gogs.js | 42 +++- public/ng/js/min/gogs-min.js | 10 +- public/ng/less/gogs/external.less | 174 ++++++++-------- routers/install.go | 49 +++-- templates/.VERSION | 2 +- templates/install.tmpl | 334 +++++++++++++----------------- 11 files changed, 424 insertions(+), 315 deletions(-) diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini index e8329933a..50fbc3cd5 100644 --- a/conf/locale/locale_en-US.ini +++ b/conf/locale/locale_en-US.ini @@ -38,6 +38,50 @@ issues = Issues cancel = Cancel +[install] +install = Installation +title = Install Steps For First-time Run +requite_db_desc = Gogs requires MySQL, PostgreSQL or SQLite3, but SQLite3 is usually available in the official binary version. +db_type = Database Type +host = Host +user = User +password = Password +db_name = Database Name +db_helper = Please use INNODB engine with utf8_general_ci charset for MySQL. +ssl_mode = SSL Mode +path = Path +sqlite_helper = The file path of SQLite3 database. +general_title = General Settings of Gogs +repo_path = Repository Root Path +repo_path_helper = All Git remote repositories will be saved to this directory. +run_user = Run User +run_user_helper = The user must have access to Repository Root Path and run Gogs. +domain = Domain +domain_helper = This affects SSH clone URLs. +app_url = Application URL +app_url_helper = This affects HTTP/HTTPS clone URL and somewhere in e-mail. +email_title = Email Service Settings(Optional) +smtp_host = SMTP Host +mailer_user = Sender E-mail +mailer_password = Sender Password +notify_title = Notification Settings(Optional) +register_confirm = Enable Register Confirmation +mail_notify = Enable Mail Notification +admin_title = Admin Account Settings +admin_name = Username +admin_password = Password +confirm_password = Confirm Password +admin_email = E-mail +install_gogs = Install Gogs +test_git_failed = Fail to test 'git' command: %v +sqlite3_not_available = Your release version does not support SQLite3, please download the official binary version from http://gogs.io/docs/installation/install_from_binary.html, NOT the gobuild version. +invalid_db_setting = Database setting is not correct: %v +invalid_repo_path = Repository root path is invalid: %v +run_user_not_match = Run user isn't the current user: %s -> %s +save_config_failed = Fail to save configuration: %v +invalid_admin_setting = Admin account setting is invalid: %v +install_success = Welcome! We're glad that you choose Gogs, have fun and take care. + [home] uname_holder = Username or E-mail password_holder = Password @@ -84,6 +128,7 @@ HttpsUrl = HTTPS URL PayloadUrl = Payload URL TeamName = Team name AuthName = Authorization name +AdminEmail = Admin E-mail require_error = ` cannot be empty.` alpha_dash_error = ` must be valid alpha or numeric or dash(-_) characters.` @@ -94,7 +139,7 @@ email_error = ` is not a valid e-mail address.` url_error = ` is not a valid URL.` unknown_error = Unknown error: captcha_incorrect = Captcha didn't match. -password_not_match = Password and re-type password are not same. +password_not_match = Password and confirm password are not same. username_been_taken = Username has been already taken. repo_name_been_taken = Repository name has been already taken. diff --git a/conf/locale/locale_zh-CN.ini b/conf/locale/locale_zh-CN.ini index a61a54ceb..7d10142e6 100644 --- a/conf/locale/locale_zh-CN.ini +++ b/conf/locale/locale_zh-CN.ini @@ -38,6 +38,50 @@ issues = 工单管理 cancel = 取消 +[install] +install = 安装页面 +title = 首次运行安装程序 +requite_db_desc = Gogs 允许后端数据库为 MySQL、PostgreSQL 或 SQLite3,但是 SQLite3 一般只有官方二进制发行版才支持。 +db_type = 数据库类型 +host = 数据库主机 +user = 数据库用户 +password = 数据库用户密码 +db_name = 数据库名称 +db_helper = 如果您使用 MySQL,请使用 INNODB 引擎以及 utf8_general_ci 字符集。 +ssl_mode = SSL 模式 +path = 数据库文件路径 +sqlite_helper = SQLite3 数据库的文件路径。 +general_title = 应用基本设置 +repo_path = 仓库根目录 +repo_path_helper = 所有 Git 远程仓库都将被存放于该目录。 +run_user = 运行系统用户 +run_user_helper = 该用户必须具有对仓库根目录和运行 Gogs 的操作权限。 +domain = 域名 +domain_helper = 该设置影响 SSH 克隆地址。 +app_url = 应用 URL +app_url_helper = 该设置影响 HTTP/HTTPS 克隆地址和一些邮箱中的链接。 +email_title = 邮件服务设置(可选) +smtp_host = SMTP 主机 +mailer_user = 发送邮箱 +mailer_password = 发送邮箱密码 +notify_title = 通知提醒设置(可选) +register_confirm = 启用注册邮箱确认 +mail_notify = 启用邮件通知提醒 +admin_title = 管理员帐号设置 +admin_name = 管理员用户名 +admin_password = 管理员密码 +confirm_password = 确认密码 +admin_email = 管理员邮箱 +install_gogs = 立即安装 +test_git_failed = 无法识别 'git' 命令:%v +sqlite3_not_available = 您所使用的发行版不支持 SQLite3,请从 http://gogs.io/docs/installation/install_from_binary.html 下载官方二进制发行版,而不是 gobuild 版本。 +invalid_db_setting = 数据库设置不正确:%v +invalid_repo_path = 仓库根目录设置不正确:%v +run_user_not_match = 运行系统用户非当前用户:%s -> %s +save_config_failed = 应用配置保存失败:%v +invalid_admin_setting = 管理员帐户设置不正确:%v +install_success = 您好!我们很高兴您选择使用 Gogs,祝您使用愉快,代码从此无 BUG! + [home] uname_holder = 用户名或邮箱 password_holder = 密码 @@ -84,6 +128,7 @@ HttpsUrl = HTTPS URL 地址 PayloadUrl = 推送地址 TeamName = 团队名称 AuthName = 认证名称 +AdminEmail = 管理员邮箱 require_error = 不能为空。 alpha_dash_error = 必须为英文字母、阿拉伯数字或横线(-_)。 diff --git a/gogs.go b/gogs.go index 1c012d409..2ca0f9ad8 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.4.9.0905 Beta" +const APP_VER = "0.5.0.0907 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/modules/auth/user_form.go b/modules/auth/user_form.go index 51a07b912..93bd01a9f 100644 --- a/modules/auth/user_form.go +++ b/modules/auth/user_form.go @@ -13,24 +13,25 @@ import ( type InstallForm struct { Database string `form:"database" binding:"Required"` - Host string `form:"host"` - User string `form:"user"` - Passwd string `form:"passwd"` + DbHost string `form:"host"` + DbUser string `form:"user"` + DbPasswd string `form:"passwd"` DatabaseName string `form:"database_name"` SslMode string `form:"ssl_mode"` DatabasePath string `form:"database_path"` - RepoRootPath string `form:"repo_path"` - RunUser string `form:"run_user"` - Domain string `form:"domain"` - AppUrl string `form:"app_url"` - AdminName string `form:"admin_name" binding:"Required;AlphaDashDot;MaxSize(30)"` - AdminPasswd string `form:"admin_pwd" binding:"Required;MinSize(6);MaxSize(255)"` - AdminEmail string `form:"admin_email" binding:"Required;Email;MaxSize(50)"` + RepoRootPath string `form:"repo_path" binding:"Required"` + RunUser string `form:"run_user" binding:"Required"` + Domain string `form:"domain" binding:"Required"` + AppUrl string `form:"app_url" binding:"Required"` SmtpHost string `form:"smtp_host"` SmtpEmail string `form:"mailer_user"` SmtpPasswd string `form:"mailer_pwd"` RegisterConfirm string `form:"register_confirm"` MailNotify string `form:"mail_notify"` + AdminName string `form:"admin_name" binding:"Required;AlphaDashDot;MaxSize(30)"` + AdminPasswd string `form:"admin_pwd" binding:"Required;MinSize(6);MaxSize(255)"` + ConfirmPasswd string `form:"confirm_passwd" binding:"Required;MinSize(6);MaxSize(255)"` + AdminEmail string `form:"admin_email" binding:"Required;Email;MaxSize(50)"` } func (f *InstallForm) Validate(ctx *macaron.Context, errs *binding.Errors, l i18n.Locale) { diff --git a/public/ng/css/gogs.css b/public/ng/css/gogs.css index 636a86677..f4d33540e 100644 --- a/public/ng/css/gogs.css +++ b/public/ng/css/gogs.css @@ -669,6 +669,19 @@ ol.linenums { #feature-wrapper .grid-1-2 { margin-bottom: 30px; } +#install-form { + padding: 15px; +} +#install-form label { + width: 35%; +} +#install-form input { + width: 30%; +} +#install-form input[type="checkbox"], +#install-form input[type="radio"] { + width: auto; +} /* The dashboard page style */ diff --git a/public/ng/js/gogs.js b/public/ng/js/gogs.js index c08a887a4..cb23c8f97 100644 --- a/public/ng/js/gogs.js +++ b/public/ng/js/gogs.js @@ -521,7 +521,7 @@ function initAdmin() { e.preventDefault(); return true; } - var $form = $('user-profile-form'); + var $form = $('#user-profile-form'); $form.attr('action', $form.data('delete-url')); }); // Create authorization. @@ -547,6 +547,43 @@ function initAdmin() { }); } +function initInstall() { + // Change database type. + (function () { + var mysql_default = '127.0.0.1:3306'; + var postgres_default = '127.0.0.1:5432'; + + $('#install-database').on("change", function () { + var val = $(this).val(); + if (val != "SQLite3") { + $('.server-sql').show(); + $('.sqlite-setting').addClass("hide"); + if (val == "PostgreSQL") { + $('.pgsql-setting').removeClass("hide"); + + // Change the host value to the Postgres default, but only + // if the user hasn't already changed it from the MySQL + // default. + if ($('#database-host').val() == mysql_default) { + $('#database-host').val(postgres_default); + } + } else if (val == 'MySQL') { + $('.pgsql-setting').addClass("hide"); + if ($('#database-host').val() == postgres_default) { + $('#database-host').val(mysql_default); + } + } else { + $('.pgsql-setting').addClass("hide"); + } + } else { + $('.server-sql').hide(); + $('.pgsql-setting').hide(); + $('.sqlite-setting').removeClass("hide"); + } + }); + }()); +} + $(document).ready(function () { initCore(); if ($('#user-profile-setting').length) { @@ -579,6 +616,9 @@ $(document).ready(function () { if ($('#admin-setting').length) { initAdmin(); } + if ($('#install-form').length) { + initInstall(); + } Tabs('#dashboard-sidebar-menu'); diff --git a/public/ng/js/min/gogs-min.js b/public/ng/js/min/gogs-min.js index 4e4d63fe5..8151792f2 100644 --- a/public/ng/js/min/gogs-min.js +++ b/public/ng/js/min/gogs-min.js @@ -1,5 +1,5 @@ -function Tabs(e){function t(e){console.log("hide",e),e.removeClass("js-tab-nav-show"),$(e.data("tab-target")).removeClass("js-tab-show").hide()}function n(e){console.log("show",e),e.addClass("js-tab-nav-show"),$(e.data("tab-target")).addClass("js-tab-show").show()}var r=$(e);if(r.length){var i=r.find(".js-tab-nav-show");i.length&&$(i.data("tab-target")).addClass("js-tab-show"),r.on("click",".js-tab-nav",function(){var e=$(this);e.hasClass("js-tab-nav-show")||(i=r.find(".js-tab-nav-show").eq(0),t(i),n(e))}),console.log("init tabs @",e)}}function initCore(){Gogs.renderMarkdown(),Gogs.renderCodeView()}function homepage(){$("#promo-form").submit(function(e){return""===$("#username").val()?(e.preventDefault(),window.location.href="/user/login",!0):void 0}),$("#register-button").click(function(e){return""===$("#username").val()?(e.preventDefault(),window.location.href="/user/sign_up",!0):void $("#promo-form").attr("action","/user/sign_up")})}function settingsProfile(){$("#user-profile-form").submit(function(e){return $("#username").data("uname")==$("#username").val()||confirm("Username has been changed, do you want to continue?")?void 0:(e.preventDefault(),!0)})}function settingsSSHKeys(){$("#ssh-add").click(function(){$("#user-ssh-add-form").removeClass("hide")})}function settingsDelete(){$("#delete-account-button").click(function(e){return confirm("This account is going to deleted, do you want to continue?")?void 0:(e.preventDefault(),!0)})}!function(e,t){"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){function n(e){var t=e.length,n=ot.type(e);return"function"===n||ot.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e}function r(e,t,n){if(ot.isFunction(t))return ot.grep(e,function(e,r){return!!t.call(e,r,e)!==n});if(t.nodeType)return ot.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(pt.test(t))return ot.filter(t,e,n);t=ot.filter(t,e)}return ot.grep(e,function(e){return ot.inArray(e,t)>=0!==n})}function i(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}function o(e){var t=wt[e]={};return ot.each(e.match(xt)||[],function(e,n){t[n]=!0}),t}function a(){mt.addEventListener?(mt.removeEventListener("DOMContentLoaded",s,!1),e.removeEventListener("load",s,!1)):(mt.detachEvent("onreadystatechange",s),e.detachEvent("onload",s))}function s(){(mt.addEventListener||"load"===event.type||"complete"===mt.readyState)&&(a(),ot.ready())}function l(e,t,n){if(void 0===n&&1===e.nodeType){var r="data-"+t.replace(kt,"-$1").toLowerCase();if(n=e.getAttribute(r),"string"==typeof n){try{n="true"===n?!0:"false"===n?!1:"null"===n?null:+n+""===n?+n:Et.test(n)?ot.parseJSON(n):n}catch(i){}ot.data(e,t,n)}else n=void 0}return n}function u(e){var t;for(t in e)if(("data"!==t||!ot.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}function c(e,t,n,r){if(ot.acceptData(e)){var i,o,a=ot.expando,s=e.nodeType,l=s?ot.cache:e,u=s?e[a]:e[a]&&a;if(u&&l[u]&&(r||l[u].data)||void 0!==n||"string"!=typeof t)return u||(u=s?e[a]=G.pop()||ot.guid++:a),l[u]||(l[u]=s?{}:{toJSON:ot.noop}),("object"==typeof t||"function"==typeof t)&&(r?l[u]=ot.extend(l[u],t):l[u].data=ot.extend(l[u].data,t)),o=l[u],r||(o.data||(o.data={}),o=o.data),void 0!==n&&(o[ot.camelCase(t)]=n),"string"==typeof t?(i=o[t],null==i&&(i=o[ot.camelCase(t)])):i=o,i}}function d(e,t,n){if(ot.acceptData(e)){var r,i,o=e.nodeType,a=o?ot.cache:e,s=o?e[ot.expando]:ot.expando;if(a[s]){if(t&&(r=n?a[s]:a[s].data)){ot.isArray(t)?t=t.concat(ot.map(t,ot.camelCase)):t in r?t=[t]:(t=ot.camelCase(t),t=t in r?[t]:t.split(" ")),i=t.length;for(;i--;)delete r[t[i]];if(n?!u(r):!ot.isEmptyObject(r))return}(n||(delete a[s].data,u(a[s])))&&(o?ot.cleanData([e],!0):rt.deleteExpando||a!=a.window?delete a[s]:a[s]=null)}}}function f(){return!0}function p(){return!1}function h(){try{return mt.activeElement}catch(e){}}function m(e){var t=Ht.split("|"),n=e.createDocumentFragment();if(n.createElement)for(;t.length;)n.createElement(t.pop());return n}function g(e,t){var n,r,i=0,o=typeof e.getElementsByTagName!==St?e.getElementsByTagName(t||"*"):typeof e.querySelectorAll!==St?e.querySelectorAll(t||"*"):void 0;if(!o)for(o=[],n=e.childNodes||e;null!=(r=n[i]);i++)!t||ot.nodeName(r,t)?o.push(r):ot.merge(o,g(r,t));return void 0===t||t&&ot.nodeName(e,t)?ot.merge([e],o):o}function v(e){jt.test(e.type)&&(e.defaultChecked=e.checked)}function y(e,t){return ot.nodeName(e,"table")&&ot.nodeName(11!==t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function b(e){return e.type=(null!==ot.find.attr(e,"type"))+"/"+e.type,e}function x(e){var t=Zt.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function w(e,t){for(var n,r=0;null!=(n=e[r]);r++)ot._data(n,"globalEval",!t||ot._data(t[r],"globalEval"))}function C(e,t){if(1===t.nodeType&&ot.hasData(e)){var n,r,i,o=ot._data(e),a=ot._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)ot.event.add(t,n,s[n][r])}a.data&&(a.data=ot.extend({},a.data))}}function S(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!rt.noCloneEvent&&t[ot.expando]){i=ot._data(t);for(r in i.events)ot.removeEvent(t,r,i.handle);t.removeAttribute(ot.expando)}"script"===n&&t.text!==e.text?(b(t).text=e.text,x(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),rt.html5Clone&&e.innerHTML&&!ot.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&jt.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}function T(t,n){var r,i=ot(n.createElement(t)).appendTo(n.body),o=e.getDefaultComputedStyle&&(r=e.getDefaultComputedStyle(i[0]))?r.display:ot.css(i[0],"display");return i.detach(),o}function E(e){var t=mt,n=Jt[e];return n||(n=T(e,t),"none"!==n&&n||(Kt=(Kt||ot("
    ',srcAction:"iframe_src",patterns:{youtube:{index:"youtube.com",id:"v=",src:"//www.youtube.com/embed/%id%?autoplay=1"},vimeo:{index:"vimeo.com/",id:"/",src:"//player.vimeo.com/video/%id%?autoplay=1"},gmaps:{index:"//maps.google.",src:"%id%&output=embed"}}},proto:{initIframe:function(){t.types.push(Z),x("BeforeChange",function(e,t,n){t!==n&&(t===Z?D():n===Z&&D(!0))}),x(l+"."+Z,function(){D()})},getIframe:function(n,i){var o=n.src,r=t.st.iframe;e.each(r.patterns,function(){return o.indexOf(this.index)>-1?(this.id&&(o="string"==typeof this.id?o.substr(o.lastIndexOf(this.id)+this.id.length,o.length):this.id.call(this,o)),o=this.src.replace("%id%",o),!1):void 0});var a={};return r.srcAction&&(a[r.srcAction]=o),t._parseMarkup(i,a,n),t.updateStatus("ready"),i}}});var K=function(e){var n=t.items.length;return e>n-1?e-n:0>e?n+e:e},Y=function(e,t,n){return e.replace(/%curr%/gi,t+1).replace(/%total%/gi,n)};e.magnificPopup.registerModule("gallery",{options:{enabled:!1,arrowMarkup:'',preload:[0,2],navigateByImgClick:!0,arrows:!0,tPrev:"Previous (Left arrow key)",tNext:"Next (Right arrow key)",tCounter:"%curr% of %total%"},proto:{initGallery:function(){var n=t.st.gallery,i=".mfp-gallery",r=Boolean(e.fn.mfpFastClick);return t.direction=!0,n&&n.enabled?(a+=" mfp-gallery",x(f+i,function(){n.navigateByImgClick&&t.wrap.on("click"+i,".mfp-img",function(){return t.items.length>1?(t.next(),!1):void 0}),o.on("keydown"+i,function(e){37===e.keyCode?t.prev():39===e.keyCode&&t.next()})}),x("UpdateStatus"+i,function(e,n){n.text&&(n.text=Y(n.text,t.currItem.index,t.items.length))}),x(p+i,function(e,i,o,r){var a=t.items.length;o.counter=a>1?Y(n.tCounter,r.index,a):""}),x("BuildControls"+i,function(){if(t.items.length>1&&n.arrows&&!t.arrowLeft){var i=n.arrowMarkup,o=t.arrowLeft=e(i.replace(/%title%/gi,n.tPrev).replace(/%dir%/gi,"left")).addClass(y),a=t.arrowRight=e(i.replace(/%title%/gi,n.tNext).replace(/%dir%/gi,"right")).addClass(y),s=r?"mfpFastClick":"click";o[s](function(){t.prev()}),a[s](function(){t.next()}),t.isIE7&&(k("b",o[0],!1,!0),k("a",o[0],!1,!0),k("b",a[0],!1,!0),k("a",a[0],!1,!0)),t.container.append(o.add(a))}}),x(m+i,function(){t._preloadTimeout&&clearTimeout(t._preloadTimeout),t._preloadTimeout=setTimeout(function(){t.preloadNearbyImages(),t._preloadTimeout=null},16)}),x(l+i,function(){o.off(i),t.wrap.off("click"+i),t.arrowLeft&&r&&t.arrowLeft.add(t.arrowRight).destroyMfpFastClick(),t.arrowRight=t.arrowLeft=null}),void 0):!1},next:function(){t.direction=!0,t.index=K(t.index+1),t.updateItemHTML()},prev:function(){t.direction=!1,t.index=K(t.index-1),t.updateItemHTML()},goTo:function(e){t.direction=e>=t.index,t.index=e,t.updateItemHTML()},preloadNearbyImages:function(){var e,n=t.st.gallery.preload,i=Math.min(n[0],t.items.length),o=Math.min(n[1],t.items.length);for(e=1;(t.direction?o:i)>=e;e++)t._preloadItem(t.index+e);for(e=1;(t.direction?i:o)>=e;e++)t._preloadItem(t.index-e)},_preloadItem:function(n){if(n=K(n),!t.items[n].preloaded){var i=t.items[n];i.parsed||(i=t.parseEl(n)),T("LazyLoad",i),"image"===i.type&&(i.img=e('').on("load.mfploader",function(){i.hasSize=!0}).on("error.mfploader",function(){i.hasSize=!0,i.loadError=!0,T("LazyLoadError",i)}).attr("src",i.src)),i.preloaded=!0}}}});var U="retina";e.magnificPopup.registerModule(U,{options:{replaceSrc:function(e){return e.src.replace(/\.\w+$/,function(e){return"@2x"+e})},ratio:1},proto:{initRetina:function(){if(window.devicePixelRatio>1){var e=t.st.retina,n=e.ratio;n=isNaN(n)?n():n,n>1&&(x("ImageHasSize."+U,function(e,t){t.img.css({"max-width":t.img[0].naturalWidth/n,width:"100%"})}),x("ElementParse."+U,function(t,i){i.src=e.replaceSrc(i,n)}))}}}}),function(){var t=1e3,n="ontouchstart"in window,i=function(){I.off("touchmove"+r+" touchend"+r)},o="mfpFastClick",r="."+o;e.fn.mfpFastClick=function(o){return e(this).each(function(){var a,s=e(this);if(n){var l,c,d,u,p,f;s.on("touchstart"+r,function(e){u=!1,f=1,p=e.originalEvent?e.originalEvent.touches[0]:e.touches[0],c=p.clientX,d=p.clientY,I.on("touchmove"+r,function(e){p=e.originalEvent?e.originalEvent.touches:e.touches,f=p.length,p=p[0],(Math.abs(p.clientX-c)>10||Math.abs(p.clientY-d)>10)&&(u=!0,i())}).on("touchend"+r,function(e){i(),u||f>1||(a=!0,e.preventDefault(),clearTimeout(l),l=setTimeout(function(){a=!1},t),o())})})}s.on("click"+r,function(){a||o()})})},e.fn.destroyMfpFastClick=function(){e(this).off("touchstart"+r+" click"+r),n&&I.off("touchmove"+r+" touchend"+r)}}(),_()})(window.jQuery||window.Zepto); \ No newline at end of file diff --git a/public/ng/js/min/gogs-min.js b/public/ng/js/min/gogs-min.js index 1a805b5f0..d27e0a8b3 100644 --- a/public/ng/js/min/gogs-min.js +++ b/public/ng/js/min/gogs-min.js @@ -1,5 +1,5 @@ -function Tabs(e){function t(e){console.log("hide",e),e.removeClass("js-tab-nav-show"),$(e.data("tab-target")).removeClass("js-tab-show").hide()}function n(e){console.log("show",e),e.addClass("js-tab-nav-show"),$(e.data("tab-target")).addClass("js-tab-show").show()}var r=$(e);if(r.length){var i=r.find(".js-tab-nav-show");i.length&&$(i.data("tab-target")).addClass("js-tab-show"),r.on("click",".js-tab-nav",function(e){e.preventDefault();var o=$(this);o.hasClass("js-tab-nav-show")||(i=r.find(".js-tab-nav-show").eq(0),t(i),n(o))}),console.log("init tabs @",e)}}function Preview(e,t){function n(e){return e.find(".js-preview-input").eq(0)}function r(e){return e.hasClass("js-preview-container")?e:e.find(".js-preview-container").eq(0)}var i=$(e),o=$(t),a=n(o);if(!a.length)return void console.log("[preview]: no preview input");var s=r(o);return s.length?(i.on("click",function(){$.post("/api/v1/markdown",{text:a.val()},function(e){s.html(e)})}),void console.log("[preview]: init preview @",e,"&",t)):void console.log("[preview]: no preview container")}function initCore(){Gogs.renderMarkdown(),Gogs.renderCodeView(),$(".js-tab-nav").click(function(e){$(this).hasClass("js-tab-nav-show")||($(this).parent().find(".js-tab-nav-show").each(function(){$(this).removeClass("js-tab-nav-show"),$($(this).data("tab-target")).hide()}),$(this).addClass("js-tab-nav-show"),$($(this).data("tab-target")).show()),e.preventDefault()})}function initUserSetting(){$("#user-profile-form").submit(function(e){var t=$("#username");return t.data("uname")==t.val()||confirm("Username has been changed, do you want to continue?")?void 0:(e.preventDefault(),!0)}),$("#ssh-add").click(function(){$("#user-ssh-add-form").removeClass("hide")}),$("#delete-account-button").click(function(e){return confirm("This account is going to be deleted, do you want to continue?")?void 0:(e.preventDefault(),!0)})}function initRepoCreate(){$("#repo-create-owner-list").on("click","li",function(){if(!$(this).hasClass("checked")){var e=$(this).data("uid");$("#repo-owner-id").val(e),$("#repo-owner-avatar").attr("src",$(this).find("img").attr("src")),$("#repo-owner-name").text($(this).text().trim()),$(this).parent().find(".checked").removeClass("checked"),$(this).addClass("checked"),console.log("set repo owner to uid :",e,$(this).text().trim())}}),$("#auth-button").click(function(e){$("#repo-migrate-auth").slideToggle("fast"),e.preventDefault()}),console.log("initRepoCreate")}function initRepo(){$("#repo-clone-ssh").click(function(){$(this).removeClass("btn-gray").addClass("btn-blue"),$("#repo-clone-https").removeClass("btn-blue").addClass("btn-gray"),$("#repo-clone-url").val($(this).data("link")),$(".clone-url").text($(this).data("link"))}),$("#repo-clone-https").click(function(){$(this).removeClass("btn-gray").addClass("btn-blue"),$("#repo-clone-ssh").removeClass("btn-blue").addClass("btn-gray"),$("#repo-clone-url").val($(this).data("link")),$(".clone-url").text($(this).data("link"))});var e=$("#repo-clone-copy");e.hover(function(){Gogs.bindCopy($(this))}),e.tipsy({fade:!0})}function initHookTypeChange(){$("select#hook-type").on("change",function(){hookTypes=["Gogs","Slack"];var e=$(this).val();hookTypes.forEach(function(t){e===t?$("div#"+t.toLowerCase()).toggleShow():$("div#"+t.toLowerCase()).toggleHide()})})}function initRepoSetting(){$("#repo-setting-form").submit(function(e){var t=$("#repo_name");return t.data("repo-name")==t.val()||confirm("Repository name has been changed, do you want to continue?")?void 0:(e.preventDefault(),!0)}),initHookTypeChange(),$("#transfer-button").click(function(){$("#transfer-form").show()}),$("#delete-button").click(function(){$("#delete-form").show()}),$("#repo-collab-list hr:last-child").remove();var e=$("#repo-collaborator").next().next().find("ul");$("#repo-collaborator").on("keyup",function(){var t=$(this);return t.val()?void Gogs.searchUsers(t.val(),e):void e.toggleHide()}).on("focus",function(){$(this).val()?e.toggleShow():e.toggleHide()}).next().next().find("ul").on("click","li",function(){$("#repo-collaborator").val($(this).text()),e.toggleHide()})}function initOrgSetting(){$("#org-setting-form").submit(function(e){var t=$("#orgname");return t.data("orgname")==t.val()||confirm("Organization name has been changed, do you want to continue?")?void 0:(e.preventDefault(),!0)}),$("#delete-org-button").click(function(e){return confirm("This organization is going to be deleted, do you want to continue?")?void 0:(e.preventDefault(),!0)}),initHookTypeChange()}function initInvite(){var e=$("#org-member-invite-list");$("#org-member-invite").on("keyup",function(){var t=$(this);return t.val()?void Gogs.searchUsers(t.val(),e):void e.toggleHide()}).on("focus",function(){$(this).val()?e.toggleShow():e.toggleHide()}).next().next().find("ul").on("click","li",function(){$("#org-member-invite").val($(this).text()),e.toggleHide()})}function initOrgTeamCreate(){$("#org-team-delete").click(function(e){if(!confirm("This team is going to be deleted, do you want to continue?"))return e.preventDefault(),!0;var t=$("#team-create-form");t.attr("action",t.data("delete-url"))})}function initTeamMembersList(){var e=$("#org-team-members-list");$("#org-team-members-add").on("keyup",function(){var t=$(this);return t.val()?void Gogs.searchUsers(t.val(),e):void e.toggleHide()}).on("focus",function(){$(this).val()?e.toggleShow():e.toggleHide()}).next().next().find("ul").on("click","li",function(){$("#org-team-members-add").val($(this).text()),e.toggleHide()})}function initTeamRepositoriesList(){var e=$("#org-team-repositories-list");$("#org-team-repositories-add").on("keyup",function(){var t=$(this);return t.val()?void Gogs.searchRepos(t.val(),e,"uid="+t.data("uid")):void e.toggleHide()}).on("focus",function(){$(this).val()?e.toggleShow():e.toggleHide()}).next().next().find("ul").on("click","li",function(){$("#org-team-repositories-add").val($(this).text()),e.toggleHide()})}function initAdmin(){$("#login-type").on("change",function(){var e=$(this).val();e.indexOf("0-")+1?($(".auth-name").toggleHide(),$(".pwd").find("input").attr("required","required").end().toggleShow()):($(".pwd").find("input").removeAttr("required").end().toggleHide(),$(".auth-name").toggleShow())}),$("#user-delete").click(function(e){if(!confirm("This account is going to be deleted, do you want to continue?"))return e.preventDefault(),!0;var t=$("#user-profile-form");t.attr("action",t.data("delete-url"))}),$("#auth-type").on("change",function(){var e=$(this).val();2==e&&($(".ldap").toggleShow(),$(".smtp").toggleHide()),3==e&&($(".smtp").toggleShow(),$(".ldap").toggleHide())}),$("#auth-delete").click(function(e){if(!confirm("This authorization is going to be deleted, do you want to continue?"))return e.preventDefault(),!0;var t=$("auth-setting-form");t.attr("action",t.data("delete-url"))})}function initInstall(){!function(){var e="127.0.0.1:3306",t="127.0.0.1:5432";$("#install-database").on("change",function(){var n=$(this).val();"SQLite3"!=n?($(".server-sql").show(),$(".sqlite-setting").addClass("hide"),"PostgreSQL"==n?($(".pgsql-setting").removeClass("hide"),$("#database-host").val()==e&&$("#database-host").val(t)):"MySQL"==n?($(".pgsql-setting").addClass("hide"),$("#database-host").val()==t&&$("#database-host").val(e)):$(".pgsql-setting").addClass("hide")):($(".server-sql").hide(),$(".pgsql-setting").hide(),$(".sqlite-setting").removeClass("hide"))})}()}function initProfile(){$("#profile-avatar").tipsy({fade:!0})}function homepage(){$("#promo-form").submit(function(e){return""===$("#username").val()?(e.preventDefault(),window.location.href=Gogs.AppSubUrl+"/user/login",!0):void 0}),$("#register-button").click(function(e){return""===$("#username").val()?(e.preventDefault(),window.location.href=Gogs.AppSubUrl+"/user/sign_up",!0):void $("#promo-form").attr("action",Gogs.AppSubUrl+"/user/sign_up")})}!function(e,t){"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){function n(e){var t=e.length,n=ot.type(e);return"function"===n||ot.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e}function r(e,t,n){if(ot.isFunction(t))return ot.grep(e,function(e,r){return!!t.call(e,r,e)!==n});if(t.nodeType)return ot.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(pt.test(t))return ot.filter(t,e,n);t=ot.filter(t,e)}return ot.grep(e,function(e){return ot.inArray(e,t)>=0!==n})}function i(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}function o(e){var t=wt[e]={};return ot.each(e.match(xt)||[],function(e,n){t[n]=!0}),t}function a(){mt.addEventListener?(mt.removeEventListener("DOMContentLoaded",s,!1),e.removeEventListener("load",s,!1)):(mt.detachEvent("onreadystatechange",s),e.detachEvent("onload",s))}function s(){(mt.addEventListener||"load"===event.type||"complete"===mt.readyState)&&(a(),ot.ready())}function l(e,t,n){if(void 0===n&&1===e.nodeType){var r="data-"+t.replace(Et,"-$1").toLowerCase();if(n=e.getAttribute(r),"string"==typeof n){try{n="true"===n?!0:"false"===n?!1:"null"===n?null:+n+""===n?+n:kt.test(n)?ot.parseJSON(n):n}catch(i){}ot.data(e,t,n)}else n=void 0}return n}function u(e){var t;for(t in e)if(("data"!==t||!ot.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}function c(e,t,n,r){if(ot.acceptData(e)){var i,o,a=ot.expando,s=e.nodeType,l=s?ot.cache:e,u=s?e[a]:e[a]&&a;if(u&&l[u]&&(r||l[u].data)||void 0!==n||"string"!=typeof t)return u||(u=s?e[a]=V.pop()||ot.guid++:a),l[u]||(l[u]=s?{}:{toJSON:ot.noop}),("object"==typeof t||"function"==typeof t)&&(r?l[u]=ot.extend(l[u],t):l[u].data=ot.extend(l[u].data,t)),o=l[u],r||(o.data||(o.data={}),o=o.data),void 0!==n&&(o[ot.camelCase(t)]=n),"string"==typeof t?(i=o[t],null==i&&(i=o[ot.camelCase(t)])):i=o,i}}function d(e,t,n){if(ot.acceptData(e)){var r,i,o=e.nodeType,a=o?ot.cache:e,s=o?e[ot.expando]:ot.expando;if(a[s]){if(t&&(r=n?a[s]:a[s].data)){ot.isArray(t)?t=t.concat(ot.map(t,ot.camelCase)):t in r?t=[t]:(t=ot.camelCase(t),t=t in r?[t]:t.split(" ")),i=t.length;for(;i--;)delete r[t[i]];if(n?!u(r):!ot.isEmptyObject(r))return}(n||(delete a[s].data,u(a[s])))&&(o?ot.cleanData([e],!0):rt.deleteExpando||a!=a.window?delete a[s]:a[s]=null)}}}function f(){return!0}function p(){return!1}function h(){try{return mt.activeElement}catch(e){}}function m(e){var t=Pt.split("|"),n=e.createDocumentFragment();if(n.createElement)for(;t.length;)n.createElement(t.pop());return n}function g(e,t){var n,r,i=0,o=typeof e.getElementsByTagName!==St?e.getElementsByTagName(t||"*"):typeof e.querySelectorAll!==St?e.querySelectorAll(t||"*"):void 0;if(!o)for(o=[],n=e.childNodes||e;null!=(r=n[i]);i++)!t||ot.nodeName(r,t)?o.push(r):ot.merge(o,g(r,t));return void 0===t||t&&ot.nodeName(e,t)?ot.merge([e],o):o}function v(e){jt.test(e.type)&&(e.defaultChecked=e.checked)}function y(e,t){return ot.nodeName(e,"table")&&ot.nodeName(11!==t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function b(e){return e.type=(null!==ot.find.attr(e,"type"))+"/"+e.type,e}function x(e){var t=Zt.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function w(e,t){for(var n,r=0;null!=(n=e[r]);r++)ot._data(n,"globalEval",!t||ot._data(t[r],"globalEval"))}function C(e,t){if(1===t.nodeType&&ot.hasData(e)){var n,r,i,o=ot._data(e),a=ot._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)ot.event.add(t,n,s[n][r])}a.data&&(a.data=ot.extend({},a.data))}}function S(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!rt.noCloneEvent&&t[ot.expando]){i=ot._data(t);for(r in i.events)ot.removeEvent(t,r,i.handle);t.removeAttribute(ot.expando)}"script"===n&&t.text!==e.text?(b(t).text=e.text,x(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),rt.html5Clone&&e.innerHTML&&!ot.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&jt.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}function T(t,n){var r,i=ot(n.createElement(t)).appendTo(n.body),o=e.getDefaultComputedStyle&&(r=e.getDefaultComputedStyle(i[0]))?r.display:ot.css(i[0],"display");return i.detach(),o}function k(e){var t=mt,n=Jt[e];return n||(n=T(e,t),"none"!==n&&n||(Kt=(Kt||ot("