Skip to content

Commit

Permalink
Fixed issue with content type over rides
Browse files Browse the repository at this point in the history
  • Loading branch information
cliftonc committed Apr 7, 2012
2 parents ebb46c3 + 37af194 commit 6e45e52
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 40 deletions.
2 changes: 2 additions & 0 deletions app-cluster.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// TODO - THIS NEEDS TO BE REPLACED WITH THE NEW Node 0.5+ multi process, see cliftonc/ted

/**
* Calipso script for running in clustered mode. Usage: node app-cluster, or
* NODE_ENV=production node app-cluster
Expand Down
19 changes: 8 additions & 11 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,14 @@ exports.boot = function (next,cluster) {

// Load configuration
var Config = require(path + "/lib/Config").Config;
app.config = new Config({},function(err) {

// TODO : Check for error

// Load application configuration
theme = app.config.get('themes:front');
// Bootstrap application
bootApplication(function () {
next(app);
});

app.config = new Config();
app.config.init();

// Load application configuration
// theme = app.config.get('themes:front');
// Bootstrap application
bootApplication(function () {
next(app);
});

};
Expand Down
13 changes: 7 additions & 6 deletions lib/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var rootpath = process.cwd() + '/',
* @type
* @options
*/
function Config(options,next) {
function Config(options) {

// Defaults
this.type = options && options.type ? options.type : 'file';
Expand All @@ -24,12 +24,13 @@ function Config(options,next) {
// Default to file based on environment
this.options = options && options.options ? options.options : { file: this.file };

// Initialise
this.nconf = require('nconf');
this.load(function(err) {
next(err);
});
}

Config.prototype.init = function() {
this.nconf = require('nconf');
this.load(function(err) {
console.log(err);
});
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Event.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function CalipsoEventEmitter(options) {
this.hook.emit('calipso::' + pre_prefix + event, data);
cb(data);
} else {
self.emitter.emit(pre_prefix + event, post_prefix + event, data, cb);
self.emitter.emit(pre_prefix + event, pre_prefix + event, data, cb);
}

}
Expand Down
1 change: 0 additions & 1 deletion lib/calipso.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ var app,
// Load configuration
initialiseCalipso();


// Return the function that manages the routing
// Ok being non-synchro
return function(req,res,next) {
Expand Down
10 changes: 8 additions & 2 deletions modules/core/content/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -767,13 +767,19 @@ function showContent(req,res,template,block,next,err,content,format) {

// Set the page layout to the content type
if(format === "html") {

if(content) {

// Change the layout
res.layout = content.layout ? content.layout : "default";

// Override of the template
template = calipso.theme.cache.contentTypes[content.contentType].view || template;
template = calipso.theme.cache.contentTypes[content.contentType] && calipso.theme.cache.contentTypes[content.contentType].view ? calipso.theme.cache.contentTypes[content.contentType].view : template;

}

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

}

if(format === "json") {
Expand Down Expand Up @@ -896,7 +902,7 @@ function getContentList(query,out,next) {

// Render the item into the response
if(out.format === 'html') {

var table = {id:'content-list',sort:true,cls:'table-admin',
columns:[{name:'_id',sort:'title',label:'Title',fn:contentLink},
{name:'contentType',label:'Type'},
Expand Down
7 changes: 7 additions & 0 deletions modules/core/contentTypes/contentTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,17 +493,24 @@ function storeContentTypes(event,contentType,next) {

ContentType.find({}).sort('contentType',1).find(function (err, types) {
if(err || !types) {

// Don't throw error, just pass back failure.
calipso.error("Error storing content types in cache: " + err.message);
return next(contentType);

} else {

types.forEach(function(type) {

calipso.data.contentTypes.push(type.contentType);

// If this is part of the start up process, lets compile all the templates
if(event === null) {
compileTemplates(null, type, function() {});
}

});

return next(contentType);
}
});
Expand Down
2 changes: 1 addition & 1 deletion modules/core/user/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ function userDisplay(req, username, next) {
}

}
next(null,responseData);
next(null, responseData);

});

Expand Down
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,38 @@
"tests": "./tests"
},
"engines": {
"node": "0.4.x || 0.5.x"
"node": "0.6.x"
},
"dependencies": {
"express": "2.5.x",
"connect": "1.8.x",
"ejs": "0.4.x",
"jade": "0.13.x",
"stylus": "0.13.x",
"underscore":"1.1.x",
"ejs": "0.6.x",
"jade": "0.20.x",
"stylus": "0.23.x",
"underscore":"1.3.x",
"mongoose": "2.5.x",
"winston": "0.3.x",
"winston": "0.5.x",
"mongodb": "0.9.x",
"connect-form": "0.2.x",
"qs": "0.3.x",
"request":"2.0.1",
"qs": "0.4.x",
"request":"2.9.x",
"pool":"0.4.x",
"mime":"1.2.x",
"cluster": "0.6.x",
"cluster": "0.7.x",
"step": "0.0.x",
"optimist":"0.2.x",
"colors":"0.5.x",
"bcrypt": "0.2.x",
"optimist":"0.3.x",
"colors":"0.6.x",
"bcrypt": "0.5.x",
"semver":"1.0.x",
"hook.io":"0.7.x",
"hook.io":"0.8.x",
"zipfile":"0.3.x",
"rimraf":"1.0.x",
"nconf":"0.2.x",
"rimraf":"2.0.x",
"nconf":"0.5.x",
"async": "0.1.x"
},
"devDependencies": {
"expresso": "0.8.x",
"should": "0.2.x"
"expresso": "*",
"should": "*"
},
"scripts": {
"install" : "bash ./bin/install.sh",
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion utils/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = exports = {
* Unsure why this can be here, and does not need to be stored.
* TODO - Figure out how this works
*/
var salt = bcrypt.gen_salt_sync(10);
var salt = bcrypt.genSaltSync(10);

/**
* Check if a string is valid against a hash
Expand Down

0 comments on commit 6e45e52

Please sign in to comment.