Example #1
0
/**
 *Init
 */
function init(module, app, next) {

  // Any pre-route config
  calipso.lib.step(

  function defineRoutes() {

    // Add a route to every page, ideally just do it on form pages, but can't tell atm
    module.router.addRoute(/.*/, allPages, {
      end: false,
      template: 'datepicker.script',
      block: 'scripts.richforms.datepicker'
    }, this.parallel());
    module.router.addRoute(/.*/, allPages, {
      end: false,
      template: 'datepicker.style',
      block: 'styles.richforms.datepicker'
    }, this.parallel());
    module.router.addRoute(/.*/, allPages, {
      end: false,
      template: 'markitup.script',
      block: 'scripts.richforms.markitup'
    }, this.parallel());
    module.router.addRoute(/.*/, allPages, {
      end: false,
      template: 'markitup.style',
      block: 'styles.richforms.markitup'
    }, this.parallel());
    app.use(calipso.lib.express["static"](__dirname + '/static'));

    module.router.addRoute('GET /richforms/preview', showPreview, {}, this.parallel());

  }, function done() {

    // Set the old function so it can be reset later
    calipso.form.render_tag_date_default = calipso.form.render_tag_date;

    // Test over-riding a form element
    calipso.form.render_tag_date = function(field, value) {

      // Default value to current date
      var dateValue = value ? value : new Date();

      // The actual date field that is visible
      var tagOutput = '<input class="jquery-ui-datepicker"' + ' id="date-' + field.name.replace('[', '_').replace(']', '') + '"' + ' value="' + calipso.date.formatDate('MM, dd yy', dateValue) + '"' + ' />';

      tagOutput += '<input type="hidden" name="' + field.name + '[date]"' + ' id="date-' + field.name.replace('[', '_').replace(']', '') + '-value"' + ' value="' + calipso.date.formatDate('MM, dd yy', dateValue) + '"' + ' />';

      return tagOutput;

    };

    // TODO : ADD TIME PICKER
    // Any schema configuration goes here
    next();

  });


};
Example #2
0
/**
 * Installation process - asynch
 * @returns
 */
function install(next) {

  // Create the default content types
  var ContentType = calipso.db.model('ContentType');

  calipso.lib.step(
    function createDefaults() {
      var c = new ContentType({contentType:'Article',
        description:'Standard page type used for most content.',
        layout:'default',
        ispublic:true
      });
      c.save(this.parallel());
      var c = new ContentType({contentType:'Block Content',
        description:'Content that is used to construct other pages in a page template via the getContent call, not visibile in the taxonomy or tag cloud.',
        layout:'default',
        ispublic:false
      });
      c.save(this.parallel());
    },
    function allDone(err) {
      if(err) {
        next(err)
      } else {
        // Cache the content types in the calipso.data object
        storeContentTypes(null,null,function(){});
        calipso.info("Content types module installed ... ");
        next();
      }
    }
  );

}
Example #3
0
exports = module.exports = function(req,options,callback) {

  /**
   *  Get additional content for blocks in the template
   */
  calipso.lib.step(
    function getContentList() {

      // Create a query and retrieve the content, has pager support, using req.moduleParams
      // But you can override on an individual query by setting in the options (second param)
      var query;
      if(options.user.isAdmin) {
        query = new Query({'tags':req.res.params.tag});
      } else {
        query = new Query({'tags':req.res.params.tag, 'status':'published'});
      }
      options.getContentList(query,{req:req,sortBy:'published,desc',pager:false},this.parallel());

    },
    function done(err, output) {

      callback(err,{ contents:output.contents, pager:output.pager });

    }
  );

};
Example #4
0
/**
 *Init
 */
function init(module, app, next, counter) {

  if (!calipso.modules.content.initialised) {
    // Wait for the dependencies to be met
    process.nextTick(function() {
      init(module, app, next);
    });
    return;
  }

  // Any pre-route config
  calipso.lib.step(

  function defineRoutes() {
    module.router.addRoute("GET /tweets", tweetStream, {
      template: 'tweetstream',
      block: 'content'
    }, this.parallel());
    module.router.addRoute("GET /tweets/:keyword", tweetStream, {
      template: 'tweetstream',
      block: 'content'
    }, this.parallel());
  }, function done() {

    next();
  });

};
Example #5
0
function doLastModules(req, res, next) {

  // Get all the postRoute modules
  var lastModules = [];
  for (var moduleName in calipso.modules) {
    if (calipso.modules[moduleName].enabled && calipso.modules[moduleName].fn.last) {
      lastModules.push(calipso.modules[moduleName]);
    }
  }


  if(lastModules.length === 0) return next();

  // Execute their routing functions
  calipso.lib.step(

  function doLastModules() {
    var group = this.group();
    lastModules.forEach(function(module) {
      module.fn.route(req, res, module, calipso.app, group());
    });
  }, function done(err) {

    // Gracefully deal with errors
    if (err) {
      res.statusCode = 500;
      console.log(err.message);
      res.errorMessage = err.message + err.stack;
    }

    next();

  });

}
Example #6
0
function showCurrent(req, res, template, block, next) {
  calipso.lib.step(function () {
    req.helpers.getContent(req, {alias:'currentcall'}, this);
  }, function done(err, current) {
    calipso.theme.renderItem(req, res, template, block, {current:current}, next);
  });

}
Example #7
0
function showHome(req, res, template, block, next) {
  calipso.lib.step(function () {
    req.helpers.getContentList({contentType:'Carousel'}, {req:req}, this);
  }, function done(err, carouselList) {
    calipso.theme.renderItem(req, res, template, block, {carouselList:carouselList}, next);
  });

}
Example #8
0
/**
 * Show languages stored in memory,
 * optionally enable translation of these by google translate.
 */
function showLanguages(req, res, template, block, next) {

  // Check to see if we should google translate?!
  // e.g. /admin/languages?translate=es
  if (req.moduleParams.translate) {

    var language = req.moduleParams.translate;
    var languageCache = req.languageCache[language];

    var gt = require('utils/googleTranslate');

    if (languageCache) {
      calipso.lib.step(
        function translateAll() {
          var group = this.group();
          for (var item in languageCache) {
            gt.googleTranslate(item, language, group());
          }
        },
        function allTranslated(err, translations) {

          if (err) {
            req.flash('error', req.t('There was an error translating that language because {msg}', {msg:err.message}));
          }

          if (!err && translations) {
            translations.forEach(function (translation) {
              req.languageCache[language][translation.string] = translation.translation;
            });
          }

          calipso.theme.renderItem(req, res, template, block, {
            languageCache:req.languageCache
          }, next);

        }
      )
    } else {

      req.flash('info', req.t('That language does not exist.'));
      calipso.theme.renderItem(req, res, template, block, {
        languageCache:req.languageCache
      }, next);

    }

  } else {

    calipso.theme.renderItem(req, res, template, block, {
      languageCache:req.languageCache
    }, next);

  }

}
Example #9
0
/**
 * Installation process - asynch
 */
function install(next) {

  // Create the default content types
  var User = calipso.db.model('User');

  calipso.lib.step(

    function createDefaults() {

      var self = this;

      // Create administrative user
      if (calipso.data.adminUser) {

        var adminUser = calipso.data.adminUser;

        // Create a new user
        var admin = new User({
          username:adminUser.username,
          fullname:adminUser.fullname,
          email:adminUser.email,
          language:adminUser.language,
          about:'',
          roles:['Administrator']
        });
        calipso.lib.crypto.hash(adminUser.password, calipso.config.get('session:secret'), function (err, hash) {
          if (err) {
            return self()(err);
          }
          admin.hash = hash;
          admin.save(self());
        }),

          // Delete this now to ensure it isn't hanging around;
          delete calipso.data.adminUser;

      } else {
        // Fatal error
        self()(new Error("No administrative user details provided through login process!"));
      }

    },
    function allDone(err) {
      if (err) {
        calipso.error("User module failed installation " + err.message);
        next();
      } else {
        calipso.info("User module installed ... ");
        roles.install(next);
      }
    }
  )

}
Example #10
0
function init(module, app, next) {
  calipso.lib.step(
    function defineRoutes() {
      module.router.addRoute(/^\/images|^\/js|^\/css|^\/favicon.ico|png$|jpg$|gif$|css$|js$/, handleStatic, {
        admin:false
      }, this.parallel());
    },
    function done() {
      next();
    });
}
Example #11
0
/**
 *Init
 */
function init(module,app,next) {

  // Version events
  calipso.e.addEvent('CONTENT_VERSION');

  calipso.lib.step(
      function defineRoutes() {

        // Menus
        module.router.addRoute('GET /content/show/:id',showContent,{admin:true},this.parallel());
        module.router.addRoute('GET /content/show/:id',showContent,{admin:true},this.parallel());

        // Crud operations
        module.router.addRoute('GET /content/show/:id/versions',listVersions,{admin:true,template:'list',block:'content.version'},this.parallel());
        module.router.addRoute('GET /content/show/:id/versions/diff/:a',diffVersion,{admin:true,template:'diff',block:'content.diff'},this.parallel());
        module.router.addRoute('GET /content/show/:id/versions/diff/:a/:b',diffVersion,{admin:true,template:'diff',block:'content.diff'},this.parallel());
        module.router.addRoute('GET /content/show/:id/version/:version',showVersion,{admin:true,template:'show',block:'content.version'},this.parallel());
        module.router.addRoute('GET /content/show/:id/version/:version/revert',revertVersion,{admin:true},this.parallel());

      },
      function done() {

        // Schema
        var ContentVersion = new calipso.lib.mongoose.Schema({
          contentId:{type: String}
          // All other properties are dynamically mapped, hence use of .set / .get
        });

        calipso.lib.mongoose.model('ContentVersion', ContentVersion);

        // Version event listeners
        calipso.e.post('CONTENT_CREATE',module.name,saveVersion);
        calipso.e.post('CONTENT_UPDATE',module.name,saveVersion);

        // Form alteration
        if(calipso.modules.content.fn.originalContentForm) {
          // We have already altered the form, so lets set it back before altering it
          calipso.modules.content.fn.contentForm = calipso.modules.content.fn.originalContentForm;
        }

        // Now, lets alter the form
        calipso.modules.content.fn.originalContentForm = calipso.modules.content.fn.contentForm;
        calipso.modules.content.fn.contentForm = function() {
          var form = calipso.modules.content.fn.originalContentForm();
          form.sections.push(contentVersionFormSection);
          return form;
        }

        next();

      }
  );
}
Example #12
0
exports = module.exports = function (req, options, callback) {

  /**
   *  Get additional content for blocks in the template
   */
  calipso.lib.step(function getContent() {
    options.getBlock(/scripts.*/, this.parallel());
  }, function done(err, scripts) {
    callback(err, {scripts:scripts});
  });


};
Example #13
0
 this.parse = function(data,taxonomy,contentType) {
   calipso.lib.step(
       function processItems() {
         var group = this.group();
         data.entry.forEach(function(item) {
           parser.emit("item", item, taxonomy, contentType, group);
         });
       },
       function processItemsDone() {
         parser.emit("done");
       }
   )
 }
Example #14
0
/**
 *Init
 */
function init(module,app,next) {

  // Version events
  calipso.e.addEvent('CONTENT_VERSION');

  // Permissions
  calipso.permission.Helper.addPermission("content:versions:view","View content versions.");
  calipso.permission.Helper.addPermission("content:versions:diff","Diff content versions.");
  calipso.permission.Helper.addPermission("content:versions:revert","Revert content versions.");

  calipso.lib.step(
      function defineRoutes() {

        var vPerm = calipso.permission.Helper.hasPermission("content:versions:view"),
            dPerm = calipso.permission.Helper.hasPermission("content:versions:diff"),
            rPerm = calipso.permission.Helper.hasPermission("content:versions:revert");


        // Menus
        module.router.addRoute('GET /content/show/:id',showContentVersionsMenu,{admin:true},this.parallel());

        // Crud operations
        module.router.addRoute('GET /content/show/:id/versions',listVersions,{admin:true,permit:vPerm,template:'list',block:'content.version'},this.parallel());
        module.router.addRoute('GET /content/show/:id/versions/diff/:a',diffVersion,{admin:true,permit:dPerm,template:'diff',block:'content.diff'},this.parallel());
        module.router.addRoute('GET /content/show/:id/versions/diff/:a/:b',diffVersion,{admin:true,permit:dPerm,template:'diff',block:'content.diff'},this.parallel());
        module.router.addRoute('GET /content/show/:id/version/:version',showVersion,{admin:true,permit:vPerm,template:'show',block:'content.version'},this.parallel());
        module.router.addRoute('GET /content/show/:id/version/:version/revert',revertVersion,{admin:true,permit:rPerm},this.parallel());

      },
      function done() {

        // Schema
        var ContentVersion = new calipso.lib.mongoose.Schema({
          contentId:{type: String}
          // All other properties are dynamically mapped, hence use of .set / .get
        });

        calipso.db.model('ContentVersion', ContentVersion);

        // Version event listeners
        calipso.e.post('CONTENT_CREATE', module.name, saveVersion);
        calipso.e.post('CONTENT_UPDATE', module.name, saveVersion);

        // Form alter of main content form
        calipso.e.custom('FORM', 'content-form', module.name, alterContentForm);

        next();

      }
  );
}
Example #15
0
/**
 * Installation process - asynch
 */
function install(next) {

  // Create the default roles
  var Role = calipso.db.model('Role');

  calipso.lib.step(

    function createDefaults() {

      var self = this;

      // Create default roles
      var r = new Role({
        name:'Guest',
        description:'Guest account',
        isAdmin:false,
        isDefault:true
      });
      r.save(self.parallel());

      var r = new Role({
        name:'Contributor',
        description:'Able to create and manage own content items linked to their own user profile area.',
        isAdmin:false,
        isDefault:false
      });
      r.save(self.parallel());

      var r = new Role({
        name:'Administrator',
        description:'Able to manage the entire site.',
        isAdmin:true,
        isDefault:false
      });
      r.save(self.parallel());

    },
    function allDone(err) {
      if (err) {
        calipso.error("User Roles sub-module failed " + err.message);
        next();
      } else {
        calipso.info("User Roles sub-module installed ... ");
        storeRoles(null, null, next);
      }
    }
  )

}
Example #16
0
exports = module.exports = function (req, options, callback) {

  /**
   *  Get additional content for blocks in the template
   */
  calipso.lib.step(function getContent() {
    options.getContent(req, "about-me", this.parallel());
    options.getBlock('user.login', this.parallel());
    options.getBlock('tagcloud', this.parallel());
  }, function done(err, about, userLogin, tagcloud) {
    callback(err, {about:about, userLogin:userLogin, tagcloud:tagcloud});
  });


};
Example #17
0
exports = module.exports = function (req, options, callback) {

  /**
   *  Get additional content for blocks in the template
   */
  calipso.lib.step(function getContent() {
    options.getBlock(/^content.*/, this.parallel());
    options.getBlock(/^admin.*/, this.parallel());
    options.getBlock('scripts.disqus', this.parallel());
  }, function done(err, content, admin, disqus) {
    callback(err, {content:content, admin:admin, disqus:disqus});
  });


};
Example #18
0
  calipso.storage.mongoConnect(function (err) {

    if (err) {
      return next(err);
    }

    // Note - the admin user is created in the user module install process
    calipso.lib.step(
      function saveConfiguration() {
        // Save configuration to file
        calipso.info("Saving configuration ... ");
        calipso.config.save(this);
      },
      function reloadConfiguration() {
        // This actually re-loads all of the modules
        calipso.info("Reloading updated configuration ... ");
        calipso.reloadConfig("ADMIN_INSTALL", calipso.config, this);
      },
      function installModules() {

        // TODO - this should just be part of enabling them the first time!

        var group = this.group();

        // Get a list of all the modules to install
        var modulesToInstall = [];
        for (var module in calipso.modules) {
          // Check to see if the module is currently enabled, if so install it
          if (calipso.modules[module].enabled && calipso.modules[module].fn && typeof calipso.modules[module].fn.install === 'function') {
            modulesToInstall.push(module);
          }
        }

        modulesToInstall.forEach(function (module) {
          calipso.info("Installing module " + module);
          calipso.modules[module].fn.install(group());
        });

      },
      function done(err) {

        res.redirect("/")
        return next(err);

      }
    );

  });
Example #19
0
exports = module.exports = function (req, options, callback) {

  /**
   *  Get additional content for blocks in the template
   */
  calipso.lib.step(

    function getContent() {
      options.getContent(req, "welcome", this.parallel());
    }, function done(err, welcome) {
      callback(err, {
        welcome:welcome
      });
    });

};
Example #20
0
exports = module.exports = function (req, options, callback) {

  /**
   *  Get additional content for blocks in the template
   */
  calipso.lib.step(function getContent() {
    options.getBlock('sidebar', this.parallel());
  }, function done(err, sidebar, userlogin) {
    if (!sidebar) {
      sidebar = "";
    }
    callback(err, {sidebar:sidebar});
  });


};
Example #21
0
function init(module, app, next) {
	calipso.e.addEvent('CIRCLE_CREATE');
	calipso.e.addEvent('CIRCLE_UPDATE');
	calipso.e.addEvent('CIRCLE_DELETE');
	calipso.e.addEvent('CALL_CREATE');
	calipso.e.addEvent('CALL_UPDATE');
	calipso.e.addEvent('CALL_DELETE');
	calipso.e.addEvent('PROJECT_CREATE');
	calipso.e.addEvent('PROJECT_UPDATE');
	calipso.e.addEvent('PROJECT_DELETE');
	calipso.e.addEvent('PROJECT_ITERATE');

	calipso.permission.Helper.addPermission("ecrafting:circle", "eCrafting", true);
	calipso.permission.Helper.addPermission("ecrafting:call", "eCrafting", true);
	calipso.permission.Helper.addPermission("ecrafting:project", "eCrafting", true);
	calipso.permission.Helper.addPermission("admin:ecrafting:circle", "eCrafting Admin", true);
	calipso.permission.Helper.addPermission("admin:ecrafting:call", "eCrafting Admin", true);
	calipso.permission.Helper.addPermission("admin:ecrafting:project", "eCrafting Admin", true);

	calipso.lib.step(
		function defineRoutes() {
			module.router.addRoute('GET /ecrafting', showMain, {template:'ecrafting', admin:true, block:'admin.show'}, this.parallel());
			module.router.addRoute('GET /about', showAbout, {template:'about', block:'content.show' }, this.parallel());
			module.router.addRoute('GET /locations', showMain, {template:'locations', block:'content.show'}, this.parallel());
			module.router.addRoute('GET /timeline', showMain, {template:'timeline', block:'content.show'}, this.parallel());
			module.router.addRoute('GET /current', showCurrent, {template:'current', block:'content.show'}, this.parallel());

	      module.router.addRoute(/.*/, allPages, {
	        end:false,
	        template:'ecrafting.script',
	        block:'scripts.ecrafting'
	      }, this.parallel());
	      module.router.addRoute(/.*/, allPages, {
	        end:false,
	        template:'ecrafting.style',
	        block:'styles.ecrafting'
	      }, this.parallel());

		},
		function done() {
			domain.init(module, app, next);
			views.init(module, app, next);
			api.init(module, app, next);
			registerEventListeners();
			next();
		});
}
Example #22
0
function init(module, app, next) {


   //If dependent on another module (e.g. content):
   //if(!calipso.modules.content.initialised) {
   //process.nextTick(function() { init(module,app,next); });
   //return;
   //}

  // Any pre-route config
  calipso.lib.step(

  function defineRoutes() {

    // Add a route to every page, notice the 'end:false' to ensure block further routing
    //module.router.addRoute(/.*/, allPages, {end:false, template:'template-all', block:'right'}, this.parallel());
    app.use(calipso.lib.express.static(__dirname + '/static'));

    // Page

    module.router.addRoute('GET /sickcase/list', case_list, {end:false,template:'case_list',block:'content.sickcase.case_list'}, this.parallel());
    module.router.addRoute('GET /sickcase/case_show/:id', case_show, {
      template: 'case_show',
      block: 'content'
    }, this.parallel());
    module.router.addRoute('GET /sickcase/edit_view/:id', edit_view, {
      template: 'edit_view',
      block: 'content'
    }, this.parallel());
    module.router.addRoute('GET /sickcase/create_view', create_view, {
      template: 'create_view',
      block: 'content'
    }, this.parallel());
    module.router.addRoute('POST /sickcase/create_post', create_post, null, this.parallel());
    module.router.addRoute('POST /sickcase', renderSampleContentPage, {
      template: 'sickcase',
      block: 'content'
    }, this.parallel());

  }, function done() {

	require('./sickcase_model');
    // Any schema configuration goes here
    next();
  });

};
Example #23
0
exports = module.exports = function(req, options, callback) {

  /**
   *  Get additional content for blocks in the template
   */
  calipso.lib.step(
    function getContent() {
      options.getBlock('search.form',this.parallel());
      options.getBlock('user.login',this.parallel());
    },
    function done(err,searchForm,userLogin) {
      callback(err,{searchForm:searchForm,userLogin:userLogin});
    }
  );


};
Example #24
0
/**
 *Init
 */
function init(module,app,next) {

  calipso.lib.step(
      function defineRoutes() {
        module.router.addRoute('GET /scheduler',schedulerAdmin,{template:'admin',block:'admin',admin:true},this.parallel());
        module.router.addRoute('POST /scheduler',createJob,{admin:true},this.parallel());
        module.router.addRoute('GET /scheduler/new',createJobForm,{admin:true,block:'admin'},this.parallel());
        module.router.addRoute('GET /scheduler/switch/:onoff.:format?',enableScheduler,{admin:true},this.parallel());
        module.router.addRoute('GET /scheduler/switch/:onoff/:jobName.:format?',enableScheduler,{admin:true},this.parallel());
        module.router.addRoute('GET /scheduler/show/:jobName',showJob,{admin:true,template:'show',block:'admin'},this.parallel());
        module.router.addRoute('GET /scheduler/edit/:jobName',editJobForm,{admin:true,block:'content'},this.parallel());
        module.router.addRoute('GET /scheduler/delete/:jobName',deleteJob,{admin:true},this.parallel());
        module.router.addRoute('POST /scheduler/:jobName',updateJob,{admin:true},this.parallel());
      },
      function done() {

        // Ensure we have the job schema defined
        var ScheduledJob = new calipso.lib.mongoose.Schema({
          name:{type: String, required: true, unique: true},
          cronTime:{type: String, "default":'* * * * * *',required: true},
          enabled:{type: Boolean, "default":false, required: true},
          module:{type: String, "default":'', required: true},
          method:{type: String, "default":'', required: true},
          args:{type: String, "default":'', required: false}
        });
        calipso.lib.mongoose.model('ScheduledJob', ScheduledJob);

        // Load the exposed job functions into a job function array
        // This scans all the other modules
        calipso.data.jobFunctions = [];
        for(var module in calipso.modules) {
          if(calipso.modules[module].enabled) {
            for(var job in calipso.modules[module].fn.jobs) {
                calipso.data.jobFunctions.push(module + "." + job);
            }
          }
        }

        // Load the current jobs into Calipso
        loadJobs(next);

      }
  );

};
Example #25
0
function showAbout(req, res, template, block, next) {
/*
    req.helpers.getContentList(query, {req:req, format:format, sortBy:sortBy}, this);

var about = calipso.helpers.getContent(req, {alias:'about'});
console.log("About: ", about);

	calipso.theme.renderItem(req, res, template, block, {content: { title: "eCrafting Dashboard" } }, next);

*/

  calipso.lib.step(function () {
    req.helpers.getContent(req, {alias:'about'}, this);
  }, function done(err, about) {
    calipso.theme.renderItem(req, res, template, block, {about:about}, next);
  });

}
Example #26
0
/**
 * Init
 */
function init(module, app, next) {

  // Any pre-route config
  calipso.lib.step(

  function defineRoutes() {

    // These are the routes that pusher is enabled on re. sending / receiving messages.
    // Pusher enabled on every page
    module.router.addRoute(/.*/, pusher, {
      end: false,
      template: 'pusher',
      block: 'scripts.pusher'
    }, this.parallel());

  }, function done() {

    // Add the socket io listener
    calipso.socket = io.listen(app);

    // Add the scoket.io connection handlers
    calipso.socket.on('connection', function(client) {

      // Store the client in the sessionCache
      calipso.sessionCache[client.sessionId] = {
        client: client
      };

      client.on('message', function(message) {
        calipso.debug("message: " + message);
      });

      client.on('disconnect', function() {
        delete calipso.sessionCache[this.sessionId];
      });

    });


    next();
  });

};
Example #27
0
/**
 *Init
 */
function init(module, app, next) {

  // Any pre-route config
  calipso.lib.step(

    function defineRoutes() {
      // Tracking code is added to every page
      module.router.addRoute(/.*/, ga, {
        end: false,
        template: 'ga',
        block: 'scripts.ga'
      }, this.parallel());
    }, 
    function done() {
	  // No initialisation?
      next();
    }
  );
}
Example #28
0
/**
 *Init
 */
function init(module, app, next) {

   calipso.lib.step(
    function defineRoutes() {
      // Add a route to every page, ideally just do it on form pages, but can't tell atm
      module.router.addRoute(/.*/, allPages, {
        end: false,
        template: 'aloha.script',
        block: 'scripts.aloha'
      }, this.parallel());
      module.router.addRoute(/.*/, allPages, {
        end: false,
        template: 'aloha.style',
        block: 'styles.aloha'
      }, this.parallel());
    },
    function done() {
      app.use(calipso.lib.express["static"](__dirname + '/static'));
      next();  
    });
};
Example #29
0
exports = module.exports = function(req, options, callback) {

  /**
   *  Get additional content for blocks in the template
   */
  calipso.lib.step(
    function getContent() {

      options.getContent(req, 'about-me', this.parallel());
      options.getBlock('tagcloud',this.parallel());
      options.getBlock(/^side.*/,this.parallel());

      // Demonstration of how to use getModuleFn
      options.getModuleFn(req,'template.templatePage',{template:'templateShow'},this.parallel());

    },
    function done(err, about,tagcloud,side,fn) {
      callback(err,{about:about,tagcloud:tagcloud, side:side, fn:fn});
    }
  );


};
Example #30
0
/**
 * Init
 */
function init(module, app, next) {

  // Register events for the Content Module
  calipso.e.addEvent('USER_CREATE');
  calipso.e.addEvent('USER_UPDATE');
  calipso.e.addEvent('USER_DELETE');
  calipso.e.addEvent('USER_LOCK');
  calipso.e.addEvent('USER_UNLOCK');
  calipso.e.addEvent('USER_LOGIN');
  calipso.e.addEvent('USER_LOGOUT');

  // Define permissions
  calipso.permission.Helper.addPermission("admin:user", "Users", true);
  calipso.permission.Helper.addPermission("admin:user:register", "Register other users.");

  calipso.lib.step(

    function defineRoutes() {
      module.router.addRoute(/.*/, setCookie, { end:false }, this.parallel());
      module.router.addRoute(/.*/, loginForm, { end:false, template:'login', block:'user.login' }, this.parallel());
      module.router.addRoute('GET /user/login', loginPage, { end:false, template:'loginPage', block:'content' }, this.parallel());
      module.router.addRoute('POST /user/login', loginUser, null, this.parallel());
      module.router.addRoute('GET /user/list', listUsers, {end:false, admin:true, template:'list', block:'content.user.list'}, this.parallel());
      module.router.addRoute('GET /admin/role/register', roleForm, {end:false, admin:true, block:'content'}, this.parallel());
      module.router.addRoute('GET /admin/role/list', listRoles, {end:false, admin:true, template:'list', block:'content.user.list'}, this.parallel());
      module.router.addRoute('GET /admin/roles/:role?', roleForm, {end:false, admin:true, block:'content'}, this.parallel());
      module.router.addRoute('POST /admin/roles/:role?', updateRole, {block:'content'}, this.parallel());
      module.router.addRoute('GET /admin/roles/:role/delete', deleteRole, {admin:true}, this.parallel());
      module.router.addRoute('GET /user/logout', logoutUser, null, this.parallel());
      module.router.addRoute('GET /user/register', registerUserForm, {block:'content'}, this.parallel());
      module.router.addRoute('POST /user/register', registerUser, null, this.parallel());
      module.router.addRoute('GET /user', myProfile, {template:'profile', block:'content'}, this.parallel());
      module.router.addRoute('GET /user/profile/:username', userProfile, {template:'profile', block:'content'}, this.parallel());
      module.router.addRoute('POST /user/profile/:username', updateUserProfile, {block:'content'}, this.parallel());
      module.router.addRoute('GET /user/profile/:username/edit', updateUserForm, {block:'content'}, this.parallel());
      module.router.addRoute('GET /user/profile/:username/lock', lockUser, {admin:true}, this.parallel());
      module.router.addRoute('GET /user/profile/:username/unlock', unlockUser, {admin:true}, this.parallel());
      module.router.addRoute('GET /user/profile/:username/delete', deleteUser, {admin:true}, this.parallel());

    },
    function done() {

      var User = new calipso.lib.mongoose.Schema({
        // Single default property
        username:{type:String, required:true, unique:true},
        fullname:{type:String, required:false},
        password:{type:String, required:false},
        hash:{type:String, required:true, "default":''},
        email:{type:String, required:true, unique:true},
        showName:{type:String, "default":'registered'},
        showEmail:{type:String, "default":'registered'},
        about:{type:String},
        language:{type:String, "default":'en'},
        roles:[String],
        locked:{type:Boolean, "default":false}
      });

      calipso.db.model('User', User);

      // Initialise roles
      roles.init(module, app, next);

    }
  )

}