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

@@ -1,6 +1,16 @@
/*!
* express
* Copyright(c) 2009-2013 TJ Holowaychuk
* Copyright(c) 2013 Roman Shtylman
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/
'use strict';
/**
* Module dependencies.
* @private
*/
var Route = require('./route');
@@ -9,11 +19,12 @@ var methods = require('methods');
var mixin = require('utils-merge');
var debug = require('debug')('express:router');
var deprecate = require('depd')('express');
var flatten = require('array-flatten');
var parseUrl = require('parseurl');
var utils = require('../utils');
/**
* Module variables.
* @private
*/
var objectRegExp = /^\[object (\S+)\]$/;
@@ -25,11 +36,11 @@ var toString = Object.prototype.toString;
*
* @param {Object} options
* @return {Router} which is an callable function
* @api public
* @public
*/
var proto = module.exports = function(options) {
options = options || {};
var opts = options || {};
function router(req, res, next) {
router.handle(req, res, next);
@@ -40,9 +51,9 @@ var proto = module.exports = function(options) {
router.params = {};
router._params = [];
router.caseSensitive = options.caseSensitive;
router.mergeParams = options.mergeParams;
router.strict = options.strict;
router.caseSensitive = opts.caseSensitive;
router.mergeParams = opts.mergeParams;
router.strict = opts.strict;
router.stack = [];
return router;
@@ -79,7 +90,7 @@ var proto = module.exports = function(options) {
* @param {String} name
* @param {Function} fn
* @return {app} for chaining
* @api public
* @public
*/
proto.param = function param(name, fn) {
@@ -118,11 +129,10 @@ proto.param = function param(name, fn) {
/**
* Dispatch a req, res into the router.
*
* @api private
* @private
*/
proto.handle = function(req, res, done) {
proto.handle = function handle(req, res, out) {
var self = this;
debug('dispatching %s %s', req.method, req.url);
@@ -146,7 +156,7 @@ proto.handle = function(req, res, done) {
// manage inter-router variables
var parentParams = req.params;
var parentUrl = req.baseUrl || '';
done = restore(done, req, 'baseUrl', 'next', 'params');
var done = restore(out, req, 'baseUrl', 'next', 'params');
// setup next layer
req.next = next;
@@ -306,11 +316,10 @@ proto.handle = function(req, res, done) {
/**
* Process any parameters for the layer.
*
* @api private
* @private
*/
proto.process_params = function(layer, called, req, res, done) {
proto.process_params = function process_params(layer, called, req, res, done) {
var params = this.params;
// captured parameters from the layer, keys and values
@@ -357,7 +366,8 @@ proto.process_params = function(layer, called, req, res, done) {
}
// param previously called with same value or error occurred
if (paramCalled && (paramCalled.error || paramCalled.match === paramVal)) {
if (paramCalled && (paramCalled.match === paramVal
|| (paramCalled.error && paramCalled.error !== 'route'))) {
// restore value
req.params[name] = paramCalled.value;
@@ -412,7 +422,7 @@ proto.process_params = function(layer, called, req, res, done) {
* handlers can operate without any code changes regardless of the "prefix"
* pathname.
*
* @api public
* @public
*/
proto.use = function use(fn) {
@@ -435,13 +445,15 @@ proto.use = function use(fn) {
}
}
var callbacks = utils.flatten(slice.call(arguments, offset));
var callbacks = flatten(slice.call(arguments, offset));
if (callbacks.length === 0) {
throw new TypeError('Router.use() requires middleware functions');
}
callbacks.forEach(function (fn) {
for (var i = 0; i < callbacks.length; i++) {
var fn = callbacks[i];
if (typeof fn !== 'function') {
throw new TypeError('Router.use() requires middleware function but got a ' + gettype(fn));
}
@@ -458,7 +470,7 @@ proto.use = function use(fn) {
layer.route = undefined;
this.stack.push(layer);
}, this);
}
return this;
};
@@ -473,10 +485,10 @@ proto.use = function use(fn) {
*
* @param {String} path
* @return {Route}
* @api public
* @public
*/
proto.route = function(path){
proto.route = function route(path) {
var route = new Route(path);
var layer = new Layer(path, {
@@ -566,9 +578,12 @@ function mergeParams(params, parent) {
var o = 0;
// determine numeric gaps
while (i === o || o in parent) {
if (i in params) i++;
if (o in parent) o++;
while (i in params) {
i++;
}
while (o in parent) {
o++;
}
// offset numeric indices in params before merge
@@ -581,7 +596,7 @@ function mergeParams(params, parent) {
}
}
return mixin(parent, params);
return mixin(obj, params);
}
// restore obj props after function