Przeglądaj źródła

Merge pull request #800 from weseek/feat/use-table-in-siteUrl-form

Feat/use table in site url form
Haru 7 lat temu
rodzic
commit
6d3519ccfe

+ 3 - 3
resource/locales/en-US/translation.json

@@ -287,7 +287,7 @@
     "Site Name": "Site name",
     "sitename_change": "You can change Site Name which is used for header and HTML title.",
     "header_content": "The contents entered here will be shown in the header etc.",
-    "Site URL": "Site URL",
+    "Site URL": "This is for the site URL setting. If this setting is not done, the site URL automatically generated from the information of the HTTP request will be used, but setting is necessary to enable some functions such as SAML authentication and OAuth authentication.",
     "siteurl_help": "Site full URL beginning from <code>http://</code> or <code>https://</code>.",
     "Confidential name": "Confidential name",
     "Default Language for new users": "Default Language for new users",
@@ -315,8 +315,8 @@
     "Enable plugin loading": "Enable plugin loading",
     "Load plugins": "Load plugins",
     "Enable": "Enable",
-    "Disable": "Disable"
-
+    "Disable": "Disable",
+    "Use env var if empty": "If the value in the database is empty, the value of the environment variable <code>%s</code> is used."
   },
   "security_setting": {
 		"Basic authentication": "Basic authentication",

+ 4 - 4
resource/locales/ja/translation.json

@@ -301,8 +301,8 @@
     "Site Name": "サイト名",
     "sitename_change": "ヘッダーや HTML タイトルに使用されるサイト名を変更できます。",
     "header_content": "ここに入力した内容は、ヘッダー等に表示されます。",
-    "Site URL": "サイトURL",
-    "siteurl_help": "<code>http://</code> または <code>https://</code> から始まるサイトのURL",
+    "Site URL": "サイトURLを明示的に指定します。この設定が行われていない場合はサイトURLがHTTPリクエストの情報から自動的生成されたものが使用されますが、SAML認証やOAuth認証等の一部機能を有効にするには設定が必要です。",
+    "siteurl_help": "<code>http://</code> または <code>https://</code> から始まるサイトのURL",
     "Confidential name": "コンフィデンシャル表示",
     "Default Language for new users": "新規ユーザーのデフォルト設定言語",
     "ex): internal use only": "例: 社外秘",
@@ -329,8 +329,8 @@
     "Enable plugin loading": "プラグインの読み込みを有効にします。",
     "Load plugins": "プラグインを読み込む",
     "Enable": "有効",
-    "Disable": "無効"
-
+    "Disable": "無効",
+    "Use env var if empty": "データベース側の値が空の場合、環境変数 <code>%s</code> の値を利用します"
    },
 
   "security_setting": {

+ 6 - 0
src/server/service/config-loader.js

@@ -110,6 +110,12 @@ const ENV_VAR_NAME_TO_CONFIG_INFO = {
   //   type:    ,
   //   default:
   // },
+  APP_SITE_URL: {
+    ns:      'crowi',
+    key:     'app:siteUrl',
+    type:    TYPES.STRING,
+    default: null
+  },
   SAML_USES_ONLY_ENV_VARS_FOR_SOME_OPTIONS: {
     ns:      'crowi',
     key:     'security:passport-saml:useOnlyEnvVarsForSomeOptions',

+ 33 - 12
src/server/views/admin/app.html

@@ -117,18 +117,39 @@
       <form action="/_api/admin/settings/siteUrl" method="post" class="form-horizontal" id="siteUrlSettingForm" role="form">
         <fieldset>
           <legend>{{ t('Site URL settings') }}</legend>
-
-          <div class="form-group">
-            <label for="settingForm[app:siteUrl]" class="col-xs-3 control-label">{{ t('app_setting.Site URL') }}</label>
-            <div class="col-xs-6">
-              <input class="form-control"
-                     id="settingForm[app:siteUrl]"
-                     type="text"
-                     name="settingForm[app:siteUrl]"
-                     value="{{ settingForm['app:siteUrl'] | default('') }}"
-                     placeholder="e.g. https://my.growi.org">
-              <p class="help-block">{{ t("app_setting.siteurl_help") }}</p>
-            </div>
+          <p class="well">{{ t('app_setting.Site URL') }}</p>
+
+          <div class="col-xs-offset-3">
+            <table class="table">
+              <colgroup>
+                <col class="from-db">
+                <col class="from-env-vars">
+              </colgroup>
+              <thead>
+              <tr><th>Database</th><th>Environment variables</th></tr>
+              </thead>
+              <tbody>
+                <tr>
+                  <td>
+                    <input class="form-control"
+                           type="text"
+                           name="settingForm[app:siteUrl]"
+                           value="{{ getConfigFromDB('crowi', 'app:siteUrl') | default('') }}"
+                           placeholder="e.g. https://my.growi.org">
+                    <p class="help-block">{{ t("app_setting.siteurl_help") }}</p>
+                  </td>
+                  <td>
+                    <input class="form-control"
+                           type="text"
+                           value="{{ getConfigFromEnvVars('crowi', 'app:siteUrl') | default('') }}"
+                           readonly>
+                    <p class="help-block">
+                      {{ t("app_setting.Use env var if empty", "APP_SITE_URL") }}
+                    </p>
+                  </td>
+                </tr>
+              </tbody>
+            </table>
           </div>
 
           <div class="form-group">