customize.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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><code>/page</code> and <code>/page/</code> both shows the page</li>
  68. <li><code>/nonexistent_page</code> shows editing form</li>
  69. <li>All pages shows the list of sub pages</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. 無効化することで、リストページの表示を高速化できます。<br>
  148. 配下ページが多い場合に効果があります。
  149. </p>
  150. </div>
  151. </div>
  152. <div class="form-group">
  153. <div class="col-xs-offset-3 col-xs-6">
  154. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  155. <button type="submit" class="btn btn-primary">更新</button>
  156. </div>
  157. </div>
  158. </fieldset>
  159. </form>
  160. <form action="/_api/admin/customize/css" method="post" class="form-horizontal" id="cutomcssSettingForm" role="form">
  161. <fieldset>
  162. <legend>カスタムCSS</legend>
  163. <p class="help-block">
  164. システム全体に適用されるCSSを記述できます。<br>
  165. 変更の反映はページの更新が必要です。
  166. </p>
  167. <div class="form-group">
  168. <div class="col-xs-12">
  169. <textarea id="taCustomCss" class="form-control" type="textarea" name="settingForm[customize:css]" rows="20">{{ settingForm['customize:css'] }}</textarea>
  170. </div>
  171. <div class="col-xs-12">
  172. <p class="help-block text-right">
  173. <i class="fa fa-fw fa-keyboard-o" aria-hidden="true"></i>
  174. Ctrl+Space でコード補完
  175. </p>
  176. </div>
  177. </div>
  178. <div class="form-group">
  179. <div class="col-xs-offset-5 col-xs-6">
  180. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  181. <button type="submit" class="btn btn-primary">更新</button>
  182. </div>
  183. </div>
  184. </fieldset>
  185. </form>
  186. </div>
  187. </div>
  188. <script>
  189. $('#cutomcssSettingForm, #cutomlayoutSettingForm, #cutombehaviorSettingForm, #customfeaturesSettingForm').each(function() {
  190. $(this).submit(function()
  191. {
  192. function showMessage(formId, msg, status) {
  193. $('#' + formId + ' .alert').remove();
  194. if (!status) {
  195. status = 'success';
  196. }
  197. var $message = $('<p class="alert"></p>');
  198. $message.addClass('alert-' + status);
  199. $message.html(msg.replace('\n', '<br>'));
  200. $message.insertAfter('#' + formId + ' legend');
  201. if (status == 'success') {
  202. setTimeout(function()
  203. {
  204. $message.fadeOut({
  205. complete: function() {
  206. $message.remove();
  207. }
  208. });
  209. }, 5000);
  210. }
  211. }
  212. var $form = $(this);
  213. var $id = $form.attr('id');
  214. var $button = $('button', this);
  215. $button.attr('disabled', 'disabled');
  216. var jqxhr = $.post($form.attr('action'), $form.serialize(), function(data)
  217. {
  218. if (data.status) {
  219. showMessage($id, '更新しました');
  220. } else {
  221. showMessage($id, data.message, 'danger');
  222. }
  223. })
  224. .fail(function() {
  225. showMessage($id, 'エラーが発生しました', 'danger');
  226. })
  227. .always(function() {
  228. $button.prop('disabled', false);
  229. });
  230. return false;
  231. });
  232. });
  233. </script>
  234. <!-- CodeMirror -->
  235. <script src="https://cdn.jsdelivr.net/g/codemirror@4.5.0(codemirror.min.js+addon/lint/css-lint.js+mode/css/css.js+addon/hint/css-hint.js+addon/hint/show-hint.js+addon/edit/matchbrackets.js+addon/edit/closebrackets.js),jquery.ui@1.11.4"></script>
  236. <script>
  237. var editor = CodeMirror.fromTextArea(document.getElementById('taCustomCss'), {
  238. mode: "css",
  239. lineNumbers: true,
  240. tabSize: 2,
  241. indentUnit: 2,
  242. theme: 'eclipse',
  243. matchBrackets: true,
  244. autoCloseBrackets: true,
  245. extraKeys: {"Ctrl-Space": "autocomplete"},
  246. });
  247. editor.on('change', function(cm, change) {
  248. cm.save();
  249. });
  250. // resizable with jquery.ui
  251. $(editor.getWrapperElement()).resizable({
  252. resize: function() {
  253. editor.setSize($(this).width(), $(this).height());
  254. }
  255. });
  256. </script>
  257. </div>
  258. {% endblock content_main %}
  259. {% block content_footer %}
  260. {% endblock content_footer %}