Beispiel #1
0
      fs.readFile(templatePath, 'utf8', function(err,data) {
        if(!err) {

          if(calipso.app.set('config').watchFiles) {

            calipso.silly("Adding watcher for " + template.name);
            fs.unwatchFile(templatePath);
            fs.watchFile(templatePath, { persistent: true, interval: 200}, function(curr,prev) {

              loadTemplate(template, templateCache, themePath, function() {
                  calipso.silly("Template " + templatePath + " reloaded ...");
              });

            });

          }

          // Precompile the view into our cache
          templateCache[template.name].template = compileTemplate(data,templatePath,templateExtension);

          path.exists(templateFnPath, function(exists) {
            if(exists) {
              templateCache[template.name].fn = require(templateFnPath);
            }
            next();
          });
        } else {
          next(err);
        }
      });
Beispiel #2
0
    AppConfig.findOne({}, function(err, c) {

      calipso.app.set('config').install = false;
      c.install = false;
      c.save(function(err) {
        if (err) {
          res.statusCode = 500;
          res.errorMessage = err.message;
          req.flash('error', req.t('Calipso has become stuck in install mode. This is a catastrophic failure, please report it on github.'));
        } else {
          req.flash('info', req.t('Calipso has been installed with default user: {user}, password: {password}.  It is a good idea to login and change this via the user profile page.',
                                  {user:'******',password:'******'}));
          if (res.statusCode != 302) {
            res.redirect("/");
          }
        }

        next();
        return;

      });
    });
Beispiel #3
0
/**
 * Installation routine, this is triggered by the install flag being set
 * in the configuration, which is detected in the core routing function
 * in calipso.js and redirected here.
 */
function install(req, res, template, block, next) {

  // If not in install mode, do not install
  if (!calipso.app.set('config').install) {
    res.redirect("/");
    next();
    return;
  }

  // Run the module install scripts
  calipso.lib.step(

  function installModules() {
    var group = this.group();
    for (var module in calipso.modules) {
      // Check to see if the module is currently enabled, if so install it
      if (calipso.modules[module].enabled && typeof calipso.modules[module].fn.install === 'function') {
        calipso.modules[module].fn.install(group());
      } else {
        // Just call the group function to enable step to continue
        group()();
      }
    }
  }, function done(err) {

    // If we encounter any issues it must be catastrophic.
    if (err) {
      res.statusCode = 500;
      res.errorMessage = err.message;
      req.flash('error', req.t('Calipso has become stuck in install mode. This is a catastrophic failure, please report it on github.'));
      next()
      return;
    }

    // Retrieve the configuration from the database
    var AppConfig = calipso.lib.mongoose.model('AppConfig');
    AppConfig.findOne({}, function(err, c) {

      calipso.app.set('config').install = false;
      c.install = false;
      c.save(function(err) {
        if (err) {
          res.statusCode = 500;
          res.errorMessage = err.message;
          req.flash('error', req.t('Calipso has become stuck in install mode. This is a catastrophic failure, please report it on github.'));
        } else {
          req.flash('info', req.t('Calipso has been installed with default user: {user}, password: {password}.  It is a good idea to login and change this via the user profile page.',
                                  {user:'******',password:'******'}));
          if (res.statusCode != 302) {
            res.redirect("/");
          }
        }

        next();
        return;

      });
    });

  })

}