1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-13 11:12:47 +00:00

updated bunch of file paths and changed the way posts are loaded

This commit is contained in:
2016-01-05 12:28:04 -06:00
parent 719ae331ae
commit c96a84d0ff
13249 changed files with 317868 additions and 2101398 deletions

View File

@@ -2,11 +2,12 @@
* Module requirements.
*/
var SchemaType = require('../schematype')
, CastError = SchemaType.CastError
, errorMessages = require('../error').messages
, utils = require('../utils')
, Document
var SchemaType = require('../schematype');
var CastError = SchemaType.CastError;
var handleBitwiseOperator = require('./operators/bitwise');
var errorMessages = require('../error').messages;
var utils = require('../utils');
var Document;
/**
* Number SchemaType constructor.
@@ -17,7 +18,7 @@ var SchemaType = require('../schematype')
* @api private
*/
function SchemaNumber (key, options) {
function SchemaNumber(key, options) {
SchemaType.call(this, key, options, 'Number');
}
@@ -41,7 +42,7 @@ SchemaNumber.prototype.constructor = SchemaNumber;
* @api private
*/
SchemaNumber.prototype.checkRequired = function checkRequired (value, doc) {
SchemaNumber.prototype.checkRequired = function checkRequired(value, doc) {
if (SchemaType._isRef(this, value, doc, true)) {
return null != value;
} else {
@@ -80,9 +81,9 @@ SchemaNumber.prototype.checkRequired = function checkRequired (value, doc) {
* @api public
*/
SchemaNumber.prototype.min = function (value, message) {
SchemaNumber.prototype.min = function(value, message) {
if (this.minValidator) {
this.validators = this.validators.filter(function (v) {
this.validators = this.validators.filter(function(v) {
return v.validator != this.minValidator;
}, this);
}
@@ -91,11 +92,12 @@ SchemaNumber.prototype.min = function (value, message) {
var msg = message || errorMessages.Number.min;
msg = msg.replace(/{MIN}/, value);
this.validators.push({
validator: this.minValidator = function (v) {
return v === null || v >= value;
validator: this.minValidator = function(v) {
return v == null || v >= value;
},
message: msg,
type: 'min'
type: 'min',
min: value
});
}
@@ -133,9 +135,9 @@ SchemaNumber.prototype.min = function (value, message) {
* @api public
*/
SchemaNumber.prototype.max = function (value, message) {
SchemaNumber.prototype.max = function(value, message) {
if (this.maxValidator) {
this.validators = this.validators.filter(function(v){
this.validators = this.validators.filter(function(v) {
return v.validator != this.maxValidator;
}, this);
}
@@ -145,10 +147,11 @@ SchemaNumber.prototype.max = function (value, message) {
msg = msg.replace(/{MAX}/, value);
this.validators.push({
validator: this.maxValidator = function(v) {
return v === null || v <= value;
return v == null || v <= value;
},
message: msg,
type: 'max'
type: 'max',
max: value
});
}
@@ -164,7 +167,7 @@ SchemaNumber.prototype.max = function (value, message) {
* @api private
*/
SchemaNumber.prototype.cast = function (value, doc, init) {
SchemaNumber.prototype.cast = function(value, doc, init) {
if (SchemaType._isRef(this, value, doc, init)) {
// wait! we may need to cast this to a document
@@ -202,15 +205,17 @@ SchemaNumber.prototype.cast = function (value, doc, init) {
? value._id // documents
: value;
if (!isNaN(val)){
if (!isNaN(val)) {
if (null === val) return val;
if ('' === val) return null;
if ('string' == typeof val) val = Number(val);
if (val instanceof Number) return val
if (typeof val === 'string' || typeof val === 'boolean') {
val = Number(val);
}
if (val instanceof Number) return val;
if ('number' == typeof val) return val;
if (val.toString && !Array.isArray(val) &&
val.toString() == Number(val)) {
return new Number(val)
return new Number(val);
}
}
@@ -221,28 +226,31 @@ SchemaNumber.prototype.cast = function (value, doc, init) {
* ignore
*/
function handleSingle (val) {
return this.cast(val)
function handleSingle(val) {
return this.cast(val);
}
function handleArray (val) {
function handleArray(val) {
var self = this;
return val.map(function (m) {
return self.cast(m)
if (!Array.isArray(val)) {
return [this.cast(val)];
}
return val.map(function(m) {
return self.cast(m);
});
}
SchemaNumber.prototype.$conditionalHandlers =
utils.options(SchemaType.prototype.$conditionalHandlers, {
'$all': handleArray,
'$bitsAllClear': handleBitwiseOperator,
'$bitsAnyClear': handleBitwiseOperator,
'$bitsAllSet': handleBitwiseOperator,
'$bitsAnySet': handleBitwiseOperator,
'$gt' : handleSingle,
'$gte': handleSingle,
'$in' : handleArray,
'$lt' : handleSingle,
'$lte': handleSingle,
'$ne' : handleSingle,
'$mod': handleArray,
'$nin': handleArray
'$mod': handleArray
});
/**
@@ -253,7 +261,7 @@ SchemaNumber.prototype.$conditionalHandlers =
* @api private
*/
SchemaNumber.prototype.castForQuery = function ($conditional, val) {
SchemaNumber.prototype.castForQuery = function($conditional, val) {
var handler;
if (arguments.length === 2) {
handler = this.$conditionalHandlers[$conditional];
@@ -262,7 +270,7 @@ SchemaNumber.prototype.castForQuery = function ($conditional, val) {
return handler.call(this, val);
} else {
val = this.cast($conditional);
return val == null ? val : val
return val == null ? val : val;
}
};