Browse Source

refs #276: Enable to select highlight.js style
rename highlight variable to highlightJsStyle

大谷 東彦 8 years ago
parent
commit
896d0efbfa

+ 1 - 1
lib/form/admin/customhighlight.js → lib/form/admin/customhighlightJsStyle.js

@@ -5,5 +5,5 @@ var form = require('express-form')
   ;
 
 module.exports = form(
-  field('settingForm[customize:highlight]')
+  field('settingForm[customize:highlightJsStyle]')
 );

+ 1 - 1
lib/form/index.js

@@ -26,7 +26,7 @@ module.exports = {
     custombehavior: require('./admin/custombehavior'),
     customlayout: require('./admin/customlayout'),
     customfeatures: require('./admin/customfeatures'),
-    customhighlight: require('./admin/customhighlight'),
+    customhighlightJsStyle: require('./admin/customhighlightJsStyle'),
     userInvite: require('./admin/userInvite'),
     slackIwhSetting: require('./admin/slackIwhSetting'),
     slackSetting: require('./admin/slackSetting'),

+ 3 - 3
lib/models/config.js

@@ -85,7 +85,7 @@ module.exports = function(crowi) {
       'customize:css' : '',
       'customize:script' : '',
       'customize:header' : '',
-      'customize:highlight' : 'github',
+      'customize:highlightJsStyle' : 'github',
       'customize:behavior' : 'crowi',
       'customize:layout' : 'crowi',
       'customize:isEnabledTimeline' : true,
@@ -371,9 +371,9 @@ module.exports = function(crowi) {
     return getValueForCrowiNS(config, key);
   }
 
-  configSchema.statics.highlightType = function(config)
+  configSchema.statics.highlightJsStyle = function(config)
   {
-    const key = 'customize:highlight';
+    const key = 'customize:highlightJsStyle';
     return getValueForCrowiNS(config, key);
   }
 

+ 1 - 1
lib/routes/index.js

@@ -77,7 +77,7 @@ module.exports = function(crowi, app) {
   app.post('/_api/admin/customize/behavior' , loginRequired(crowi, app) , middleware.adminRequired() , csrf, form.admin.custombehavior, admin.api.customizeSetting);
   app.post('/_api/admin/customize/layout'   , loginRequired(crowi, app) , middleware.adminRequired() , csrf, form.admin.customlayout, admin.api.customizeSetting);
   app.post('/_api/admin/customize/features' , loginRequired(crowi, app) , middleware.adminRequired() , csrf, form.admin.customfeatures, admin.api.customizeSetting);
-  app.post('/_api/admin/customize/highlight' , loginRequired(crowi, app) , middleware.adminRequired() , csrf, form.admin.customhighlight, admin.api.customizeSetting);
+  app.post('/_api/admin/customize/highlightJsStyle' , loginRequired(crowi, app) , middleware.adminRequired() , csrf, form.admin.customhighlightJsStyle, admin.api.customizeSetting);
 
   // search admin
   app.get('/admin/search'              , loginRequired(crowi, app) , middleware.adminRequired() , admin.search.index);

+ 2 - 2
lib/util/swigFunctions.js

@@ -107,9 +107,9 @@ module.exports = function(crowi, app, req, locals) {
     return Config.layoutType(config);
   }
 
-  locals.highlightType = function() {
+  locals.highlightJsStyle = function() {
     var config = crowi.getConfig()
-    return Config.highlightType(config);
+    return Config.highlightJsStyle(config);
   }
 
   locals.isEnabledTimeline = function() {

+ 5 - 5
lib/views/admin/customize.html

@@ -143,12 +143,12 @@
       </fieldset>
       </form>
 
-      <form action="/_api/admin/customize/highlight" method="post" class="form-horizontal" id="cutomhighlightSettingForm" role="form">
+      <form action="/_api/admin/customize/highlightJsStyle" method="post" class="form-horizontal" id="cutomhighlightJsStyleSettingForm" role="form">
         <fieldset>
           <legend>ハイライト設定</legend>
           <div class="form-group">
             <div class="col-xs-3">
-              <select class="form-control" name="settingForm[customize:highlight]" onChange="selectHighlight()">
+              <select class="form-control" name="settingForm[customize:highlightJsStyle]" onChange="selectHighlight()">
                 {% for key in Object.keys(highlightJsCssSelectorOptions) %}
                   <option value={{key}}>{{highlightJsCssSelectorOptions[key]}}</option>
                 {% endfor %}
@@ -373,7 +373,7 @@ window.addEventListener('load', (event) => {
   </div>
 
   <script>
-    $('#cutomcssSettingForm, #cutomscriptSettingForm, #cutomlayoutSettingForm, #cutombehaviorSettingForm, #customfeaturesSettingForm, #cutomheaderSettingForm, #cutomhighlightSettingForm').each(function() {
+    $('#cutomcssSettingForm, #cutomscriptSettingForm, #cutomlayoutSettingForm, #cutombehaviorSettingForm, #customfeaturesSettingForm, #cutomheaderSettingForm, #cutomhighlightJsStyleSettingForm').each(function() {
       $(this).submit(function()
       {
         function showMessage(formId, msg, status) {
@@ -424,11 +424,11 @@ window.addEventListener('load', (event) => {
     hljs.initHighlighting()
 
     // 保存した highlight の値を selector に復元する
-    $('#cutomhighlightSettingForm select').val('{{ highlightType() }}');
+    $('#cutomhighlightJsStyleSettingForm select').val('{{ highlightJsStyle() }}');
 
     function selectHighlight() {
       // selecter で選択された値
-      var val = $('#cutomhighlightSettingForm select').val()
+      var val = $('#cutomhighlightJsStyleSettingForm select').val()
       // 追加する style の DOM
       var style = `<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@9.12.0/styles/${val}.css">`;
       // body の最後に追加 layout.html は body に読み込まれてるため、body の一番下に追加しないと上書きされない

+ 1 - 1
lib/views/layout/2column.html

@@ -2,7 +2,7 @@
 
 {% block highlight_js_css %}
   <!-- highlight.js -->
-  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@9.12.0/styles/{{ highlightType() }}.css">
+  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@9.12.0/styles/{{ highlightJsStyle() }}.css">
 {% endblock %}
 
 {% block layout_sidebar %}

+ 1 - 1
lib/views/page_presentation.html

@@ -49,7 +49,7 @@ gh/highlightjs/cdn-release@9.12.0/build/languages/yaml.min.js
     <!-- Google Fonts -->
     <link href='https://fonts.googleapis.com/css?family=Lato:400,700' rel='stylesheet' type='text/css'>
     <!-- highlight.js -->
-    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@9.12.0/styles/{{ highlightType() }}.css">
+    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@9.12.0/styles/{{ highlightJsStyle() }}.css">
 
     <style>
       {{ customCss() }}