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

Merge remote-tracking branch 'origin/feature-rc3.0.0/284-add-custom-title-tag-contents'

# Conflicts:
#	lib/util/swigFunctions.js
#	lib/views/layout/layout.html
Yuki Takei 8 лет назад
Родитель
Сommit
1431669fd3

+ 2 - 2
lib/locales/en-US/translation.json

@@ -226,8 +226,8 @@
   },
   },
 
 
   "app_setting": {
   "app_setting": {
-    "Wiki name": "Wiki name",
-    "wiki_change": "You can change Wiki name which is used for header and HTML title.",
+    "Site Name": "Site name",
+    "sitename_change": "You can change Site Name which is used for header and HTML title.",
     "header_content": "The contents entered here will be shown in the header etc.",
     "header_content": "The contents entered here will be shown in the header etc.",
     "Confidential name": "Confidential name",
     "Confidential name": "Confidential name",
     "ex): internal use only":"ex): internal use only",
     "ex): internal use only":"ex): internal use only",

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

@@ -243,8 +243,8 @@
   },
   },
 
 
   "app_setting": {
   "app_setting": {
-    "Wiki name": "Wikiの名前",
-    "wiki_change": "ヘッダーやHTMLタイトルに使用されるWikiの名前を変更できます。",
+    "Site Name": "サイト名",
+    "sitename_change": "ヘッダーや HTML タイトルに使用されるサイト名を変更できます。",
     "header_content": "ここに入力した内容は、ヘッダー等に表示されます。",
     "header_content": "ここに入力した内容は、ヘッダー等に表示されます。",
     "Confidential name": "コンフィデンシャル表示",
     "Confidential name": "コンフィデンシャル表示",
     "ex): internal use only": "例: 社外秘",
     "ex): internal use only": "例: 社外秘",

+ 10 - 2
lib/models/config.js

@@ -372,10 +372,18 @@ module.exports = function(crowi) {
     return getValueForCrowiNS(config, key);
     return getValueForCrowiNS(config, key);
   }
   }
 
 
-  configSchema.statics.customTitle = function(config)
+  configSchema.statics.customTitle = function(config, page)
   {
   {
     const key = 'customize:title';
     const key = 'customize:title';
-    return getValueForCrowiNS(config, key);
+    let customTitle = getValueForCrowiNS(config, key);
+
+    if (customTitle == null || customTitle.trim().length == 0) {
+      customTitle = '{{page}} - {{sitename}}';
+    }
+
+    return customTitle
+      .replace('{{sitename}}', this.appTitle(config))
+      .replace('{{page}}', page);
   }
   }
 
 
   configSchema.statics.behaviorType = function(config)
   configSchema.statics.behaviorType = function(config)

+ 3 - 6
lib/util/swigFunctions.js

@@ -128,12 +128,9 @@ module.exports = function(crowi, app, req, locals) {
     return Config.theme(config);
     return Config.theme(config);
   }
   }
 
 
-  locals.customTitle = function() {
-    var config = crowi.getConfig();
-    var title = Config.customTitle(config);
-    var app_title = Config.appTitle(config);
-    var custom_title = title.replace('{{sitename}}', app_title);
-    return custom_title;
+  locals.customTitle = function(page) {
+    const config = crowi.getConfig();
+    return Config.customTitle(config, page);
   }
   }
 
 
   locals.behaviorType = function() {
   locals.behaviorType = function() {

+ 2 - 2
lib/views/admin/app.html

@@ -36,10 +36,10 @@
       <fieldset>
       <fieldset>
         <legend>{{ t('App settings') }}</legend>
         <legend>{{ t('App settings') }}</legend>
         <div class="form-group">
         <div class="form-group">
-          <label for="settingForm[app:title]" class="col-xs-3 control-label">{{ t('app_setting.Wiki name') }}</label>
+          <label for="settingForm[app:title]" class="col-xs-3 control-label">{{ t('app_setting.Site Name') }}</label>
           <div class="col-xs-6">
           <div class="col-xs-6">
             <input class="form-control" type="text" name="settingForm[app:title]" value="{{ settingForm['app:title'] | default('') }}">
             <input class="form-control" type="text" name="settingForm[app:title]" value="{{ settingForm['app:title'] | default('') }}">
-            <p class="help-block">{{ t("app_setting.wiki_change") }}</p>
+            <p class="help-block">{{ t("app_setting.sitename_change") }}</p>
           </div>
           </div>
         </div>
         </div>
 
 

+ 32 - 43
lib/views/admin/customize.html

@@ -1,6 +1,6 @@
 {% extends '../layout/admin.html' %}
 {% extends '../layout/admin.html' %}
 
 
-{% block html_title %}{{ t('Customize') }} {% endblock %}
+{% block html_title %}{{ customTitle(t('Customize')) }} {% endblock %}
 
 
 {% block style_css_block %}
 {% block style_css_block %}
   <link rel="stylesheet" href="{{ webpack_asset('style').css }}">
   <link rel="stylesheet" href="{{ webpack_asset('style').css }}">
@@ -315,6 +315,37 @@ export  $initHighlight;</code></pre>
         </fieldset>
         </fieldset>
       </form>
       </form>
 
 
+      <form action="/_api/admin/customize/title" method="post" class="form-horizontal" id="customtitleSettingForm" role="form">
+        <fieldset>
+          <legend>カスタム Title</legend>
+
+          <p class="well">
+            <code>&lt;title&gt;</code>タグのコンテンツをカスタマイズできます。<br>
+            <code>&#123;&#123;sitename&#125;&#125;</code>がサイト名、<code>&#123;&#123;page&#125;&#125;</code>がページ名またはページパスに置換されます
+          </p>
+
+          <p class="help-block">
+            Default Value: <code>&#123;&#123;page&#125;&#125; - &#123;&#123;sitename&#125;&#125;</code>
+            <br>
+            Default Output: <pre><code class="xml">&lt;title&gt;/Sandbox - {{ appTitle }}&lt;&#047;title&gt;</code></pre>
+          </p>
+
+          <div class="form-group">
+            <div class="col-xs-12">
+              <input class="form-control" name="settingForm[customize:title]" value="{{ settingForm['customize:title'] }}"></input>
+            </div>
+          </div>
+
+          <div class="form-group">
+            <div class="col-xs-offset-5 col-xs-6">
+              <input type="hidden" name="_csrf" value="{{ csrf() }}">
+              <button type="submit" class="btn btn-primary">更新</button>
+            </div>
+          </div>
+
+        </fieldset>
+      </form>
+
       <form action="/_api/admin/customize/header" method="post" class="form-horizontal" id="cutomheaderSettingForm" role="form">
       <form action="/_api/admin/customize/header" method="post" class="form-horizontal" id="cutomheaderSettingForm" role="form">
       <fieldset>
       <fieldset>
         <legend>カスタムヘッダーHTML</legend>
         <legend>カスタムヘッダーHTML</legend>
@@ -352,48 +383,6 @@ export  $initHighlight;</code></pre>
       </fieldset>
       </fieldset>
       </form>
       </form>
 
 
-      <form action="/_api/admin/customize/title" method="post" class="form-horizontal" id="customtitleSettingForm" role="form">
-        <fieldset>
-          <legend>カスタムヘッダーTitle</legend>
-
-          <p class="well">
-            ヘッダーの&lt;title&gt;タグのコンテンツをカスタムできる。サイト名を入れたい位置に、&#123;&#123;sitename&#125;&#125;
-            パスを入れたい位置に&#123;&#123;path&#125;&#125;を置くことでそれぞれの値に自動置換されます。それ以外の部分は自由に記述して下さい。<br>
-          </p>
-
-          <p class="help-block">
-            Examples:
-            <pre><code>&#123;&#123;sitename&#125;&#125; hoge - &#123;&#123;path&#125;&#125;</code></pre>
-          </p>
-
-          <p class="help-block">
-            Output:
-            <pre><code>&lt;title&gt;GROWI hoge - /xxx/yyy/zzz/Sandbox&lt;&#047;title&gt;</code></pre>
-          </p>
-
-          <div class="form-group">
-            <div class="col-xs-12">
-              <div id="custom-title-editor"></div>
-              <input type="hidden" id="inputCustomTitle" name="settingForm[customize:title]" value="{{ settingForm['customize:title'] }}">
-            </div>
-            <div class="col-xs-12">
-              <p class="help-block text-right">
-                <i class="fa fa-fw fa-keyboard-o" aria-hidden="true"></i>
-                Ctrl+Space でコード補完
-              </p>
-            </div>
-          </div>
-
-          <div class="form-group">
-            <div class="col-xs-offset-5 col-xs-6">
-              <input type="hidden" name="_csrf" value="{{ csrf() }}">
-              <button type="submit" class="btn btn-primary">更新</button>
-            </div>
-          </div>
-
-        </fieldset>
-        </form>
-
       <form action="/_api/admin/customize/css" method="post" class="form-horizontal" id="cutomcssSettingForm" role="form">
       <form action="/_api/admin/customize/css" method="post" class="form-horizontal" id="cutomcssSettingForm" role="form">
       <fieldset>
       <fieldset>
         <legend>{{ t('customize_page.Custom CSS') }}</legend>
         <legend>{{ t('customize_page.Custom CSS') }}</legend>

+ 1 - 0
lib/views/layout-crowi/base/layout.html

@@ -1,5 +1,6 @@
 {% extends '../../layout/layout.html' %}
 {% extends '../../layout/layout.html' %}
 
 
+{% block html_title %}{{ customTitle(path) }}{% endblock %}
 
 
 {% block layout_main %}
 {% block layout_main %}
 <div class="container-fluid">
 <div class="container-fluid">

+ 0 - 1
lib/views/layout-growi/base/layout.html

@@ -1,6 +1,5 @@
 {% extends '../../layout/layout.html' %}
 {% extends '../../layout/layout.html' %}
 
 
-
 {% block layout_main %}
 {% block layout_main %}
 <div class="container-fluid">
 <div class="container-fluid">
 
 

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

@@ -4,7 +4,7 @@
 <head>
 <head>
   <meta charset="utf-8">
   <meta charset="utf-8">
   <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
   <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
-  <title>{% block html_title %}{{ path|path2name }} · {{ path }}{% endblock %} {{ appTitle() }}</title>
+  <title>{% block html_title %}{{ customTitle(path) }}{% endblock %}</title>
   <meta name="description" content="">
   <meta name="description" content="">
   <meta name="author" content="">
   <meta name="author" content="">
 
 

+ 1 - 1
lib/views/login/error.html

@@ -2,7 +2,7 @@
 
 
 {% block html_base_css %}error nologin{% endblock %}
 {% block html_base_css %}error nologin{% endblock %}
 
 
-{% block html_title %}セットアップ {% endblock %}
+{% block html_title %}{{ customTitle('セットアップ') }}{% endblock %}
 
 
 
 
 
 

+ 0 - 11
resource/js/app.js

@@ -26,7 +26,6 @@ import SearchTypeahead  from './components/SearchTypeahead';
 import CustomCssEditor  from './components/Admin/CustomCssEditor';
 import CustomCssEditor  from './components/Admin/CustomCssEditor';
 import CustomScriptEditor from './components/Admin/CustomScriptEditor';
 import CustomScriptEditor from './components/Admin/CustomScriptEditor';
 import CustomHeaderEditor from './components/Admin/CustomHeaderEditor';
 import CustomHeaderEditor from './components/Admin/CustomHeaderEditor';
-import CustomTitleEditor from './components/Admin/CustomTitleEditor';
 
 
 import * as entities from 'entities';
 import * as entities from 'entities';
 
 
@@ -213,16 +212,6 @@ if (customHeaderEditorElem != null) {
     customHeaderEditorElem
     customHeaderEditorElem
   )
   )
 }
 }
-const customTitleEditorElem = document.getElementById('custom-title-editor');
-if (customTitleEditorElem != null) {
-  // get input[type=hidden] element
-  const customTitleInputElem = document.getElementById('inputCustomTitle');
-
-  ReactDOM.render(
-    <CustomTitleEditor inputElem={customTitleInputElem} />,
-    customTitleEditorElem
-  )
-}
 
 
 // うわーもうー (commented by Crowi team -- 2018.03.23 Yuki Takei)
 // うわーもうー (commented by Crowi team -- 2018.03.23 Yuki Takei)
 $('a[data-toggle="tab"][href="#revision-history"]').on('show.bs.tab', function() {
 $('a[data-toggle="tab"][href="#revision-history"]').on('show.bs.tab', function() {

+ 0 - 60
resource/js/components/Admin/CustomTitleEditor.js

@@ -1,60 +0,0 @@
-import React from 'react';
-import PropTypes from 'prop-types';
-
-import { UnControlled as CodeMirror } from 'react-codemirror2';
-require('codemirror/lib/codemirror.css');
-require('codemirror/addon/display/autorefresh');
-require('codemirror/addon/hint/show-hint');
-require('codemirror/addon/edit/matchbrackets');
-require('codemirror/addon/edit/closebrackets');
-require('codemirror/mode/htmlmixed/htmlmixed');
-require('codemirror/theme/eclipse.css');
-
-require('jquery-ui/ui/widgets/resizable');
-
-export default class CustomTitleEditor extends React.Component {
-
-  constructor(props) {
-    super(props);
-  }
-
-  render() {
-    // get initial value from inputElem
-
-    const value = this.props.inputElem.value;
-
-    return (
-      <CodeMirror
-        value={value}
-        autoFocus={true}
-        options={{
-          mode: 'htmlmixed',
-          lineNumbers: true,
-          tabSize: 2,
-          indentUnit: 2,
-          theme: 'eclipse',
-          autoRefresh: true,
-          matchBrackets: true,
-          autoCloseBrackets: true,
-          extraKeys: {'Ctrl-Space': 'autocomplete'},
-        }}
-        editorDidMount={(editor, next) => {
-          // resizable with jquery.ui
-          $(editor.getWrapperElement()).resizable({
-            resize: function() {
-              editor.setSize($(this).width(), $(this).height());
-            }
-          });
-        }}
-        onChange={(editor, data, value) => {
-          this.props.inputElem.value = value;
-        }}
-      />
-    );
-  }
-
-}
-
-CustomTitleEditor.propTypes = {
-  inputElem: PropTypes.object.isRequired,
-};