Browse Source

install: able to enable console mode (#3119)

pull/4289/merge
Unknwon 8 years ago
parent
commit
2d4dc544be
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 2
      conf/locale/locale_en-US.ini
  2. 4
      modules/bindata/bindata.go
  3. 1
      modules/form/user.go
  4. 13
      public/css/gogs.css
  5. 71
      public/js/gogs.js
  6. 16
      public/less/_install.less
  7. 6
      routers/install.go
  8. 74
      templates/install.tmpl

2
conf/locale/locale_en-US.ini

@ -82,6 +82,8 @@ app_url = Application URL
app_url_helper = This affects HTTP/HTTPS clone URL and somewhere in email. app_url_helper = This affects HTTP/HTTPS clone URL and somewhere in email.
log_root_path = Log Path log_root_path = Log Path
log_root_path_helper = Directory to write log files to. log_root_path_helper = Directory to write log files to.
enable_console_mode = Enable Console Mode
enable_console_mode_popup = In addition to file mode, also print logs to console.
optional_title = Optional Settings optional_title = Optional Settings
email_title = Email Service Settings email_title = Email Service Settings

4
modules/bindata/bindata.go

File diff suppressed because one or more lines are too long

1
modules/form/user.go

@ -29,6 +29,7 @@ type Install struct {
HTTPPort string `binding:"Required"` HTTPPort string `binding:"Required"`
AppUrl string `binding:"Required"` AppUrl string `binding:"Required"`
LogRootPath string `binding:"Required"` LogRootPath string `binding:"Required"`
EnableConsoleMode bool
SMTPHost string SMTPHost string
SMTPFrom string SMTPFrom string

13
public/css/gogs.css

@ -888,7 +888,7 @@ footer .ui.language .menu {
width: 320px !important; width: 320px !important;
} }
.install form input { .install form input {
width: 35% !important; width: 300px !important;
} }
.install form .field { .install form .field {
text-align: left; text-align: left;
@ -897,17 +897,16 @@ footer .ui.language .menu {
margin-left: 335px !important; margin-left: 335px !important;
} }
.install form .field.optional .title { .install form .field.optional .title {
margin-left: 38%; margin-left: 320px !important;
} }
.install .ui .checkbox { .install .ui.checkbox {
margin-left: 40% !important; margin-left: 335px !important;
} }
.install .ui .checkbox label { .install .ui.checkbox label {
width: auto !important; width: auto !important;
} }
.install #use-builtin-ssh-server { .install .inline.checkbox {
margin-top: -1em; margin-top: -1em;
margin-left: -15px !important;
margin-bottom: 2em; margin-bottom: 2em;
} }
.form .help { .form .help {

71
public/js/gogs.js

@ -204,76 +204,6 @@ function initCommentForm() {
selectItem('.select-assignee', '#assignee_id'); selectItem('.select-assignee', '#assignee_id');
} }
function initInstall() {
if ($('.install').length == 0) {
return;
}
// Database type change detection.
$("#db_type").change(function () {
var sqliteDefault = 'data/gogs.db';
var dbType = $(this).val();
if (dbType === "SQLite3") {
$('#sql_settings').hide();
$('#pgsql_settings').hide();
$('#sqlite_settings').show();
if (dbType === "SQLite3") {
$('#db_path').val(sqliteDefault);
}
return;
}
var dbDefaults = {
"MySQL": "127.0.0.1:3306",
"PostgreSQL": "127.0.0.1:5432",
"MSSQL": "127.0.0.1, 1433"
};
$('#sqlite_settings').hide();
$('#sql_settings').show();
$('#pgsql_settings').toggle(dbType === "PostgreSQL");
$.each(dbDefaults, function(type, defaultHost) {
if ($('#db_host').val() == defaultHost) {
$('#db_host').val(dbDefaults[dbType]);
return false;
}
});
});
// TODO: better handling of exclusive relations.
$('#offline-mode input').change(function () {
if ($(this).is(':checked')) {
$('#disable-gravatar').checkbox('check');
$('#federated-avatar-lookup').checkbox('uncheck');
}
});
$('#disable-gravatar input').change(function () {
if ($(this).is(':checked')) {
$('#federated-avatar-lookup').checkbox('uncheck');
} else {
$('#offline-mode').checkbox('uncheck');
}
});
$('#federated-avatar-lookup input').change(function () {
if ($(this).is(':checked')) {
$('#disable-gravatar').checkbox('uncheck');
$('#offline-mode').checkbox('uncheck');
}
});
$('#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() {
if ($('.repository').length == 0) { if ($('.repository').length == 0) {
return; return;
@ -1424,7 +1354,6 @@ $(document).ready(function () {
searchRepositories(); searchRepositories();
initCommentForm(); initCommentForm();
initInstall();
initRepository(); initRepository();
initWikiForm(); initWikiForm();
initEditForm(); initEditForm();

16
public/less/_install.less

@ -1,14 +1,15 @@
.install { .install {
@input-padding: 320px !important;
padding-top: 45px; padding-top: 45px;
padding-bottom: @footer-margin * 2; padding-bottom: @footer-margin * 2;
form { form {
@input-padding: 320px !important;
label { label {
text-align: right; text-align: right;
width: @input-padding; width: @input-padding;
} }
input { input {
width: 35% !important; width: 300px !important;
} }
.field { .field {
text-align: left; text-align: left;
@ -16,21 +17,18 @@
margin-left: @input-padding+15px; margin-left: @input-padding+15px;
} }
&.optional .title { &.optional .title {
margin-left: 38%; margin-left: @input-padding;
} }
} }
} }
.ui { .ui.checkbox {
.checkbox { margin-left: @input-padding+15px;
margin-left: 40% !important;
label { label {
width: auto !important; width: auto !important;
} }
} }
} .inline.checkbox {
#use-builtin-ssh-server {
margin-top: -1em; margin-top: -1em;
margin-left: -15px !important;
margin-bottom: 2em; margin-bottom: 2em;
} }
} }

6
routers/install.go

@ -335,7 +335,11 @@ func InstallPost(ctx *context.Context, f form.Install) {
cfg.Section("session").Key("PROVIDER").SetValue("file") cfg.Section("session").Key("PROVIDER").SetValue("file")
cfg.Section("log").Key("MODE").SetValue("file") mode := "file"
if f.EnableConsoleMode {
mode = "console, file"
}
cfg.Section("log").Key("MODE").SetValue(mode)
cfg.Section("log").Key("LEVEL").SetValue("Info") cfg.Section("log").Key("LEVEL").SetValue("Info")
cfg.Section("log").Key("ROOT_PATH").SetValue(f.LogRootPath) cfg.Section("log").Key("ROOT_PATH").SetValue(f.LogRootPath)

74
templates/install.tmpl

@ -99,7 +99,7 @@
<input id="ssh_port" name="ssh_port" value="{{.ssh_port}}"> <input id="ssh_port" name="ssh_port" value="{{.ssh_port}}">
<span class="help">{{.i18n.Tr "install.ssh_port_helper"}}</span> <span class="help">{{.i18n.Tr "install.ssh_port_helper"}}</span>
</div> </div>
<div class="inline field" id="use-builtin-ssh-server"> <div class="inline field checkbox">
<div class="ui checkbox"> <div class="ui checkbox">
<label class="poping up" data-content="{{.i18n.Tr "install.use_builtin_ssh_server_popup"}}"><strong>{{.i18n.Tr "install.use_builtin_ssh_server"}}</strong></label> <label class="poping up" data-content="{{.i18n.Tr "install.use_builtin_ssh_server_popup"}}"><strong>{{.i18n.Tr "install.use_builtin_ssh_server"}}</strong></label>
<input name="use_builtin_ssh_server" type="checkbox" {{if .use_builtin_ssh_server}}checked{{end}}> <input name="use_builtin_ssh_server" type="checkbox" {{if .use_builtin_ssh_server}}checked{{end}}>
@ -120,6 +120,12 @@
<input id="log_root_path" name="log_root_path" value="{{.log_root_path}}" placeholder="log" required> <input id="log_root_path" name="log_root_path" value="{{.log_root_path}}" placeholder="log" required>
<span class="help">{{.i18n.Tr "install.log_root_path_helper"}}</span> <span class="help">{{.i18n.Tr "install.log_root_path_helper"}}</span>
</div> </div>
<div class="inline field checkbox">
<div class="ui checkbox">
<label class="poping up" data-content="{{.i18n.Tr "install.enable_console_mode_popup"}}"><strong>{{.i18n.Tr "install.enable_console_mode"}}</strong></label>
<input name="enable_console_mode" type="checkbox" {{if .enable_console_mode}}checked{{end}}>
</div>
</div>
<!-- Optional Settings --> <!-- Optional Settings -->
@ -247,4 +253,70 @@
</div> </div>
</div> </div>
</div> </div>
<script>
// Database type change detection.
$("#db_type").change(function () {
var sqliteDefault = 'data/gogs.db';
var dbType = $(this).val();
if (dbType === "SQLite3") {
$('#sql_settings').hide();
$('#pgsql_settings').hide();
$('#sqlite_settings').show();
if (dbType === "SQLite3") {
$('#db_path').val(sqliteDefault);
}
return;
}
var dbDefaults = {
"MySQL": "127.0.0.1:3306",
"PostgreSQL": "127.0.0.1:5432",
"MSSQL": "127.0.0.1, 1433"
};
$('#sqlite_settings').hide();
$('#sql_settings').show();
$('#pgsql_settings').toggle(dbType === "PostgreSQL");
$.each(dbDefaults, function(type, defaultHost) {
if ($('#db_host').val() == defaultHost) {
$('#db_host').val(dbDefaults[dbType]);
return false;
}
});
});
// TODO: better handling of exclusive relations.
$('#offline-mode input').change(function () {
if ($(this).is(':checked')) {
$('#disable-gravatar').checkbox('check');
$('#federated-avatar-lookup').checkbox('uncheck');
}
});
$('#disable-gravatar input').change(function () {
if ($(this).is(':checked')) {
$('#federated-avatar-lookup').checkbox('uncheck');
} else {
$('#offline-mode').checkbox('uncheck');
}
});
$('#federated-avatar-lookup input').change(function () {
if ($(this).is(':checked')) {
$('#disable-gravatar').checkbox('uncheck');
$('#offline-mode').checkbox('uncheck');
}
});
$('#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');
}
});
</script>
{{template "base/footer" .}} {{template "base/footer" .}}

Loading…
Cancel
Save