1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-12 10:52: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 4bb8cae81e
commit 6ab45fe935
13249 changed files with 317868 additions and 2101398 deletions

View File

@@ -2,23 +2,22 @@
* Module dependencies.
*/
var SchemaType = require('../schematype')
, CastError = SchemaType.CastError
, NumberSchema = require('./number')
, Types = {
Boolean: require('./boolean')
, Date: require('./date')
, Number: require('./number')
, String: require('./string')
, ObjectId: require('./objectid')
, Buffer: require('./buffer')
}
, MongooseArray = require('../types').Array
, EmbeddedDoc = require('../types').Embedded
, Mixed = require('./mixed')
, cast = require('../cast')
, utils = require('../utils')
, isMongooseObject = utils.isMongooseObject
var SchemaType = require('../schematype'),
CastError = SchemaType.CastError,
Types = {
Boolean: require('./boolean'),
Date: require('./date'),
Number: require('./number'),
String: require('./string'),
ObjectId: require('./objectid'),
Buffer: require('./buffer')
},
MongooseArray = require('../types').Array,
EmbeddedDoc = require('../types').Embedded,
Mixed = require('./mixed'),
cast = require('../cast'),
utils = require('../utils'),
isMongooseObject = utils.isMongooseObject;
/**
* Array SchemaType constructor
@@ -30,7 +29,7 @@ var SchemaType = require('../schematype')
* @api private
*/
function SchemaArray (key, cast, options) {
function SchemaArray(key, cast, options) {
if (cast) {
var castOptions = {};
@@ -63,16 +62,16 @@ function SchemaArray (key, cast, options) {
SchemaType.call(this, key, options, 'Array');
var self = this
, defaultArr
, fn;
var self = this,
defaultArr,
fn;
if (this.defaultValue) {
defaultArr = this.defaultValue;
fn = 'function' == typeof defaultArr;
}
this.default(function(){
this.default(function() {
var arr = fn ? defaultArr() : defaultArr || [];
return new MongooseArray(arr, self.path, this);
});
@@ -99,7 +98,7 @@ SchemaArray.prototype.constructor = SchemaArray;
* @api private
*/
SchemaArray.prototype.checkRequired = function (value) {
SchemaArray.prototype.checkRequired = function(value) {
return !!(value && value.length);
};
@@ -111,7 +110,7 @@ SchemaArray.prototype.checkRequired = function (value) {
* @api private
*/
SchemaArray.prototype.applyGetters = function (value, scope) {
SchemaArray.prototype.applyGetters = function(value, scope) {
if (this.caster.options && this.caster.options.ref) {
// means the object id was populated
return value;
@@ -129,7 +128,7 @@ SchemaArray.prototype.applyGetters = function (value, scope) {
* @api private
*/
SchemaArray.prototype.cast = function (value, doc, init) {
SchemaArray.prototype.cast = function(value, doc, init) {
if (Array.isArray(value)) {
if (!value.length && doc) {
@@ -149,7 +148,7 @@ SchemaArray.prototype.cast = function (value, doc, init) {
if (this.caster) {
try {
for (var i = 0, l = value.length; i < l; i++) {
for (i = 0, l = value.length; i < l; i++) {
value[i] = this.caster.cast(value[i], doc, init);
}
} catch (e) {
@@ -177,9 +176,9 @@ SchemaArray.prototype.cast = function (value, doc, init) {
* @api private
*/
SchemaArray.prototype.castForQuery = function ($conditional, value) {
var handler
, val;
SchemaArray.prototype.castForQuery = function($conditional, value) {
var handler,
val;
if (arguments.length === 2) {
handler = this.$conditionalHandlers[$conditional];
@@ -198,7 +197,10 @@ SchemaArray.prototype.castForQuery = function ($conditional, value) {
var caster = this.caster;
if (Array.isArray(val)) {
val = val.map(function (v) {
val = val.map(function(v) {
if (utils.isObject(v) && v.$elemMatch) {
return v;
}
if (method) v = method.call(caster, v);
return isMongooseObject(v) ?
v.toObject({ virtuals: false }) :
@@ -221,14 +223,14 @@ SchemaArray.prototype.castForQuery = function ($conditional, value) {
* $atomic cast helpers
*/
function castToNumber (val) {
function castToNumber(val) {
return Types.Number.prototype.cast.call(this, val);
}
function castArraysOfNumbers (arr, self) {
function castArraysOfNumbers(arr, self) {
self || (self = this);
arr.forEach(function (v, i) {
arr.forEach(function(v, i) {
if (Array.isArray(v)) {
castArraysOfNumbers(v, self);
} else {
@@ -237,7 +239,7 @@ function castArraysOfNumbers (arr, self) {
});
}
function cast$near (val) {
function cast$near(val) {
if (Array.isArray(val)) {
castArraysOfNumbers(val, this);
return val;
@@ -250,7 +252,7 @@ function cast$near (val) {
return SchemaArray.prototype.castForQuery.call(this, val);
}
function cast$geometry (val, self) {
function cast$geometry(val, self) {
switch (val.$geometry.type) {
case 'Polygon':
case 'LineString':
@@ -269,7 +271,7 @@ function cast$geometry (val, self) {
return val;
}
function cast$within (val) {
function cast$within(val) {
var self = this;
if (val.$maxDistance) {
@@ -278,27 +280,27 @@ function cast$within (val) {
if (val.$box || val.$polygon) {
var type = val.$box ? '$box' : '$polygon';
val[type].forEach(function (arr) {
val[type].forEach(function(arr) {
if (!Array.isArray(arr)) {
var msg = 'Invalid $within $box argument. '
+ 'Expected an array, received ' + arr;
throw new TypeError(msg);
}
arr.forEach(function (v, i) {
arr.forEach(function(v, i) {
arr[i] = castToNumber.call(this, v);
});
})
});
} else if (val.$center || val.$centerSphere) {
var type = val.$center ? '$center' : '$centerSphere';
val[type].forEach(function (item, i) {
type = val.$center ? '$center' : '$centerSphere';
val[type].forEach(function(item, i) {
if (Array.isArray(item)) {
item.forEach(function (v, j) {
item.forEach(function(v, j) {
item[j] = castToNumber.call(this, v);
});
} else {
val[type][i] = castToNumber.call(this, item);
}
})
});
} else if (val.$geometry) {
cast$geometry(val, this);
}
@@ -306,12 +308,12 @@ function cast$within (val) {
return val;
}
function cast$all (val) {
function cast$all(val) {
if (!Array.isArray(val)) {
val = [val];
}
val = val.map(function (v) {
val = val.map(function(v) {
if (utils.isObject(v)) {
var o = {};
o[this.path] = v;
@@ -323,28 +325,23 @@ function cast$all (val) {
return this.castForQuery(val);
}
function cast$elemMatch (val) {
var hasDollarKey = false;
function cast$elemMatch(val) {
var keys = Object.keys(val);
var numKeys = keys.length;
var key;
var value;
for (var i = 0; i < numKeys; ++i) {
var key = keys[i];
var value = val[key];
key = keys[i];
value = val[key];
if (key.indexOf('$') === 0 && value) {
val[key] = this.castForQuery(key, value);
hasDollarKey = true;
}
}
if (hasDollarKey) {
return val;
}
return cast(this.casterConstructor.schema, val);
}
function cast$geoIntersects (val) {
function cast$geoIntersects(val) {
var geo = val.$geometry;
if (!geo) return;