var async = require('async');

module.exports = function(ctrlers, locals, theme) {

  var config = ctrlers.config;
  var user = ctrlers.user;
  var board = ctrlers.board;

  var read = function(callback) {
    async.parallel({
      config: config.read,
      users: user.list,
      boards: board.ls,
      themes: theme.list
    }, callback);
  };

  return {
    // PAGE: 管理后台首页
    page: function(req, res, next) {
      read(function(err, info) {
        if (err) return next(err);
        if (info.themes && info.themes.name) {
          var themes = {}
          themes[info.themes.name] = info.themes;
          info.themes = themes;
        }
        console.log(info.themes)
        theme.render('flat/admin/index', info, function(err, html) {
          if (err) return next(err);
          res.send(html);
        });
      });
    },
    // API: 更新网站设置
    update: function(req, res, next) {
      if (!req.body.setting) return next(new Error('缺少表单'));
      var id = req.body.setting._id;
      var settings = req.body.setting;
      if (settings._id) delete settings._id;
      config.update(id, settings, function(err, site) {
        if (err) return next(err);
        locals.site = site;
        return res.json(site);
      });
    }
  }
}
@@ -238,451 +238,397 @@
 ig: 
-config.read,%0A      users: user.list,%0A      boards: board.ls,%0A      themes: theme.list%0A    %7D, callback);%0A  %7D;%0A%0A  return %7B%0A    // PAGE: %E7%AE%A1%E7%90%86%E5%90%8E%E5%8F%B0%E9%A6%96%E9%A1%B5%0A    page: function(req, res, next) %7B%0A      read(function(err, info) %7B%0A        if (err) return next(err);%0A        if (info.themes && info.themes.name) %7B%0A          var themes = %7B%7D%0A          themes%5Binfo.themes.name%5D = info.themes;%0A          info.themes = themes;%0A        %7D%0A        console.log(info.themes)
+function(cb) %7B%0A        config.read(cb);%0A      %7D,%0A      users: function(cb) %7B%0A        user.list(cb);%0A      %7D,%0A      boards: function(cb) %7B%0A        board.ls(cb);%0A      %7D,%0A      themes: function(cb) %7B%0A        theme.list(cb);%0A      %7D%0A    %7D, callback);%0A  %7D;%0A%0A  return %7B%0A    // PAGE: %E7%AE%A1%E7%90%86%E5%90%8E%E5%8F%B0%E9%A6%96%E9%A1%B5%0A    page: function(req, res, next) %7B%0A      read(function(err, info) %7B%0A        if (err) return next(err);
 %0A   

修复管理平台数据获取的 bug