install.tmpl 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. {{template "base/head" .}}
  2. <div class="install">
  3. <div class="ui middle very relaxed page grid">
  4. <div class="sixteen wide center aligned centered column">
  5. <h3 class="ui top attached header">
  6. {{.i18n.Tr "install.title"}}
  7. </h3>
  8. <div class="ui attached segment">
  9. {{template "base/alert" .}}
  10. <p>{{.i18n.Tr "install.docker_helper" "https://github.com/gogs/gogs/tree/main/docker" | Safe}}</p>
  11. <form class="ui form" action="{{AppSubURL}}/install" method="post">
  12. <!-- Dtabase Settings -->
  13. <h4 class="ui dividing header">{{.i18n.Tr "install.db_title"}}</h4>
  14. <p>{{.i18n.Tr "install.requite_db_desc"}}</p>
  15. <div class="inline required field {{if .Err_DbType}}error{{end}}">
  16. <label>{{.i18n.Tr "install.db_type"}}</label>
  17. <div class="ui selection database type dropdown">
  18. <input type="hidden" id="db_type" name="db_type" value="{{.CurDbOption}}">
  19. <div class="text">{{.CurDbOption}}</div>
  20. <i class="dropdown icon"></i>
  21. <div class="menu">
  22. {{range .DbOptions}}
  23. <div class="item" data-value="{{.}}">{{.}}</div>
  24. {{end}}
  25. </div>
  26. </div>
  27. </div>
  28. <div id="sql_settings" class="{{if eq .CurDbOption "SQLite3"}}hide{{end}}">
  29. <div class="inline required field {{if .Err_DbSetting}}error{{end}}">
  30. <label for="db_host">{{.i18n.Tr "install.host"}}</label>
  31. <input id="db_host" name="db_host" value="{{.db_host}}">
  32. </div>
  33. <div class="inline required field {{if .Err_DbSetting}}error{{end}}">
  34. <label for="db_user">{{.i18n.Tr "install.user"}}</label>
  35. <input id="db_user" name="db_user" value="{{.db_user}}">
  36. </div>
  37. <div class="inline required field {{if .Err_DbSetting}}error{{end}}">
  38. <label for="db_passwd">{{.i18n.Tr "install.password"}}</label>
  39. <input id="db_passwd" name="db_passwd" type="password" value="{{.db_passwd}}">
  40. </div>
  41. <div class="inline required field {{if .Err_DbSetting}}error{{end}}">
  42. <label for="db_name">{{.i18n.Tr "install.db_name"}}</label>
  43. <input id="db_name" name="db_name" value="{{.db_name}}">
  44. <span class="help">{{.i18n.Tr "install.db_helper"}}</span>
  45. </div>
  46. </div>
  47. <div id="pgsql_settings" class="{{if not (eq .CurDbOption "PostgreSQL")}}hide{{end}}">
  48. <div class="inline required field">
  49. <label for="db_schema">{{.i18n.Tr "install.db_schema"}}</label>
  50. <input id="db_schema" name="db_schema" value="{{.db_schema}}">
  51. </div>
  52. <div class="inline required field">
  53. <label>{{.i18n.Tr "install.ssl_mode"}}</label>
  54. <div class="ui selection database type dropdown">
  55. <input type="hidden" name="ssl_mode" value="{{if .ssl_mode}}{{.ssl_mode}}{{else}}disable{{end}}">
  56. <div class="default text">disable</div>
  57. <i class="dropdown icon"></i>
  58. <div class="menu">
  59. <div class="item" data-value="disable">Disable</div>
  60. <div class="item" data-value="require">Require</div>
  61. <div class="item" data-value="verify-full">Verify Full</div>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. <div id="sqlite_settings" class="{{if not (eq .CurDbOption "SQLite3")}}hide{{end}}">
  67. <div class="inline required field {{if or .Err_DbPath .Err_DbSetting}}error{{end}}">
  68. <label for="db_path">{{.i18n.Tr "install.path"}}</label>
  69. <input id="db_path" name="db_path" value="{{.db_path}}">
  70. <span class="help">{{.i18n.Tr "install.sqlite_helper" | Safe}}</span>
  71. </div>
  72. </div>
  73. <!-- General Settings -->
  74. <h4 class="ui dividing header">{{.i18n.Tr "install.general_title"}}</h4>
  75. <div class="inline required field {{if .Err_AppName}}error{{end}}">
  76. <label for="app_name">{{.i18n.Tr "install.app_name"}}</label>
  77. <input id="app_name" name="app_name" value="{{.app_name}}" required>
  78. <span class="help">{{.i18n.Tr "install.app_name_helper"}}</span>
  79. </div>
  80. <div class="inline required field {{if .Err_RepoRootPath}}error{{end}}">
  81. <label for="repo_root_path">{{.i18n.Tr "install.repo_path"}}</label>
  82. <input id="repo_root_path" name="repo_root_path" value="{{.repo_root_path}}" required>
  83. <span class="help">{{.i18n.Tr "install.repo_path_helper"}}</span>
  84. </div>
  85. <div class="inline required field {{if .Err_RunUser}}error{{end}}">
  86. <label for="run_user">{{.i18n.Tr "install.run_user"}}</label>
  87. <input id="run_user" name="run_user" value="{{.run_user}}" required>
  88. <span class="help">{{.i18n.Tr "install.run_user_helper"}}</span>
  89. </div>
  90. <div class="inline required field">
  91. <label for="domain">{{.i18n.Tr "install.domain"}}</label>
  92. <input id="domain" name="domain" value="{{.domain}}" placeholder="e.g. try.gogs.io" required>
  93. <span class="help">{{.i18n.Tr "install.domain_helper"}}</span>
  94. </div>
  95. <div class="inline required field">
  96. <label for="ssh_port">{{.i18n.Tr "install.ssh_port"}}</label>
  97. <input id="ssh_port" name="ssh_port" value="{{.ssh_port}}">
  98. <span class="help">{{.i18n.Tr "install.ssh_port_helper"}}</span>
  99. </div>
  100. <div class="inline field checkbox">
  101. <div class="ui checkbox">
  102. <label class="poping up" data-content="{{.i18n.Tr "install.use_builtin_ssh_server_popup"}}"><strong>{{.i18n.Tr "install.use_builtin_ssh_server"}}</strong></label>
  103. <input name="use_builtin_ssh_server" type="checkbox" {{if .use_builtin_ssh_server}}checked{{end}}>
  104. </div>
  105. </div>
  106. <div class="inline required field">
  107. <label for="http_port">{{.i18n.Tr "install.http_port"}}</label>
  108. <input id="http_port" name="http_port" value="{{.http_port}}" required>
  109. <span class="help">{{.i18n.Tr "install.http_port_helper"}}</span>
  110. </div>
  111. <div class="inline required field">
  112. <label for="app_url">{{.i18n.Tr "install.app_url"}}</label>
  113. <input id="app_url" name="app_url" value="{{.app_url}}" placeholder="e.g. https://try.gogs.io" required>
  114. <span class="help">{{.i18n.Tr "install.app_url_helper"}}</span>
  115. </div>
  116. <div class="inline required field">
  117. <label for="log_root_path">{{.i18n.Tr "install.log_root_path"}}</label>
  118. <input id="log_root_path" name="log_root_path" value="{{.log_root_path}}" placeholder="log" required>
  119. <span class="help">{{.i18n.Tr "install.log_root_path_helper"}}</span>
  120. </div>
  121. <div class="inline field checkbox">
  122. <div class="ui checkbox">
  123. <label class="poping up" data-content="{{.i18n.Tr "install.enable_console_mode_popup"}}"><strong>{{.i18n.Tr "install.enable_console_mode"}}</strong></label>
  124. <input name="enable_console_mode" type="checkbox" {{if .enable_console_mode}}checked{{end}}>
  125. </div>
  126. </div>
  127. <!-- Optional Settings -->
  128. <h4 class="ui dividing header">{{.i18n.Tr "install.optional_title"}}</h4>
  129. <!-- Email -->
  130. <div class="ui accordion optional field">
  131. <div class="title {{if .Err_SMTP}}text red{{end}}">
  132. <i class="icon dropdown"></i>
  133. {{.i18n.Tr "install.email_title"}}
  134. </div>
  135. <div class="content {{if .Err_SMTP}}active{{end}}">
  136. <div class="inline field {{if .Err_SMTPHost}}error{{end}}">
  137. <label for="smtp_host">{{.i18n.Tr "install.smtp_host"}}</label>
  138. <input id="smtp_host" name="smtp_host" value="{{.smtp_host}}">
  139. </div>
  140. <div class="inline field {{if .Err_SMTPFrom}}error{{end}}">
  141. <label for="smtp_from">{{.i18n.Tr "install.smtp_from"}}</label>
  142. <input id="smtp_from" name="smtp_from" value="{{.smtp_from}}">
  143. <span class="help">{{.i18n.Tr "install.smtp_from_helper"}}</span>
  144. </div>
  145. <div class="inline field {{if .Err_SMTPUser}}error{{end}}">
  146. <label for="smtp_user">{{.i18n.Tr "install.mailer_user"}}</label>
  147. <input id="smtp_user" name="smtp_user" value="{{.smtp_user}}">
  148. </div>
  149. <div class="inline field">
  150. <label for="smtp_passwd">{{.i18n.Tr "install.mailer_password"}}</label>
  151. <input id="smtp_passwd" name="smtp_passwd" type="password" value="{{.smtp_passwd}}">
  152. </div>
  153. <div class="inline field">
  154. <div class="ui checkbox">
  155. <label><strong>{{.i18n.Tr "install.register_confirm"}}</strong></label>
  156. <input name="register_confirm" type="checkbox" {{if .register_confirm}}checked{{end}}>
  157. </div>
  158. </div>
  159. <div class="inline field">
  160. <div class="ui checkbox">
  161. <label><strong>{{.i18n.Tr "install.mail_notify"}}</strong></label>
  162. <input name="mail_notify" type="checkbox" {{if .mail_notify}}checked{{end}}>
  163. </div>
  164. </div>
  165. </div>
  166. </div>
  167. <!-- Server and other services -->
  168. <div class="ui accordion optional field">
  169. <div class="title {{if .Err_Services}}text red{{end}}">
  170. <i class="icon dropdown"></i>
  171. {{.i18n.Tr "install.server_service_title"}}
  172. </div>
  173. <div class="content {{if .Err_Services}}active{{end}}">
  174. <div class="inline field">
  175. <div class="ui checkbox" id="offline-mode">
  176. <label class="poping up" data-content="{{.i18n.Tr "install.offline_mode_popup"}}"><strong>{{.i18n.Tr "install.offline_mode"}}</strong></label>
  177. <input name="offline_mode" type="checkbox" {{if .offline_mode}}checked{{end}}>
  178. </div>
  179. </div>
  180. <div class="inline field">
  181. <div class="ui checkbox" id="disable-gravatar">
  182. <label class="poping up" data-content="{{.i18n.Tr "install.disable_gravatar_popup"}}"><strong>{{.i18n.Tr "install.disable_gravatar"}}</strong></label>
  183. <input name="disable_gravatar" type="checkbox" {{if .disable_gravatar}}checked{{end}}>
  184. </div>
  185. </div>
  186. <div class="inline field">
  187. <div class="ui checkbox" id="federated-avatar-lookup">
  188. <label class="poping up" data-content="{{.i18n.Tr "install.federated_avatar_lookup_popup"}}"><strong>{{.i18n.Tr "install.federated_avatar_lookup"}}</strong></label>
  189. <input name="enable_federated_avatar" type="checkbox" {{if .enable_federated_avatar}}checked{{end}}>
  190. </div>
  191. </div>
  192. <div class="inline field">
  193. <div class="ui checkbox" id="disable-registration">
  194. <label class="poping up" data-content="{{.i18n.Tr "install.disable_registration_popup"}}"><strong>{{.i18n.Tr "install.disable_registration"}}</strong></label>
  195. <input name="disable_registration" type="checkbox" {{if .disable_registration}}checked{{end}}>
  196. </div>
  197. </div>
  198. <div class="inline field">
  199. <div class="ui checkbox" id="enable-captcha">
  200. <label class="poping up" data-content="{{.i18n.Tr "install.enable_captcha_popup"}}"><strong>{{.i18n.Tr "install.enable_captcha"}}</strong></label>
  201. <input name="enable_captcha" type="checkbox" {{if .enable_captcha}}checked{{end}}>
  202. </div>
  203. </div>
  204. <div class="inline field">
  205. <div class="ui checkbox">
  206. <label class="poping up" data-content="{{.i18n.Tr "install.require_sign_in_view_popup"}}"><strong>{{.i18n.Tr "install.require_sign_in_view"}}</strong></label>
  207. <input name="require_sign_in_view" type="checkbox" {{if .require_sign_in_view}}checked{{end}}>
  208. </div>
  209. </div>
  210. </div>
  211. </div>
  212. <!-- Admin -->
  213. <div class="ui accordion optional field">
  214. <div class="title {{if .Err_Admin}}text red{{end}}">
  215. <i class="icon dropdown"></i>
  216. {{.i18n.Tr "install.admin_title"}}
  217. </div>
  218. <div class="content {{if .Err_Admin}}active{{end}}">
  219. <p class="center">{{.i18n.Tr "install.admin_setting_desc"}}</p>
  220. <div class="inline field {{if .Err_AdminName}}error{{end}}">
  221. <label for="admin_name">{{.i18n.Tr "install.admin_name"}}</label>
  222. <input id="admin_name" name="admin_name" value="{{.admin_name}}">
  223. </div>
  224. <div class="inline field {{if .Err_AdminPasswd}}error{{end}}">
  225. <label for="admin_passwd">{{.i18n.Tr "install.admin_password"}}</label>
  226. <input id="admin_passwd" name="admin_passwd" type="password" value="{{.admin_passwd}}">
  227. </div>
  228. <div class="inline field {{if .Err_AdminPasswd}}error{{end}}">
  229. <label for="admin_confirm_passwd">{{.i18n.Tr "install.confirm_password"}}</label>
  230. <input id="admin_confirm_passwd" name="admin_confirm_passwd" type="password" value="{{.admin_confirm_passwd}}">
  231. </div>
  232. <div class="inline field {{if .Err_AdminEmail}}error{{end}}">
  233. <label for="admin_email">{{.i18n.Tr "install.admin_email"}}</label>
  234. <input id="admin_email" name="admin_email" type="email" value="{{.admin_email}}">
  235. </div>
  236. </div>
  237. </div>
  238. <div class="ui divider"></div>
  239. <div class="inline field">
  240. <label></label>
  241. <button class="ui primary button">{{.i18n.Tr "install.install_gogs"}}</button>
  242. </div>
  243. </form>
  244. </div>
  245. </div>
  246. </div>
  247. </div>
  248. <script>
  249. // Database type change detection.
  250. $("#db_type").change(function () {
  251. var sqliteDefault = 'data/gogs.db';
  252. var dbType = $(this).val();
  253. if (dbType === "SQLite3") {
  254. $('#sql_settings').hide();
  255. $('#pgsql_settings').hide();
  256. $('#sqlite_settings').show();
  257. if (dbType === "SQLite3") {
  258. $('#db_path').val(sqliteDefault);
  259. }
  260. return;
  261. }
  262. var dbDefaults = {
  263. "MySQL": "127.0.0.1:3306",
  264. "PostgreSQL": "127.0.0.1:5432",
  265. };
  266. $('#sqlite_settings').hide();
  267. $('#sql_settings').show();
  268. $('#pgsql_settings').toggle(dbType === "PostgreSQL");
  269. $.each(dbDefaults, function(type, defaultHost) {
  270. if ($('#db_host').val() == defaultHost) {
  271. $('#db_host').val(dbDefaults[dbType]);
  272. return false;
  273. }
  274. });
  275. });
  276. // TODO: better handling of exclusive relations.
  277. $('#offline-mode input').change(function () {
  278. if ($(this).is(':checked')) {
  279. $('#disable-gravatar').checkbox('check');
  280. $('#federated-avatar-lookup').checkbox('uncheck');
  281. }
  282. });
  283. $('#disable-gravatar input').change(function () {
  284. if ($(this).is(':checked')) {
  285. $('#federated-avatar-lookup').checkbox('uncheck');
  286. } else {
  287. $('#offline-mode').checkbox('uncheck');
  288. }
  289. });
  290. $('#federated-avatar-lookup input').change(function () {
  291. if ($(this).is(':checked')) {
  292. $('#disable-gravatar').checkbox('uncheck');
  293. $('#offline-mode').checkbox('uncheck');
  294. }
  295. });
  296. $('#disable-registration input').change(function () {
  297. if ($(this).is(':checked')) {
  298. $('#enable-captcha').checkbox('uncheck');
  299. }
  300. });
  301. $('#enable-captcha input').change(function () {
  302. if ($(this).is(':checked')) {
  303. $('#disable-registration').checkbox('uncheck');
  304. }
  305. });
  306. </script>
  307. {{template "base/footer" .}}