#697 add install option

This commit is contained in:
Unknwon 2015-09-13 12:14:32 -04:00
parent b0bf4cc1cb
commit 5f1183cecf
7 changed files with 27 additions and 6 deletions

View file

@ -102,6 +102,8 @@ disable_gravatar = Disable Gravatar Service
disable_gravatar_popup = Disable Gravatar and custom sources, all avatars are uploaded by users or default. disable_gravatar_popup = Disable Gravatar and custom sources, all avatars are uploaded by users or default.
disable_registration = Disable Self-registration disable_registration = Disable Self-registration
disable_registration_popup = Disable user self-registration, only admin can create accounts. disable_registration_popup = Disable user self-registration, only admin can create accounts.
enable_captcha = Enable Captcha
enable_captcha_popup = Require validate captcha for user self-registration.
require_sign_in_view = Enable Require Sign In to View Pages require_sign_in_view = Enable Require Sign In to View Pages
require_sign_in_view_popup = Only signed in users can view pages, visitors will only be able to see sign in/up pages. require_sign_in_view_popup = Only signed in users can view pages, visitors will only be able to see sign in/up pages.
admin_setting_desc = You do not have to create an admin account right now, user whoever ID=1 will gain admin access automatically. admin_setting_desc = You do not have to create an admin account right now, user whoever ID=1 will gain admin access automatically.

View file

@ -721,7 +721,7 @@ notices=系统提示管理
monitor=应用监控面板 monitor=应用监控面板
first_page=首页 first_page=首页
last_page=末页 last_page=末页
total=总计: total=总计:%d
dashboard.statistic=应用统计数据 dashboard.statistic=应用统计数据
dashboard.operations=管理员操作 dashboard.operations=管理员操作

View file

@ -38,6 +38,7 @@ type InstallForm struct {
OfflineMode bool OfflineMode bool
DisableGravatar bool DisableGravatar bool
DisableRegistration bool DisableRegistration bool
EnableCaptcha bool
RequireSignInView bool RequireSignInView bool
AdminName string `binding:"OmitEmpty;AlphaDashDot;MaxSize(30)" locale:"install.admin_name"` AdminName string `binding:"OmitEmpty;AlphaDashDot;MaxSize(30)" locale:"install.admin_name"`

File diff suppressed because one or more lines are too long

View file

@ -187,6 +187,16 @@ function initInstall() {
$('#disable-gravatar').checkbox('check'); $('#disable-gravatar').checkbox('check');
} }
}); });
$('#disable-registration input').change(function () {
if ($(this).is(':checked')) {
$('#enable-captcha').checkbox('uncheck');
}
});
$('#enable-captcha input').change(function () {
if ($(this).is(':checked')) {
$('#disable-registration').checkbox('uncheck');
}
});
} }
function initRepository() { function initRepository() {

View file

@ -151,6 +151,7 @@ func Install(ctx *middleware.Context) {
form.OfflineMode = setting.OfflineMode form.OfflineMode = setting.OfflineMode
form.DisableGravatar = setting.DisableGravatar form.DisableGravatar = setting.DisableGravatar
form.DisableRegistration = setting.Service.DisableRegistration form.DisableRegistration = setting.Service.DisableRegistration
form.EnableCaptcha = setting.Service.EnableCaptcha
form.RequireSignInView = setting.Service.RequireSignInView form.RequireSignInView = setting.Service.RequireSignInView
auth.AssignForm(form, ctx.Data) auth.AssignForm(form, ctx.Data)
@ -301,6 +302,7 @@ func InstallPost(ctx *middleware.Context, form auth.InstallForm) {
cfg.Section("server").Key("OFFLINE_MODE").SetValue(com.ToStr(form.OfflineMode)) cfg.Section("server").Key("OFFLINE_MODE").SetValue(com.ToStr(form.OfflineMode))
cfg.Section("picture").Key("DISABLE_GRAVATAR").SetValue(com.ToStr(form.DisableGravatar)) cfg.Section("picture").Key("DISABLE_GRAVATAR").SetValue(com.ToStr(form.DisableGravatar))
cfg.Section("service").Key("DISABLE_REGISTRATION").SetValue(com.ToStr(form.DisableRegistration)) cfg.Section("service").Key("DISABLE_REGISTRATION").SetValue(com.ToStr(form.DisableRegistration))
cfg.Section("service").Key("ENABLE_CAPTCHA").SetValue(com.ToStr(form.EnableCaptcha))
cfg.Section("service").Key("REQUIRE_SIGNIN_VIEW").SetValue(com.ToStr(form.RequireSignInView)) cfg.Section("service").Key("REQUIRE_SIGNIN_VIEW").SetValue(com.ToStr(form.RequireSignInView))
cfg.Section("").Key("RUN_MODE").SetValue("prod") cfg.Section("").Key("RUN_MODE").SetValue("prod")

View file

@ -170,11 +170,17 @@
</div> </div>
</div> </div>
<div class="inline field"> <div class="inline field">
<div class="ui checkbox"> <div class="ui checkbox" id="disable-registration">
<label class="poping up" data-content="{{.i18n.Tr "install.disable_registration_popup"}}"><strong>{{.i18n.Tr "install.disable_registration"}}</strong></label> <label class="poping up" data-content="{{.i18n.Tr "install.disable_registration_popup"}}"><strong>{{.i18n.Tr "install.disable_registration"}}</strong></label>
<input name="disable_registration" type="checkbox" {{if .disable_registration}}checked{{end}}> <input name="disable_registration" type="checkbox" {{if .disable_registration}}checked{{end}}>
</div> </div>
</div> </div>
<div class="inline field">
<div class="ui checkbox" id="enable-captcha">
<label class="poping up" data-content="{{.i18n.Tr "install.enable_captcha_popup"}}"><strong>{{.i18n.Tr "install.enable_captcha"}}</strong></label>
<input name="enable_captcha" type="checkbox" {{if .enable_captcha}}checked{{end}}>
</div>
</div>
<div class="inline field"> <div class="inline field">
<div class="ui checkbox"> <div class="ui checkbox">
<label class="poping up" data-content="{{.i18n.Tr "install.require_sign_in_view_popup"}}"><strong>{{.i18n.Tr "install.require_sign_in_view"}}</strong></label> <label class="poping up" data-content="{{.i18n.Tr "install.require_sign_in_view_popup"}}"><strong>{{.i18n.Tr "install.require_sign_in_view"}}</strong></label>