فهرست منبع

Do not use app:uploadable key but Config.isUploadable() instead.

Sotaro KARASAWA 10 سال پیش
والد
کامیت
b87c25b1bf
3فایلهای تغییر یافته به همراه24 افزوده شده و 5 حذف شده
  1. 17 4
      lib/models/config.js
  2. 6 0
      lib/util/swigFunctions.js
  3. 1 1
      lib/views/_form.html

+ 17 - 4
lib/models/config.js

@@ -19,9 +19,9 @@ module.exports = function(crowi) {
   function getArrayForInstalling()
   {
     return {
+      //'app:installed'     : "0.0.0",
       'app:title'         : 'Crowi',
       'app:confidential'  : '',
-      'app:uploadable'  : false,
 
       'security:registrationMode'      : 'Open',
       'security:registrationWhiteList' : [],
@@ -159,9 +159,6 @@ module.exports = function(crowi) {
           config[el.ns][el.key] = JSON.parse(el.value);
         });
 
-        // temporary ...
-        config.crowi['app:uploadable'] = Config.isUploadable(config);
-
         debug('Config loaded', config);
         return callback(null, config);
       });
@@ -179,6 +176,22 @@ module.exports = function(crowi) {
     return true;
   };
 
+  /*
+  configSchema.statics.isInstalled = function(config)
+  {
+    if (!config.crowi) {
+      return false;
+    }
+
+    if (config.crowi['app:installed']
+       && config.crowi['app:installed'] !== '0.0.0') {
+      return true;
+    }
+
+    return false;
+  }
+  */
+
   Config = mongoose.model('Config', configSchema);
   Config.SECURITY_REGISTRATION_MODE_OPEN       = SECURITY_REGISTRATION_MODE_OPEN;
   Config.SECURITY_REGISTRATION_MODE_RESTRICTED = SECURITY_REGISTRATION_MODE_RESTRICTED;

+ 6 - 0
lib/util/swigFunctions.js

@@ -1,6 +1,7 @@
 module.exports = function(crowi, app, locals) {
   var debug = require('debug')('crowi:lib:swigFunctions')
     , Page = crowi.model('Page')
+    , Config = crowi.model('Config')
     , User = crowi.model('User')
   ;
 
@@ -14,6 +15,11 @@ module.exports = function(crowi, app, locals) {
     return config.crowi['google:clientId'] && config.crowi['google:clientSecret'];
   };
 
+  locals.isUploadable = function() {
+    var config = crowi.getConfig()
+    return Config.isUploadable(config);
+  };
+
   locals.user_page_root = function(user) {
     if (!user) {
       return '';

+ 1 - 1
lib/views/_form.html

@@ -9,7 +9,7 @@
 </div>
 {% endif %}
 <div id="form-box" class="row">
-  <form action="{{ path }}/edit" id="page-form" method="post" class="col-md-6 {% if config.crowi['app:uploadable'] %}uploadable{% endif %}">
+  <form action="{{ path }}/edit" id="page-form" method="post" class="col-md-6 {% if isUploadable() %}uploadable{% endif %}">
     <textarea name="pageForm[body]" class="form-control form-body-height" id="form-body">{% if pageForm.body %}{{ pageForm.body }}{% elseif not revision.body %}# {{ path|path2name }}{% else %}{{ revision.body }}{% endif %}</textarea>
 
     <input type="hidden" name="pageForm[format]" value="markdown" id="form-format">