customize.html 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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/css" method="post" class="form-horizontal" id="cutomcssSettingForm" role="form">
  130. <fieldset>
  131. <legend>カスタムCSS</legend>
  132. <p class="help-block">
  133. システム全体に適用されるCSSを記述できます。<br>
  134. 変更の反映はページの更新が必要です。
  135. </p>
  136. <div class="form-group">
  137. <div class="col-xs-12">
  138. <textarea id="taCustomCss" class="form-control" type="textarea" name="settingForm[customize:css]" rows="20">{{ settingForm['customize:css'] }}</textarea>
  139. </div>
  140. <div class="col-xs-12">
  141. <p class="help-block text-right">
  142. <i class="fa fa-fw fa-keyboard-o" aria-hidden="true"></i>
  143. Ctrl+Space でコード補完
  144. </p>
  145. </div>
  146. </div>
  147. <div class="form-group">
  148. <div class="col-xs-offset-5 col-xs-6">
  149. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  150. <button type="submit" class="btn btn-primary">更新</button>
  151. </div>
  152. </div>
  153. </fieldset>
  154. </form>
  155. </div>
  156. </div>
  157. <script>
  158. $('#cutomcssSettingForm, #cutomlayoutSettingForm, #cutombehaviorSettingForm').each(function() {
  159. $(this).submit(function()
  160. {
  161. function showMessage(formId, msg, status) {
  162. $('#' + formId + ' .alert').remove();
  163. if (!status) {
  164. status = 'success';
  165. }
  166. var $message = $('<p class="alert"></p>');
  167. $message.addClass('alert-' + status);
  168. $message.html(msg.replace('\n', '<br>'));
  169. $message.insertAfter('#' + formId + ' legend');
  170. if (status == 'success') {
  171. setTimeout(function()
  172. {
  173. $message.fadeOut({
  174. complete: function() {
  175. $message.remove();
  176. }
  177. });
  178. }, 5000);
  179. }
  180. }
  181. var $form = $(this);
  182. var $id = $form.attr('id');
  183. var $button = $('button', this);
  184. $button.attr('disabled', 'disabled');
  185. var jqxhr = $.post($form.attr('action'), $form.serialize(), function(data)
  186. {
  187. if (data.status) {
  188. showMessage($id, '更新しました');
  189. } else {
  190. showMessage($id, data.message, 'danger');
  191. }
  192. })
  193. .fail(function() {
  194. showMessage($id, 'エラーが発生しました', 'danger');
  195. })
  196. .always(function() {
  197. $button.prop('disabled', false);
  198. });
  199. return false;
  200. });
  201. });
  202. </script>
  203. <!-- CodeMirror -->
  204. <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>
  205. <script>
  206. var editor = CodeMirror.fromTextArea(document.getElementById('taCustomCss'), {
  207. mode: "css",
  208. lineNumbers: true,
  209. tabSize: 2,
  210. indentUnit: 2,
  211. theme: 'eclipse',
  212. matchBrackets: true,
  213. autoCloseBrackets: true,
  214. extraKeys: {"Ctrl-Space": "autocomplete"},
  215. });
  216. editor.on('change', function(cm, change) {
  217. cm.save();
  218. });
  219. // resizable with jquery.ui
  220. $(editor.getWrapperElement()).resizable({
  221. resize: function() {
  222. editor.setSize($(this).width(), $(this).height());
  223. }
  224. });
  225. </script>
  226. </div>
  227. {% endblock content_main %}
  228. {% block content_footer %}
  229. {% endblock content_footer %}