From 0ddb1eb769610f1d74997ad12d848ae5a0bdb4ab Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sun, 7 Sep 2014 19:02:58 -0400 Subject: [PATCH] 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 | 170 +++++++++-------- routers/install.go | 49 ++--- templates/.VERSION | 2 +- templates/install.tmpl | 306 +++++++++++++----------------- 11 files changed, 408 insertions(+), 299 deletions(-) diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini index e8329933a43..50fbc3cd5a6 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 a61a54ceb20..7d10142e62f 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 1c012d40983..2ca0f9ad87f 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 51a07b91286..93bd01a9fd9 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 636a8667742..f4d33540e58 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 c08a887a4cf..cb23c8f97ba 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 4e4d63fe520..8151792f250 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("