Skip to content

Commit

Permalink
Merge branch 'master' into issue/622
Browse files Browse the repository at this point in the history
  • Loading branch information
brianhyder committed May 30, 2015
2 parents 6edb0f5 + 91988ca commit 39e6f68
Show file tree
Hide file tree
Showing 21 changed files with 1,954 additions and 356 deletions.
62 changes: 25 additions & 37 deletions controllers/base_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,28 @@ module.exports = function BaseControllerModule(pb) {
});
});
this.ts = this.templateService;

//build out a base service context that can be cloned and passed to any
//service objects
this.context = {
req: this.req,
session: this.session,
ls: this.ls,
ts: this.ts
};

cb();
};

/**
* Retrieves a context object that contains the necessary information for
* service prototypes
* @method getServiceContext
* @return {Object}
*/
BaseController.prototype.getServiceContext = function(){
return util.merge(this.context, {});
};

/**
*
Expand Down Expand Up @@ -358,64 +377,33 @@ module.exports = function BaseControllerModule(pb) {

/**
* The sanitization rules that apply to Pages and Articles
* @deprecated Since 0.4.1
* @static
* @method getContentSanitizationRules
*/
BaseController.getContentSanitizationRules = function() {
return {
allowedTags: [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'p', 'a', 'ul', 'ol', 'nl', 'li', 'b', 'i', 'strong', 'em', 'strike', 'code', 'hr', 'br', 'div', 'table', 'thead', 'caption', 'tbody', 'tr', 'th', 'td', 'pre', 'img', 'u', 'span' ],
allowedAttributes: {
a: [ 'href', 'name', 'target', 'class', 'align'],
img: [ 'src', 'class', 'align'],
p: ['align', 'class'],
h1: ['style', 'class', 'align'],
h2: ['style', 'class', 'align'],
h3: ['style', 'class', 'align'],
h4: ['style', 'class', 'align'],
h5: ['style', 'class', 'align'],
h6: ['style', 'class', 'align'],
div: ['style', 'class', 'align'],
span: ['style', 'class', 'align'],
table: ['style', 'class', 'align'],
tr: ['style', 'class', 'align'],
th: ['style', 'class', 'align'],
td: ['style', 'class', 'align'],
},

// Lots of these won't come up by default because we don't allow them
selfClosing: [ 'img', 'br', 'hr', 'area', 'base', 'basefont', 'input', 'link', 'meta' ],

// URL schemes we permit
allowedSchemes: [ 'http', 'https', 'ftp', 'mailto' ]
};
return pb.BaseObjectService.getContentSanitizationRules();
};

/**
* @deprecated Since 0.4.1
* @static
* @method getDefaultSanitizationRules
*/
BaseController.getDefaultSanitizationRules = function() {
return {
allowedTags: [],
allowedAttributes: {}
};
return pb.BaseObjectService.getDefaultSanitizationRules();
};

/**
*
* @deprecated Since 0.4.1
* @static
* @method sanitize
* @param {String} value
* @param {Object} [config]
*/
BaseController.sanitize = function(value, config) {
if (!value) {
return value;
}
else if (!util.isObject(config)) {
config = BaseController.getDefaultSanitizationRules();
}
return Sanitizer(value, config);
return pb.BaseObjectService.sanitize(value, config);
};

/**
Expand Down
9 changes: 5 additions & 4 deletions include/dao/dao.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ module.exports = function DAOModule(pb) {
* @param {String} key The key to search for
* @param {*} val The value to search for
* @param {String} collection The collection to search in
* @param {Object} Key value pair object to exclude the retrival of data
* @param {Object} opts Key value pair object to exclude the retrival of data
* @param {Function} cb Callback function
*/
DAO.prototype.loadByValue = function(key, val, collection, opts, cb) {
Expand All @@ -120,7 +120,7 @@ module.exports = function DAOModule(pb) {
* @method loadByValues
* @param {Object} where Key value pair object
* @param {String} collection The collection to search in
* @param {Object} Key value pair object to exclude the retrival of data
* @param {Object} opts Key value pair object to exclude the retrival of data
* @param {Function} cb Callback function
*/
DAO.prototype.loadByValues = function(where, collection, opts, cb) {
Expand Down Expand Up @@ -153,6 +153,7 @@ module.exports = function DAOModule(pb) {
*/
DAO.prototype.count = function(entityType, where, cb) {
var options = {
count: true,
entityType: entityType,
where: where
};
Expand Down Expand Up @@ -335,8 +336,8 @@ module.exports = function DAOModule(pb) {

//log the result
if(pb.config.db.query_logging){
var query = "DAO: SELECT %j FROM %s.%s WHERE %j";
var args = [select, self.dbName, entityType, where];
var query = "DAO: %s %j FROM %s.%s WHERE %j";
var args = [options.count ? 'COUNT' : 'SELECT', select, self.dbName, entityType, where];
if (typeof orderBy !== 'undefined') {
query += " ORDER BY %j";
args.push(orderBy);
Expand Down
11 changes: 7 additions & 4 deletions include/requirements.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,17 @@ module.exports = function PB(config) {
pb.SectionService = require(config.docRoot+'/include/service/entities/section_service.js')(pb);
pb.TopMenuService = require(config.docRoot+'/include/theme/top_menu.js')(pb);

//object services
pb.BaseObjectService = require(path.join(config.docRoot, '/include/service/base_object_service.js'))(pb);
pb.TopicService = require(path.join(config.docRoot, '/include/service/entities/topic_service.js'))(pb);
pb.ArticleServiceV2 = require(path.join(config.docRoot, '/include/service/entities/content/article_service_v2.js'))(pb);
pb.ArticleRenderer = require(path.join(config.docRoot, '/include/service/entities/content/article_renderer.js'))(pb);
pb.ContentViewLoader = require(path.join(config.docRoot, '/include/service/entities/content/content_view_loader.js'))(pb);

var ArticleServiceModule = require(path.join(config.docRoot, '/include/service/entities/article_service.js'))(pb);
pb.ArticleService = ArticleServiceModule.ArticleService;
pb.MediaLoader = ArticleServiceModule.MediaLoader;
pb.CommentService = require(config.docRoot+'/include/theme/comments.js')(pb);

//object services
pb.BaseObjectService = require(path.join(config.docRoot, '/include/service/base_object_service.js'))(pb);
pb.TopicService = require(path.join(config.docRoot, '/include/service/entities/topic_service.js'))(pb);

return pb;
};
Loading

0 comments on commit 39e6f68

Please sign in to comment.