diff --git a/app/controllers/forms.server.controller.js b/app/controllers/forms.server.controller.js index 10b44bfb..84bf3e1f 100644 --- a/app/controllers/forms.server.controller.js +++ b/app/controllers/forms.server.controller.js @@ -226,7 +226,6 @@ exports.read = function(req, res) { }); } return res.json(newForm); - }; /** diff --git a/app/routes/core.server.routes.js b/app/routes/core.server.routes.js index cfc01c94..166bfd03 100755 --- a/app/routes/core.server.routes.js +++ b/app/routes/core.server.routes.js @@ -7,11 +7,11 @@ var forms = require('../../app/controllers/forms.server.controller'), core = require('../../app/controllers/core.server.controller'); module.exports = function(app) { - // Root routing + // Core routing app.route('/').get(core.index); + app.route('/subdomain/api/').get(core.redoc); - app.route('/subdomain/^(?!api$)[A-Za-z0-9]*/').get(core.form); - app.route('/subdomain/^(?!api$)[A-Za-z0-9]*/forms/:formId([a-zA-Z0-9]+)') - .get(forms.read) + app.route('/subdomain/:userSlug((?!api$)[A-Za-z0-9]+)/').get(core.form); + app.route('/subdomain/:userSlug((?!api$)[A-Za-z0-9]+)/forms/:formId([a-zA-Z0-9]+)').get(forms.read) .post(forms.createSubmission); }; diff --git a/config/config.js b/config/config.js index 76186360..69daa792 100755 --- a/config/config.js +++ b/config/config.js @@ -31,7 +31,7 @@ if( fs.existsSync('./config/env/api_keys.js') ){ exports, require('./env/api_keys') ); -}else { +} else { module.exports = exports; } diff --git a/config/express.js b/config/express.js index 2aa46547..54c1670a 100755 --- a/config/express.js +++ b/config/express.js @@ -81,8 +81,14 @@ module.exports = function(db) { var urlPath = url.parse(req.url).path.split('/'); if(urlPath.indexOf('static') > -1){ + //console.log("STATIC FILE\n\n\n\n"); urlPath.splice(1,1); req.root = 'https://' + config.baseUrl + urlPath.join('/'); + console.log(req.root); + return next(); + } + + if(urlPath.indexOf('users') > -1 && urlPath.indexOf('me') > -1){ return next(); } @@ -105,8 +111,7 @@ module.exports = function(db) { } User.findOne({username: req.subdomains.reverse()[0]}).exec(function (err, user) { - console.log("user"); - console.log(user); + if (err) { console.log(err); req.subdomains = null; @@ -127,6 +132,7 @@ module.exports = function(db) { // TODO: check path and query strings are preserved // reassign url + console.log("path: "+path); req.url = path; req.userId = user._id; diff --git a/public/form_modules/forms/base/directives/field.client.directive.js b/public/form_modules/forms/base/directives/field.client.directive.js index 4b7dbae8..cca0b013 100644 --- a/public/form_modules/forms/base/directives/field.client.directive.js +++ b/public/form_modules/forms/base/directives/field.client.directive.js @@ -8,7 +8,7 @@ var __indexOf = [].indexOf || function(item) { return -1; }; -angular.module('forms').directive('fieldDirective', ['$http', '$compile', '$rootScope', '$templateCache', 'supportedFields', +angular.module('view-form').directive('fieldDirective', ['$http', '$compile', '$rootScope', '$templateCache', 'supportedFields', function($http, $compile, $rootScope, $templateCache, supportedFields) { var getTemplateUrl = function(fieldType) {