customize.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. {% extends '../layout/admin.html' %}
  2. {% block html_title %}カスタマイズ · {% endblock %}
  3. {% block html_additional_headers %}
  4. <!-- CodeMirror -->
  5. <link rel="stylesheet" href="https://cdn.jsdelivr.net/g/codemirror@4.5.0(codemirror.css+addon/hint/show-hint.css)">
  6. <link rel="stylesheet" href="https://cdn.jsdelivr.net/jquery.ui/1.11.4/jquery-ui.min.css">
  7. <link rel="stylesheet" href="https://cdn.jsdelivr.net/codemirror/4.5.0/theme/eclipse.css">
  8. <style>
  9. .CodeMirror {
  10. border: 1px solid #eee;
  11. }
  12. </style>
  13. {% endblock %}
  14. {% block content_head %}
  15. <div class="header-wrap">
  16. <header id="page-header">
  17. <h1 class="title" id="">カスタマイズ</h1>
  18. </header>
  19. </div>
  20. {% endblock %}
  21. {% block content_main %}
  22. <div class="content-main admin-customize">
  23. {% set smessage = req.flash('successMessage') %}
  24. {% if smessage.length %}
  25. <div class="alert alert-success">
  26. {{ smessage }}
  27. </div>
  28. {% endif %}
  29. {% set emessage = req.flash('errorMessage') %}
  30. {% if emessage.length %}
  31. <div class="alert alert-danger">
  32. {{ emessage }}
  33. </div>
  34. {% endif %}
  35. <div class="row">
  36. <div class="col-md-3">
  37. {% include './widget/menu.html' with {current: 'customize'} %}
  38. </div>
  39. <div class="col-md-9">
  40. <form action="/_api/admin/customize/behavior" method="post" class="form-horizontal" id="cutombehaviorSettingForm" role="form">
  41. <fieldset>
  42. <legend>挙動</legend>
  43. <div class="form-group">
  44. <div class="col-xs-6">
  45. <h4>
  46. <input type="radio" name="settingForm[customize:behavior]" value="crowi"
  47. {% if !settingForm['customize:behavior'] || 'crowi' === settingForm['customize:behavior'] %}checked="checked"{% endif %}>
  48. Official Crowi Behavior
  49. </h4>
  50. <ul>
  51. <li><code>/page</code> shows the page</li>
  52. <li><code>/page/</code> shows the list of sub pages</li>
  53. <ul>
  54. <li>If portal is applied to <code>/page/</code> , the portal and the list of sub pages are shown</li>
  55. </ul>
  56. <li><code>/nonexistent_page</code> shows editing form</li>
  57. <li><code>/nonexistent_page/</code> the list of sub pages</li>
  58. </ul>
  59. </div>
  60. <div class="col-xs-6">
  61. <h4>
  62. <input type="radio" name="settingForm[customize:behavior]" value="crowi-plus"
  63. {% if 'crowi-plus' === settingForm['customize:behavior'] %}checked="checked"{% endif %}>
  64. crowi-plus Simplified Behavior <small class="text-success">(Recommended)</small>
  65. </h4>
  66. <ul>
  67. <li>Both of <code>/page</code> and <code>/page/</code> shows the same page</li>
  68. <li><code>/nonexistent_page</code> shows editing form</li>
  69. <li>All pages shows the list of sub pages when using <b>crowi-plus Enhanced Layout</b></li>
  70. </ul>
  71. </div>
  72. </div>
  73. <div class="form-group">
  74. <div class="col-xs-offset-5 col-xs-6">
  75. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  76. <button type="submit" class="btn btn-primary">更新</button>
  77. </div>
  78. </div>
  79. </fieldset>
  80. </form>
  81. <form action="/_api/admin/customize/layout" method="post" class="form-horizontal" id="cutomlayoutSettingForm" role="form">
  82. <fieldset>
  83. <legend>レイアウト</legend>
  84. <div class="form-group">
  85. <div class="col-xs-6">
  86. <h4>
  87. <input type="radio" name="settingForm[customize:layout]" value="crowi"
  88. {% if !settingForm['customize:layout'] || 'crowi' === settingForm['customize:layout'] %}checked="checked"{% endif %}>
  89. Official Crowi Classic Layout
  90. </h4>
  91. <a href="/images/admin/customize/layout-classic.gif" class="ss-container">
  92. <img src="/images/admin/customize/layout-classic-thumb.gif" width="240px">
  93. </a>
  94. <ul>
  95. <li>Functional</li>
  96. <ul>
  97. <li>Collapsible Sidebar</li>
  98. <li>Show and post comments in Sidebar</li>
  99. <li>Collapsible Table-of-contents</li>
  100. </ul>
  101. </ul>
  102. </div>
  103. <div class="col-xs-6">
  104. <h4>
  105. <input type="radio" name="settingForm[customize:layout]" value="crowi-plus"
  106. {% if 'crowi-plus' === settingForm['customize:layout'] %}checked="checked"{% endif %}>
  107. crowi-plus Enhanced Layout <small class="text-success">(Recommended)</small>
  108. </h4>
  109. <a href="/images/admin/customize/layout-crowi-plus.gif" class="ss-container">
  110. <img src="/images/admin/customize/layout-crowi-plus-thumb.gif" width="240px">
  111. </a>
  112. <ul>
  113. <li>Simple and Clear</li>
  114. <ul>
  115. <li>Show and post comments from the bottom of the page</li>
  116. <li>Affix Table-of-contents</li>
  117. </ul>
  118. </ul>
  119. </div>
  120. </div>
  121. <div class="form-group">
  122. <div class="col-xs-offset-5 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/customize/highlight" method="post" class="form-horizontal" id="cutomhighlightSettingForm" role="form">
  130. <fieldset>
  131. <legend>ハイライト設定</legend>
  132. <div class="form-group">
  133. <div class="col-xs-3">
  134. <select class="form-control" name="settingForm[customize:highlight]">
  135. <option value="atom-one-dark">Atom One Dark</option>
  136. <option value="atom-one-light">Atom One Light</option>
  137. <option value="github-gist">Github Gist</option>
  138. <option value="github">Github</option>
  139. <option value="hybrid">Hybrid</option>
  140. <option value="monokai">Monokai</option>
  141. <option value="tomorrow-night">Tomorrow Night</option>
  142. <option value="vs">Vs</option>
  143. <option value="vs2015">Vs 2015</option>
  144. <option value="xcode">Xcode</option>
  145. </select>
  146. </div>
  147. </div>
  148. <div class="form-group">
  149. <div class="col-xs-offset-5 col-xs-6">
  150. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  151. <button type="submit" class="btn btn-primary">更新</button>
  152. </div>
  153. </div>
  154. </fieldset>
  155. </form>
  156. <form action="/_api/admin/customize/features" method="post" class="form-horizontal" id="customfeaturesSettingForm" role="form">
  157. <fieldset>
  158. <legend>機能</legend>
  159. <p class="well">機能の有効/無効を選択できます。</p>
  160. <div class="form-group">
  161. <label for="settingForm[customize:isEnabledTimeline]" class="col-xs-3 control-label">タイムライン機能</label>
  162. <div class="col-xs-9">
  163. <div class="btn-group btn-toggle" data-toggle="buttons">
  164. <label class="btn btn-default {% if settingForm['customize:isEnabledTimeline'] %}active{% endif %}" data-active-class="primary">
  165. <input name="settingForm[customize:isEnabledTimeline]" value="true" type="radio"
  166. {% if true === settingForm['customize:isEnabledTimeline'] %}checked{% endif %}> 有効
  167. </label>
  168. <label class="btn btn-default {% if !settingForm['customize:isEnabledTimeline'] %}active{% endif %}" data-active-class="primary">
  169. <input name="settingForm[customize:isEnabledTimeline]" value="false" type="radio"
  170. {% if !settingForm['customize:isEnabledTimeline'] %}checked{% endif %}> 無効
  171. </label>
  172. </div>
  173. <p class="help-block">
  174. 配下ページのタイムラインを表示できます。
  175. </p>
  176. <p class="help-block">
  177. 配下ページが多い場合はページロード時のパフォーマンスが落ちます。<br>
  178. 無効化することでリストページの表示を高速化できます。
  179. </p>
  180. </div>
  181. </div>
  182. <div class="form-group">
  183. <label for="settingForm[customize:isSavedStatesOfTabChanges]" class="col-xs-3 control-label">タブ変更をブラウザ履歴に保存</label>
  184. <div class="col-xs-9">
  185. <div class="btn-group btn-toggle" data-toggle="buttons">
  186. <label class="btn btn-default {% if settingForm['customize:isSavedStatesOfTabChanges'] %}active{% endif %}" data-active-class="primary">
  187. <input name="settingForm[customize:isSavedStatesOfTabChanges]" value="true" type="radio"
  188. {% if true === settingForm['customize:isSavedStatesOfTabChanges'] %}checked{% endif %}> 有効
  189. </label>
  190. <label class="btn btn-default {% if !settingForm['customize:isSavedStatesOfTabChanges'] %}active{% endif %}" data-active-class="primary">
  191. <input name="settingForm[customize:isSavedStatesOfTabChanges]" value="false" type="radio"
  192. {% if !settingForm['customize:isSavedStatesOfTabChanges'] %}checked{% endif %}> 無効
  193. </label>
  194. </div>
  195. <p class="help-block">
  196. 編集タブやヒストリータブ等の切り替えをブラウザ履歴に保存し、ブラウザの戻る/進む操作の対象にします。<br>
  197. 無効化することで、ページ遷移のみを戻る/進む操作の対象にすることができます。
  198. </p>
  199. </div>
  200. </div>
  201. <div class="form-group">
  202. <div class="col-xs-offset-3 col-xs-6">
  203. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  204. <button type="submit" class="btn btn-primary">更新</button>
  205. </div>
  206. </div>
  207. </fieldset>
  208. </form>
  209. <form action="/_api/admin/customize/header" method="post" class="form-horizontal" id="cutomheaderSettingForm" role="form">
  210. <fieldset>
  211. <legend>カスタムヘッダーHTML</legend>
  212. <p class="well">
  213. システム全体に適用される HTML を記述できます。<code>&lt;header&gt;</code> タグ内の他の <code>&lt;script&gt;</code> タグ読み込み前に展開されます。<br>
  214. 変更の反映はページの更新が必要です。
  215. </p>
  216. <p class="help-block">
  217. Examples:
  218. <pre><code>&lt;script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.12.0/build/languages/yaml.min.js" defer&gt;&lt;script&gt;</script></code></pre>
  219. </p>
  220. <div class="form-group">
  221. <div class="col-xs-12">
  222. <div id="custom-header-editor"></div>
  223. <input type="hidden" id="inputCustomHeader" name="settingForm[customize:header]" value="{{ settingForm['customize:header'] }}">
  224. </div>
  225. <div class="col-xs-12">
  226. <p class="help-block text-right">
  227. <i class="fa fa-fw fa-keyboard-o" aria-hidden="true"></i>
  228. Ctrl+Space でコード補完
  229. </p>
  230. </div>
  231. </div>
  232. <div class="form-group">
  233. <div class="col-xs-offset-5 col-xs-6">
  234. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  235. <button type="submit" class="btn btn-primary">更新</button>
  236. </div>
  237. </div>
  238. </fieldset>
  239. </form>
  240. <form action="/_api/admin/customize/css" method="post" class="form-horizontal" id="cutomcssSettingForm" role="form">
  241. <fieldset>
  242. <legend>カスタムヘッダーCSS</legend>
  243. <p class="well">
  244. システム全体に適用されるCSSを記述できます。<code>&lt;header&gt;</code> タグ内に展開されます。<br>
  245. 変更の反映はページの更新が必要です。
  246. </p>
  247. <div class="form-group">
  248. <div class="col-xs-12">
  249. <div id="custom-css-editor"></div>
  250. <input type="hidden" id="inputCustomCss" name="settingForm[customize:css]" value="{{ settingForm['customize:css'] }}">
  251. </div>
  252. <div class="col-xs-12">
  253. <p class="help-block text-right">
  254. <i class="fa fa-fw fa-keyboard-o" aria-hidden="true"></i>
  255. Ctrl+Space でコード補完
  256. </p>
  257. </div>
  258. </div>
  259. <div class="form-group">
  260. <div class="col-xs-offset-5 col-xs-6">
  261. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  262. <button type="submit" class="btn btn-primary">更新</button>
  263. </div>
  264. </div>
  265. </fieldset>
  266. </form>
  267. <form action="/_api/admin/customize/script" method="post" class="form-horizontal" id="cutomscriptSettingForm" role="form">
  268. <fieldset>
  269. <legend>カスタムスクリプト</legend>
  270. <p class="well">
  271. システム全体に適用されるJavaScriptを記述できます。<code>&lt;body&gt;</code> タグ内の最後に展開されます。<br>
  272. 変更の反映はページの更新が必要です。
  273. </p>
  274. <p class="help-block">
  275. Placeholders:<br>
  276. (Available after <code>load</code> event)
  277. <dl class="dl-horizontal">
  278. <dt><code>$</code></dt>
  279. <dd>jQuery instance</dd>
  280. <dt><code>crowi</code></dt>
  281. <dd>Crowi context instance</dd>
  282. <dt><code>Crowi</code></dt>
  283. <dd>Crowi legacy instance (jQuery based)</dd>
  284. <dt><code>crowiRenderer</code></dt>
  285. <dd>Crowi Renderer instance</dd>
  286. <dt><code>crowiPlugin</code></dt>
  287. <dd>crowi-plus plugin manager instance</dd>
  288. </dl>
  289. </p>
  290. <p class="help-block">
  291. Examples:
  292. <pre><code>console.log($('.main-container'));
  293. window.addEventListener('load', (event) => {
  294. console.log('config: ', crowi.config);
  295. });</code></pre>
  296. </p>
  297. <div class="form-group">
  298. <div class="col-xs-12">
  299. <div id="custom-script-editor"></div>
  300. <input type="hidden" id="inputCustomScript" name="settingForm[customize:script]" value="{{ settingForm['customize:script'] }}">
  301. </div>
  302. <div class="col-xs-12">
  303. <p class="help-block text-right">
  304. <i class="fa fa-fw fa-keyboard-o" aria-hidden="true"></i>
  305. Ctrl+Space でコード補完
  306. </p>
  307. </div>
  308. </div>
  309. <div class="form-group">
  310. <div class="col-xs-offset-5 col-xs-6">
  311. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  312. <button type="submit" class="btn btn-primary">更新</button>
  313. </div>
  314. </div>
  315. </fieldset>
  316. </form>
  317. </div>
  318. </div>
  319. <script>
  320. $('#cutomcssSettingForm, #cutomscriptSettingForm, #cutomlayoutSettingForm, #cutombehaviorSettingForm, #customfeaturesSettingForm, #cutomheaderSettingForm, #cutomhighlightSettingForm').each(function() {
  321. $(this).submit(function()
  322. {
  323. function showMessage(formId, msg, status) {
  324. $('#' + formId + ' .alert').remove();
  325. if (!status) {
  326. status = 'success';
  327. }
  328. var $message = $('<p class="alert"></p>');
  329. $message.addClass('alert-' + status);
  330. $message.html(msg.replace('\n', '<br>'));
  331. $message.insertAfter('#' + formId + ' legend');
  332. if (status == 'success') {
  333. setTimeout(function()
  334. {
  335. $message.fadeOut({
  336. complete: function() {
  337. $message.remove();
  338. }
  339. });
  340. }, 5000);
  341. }
  342. }
  343. var $form = $(this);
  344. var $id = $form.attr('id');
  345. var $button = $('button', this);
  346. $button.attr('disabled', 'disabled');
  347. var jqxhr = $.post($form.attr('action'), $form.serialize(), function(data)
  348. {
  349. if (data.status) {
  350. showMessage($id, '更新しました');
  351. } else {
  352. showMessage($id, data.message, 'danger');
  353. }
  354. })
  355. .fail(function() {
  356. showMessage($id, 'エラーが発生しました', 'danger');
  357. })
  358. .always(function() {
  359. $button.prop('disabled', false);
  360. });
  361. return false;
  362. });
  363. });
  364. // 保存した highlight の値を selector に復元する
  365. $('#cutomhighlightSettingForm select').val('{{ highlightType() }}');
  366. </script>
  367. </div>
  368. {% endblock content_main %}
  369. {% block content_footer %}
  370. {% endblock content_footer %}