got subdomain support to work
This commit is contained in:
parent
20b599680d
commit
f00edf73dd
|
@ -285,6 +285,9 @@ exports.read = function(req, res) {
|
|||
var newForm = req.form.toJSON({virtuals : true});
|
||||
newForm.plugins.oscarhost.settings.validUpdateTypes = validUpdateTypes;
|
||||
|
||||
if(newForm){
|
||||
return res.json(newForm);
|
||||
}
|
||||
|
||||
if (req.userId) {
|
||||
if(req.form.admin._id+'' === req.userId+''){
|
||||
|
@ -293,11 +296,13 @@ exports.read = function(req, res) {
|
|||
return res.status(404).send({
|
||||
message: 'Form Does Not Exist'
|
||||
});
|
||||
}else {
|
||||
if(newForm) return res.json(newForm);
|
||||
}
|
||||
|
||||
return res.status(404).send({
|
||||
/*return res.status(404).send({
|
||||
message: 'Form Does Not Exist'
|
||||
});
|
||||
});*/
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -54,12 +54,10 @@ var VisitorDataSchema = new Schema({
|
|||
type: Schema.Types.ObjectId
|
||||
},
|
||||
timeElapsed: {
|
||||
type: Number,
|
||||
required: true
|
||||
type: Number
|
||||
},
|
||||
isSubmitted: {
|
||||
type: Boolean,
|
||||
required: true
|
||||
type: Boolean
|
||||
},
|
||||
language: {
|
||||
type: String
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
var forms = require('../../app/controllers/forms.server.controller');
|
||||
var forms = require('../../app/controllers/forms.server.controller'),
|
||||
core = require('../../app/controllers/core.server.controller');
|
||||
|
||||
module.exports = function(app) {
|
||||
// Root routing
|
||||
var core = require('../../app/controllers/core.server.controller');
|
||||
app.route('/').get(core.index);
|
||||
app.route('/subdomain/([a-zA-Z0-9]+)/').get(core.form);
|
||||
app.route('/subdomain/*/forms/:formId([a-zA-Z0-9]+)')
|
||||
|
|
17
config/env/all.js
vendored
17
config/env/all.js
vendored
|
@ -7,8 +7,8 @@ module.exports = {
|
|||
description: process.env.APP_DESC || 'Opensource form builder alternative to TypeForm',
|
||||
keywords: process.env.APP_KEYWORDS || 'typeform, pdfs, forms, opensource, formbuilder, google forms, nodejs'
|
||||
},
|
||||
port: process.env.PORT || 5000,
|
||||
socketPort: process.env.SOCKET_PORT || 35729,
|
||||
port: process.env.PORT || 3000,
|
||||
socketPort: process.env.SOCKET_PORT || 20523,
|
||||
|
||||
templateEngine: 'swig',
|
||||
|
||||
|
@ -94,15 +94,10 @@ module.exports = {
|
|||
'public/config.js',
|
||||
'public/application.js',
|
||||
'public/dist/populate_template_cache.js',
|
||||
'public/form_modules/*/*.js',
|
||||
'public/form_modules/*/*/*/*/*.js',
|
||||
'public/form_modules/*/*/*.js',
|
||||
'public/form_modules/*/*/*/*.js',
|
||||
'!public/form_modules/**/gruntfile.js',
|
||||
'!public/form_modules/**/demo/**/*.js',
|
||||
'!public/form_modules/**/dist/**/*.js',
|
||||
'!public/form_modules/**/node_modules/**/*.js',
|
||||
'!public/form_modules/**/tests/**/*.js'
|
||||
'public/form_modules/forms/*.js',
|
||||
'public/form_modules/forms/*/*/*/*.js',
|
||||
'public/form_modules/forms/*/*.js',
|
||||
'public/form_modules/forms/*/*/*.js'
|
||||
],
|
||||
views: [
|
||||
'public/modules/**/*.html',
|
||||
|
|
|
@ -74,12 +74,17 @@ module.exports = function(db) {
|
|||
var subdomains = req.subdomains;
|
||||
var host = req.hostname;
|
||||
|
||||
|
||||
// remove www if chosen to ignore
|
||||
if (ignoreWWW) {
|
||||
var wwwi = subdomains.indexOf('www');
|
||||
if (wwwi >= 0) subdomains.splice(wwwi, 1);
|
||||
}
|
||||
|
||||
if(subdomains.slice(0, 4).join('.')+'' === '1.0.0.127'){
|
||||
subdomains = subdomains.slice(4);
|
||||
}
|
||||
|
||||
// continue if no subdomains
|
||||
if (!subdomains.length) return next();
|
||||
|
||||
|
@ -87,7 +92,7 @@ module.exports = function(db) {
|
|||
if(url.parse(req.url).path.split('/')[1] === ignoreWithStartPath) return next();
|
||||
}
|
||||
|
||||
User.findOne({username: req.subdomains[0]}).exec(function (err, user) {
|
||||
User.findOne({username: req.subdomains.reverse()[0]}).exec(function (err, user) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
req.subdomains = null;
|
||||
|
|
|
@ -87,7 +87,8 @@
|
|||
"soap": "^0.11.0",
|
||||
"socket.io": "^1.4.6",
|
||||
"socket.io-redis": "^1.0.0",
|
||||
"swig": "~1.4.1"
|
||||
"swig": "~1.4.1",
|
||||
"wildcard-subdomains": "github:whitef0x0/wildcard-subdomains"
|
||||
},
|
||||
"devDependencies": {
|
||||
"coveralls": "^2.11.4",
|
||||
|
|
601
public/dist/application.js
vendored
601
public/dist/application.js
vendored
File diff suppressed because one or more lines are too long
10
public/dist/application.min.js
vendored
10
public/dist/application.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -55,7 +55,7 @@ angular.module(ApplicationConfiguration.applicationModuleName).run(['$rootScope'
|
|||
authenticator = new Authorizer(user);
|
||||
//console.log('access denied: '+!authenticator.canAccess(permissions));
|
||||
//console.log(permissions);
|
||||
if( (permissions != null) ){
|
||||
if( (permissions !== null) ){
|
||||
if( !authenticator.canAccess(permissions) ){
|
||||
event.preventDefault();
|
||||
//console.log('access denied');
|
||||
|
|
|
@ -11,6 +11,8 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope
|
|||
|
||||
CurrentForm.setForm($scope.myform);
|
||||
|
||||
$scope.formURL = $scope.myform.admin.username + '.' + window.location.host;
|
||||
|
||||
$scope.tabData = [
|
||||
{
|
||||
heading: $filter('translate')('CREATE_TAB'),
|
||||
|
|
|
@ -63,7 +63,7 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope',
|
|||
completion: 0,
|
||||
average_time: 0,
|
||||
total_time: 0
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var stats = {
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
</div>
|
||||
<div class="col-xs-1 col-sm-2">
|
||||
<small class="pull-right">
|
||||
<a class="btn btn-default view-form-btn" href="/#!/forms/{{myform._id}}">
|
||||
<a class="btn btn-default view-form-btn" href="//{{formURL}}/#!/forms/{{myform._id}}">
|
||||
<span class="hidden-xs hidden-sm">
|
||||
{{ 'VIEW' | translate }}
|
||||
<span ng-show="myform.isLive">
|
||||
|
|
|
@ -9,22 +9,7 @@ angular.module('forms').config(['$stateProvider',
|
|||
state('listForms', {
|
||||
url: '/forms',
|
||||
templateUrl: 'modules/forms/admin/views/list-forms.client.view.html'
|
||||
}).
|
||||
state('submitForm', {
|
||||
url: '/forms/:formId',
|
||||
templateUrl: 'modules/forms/base/views/submit-form.client.view.html',
|
||||
data: {
|
||||
hideNav: true
|
||||
},
|
||||
resolve: {
|
||||
Forms: 'Forms',
|
||||
myForm: function (Forms, $stateParams) {
|
||||
return Forms.get({formId: $stateParams.formId}).$promise;
|
||||
}
|
||||
},
|
||||
controller: 'SubmitFormController',
|
||||
controllerAs: 'ctrl'
|
||||
}).state('viewForm', {
|
||||
}).state('viewForm', {
|
||||
url: '/forms/:formId/admin',
|
||||
templateUrl: 'modules/forms/admin/views/admin-form.client.view.html',
|
||||
data: {
|
||||
|
|
Loading…
Reference in a new issue