Sotaro KARASAWA 11 лет назад
Родитель
Сommit
68a854fbba
6 измененных файлов с 76 добавлено и 3 удалено
  1. 2 1
      app.js
  2. 42 0
      lib/mailer.js
  3. 17 1
      lib/middlewares.js
  4. 2 1
      package.json
  5. 8 0
      resource/css/_form.scss
  6. 5 0
      views/layout/2column.html

+ 2 - 1
app.js

@@ -16,7 +16,6 @@ var express  = require('express')
   , middleware = require('./lib/middlewares')
   , time     = require('time')
   , async    = require('async')
-  , nodemailer = require("nodemailer")
   , models
   , config
   , server
@@ -98,6 +97,8 @@ async.series([
         },
       });
 
+      app.set('mailer', require('./lib/mailer')(app));
+
       next();
     });
 

+ 42 - 0
lib/mailer.js

@@ -0,0 +1,42 @@
+/**
+ * mailer
+ */
+
+module.exports = function(app) {
+  'use strict';
+
+  var debug = require('debug')('crowi:lib:mailer')
+    , nodemailer = require("nodemailer")
+    , config = app.set('config')
+    , mailConfig = {}
+    , mailer = {}
+    ;
+
+  function initialize() {
+    // SMTP 設定がある場合はそれを優先
+    //if config.crowi
+
+    // AWS 設定がある場合はSESを設定
+    var ses = require('nodemailer-ses-transport');
+    var transporter = nodemailer.createTransport(ses({
+        accessKeyId: 'AWSACCESSKEY',
+        secretAccessKey: 'AWS/Secret/key'
+    }));
+  }
+
+  function setupMailConfig (overrideConfig) {
+    var c = overrideConfig
+      , mc = {}
+      ;
+    mc = mailConfig;
+
+    mc.from = c.from || mailConfig.from;
+    mc.subject = c.subject || mailConfig.subject;
+
+    return mc;
+  }
+
+
+  initialize();
+  return mailer;
+};

+ 17 - 1
lib/middlewares.js

@@ -114,10 +114,26 @@ exports.applicationInstalled = function() {
   return function(req, res, next) {
     var config = req.config;
 
-    if (Object.keys(config.crowi).length == 0) {
+    if (Object.keys(config.crowi).length === 0) {
       return res.redirect('/installer');
     }
 
     return next();
   };
 };
+
+exports.awsEnabled = function() {
+  return function (req, res, next) {
+    var config = req.config;
+    if (config.crowi['aws:region'] != ''
+        && config.crowi['aws:bucket'] != ''
+        && config.crowi['aws:accessKeyId'] != ''
+        && config.crowi['aws:secretAccessKey'] != ''
+       ) {
+      req.flash('globalError', 'AWS settings required to use this function. Please ask the administrator.');
+      return res.redirect('/');
+    }
+
+    return next();
+  };
+};

+ 2 - 1
package.json

@@ -45,7 +45,8 @@
     "grunt-cli": "~0.1.13",
     "bower": "~1.3.9",
     "cli": "~0.6.4",
-    "nodemailer": "~1.2.2"
+    "nodemailer": "~1.2.2",
+    "nodemailer-ses-transport": "~1.1.0"
   },
   "devDependencies": {},
   "license": [

+ 8 - 0
resource/css/_form.scss

@@ -12,6 +12,14 @@ textarea.form-body-height {
   height: 300px;
 }
 
+input::-webkit-input-placeholder {
+  color: #ccc;
+}
+input:-moz-placeholder {
+  color: #ccc;
+}
+
+
 .form-maximized {
   position: absolute;
   background: #fff;

+ 5 - 0
views/layout/2column.html

@@ -29,6 +29,11 @@
         </a>
       </li>
       {% endif %}
+      <li id="">
+        <a href="#" id="createPage">
+          <i class="fa fa-plus"> 新規</i>
+        </a>
+      </li>
       {% if user %}
       {#
       <li id="" class="notif">