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

Ensure to get app title from Config class method

Yuki Takei 8 лет назад
Родитель
Сommit
524fb127a9

+ 7 - 1
lib/models/config.js

@@ -253,6 +253,12 @@ module.exports = function(crowi) {
       });
   };
 
+  configSchema.statics.appTitle = function(config)
+  {
+    const key = 'app:title';
+    return getValueForCrowiNS(config, key) || 'GROWI';
+  };
+
   configSchema.statics.isEnabledPassport = function(config)
   {
     // always true if growi installed cleanly
@@ -477,7 +483,7 @@ module.exports = function(crowi) {
 
     const local_config = {
       crowi: {
-        title: config.crowi['app:title'],
+        title: Config.appTitle(crowi),
         url: config.crowi['app:url'] || '',
       },
       upload: {

+ 3 - 2
lib/models/user.js

@@ -565,6 +565,7 @@ module.exports = function(crowi) {
   userSchema.statics.createUsersByInvitation = function(emailList, toSendEmail, callback) {
     var User = this
       , createdUserList = []
+      , Config = crowi.model('Config')
       , config = crowi.getConfig()
       , mailer = crowi.getMailer()
       ;
@@ -641,13 +642,13 @@ module.exports = function(crowi) {
 
               mailer.send({
                   to: user.email,
-                  subject: 'Invitation to ' + config.crowi['app:title'],
+                  subject: 'Invitation to ' + Config.appTitle(config),
                   template: 'admin/userInvitation.txt',
                   vars: {
                     email: user.email,
                     password: user.password,
                     url: config.crowi['app:url'],
-                    appTitle: config.crowi['app:title'],
+                    appTitle: Config.appTitle(config),
                   }
                 },
                 function (err, s) {

+ 3 - 2
lib/routes/login.js

@@ -193,6 +193,7 @@ module.exports = function(crowi, app) {
           } else {
 
             // 作成後、承認が必要なモードなら、管理者に通知する
+            const appTitle = Config.appTitle(config);
             if (config.crowi['security:registrationMode'] === Config.SECURITY_REGISTRATION_MODE_RESTRICTED) {
               // TODO send mail
               User.findAdmins(function(err, admins) {
@@ -201,13 +202,13 @@ module.exports = function(crowi, app) {
                   function(adminUser, next) {
                     mailer.send({
                         to: adminUser.email,
-                        subject: '[' + config.crowi['app:title'] + ':admin] A New User Created and Waiting for Activation',
+                        subject: '[' + appTitle + ':admin] A New User Created and Waiting for Activation',
                         template: 'admin/userWaitingActivation.txt',
                         vars: {
                           createdUser: userData,
                           adminUser: adminUser,
                           url: config.crowi['app:url'],
-                          appTitle: config.crowi['app:title'],
+                          appTitle: appTitle,
                         }
                       },
                       function (err, s) {

+ 2 - 1
lib/util/mailer.js

@@ -8,6 +8,7 @@ module.exports = function(crowi) {
   var debug = require('debug')('crowi:lib:mailer')
     , nodemailer = require('nodemailer')
     , swig = require('swig-templates')
+    , Config = crowi.model('Config')
     , config = crowi.getConfig()
     , mailConfig = {}
     , mailer = {}
@@ -81,7 +82,7 @@ module.exports = function(crowi) {
     }
 
     mailConfig.from = config.crowi['mail:from'];
-    mailConfig.subject = (config.crowi['app:title'] || 'GROWI')  + 'からのメール';
+    mailConfig.subject = Config.appTitle(config)  + 'からのメール';
 
     debug('mailer initialized');
   }

+ 1 - 1
lib/util/slack.js

@@ -206,7 +206,7 @@ module.exports = function(crowi) {
 
     var message = {
       channel: '#' + channel,
-      username: config.crowi['app:title'] || 'GROWI',
+      username: Config.appTitle(config),
       text: this.getSlackMessageText(page.path, user, updateType),
       attachments: [attachment],
     };

+ 9 - 1
lib/util/swigFunctions.js

@@ -37,6 +37,14 @@ module.exports = function(crowi, app, req, locals) {
     return fontSize;
   }
 
+  /**
+   * return app title
+   */
+  locals.appTitle = function() {
+    var config = crowi.getConfig()
+    return Config.appTitle(config);
+  }
+
   /**
    * return true if enabled
    */
@@ -123,7 +131,7 @@ module.exports = function(crowi, app, req, locals) {
   locals.customTitle = function() {
     var config = crowi.getConfig();
     var title = Config.customTitle(config);
-    var app_title = config.crowi['app:title'] ? config.crowi['app:title'] : 'GROWI';
+    var app_title = Config.appTitle(config);
     var custom_title = title.replace('{{sitename}}', app_title);
     return custom_title;
   }

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

@@ -4,13 +4,13 @@
 <head>
   <meta charset="utf-8">
   <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
-  <title>{% block html_title %}{{ path|path2name }} · {{ path }}{% endblock %} {{ config.crowi['app:title'] | default('GROWI') }}</title>
+  <title>{% block html_title %}{{ path|path2name }} · {{ path }}{% endblock %} {{ appTitle() }}</title>
   <meta name="description" content="">
   <meta name="author" content="">
 
   <meta name="viewport" content="width=device-width,initial-scale=1">
 
-  <meta name="apple-mobile-web-app-title" content="{{ config.crowi['app:title'] | default('GROWI') }}">
+  <meta name="apple-mobile-web-app-title" content="{{ appTitle() }}">
 
   {% include '../widget/favicon.html' %}
 
@@ -134,7 +134,7 @@ gh/highlightjs/cdn-release@9.12.0/build/languages/yaml.min.js
             <div class="logo-mark">{% include '../widget/logo.html' %}</div>
           </b>
           <span class="hidden-xs" style="color: black">
-            {% set appTitle = config.crowi['app:title'] | default('GROWI') %}
+            {% set appTitle = appTitle() %}
             {% set appTitleFontSize = getAppTitleFontSize(appTitle) %}
             <span class="logo-text">
               <svg xmlns="http://www.w3.org/2000/svg">

+ 1 - 3
lib/views/login.html

@@ -27,9 +27,7 @@
   <div class="row">
     <div class="login-header col-sm-offset-4 col-sm-4">
       <div class="logo">{% include 'widget/logo.html' %}</div>
-      <h1>
-        {{ config.crowi['app:title'] || 'GROWI' }}
-      </h1>
+      <h1>{{ appTitle() }}</h1>
 
       <div class="login-form-errors">
         {% if isLdapSetupFailed() %}

+ 1 - 1
lib/views/widget/page_side_content.html

@@ -2,7 +2,7 @@
 <ul class="fitted-list">
   <li class="input-group">
     <span class="input-group-addon">{{ t('Share Link') }}</span>
-    <input readonly class="copy-link form-control" type="text" value="{{ config.crowi['app:title'] | default('GROWI') }} {{ path }}  {{ baseUrl }}/{{ page._id.toString() }}">
+    <input readonly class="copy-link form-control" type="text" value="{{ appTitle() }} {{ path }}  {{ baseUrl }}/{{ page._id.toString() }}">
   </li>
   <li class="input-group">
     <span class="input-group-addon">Markdown</span>