2
0

customize.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  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/features" method="post" class="form-horizontal" id="customfeaturesSettingForm" role="form">
  130. <fieldset>
  131. <legend>機能</legend>
  132. <p class="well">機能の有効/無効を選択できます。</p>
  133. <div class="form-group">
  134. <label for="settingForm[customize:isEnabledTimeline]" class="col-xs-3 control-label">タイムライン機能</label>
  135. <div class="col-xs-9">
  136. <div class="btn-group btn-toggle" data-toggle="buttons">
  137. <label class="btn btn-default {% if settingForm['customize:isEnabledTimeline'] %}active{% endif %}" data-active-class="primary">
  138. <input name="settingForm[customize:isEnabledTimeline]" value="true" type="radio"
  139. {% if true === settingForm['customize:isEnabledTimeline'] %}checked{% endif %}> 有効
  140. </label>
  141. <label class="btn btn-default {% if !settingForm['customize:isEnabledTimeline'] %}active{% endif %}" data-active-class="primary">
  142. <input name="settingForm[customize:isEnabledTimeline]" value="false" type="radio"
  143. {% if !settingForm['customize:isEnabledTimeline'] %}checked{% endif %}> 無効
  144. </label>
  145. </div>
  146. <p class="help-block">
  147. 配下ページのタイムラインを表示できます。
  148. </p>
  149. <p class="help-block">
  150. 配下ページが多い場合はページロード時のパフォーマンスが落ちます。<br>
  151. 無効化することでリストページの表示を高速化できます。
  152. </p>
  153. </div>
  154. </div>
  155. <div class="form-group">
  156. <label for="settingForm[customize:isSavedStatesOfTabChanges]" class="col-xs-3 control-label">タブ変更をブラウザ履歴に保存</label>
  157. <div class="col-xs-9">
  158. <div class="btn-group btn-toggle" data-toggle="buttons">
  159. <label class="btn btn-default {% if settingForm['customize:isSavedStatesOfTabChanges'] %}active{% endif %}" data-active-class="primary">
  160. <input name="settingForm[customize:isSavedStatesOfTabChanges]" value="true" type="radio"
  161. {% if true === settingForm['customize:isSavedStatesOfTabChanges'] %}checked{% endif %}> 有効
  162. </label>
  163. <label class="btn btn-default {% if !settingForm['customize:isSavedStatesOfTabChanges'] %}active{% endif %}" data-active-class="primary">
  164. <input name="settingForm[customize:isSavedStatesOfTabChanges]" value="false" type="radio"
  165. {% if !settingForm['customize:isSavedStatesOfTabChanges'] %}checked{% endif %}> 無効
  166. </label>
  167. </div>
  168. <p class="help-block">
  169. 編集タブやヒストリータブ等の切り替えをブラウザ履歴に保存し、ブラウザの戻る/進む操作の対象にします。<br>
  170. 無効化することで、ページ遷移のみを戻る/進む操作の対象にすることができます。
  171. </p>
  172. </div>
  173. </div>
  174. <div class="form-group">
  175. <div class="col-xs-offset-3 col-xs-6">
  176. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  177. <button type="submit" class="btn btn-primary">更新</button>
  178. </div>
  179. </div>
  180. </fieldset>
  181. </form>
  182. <form action="/_api/admin/customize/css" method="post" class="form-horizontal" id="cutomcssSettingForm" role="form">
  183. <fieldset>
  184. <legend>カスタムCSS</legend>
  185. <p class="help-block">
  186. システム全体に適用されるCSSを記述できます。<br>
  187. 変更の反映はページの更新が必要です。
  188. </p>
  189. <div class="form-group">
  190. <div class="col-xs-12">
  191. <textarea id="taCustomCss" class="form-control" type="textarea" name="settingForm[customize:css]" rows="20">{{ settingForm['customize:css'] }}</textarea>
  192. </div>
  193. <div class="col-xs-12">
  194. <p class="help-block text-right">
  195. <i class="fa fa-fw fa-keyboard-o" aria-hidden="true"></i>
  196. Ctrl+Space でコード補完
  197. </p>
  198. </div>
  199. </div>
  200. <div class="form-group">
  201. <div class="col-xs-offset-5 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/customize/script" method="post" class="form-horizontal" id="cutomscriptSettingForm" role="form">
  209. <fieldset>
  210. <legend>カスタムスクリプト</legend>
  211. <p class="help-block">
  212. システム全体に適用されるJavaScriptを記述できます。<br>
  213. 変更の反映はページの更新が必要です。
  214. </p>
  215. <div class="form-group">
  216. <div class="col-xs-12">
  217. <textarea id="taCustomScript" class="form-control" type="textarea" name="settingForm[customize:script]" rows="20">{{ settingForm['customize:script'] }}</textarea>
  218. </div>
  219. <div class="col-xs-12">
  220. <p class="help-block text-right">
  221. <i class="fa fa-fw fa-keyboard-o" aria-hidden="true"></i>
  222. Ctrl+Space でコード補完
  223. </p>
  224. </div>
  225. </div>
  226. <div class="form-group">
  227. <div class="col-xs-offset-5 col-xs-6">
  228. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  229. <button type="submit" class="btn btn-primary">更新</button>
  230. </div>
  231. </div>
  232. </fieldset>
  233. </form>
  234. </div>
  235. </div>
  236. <script>
  237. $('#cutomcssSettingForm, #cutomscriptSettingForm, #cutomlayoutSettingForm, #cutombehaviorSettingForm, #customfeaturesSettingForm').each(function() {
  238. $(this).submit(function()
  239. {
  240. function showMessage(formId, msg, status) {
  241. $('#' + formId + ' .alert').remove();
  242. if (!status) {
  243. status = 'success';
  244. }
  245. var $message = $('<p class="alert"></p>');
  246. $message.addClass('alert-' + status);
  247. $message.html(msg.replace('\n', '<br>'));
  248. $message.insertAfter('#' + formId + ' legend');
  249. if (status == 'success') {
  250. setTimeout(function()
  251. {
  252. $message.fadeOut({
  253. complete: function() {
  254. $message.remove();
  255. }
  256. });
  257. }, 5000);
  258. }
  259. }
  260. var $form = $(this);
  261. var $id = $form.attr('id');
  262. var $button = $('button', this);
  263. $button.attr('disabled', 'disabled');
  264. var jqxhr = $.post($form.attr('action'), $form.serialize(), function(data)
  265. {
  266. if (data.status) {
  267. showMessage($id, '更新しました');
  268. } else {
  269. showMessage($id, data.message, 'danger');
  270. }
  271. })
  272. .fail(function() {
  273. showMessage($id, 'エラーが発生しました', 'danger');
  274. })
  275. .always(function() {
  276. $button.prop('disabled', false);
  277. });
  278. return false;
  279. });
  280. });
  281. </script>
  282. <!-- CodeMirror -->
  283. <script src="https://cdn.jsdelivr.net/g/codemirror@4.5.0(codemirror.min.js+addon/lint/css-lint.js+addon/lint/javascript-lint.js+mode/css/css.js+mode/javascript/javascript.js+addon/hint/css-hint.js+addon/hint/javascript-hint.js+addon/hint/show-hint.js+addon/edit/matchbrackets.js+addon/edit/closebrackets.js),jquery.ui@1.11.4"></script>
  284. <script>
  285. // Configure for CSS editor
  286. var editorCss = CodeMirror.fromTextArea(document.getElementById('taCustomCss'), {
  287. mode: "css",
  288. lineNumbers: true,
  289. tabSize: 2,
  290. indentUnit: 2,
  291. theme: 'eclipse',
  292. matchBrackets: true,
  293. autoCloseBrackets: true,
  294. extraKeys: {"Ctrl-Space": "autocomplete"},
  295. });
  296. editorCss.on('change', function(cm, change) {
  297. cm.save();
  298. });
  299. // resizable with jquery.ui
  300. $(editorCss.getWrapperElement()).resizable({
  301. resize: function() {
  302. editorCss.setSize($(this).width(), $(this).height());
  303. }
  304. });
  305. // Configure for JavaScript editor
  306. var editorScript = CodeMirror.fromTextArea(document.getElementById('taCustomScript'), {
  307. mode: "javascript",
  308. lineNumbers: true,
  309. tabSize: 2,
  310. indentUnit: 2,
  311. theme: 'eclipse',
  312. matchBrackets: true,
  313. autoCloseBrackets: true,
  314. extraKeys: {"Ctrl-Space": "autocomplete"},
  315. });
  316. editorScript.on('change', function(cm, change) {
  317. cm.save();
  318. });
  319. // resizable with jquery.ui
  320. $(editorScript.getWrapperElement()).resizable({
  321. resize: function() {
  322. editorScript.setSize($(this).width(), $(this).height());
  323. }
  324. });
  325. </script>
  326. </div>
  327. {% endblock content_main %}
  328. {% block content_footer %}
  329. {% endblock content_footer %}