app.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. {% extends '../layout/admin.html' %}
  2. {% block html_title %}アプリ設定 · {% endblock %}
  3. {% block content_head %}
  4. <div class="header-wrap">
  5. <header id="page-header">
  6. <h1 class="title" id="">アプリ設定</h1>
  7. </header>
  8. </div>
  9. {% endblock %}
  10. {% block content_main %}
  11. <div class="content-main">
  12. {% set smessage = req.flash('successMessage') %}
  13. {% if smessage.length %}
  14. <div class="alert alert-success">
  15. {{ smessage }}
  16. </div>
  17. {% endif %}
  18. {% set emessage = req.flash('errorMessage') %}
  19. {% if emessage.length %}
  20. <div class="alert alert-danger">
  21. {{ emessage }}
  22. </div>
  23. {% endif %}
  24. <div class="row">
  25. <div class="col-md-3">
  26. {% include './widget/menu.html' with {current: 'app'} %}
  27. </div>
  28. <div class="col-md-9">
  29. <form action="/_api/admin/settings/app" method="post" class="form-horizontal" id="appSettingForm" role="form">
  30. <fieldset>
  31. <legend>アプリ設定</legend>
  32. <div class="form-group">
  33. <label for="settingForm[app:title]" class="col-xs-3 control-label">Wikiの名前</label>
  34. <div class="col-xs-6">
  35. <input class="form-control" type="text" name="settingForm[app:title]" value="{{ settingForm['app:title'] }}">
  36. <p class="help-block">ヘッダーやHTMLタイトルに使用されるWikiの名前を変更できます。</p>
  37. </div>
  38. </div>
  39. <div class="form-group">
  40. <label for="settingForm[app:confidential]" class="col-xs-3 control-label">コンフィデンシャル表示</label>
  41. <div class="col-xs-6">
  42. <input class="form-control" type="text" name="settingForm[app:confidential]" value="{{ settingForm['app:confidential'] }}" placeholder="例: 社外秘">
  43. <p class="help-block">ここに入力した内容は、ヘッダー等に表示されます。</p>
  44. </div>
  45. </div>
  46. <div class="form-group">
  47. <div class="col-xs-offset-3 col-xs-6">
  48. <input type="checkbox" name="settingForm[app:fileUpload]" value="1"
  49. {% if settingForm['app:fileUpload'] %}
  50. checked
  51. {% endif %}
  52. {% if not isUploadable() %}
  53. disabled="disabled"
  54. {% else %}
  55. {% endif %}
  56. >
  57. <label for="settingForm[app:fileUpload]" class="">画像以外のファイルアップロードを許可</label>
  58. <p class="help-block">
  59. ファイルアップロードの設定を有効にしている場合にのみ、選択可能です。<br>
  60. 許可をしている場合、画像以外のファイルをページに添付可能になります。
  61. </p>
  62. </div>
  63. </div>
  64. <div class="form-group">
  65. <div class="col-xs-offset-3 col-xs-6">
  66. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  67. <button type="submit" class="btn btn-primary">更新</button>
  68. </div>
  69. </div>
  70. </fieldset>
  71. </form>
  72. <form action="/_api/admin/settings/sec" method="post" class="form-horizontal" id="secSettingForm" role="form">
  73. <fieldset>
  74. <legend>セキュリティ設定</legend>
  75. <div class="form-group">
  76. <label for="settingForm[security:registrationMode]" class="col-xs-3 control-label">Basic認証</label>
  77. <div class="col-xs-3">
  78. <label for="">ID</label>
  79. <input class="form-control" type="text" name="settingForm[security:basicName]" value="{{ settingForm['security:basicName']|default('') }}">
  80. </div>
  81. <div class="col-xs-3">
  82. <label for="">パスワード</label>
  83. <input class="form-control" type="text" name="settingForm[security:basicSecret]" value="{{ settingForm['security:basicSecret']|default('') }}">
  84. </div>
  85. <div class="col-xs-offset-3 col-xs-9">
  86. <p class="help-block">
  87. Basic認証を設定すると、ページ全体に共通の認証がかかります。<br>
  88. IDとパスワードは暗号化されずに送信されるのでご注意下さい。<br>
  89. </p>
  90. </div>
  91. </div>
  92. <div class="form-group">
  93. <label for="settingForm[security:restrictGuestMode]" class="col-xs-3 control-label">ゲストユーザーのアクセス</label>
  94. <div class="col-xs-6">
  95. <select class="form-control" name="settingForm[security:restrictGuestMode]" value="{{ settingForm['security:restrictGuestMode'] }}">
  96. {% for modeValue, modeLabel in consts.restrictGuestMode %}
  97. <option value="{{ modeValue }}" {% if modeValue == settingForm['security:restrictGuestMode'] %}selected{% endif %} >{{ modeLabel }}</option>
  98. {% endfor %}
  99. </select>
  100. </div>
  101. </div>
  102. <div class="form-group">
  103. <label for="settingForm[security:registrationMode]" class="col-xs-3 control-label">登録の制限</label>
  104. <div class="col-xs-6">
  105. <select class="form-control" name="settingForm[security:registrationMode]" value="{{ settingForm['security:registrationMode'] }}">
  106. {% for modeValue, modeLabel in consts.registrationMode %}
  107. <option value="{{ modeValue }}" {% if modeValue == settingForm['security:registrationMode'] %}selected{% endif %} >{{ modeLabel }}</option>
  108. {% endfor %}
  109. </select>
  110. <p class="help-block">ここに入力した内容は、ヘッダー等に表示されます。</p>
  111. </div>
  112. </div>
  113. <div class="form-group">
  114. <label for="settingForm[security:registrationWhiteList]" class="col-xs-3 control-label">登録許可メールアドレスの<br>ホワイトリスト</label>
  115. <div class="col-xs-8">
  116. <textarea class="form-control" type="textarea" name="settingForm[security:registrationWhiteList]" placeholder="例: @crowi.wiki">{{ settingForm['security:registrationWhiteList']|join('&#13')|raw }}</textarea>
  117. <p class="help-block">登録可能なメールアドレスを制限することができます。例えば、会社で使う場合、<code>@crowi.wiki</code> などと記載すると、その会社のメールアドレスを持っている人のみ登録可能になります。<br>
  118. 1行に1メールアドレス入力してください。</p>
  119. </div>
  120. </div>
  121. <div class="form-group">
  122. <div class="col-xs-offset-3 col-xs-6">
  123. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  124. <button type="submit" class="btn btn-primary">更新</button>
  125. </div>
  126. </div>
  127. </fieldset>
  128. </form>
  129. <form action="/_api/admin/settings/mail" method="post" class="form-horizontal" id="mailSettingForm" role="form">
  130. <fieldset>
  131. <legend>メールの設定</legend>
  132. <p class="well">SMTPの設定がされている場合、それが利用されます。SMTP設定がなく、AWSの設定がある場合、SESでの送信を試みます。<br>どちらの設定もない場合、メールは送信されません。</p>
  133. <div class="form-group">
  134. <label for="settingForm[mail.from]" class="col-xs-3 control-label">Fromアドレス</label>
  135. <div class="col-xs-6">
  136. <input class="form-control" type="text" name="settingForm[mail:from]" placeholder="例: mail@crowi.wiki" value="{{ settingForm['mail:from'] }}">
  137. </div>
  138. </div>
  139. <div class="form-group">
  140. <label class="col-xs-3 control-label">SMTP設定</label>
  141. <div class="col-xs-4">
  142. <label for="">ホスト</label>
  143. <input class="form-control" type="text" name="settingForm[mail:smtpHost]" value="{{ settingForm['mail:smtpHost']|default('') }}">
  144. </div>
  145. <div class="col-xs-2">
  146. <label for="">ポート</label>
  147. <input class="form-control" type="text" name="settingForm[mail:smtpPort]" value="{{ settingForm['mail:smtpPort']|default('') }}">
  148. </div>
  149. </div>
  150. <div class="form-group">
  151. <div class="col-xs-3 col-xs-offset-3">
  152. <label for="">ユーザー</label>
  153. <input class="form-control" type="text" name="settingForm[mail:smtpUser]" value="{{ settingForm['mail:smtpUser']|default('') }}">
  154. </div>
  155. <div class="col-xs-3">
  156. <label for="">パスワード</label>
  157. <input class="form-control" type="password" name="settingForm[mail:smtpPassword]" value="{{ settingForm['mail:smtpPassword']|default('') }}">
  158. </div>
  159. </div>
  160. <div class="form-group">
  161. <div class="col-xs-offset-3 col-xs-6">
  162. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  163. <button type="submit" class="btn btn-primary">更新</button>
  164. </div>
  165. </div>
  166. </fieldset>
  167. </form>
  168. <form action="/_api/admin/settings/aws" method="post" class="form-horizontal" id="awsSettingForm" role="form">
  169. <fieldset>
  170. <legend>AWS設定</legend>
  171. <p class="well">AWS にアクセスするための設定を行います。AWS の設定を完了させると、ファイルアップロード機能、プロフィール写真機能などが有効になります。<br>
  172. また、SMTP の設定が無い場合、SES を利用したメール送信が行われます。FromメールアドレスのVerify、プロダクション利用設定をする必要があります。<br>
  173. <br>
  174. <span class="text-danger"><i class="fa fa-warning"></i> この設定を途中で変更すると、これまでにアップロードしたファイル等へのアクセスができなくなりますのでご注意下さい。</span>
  175. </p>
  176. <div class="form-group">
  177. <label for="settingForm[app.region]" class="col-xs-3 control-label">リージョン</label>
  178. <div class="col-xs-6">
  179. <input class="form-control" type="text" name="settingForm[aws:region]" placeholder="例: ap-northeast-1" value="{{ settingForm['aws:region'] }}">
  180. </div>
  181. </div>
  182. <div class="form-group">
  183. <label for="settingForm[aws:bucket]" class="col-xs-3 control-label">バケット名</label>
  184. <div class="col-xs-6">
  185. <input class="form-control" type="text" name="settingForm[aws:bucket]" placeholder="例: crowi" value="{{ settingForm['aws:bucket'] }}">
  186. </div>
  187. </div>
  188. <div class="form-group">
  189. <label for="settingForm[aws:accessKeyId]" class="col-xs-3 control-label">Access Key ID</label>
  190. <div class="col-xs-6">
  191. <input class="form-control" type="text" name="settingForm[aws:accessKeyId]" value="{{ settingForm['aws:accessKeyId'] }}">
  192. </div>
  193. </div>
  194. <div class="form-group">
  195. <label for="settingForm[aws:secretAccessKey]" class="col-xs-3 control-label">Secret Access Key</label>
  196. <div class="col-xs-6">
  197. <input class="form-control" type="text" name="settingForm[aws:secretAccessKey]" value="{{ settingForm['aws:secretAccessKey'] }}">
  198. </div>
  199. </div>
  200. <div class="form-group">
  201. <div class="col-xs-offset-3 col-xs-6">
  202. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  203. <button type="submit" class="btn btn-primary">更新</button>
  204. </div>
  205. </div>
  206. </fieldset>
  207. </form>
  208. <form action="/_api/admin/settings/google" method="post" class="form-horizontal" id="googleSettingForm" role="form">
  209. <fieldset>
  210. <legend>Google 設定</legend>
  211. <p class="well">
  212. Google Cloud Platform の <a href="https://console.cloud.google.com/apis/credentials">API Manager</a>
  213. から OAuth2 Client ID を作成すると、Google アカウントにコネクトして登録やログインが可能になります。
  214. </p>
  215. <ol class="help-block">
  216. <li><a href="https://console.cloud.google.com/apis/credentials">API Manager</a> へアクセス</li>
  217. <li>プロジェクトを作成していない場合は作成してください</li>
  218. <li>「認証情報を作成」-> OAuthクライアントID</li>
  219. <ol>
  220. <li>「ウェブアプリケーション」を選択</li>
  221. <li>承認済みのリダイレクトURLに、 <code>https://${crowi.host}/google/callback</code> を入力<br>
  222. (<code>${crowi.host}</code>は環境に合わせて変更してください)</li>
  223. </ol>
  224. </ol>
  225. <div class="form-group">
  226. <label for="settingForm[google:clientId]" class="col-xs-3 control-label">Client ID</label>
  227. <div class="col-xs-6">
  228. <input class="form-control" type="text" name="settingForm[google:clientId]" value="{{ settingForm['google:clientId'] }}">
  229. </div>
  230. </div>
  231. <div class="form-group">
  232. <label for="settingForm[google:clientSecret]" class="col-xs-3 control-label">Client Secret</label>
  233. <div class="col-xs-6">
  234. <input class="form-control" type="text" name="settingForm[google:clientSecret]" value="{{ settingForm['google:clientSecret'] }}">
  235. </div>
  236. </div>
  237. <div class="form-group">
  238. <div class="col-xs-offset-3 col-xs-6">
  239. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  240. <button type="submit" class="btn btn-primary">更新</button>
  241. </div>
  242. </div>
  243. </fieldset>
  244. </form>
  245. <form action="/_api/admin/settings/plugin" method="post" class="form-horizontal" id="pluginSettingForm" role="form">
  246. <fieldset>
  247. <legend>プラグイン設定</legend>
  248. <p class="well">プラグインの読み込みを有効にします。</p>
  249. <div class="form-group">
  250. <label for="settingForm[plugin:isEnabledPlugins]" class="col-xs-3 control-label">プラグインを読み込む</label>
  251. <div class="col-xs-6">
  252. <div class="btn-group btn-toggle" data-toggle="buttons">
  253. <label class="btn btn-default {% if settingForm['plugin:isEnabledPlugins'] %}active{% endif %}" data-active-class="primary">
  254. <input name="settingForm[plugin:isEnabledPlugins]" value="true" type="radio"
  255. {% if true === settingForm['plugin:isEnabledPlugins'] %}checked{% endif %}> 有効
  256. </label>
  257. <label class="btn btn-default {% if !settingForm['plugin:isEnabledPlugins'] %}active{% endif %}" data-active-class="primary">
  258. <input name="settingForm[plugin:isEnabledPlugins]" value="false" type="radio"
  259. {% if !settingForm['plugin:isEnabledPlugins'] %}checked{% endif %}> 無効
  260. </label>
  261. </div>
  262. </div>
  263. </div>
  264. <div class="form-group">
  265. <div class="col-xs-offset-3 col-xs-6">
  266. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  267. <button type="submit" class="btn btn-primary">更新</button>
  268. </div>
  269. </div>
  270. </fieldset>
  271. </form>
  272. </div>
  273. </div>
  274. <script>
  275. $('#appSettingForm, #secSettingForm, #mailSettingForm, #awsSettingForm, #googleSettingForm, #pluginSettingForm').each(function() {
  276. $(this).submit(function()
  277. {
  278. function showMessage(formId, msg, status) {
  279. $('#' + formId + ' .alert').remove();
  280. if (!status) {
  281. status = 'success';
  282. }
  283. var $message = $('<p class="alert"></p>');
  284. $message.addClass('alert-' + status);
  285. $message.html(msg.replace('\n', '<br>'));
  286. $message.insertAfter('#' + formId + ' legend');
  287. if (status == 'success') {
  288. setTimeout(function()
  289. {
  290. $message.fadeOut({
  291. complete: function() {
  292. $message.remove();
  293. }
  294. });
  295. }, 5000);
  296. }
  297. }
  298. var $form = $(this);
  299. var $id = $form.attr('id');
  300. var $button = $('button', this);
  301. $button.attr('disabled', 'disabled');
  302. var jqxhr = $.post($form.attr('action'), $form.serialize(), function(data)
  303. {
  304. if (data.status) {
  305. showMessage($id, '更新しました');
  306. } else {
  307. showMessage($id, data.message, 'danger');
  308. }
  309. })
  310. .fail(function() {
  311. showMessage($id, 'エラーが発生しました', 'danger');
  312. })
  313. .always(function() {
  314. $button.prop('disabled', false);
  315. });
  316. return false;
  317. });
  318. });
  319. </script>
  320. </div>
  321. {% endblock content_main %}
  322. {% block content_footer %}
  323. {% endblock content_footer %}