Просмотр исходного кода

Merge pull request #336 from weseek/imprv/324-enable-attach-title-header-settings

Imprv/324 enable attach title header settings
Yuki Takei 8 лет назад
Родитель
Сommit
cdf9acc21e

+ 2 - 1
lib/form/admin/customfeatures.js

@@ -5,6 +5,7 @@ var form = require('express-form')
 
 module.exports = form(
   field('settingForm[customize:isEnabledTimeline]').trim().toBooleanStrict(),
-  field('settingForm[customize:isSavedStatesOfTabChanges]').trim().toBooleanStrict()
+  field('settingForm[customize:isSavedStatesOfTabChanges]').trim().toBooleanStrict(),
+  field('settingForm[customize:isEnabledAttachTitleHeader]').trim().toBooleanStrict()
 );
 

+ 4 - 1
lib/locales/en-US/translation.json

@@ -306,7 +306,10 @@
     "reflect_change": "You need to reload the page to reflect the change.",
     "ctrl_space": "Ctrl+Space to Autocomplete",
     "Custom script": "Custom script",
-    "write_java": "You can write Javascript that is applied to whole system."
+    "write_java": "You can write Javascript that is applied to whole system.",
+    "attach_title_header": "Attach title header",
+    "attach_title_header_desc": "Attach the page path to new page first line when you create new page.(ON is Crowi default)",
+    "by_invalidating_title_header": "By invalidating, you can create the page cleanly.(OFF is GROWI standard)"
   },
 
   "user_management": {

+ 4 - 2
lib/locales/ja/translation.json

@@ -326,8 +326,10 @@
     "reflect_change": "変更の反映はページの更新が必要です。",
     "ctrl_space": "Ctrl+Space でコード補完",
     "Custom script": "カスタムスクリプト",
-    "write_java": "システム全体に適用されるJavaScriptを記述できます。"
-
+    "write_java": "システム全体に適用されるJavaScriptを記述できます。",
+    "attach_title_header": "タイトルヘッダの挿入",
+    "attach_title_header_desc": "新規作成したページの1行目にページのパスをタイトルヘッダとして挿入します。(Crowi の規定値はON)",
+    "by_invalidating_title_header": "無効化することで、まっさらな状態からページを作成することができます。(GROWI の標準はOFF)"
   },
 
   "user_management": {

+ 8 - 0
lib/models/config.js

@@ -32,6 +32,7 @@ module.exports = function(crowi) {
     config['customize:behavior'] = 'growi';
     config['customize:layout'] = 'growi';
     config['customize:isSavedStatesOfTabChanges'] = false;
+    config['customize:isEnabledAttachTitleHeader'] = false;
 
     return config;
   }
@@ -91,6 +92,7 @@ module.exports = function(crowi) {
       'customize:layout' : 'crowi',
       'customize:isEnabledTimeline' : true,
       'customize:isSavedStatesOfTabChanges' : true,
+      'customize:isEnabledAttachTitleHeader' : true,
     };
   }
 
@@ -422,6 +424,12 @@ module.exports = function(crowi) {
     return getValueForCrowiNS(config, key);
   };
 
+  configSchema.statics.isEnabledAttachTitleHeader = function(config)
+  {
+    const key = 'customize:isEnabledAttachTitleHeader';
+    return getValueForCrowiNS(config, key);
+  };
+
   configSchema.statics.fileUploadEnabled = function(config)
   {
     const Config = this;

+ 5 - 0
lib/util/swigFunctions.js

@@ -171,6 +171,11 @@ module.exports = function(crowi, app, req, locals) {
     return Config.isUploadable(config);
   };
 
+  locals.isEnabledAttachTitleHeader = function() {
+    var config = crowi.getConfig()
+    return Config.isEnabledAttachTitleHeader(config);
+  };
+
   locals.parentPath = function(path) {
     if (path == '/') {
       return path;

+ 19 - 0
lib/views/admin/customize.html

@@ -244,6 +244,25 @@
           </div>
         </div>
 
+        <div class="form-group">
+          <label for="settingForm[customize:isEnabledAttachTitleHeader]" class="col-xs-3 control-label">{{ t("customize_page.attach_title_header") }}</label>
+          <div class="col-xs-9">
+            <div class="btn-group btn-toggle" data-toggle="buttons">
+              <label class="btn btn-default btn-rounded btn-outline {% if settingForm['customize:isEnabledAttachTitleHeader'] %}active{% endif %}" data-active-class="primary">
+                <input name="settingForm[customize:isEnabledAttachTitleHeader]" value="true" type="radio" {% if true===settingForm['customize:isEnabledAttachTitleHeader'] %}checked{% endif %}> ON
+              </label>
+              <label class="btn btn-default btn-rounded btn-outline {% if !settingForm['customize:isEnabledAttachTitleHeader'] %}active{% endif %}" data-active-class="default">
+                <input name="settingForm[customize:isEnabledAttachTitleHeader]" value="false" type="radio" {% if !settingForm['customize:isEnabledAttachTitleHeader'] %}checked{% endif %}> OFF
+              </label>
+            </div>
+
+            <p class="help-block">
+              {{ t("customize_page.attach_title_header_desc") }}<br>
+              {{ t("customize_page.by_invalidating_title_header") }}
+            </p>
+          </div>
+        </div>
+
         <div class="form-group">
           <div class="col-xs-offset-3 col-xs-6">
             <input type="hidden" name="_csrf" value="{{ csrf() }}">

+ 2 - 6
lib/views/widget/not_found_content.html

@@ -16,13 +16,9 @@
   {% include 'not_found_tabs.html' %}
 
   <div class="tab-content">
-    {#
-     # Commented out temporally -- 2018.04.07 Yuki Takei
-     # This will be fixed by https://github.com/weseek/growi/issues/324
-     #
-     #
+    {% if isEnabledAttachTitleHeader() %}
     <script type="text/template" id="raw-text-original"># {{ path|path2name }}</script>
-     #}
+    {% endif %}
     {# list view #}
     <div class="p-t-10 active tab-pane page-list-container" id="revision-body">
       {% if pages.length == 0 %}