summaryrefslogtreecommitdiff
path: root/server/lib
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-08-25 18:32:14 -0400
committerJules Laplace <jules@okfoc.us>2015-08-25 18:32:14 -0400
commit630c08b712a2ace833217428f1ef20bddc0b975d (patch)
tree196f58ec99ace6e348148b6d5bc0408a11319fae /server/lib
parenta9bf197a6e8f91cc91d772238168d9be1beb3c4d (diff)
blueprint integration into project editor
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/api/blueprint.js3
-rw-r--r--server/lib/api/projects.js14
-rw-r--r--server/lib/schemas/Blueprint.js1
-rw-r--r--server/lib/schemas/Project.js2
-rw-r--r--server/lib/util.js4
5 files changed, 22 insertions, 2 deletions
diff --git a/server/lib/api/blueprint.js b/server/lib/api/blueprint.js
index e581d8f..222b466 100644
--- a/server/lib/api/blueprint.js
+++ b/server/lib/api/blueprint.js
@@ -92,6 +92,9 @@ var blueprint = {
doc.name = util.sanitize(data.name)
doc.slug = util.slugify(data.name)
+ doc.units = util.sanitize(data.units)
+ doc.viewHeight = util.sanitizeNumber(data.viewHeight)
+ doc.wallHeight = util.sanitizeNumber(data.wallHeight)
doc.shapes = JSON.parse(data.shapes)
doc.startPosition = JSON.parse(data.startPosition)
diff --git a/server/lib/api/projects.js b/server/lib/api/projects.js
index 3810168..50d3b49 100644
--- a/server/lib/api/projects.js
+++ b/server/lib/api/projects.js
@@ -37,7 +37,12 @@ var projects = {
data.slug = util.slugify(data.name) + "-" + (+new Date)
data.description = util.sanitize(data.description)
data.viewHeight = Number(data.viewHeight || 0)
- data.rooms = JSON.parse(data.rooms)
+ if (data.shapes) {
+ data.shapes = JSON.parse(data.shapes)
+ }
+ else {
+ data.rooms = JSON.parse(data.rooms)
+ }
data.walls = JSON.parse(data.walls)
data.media = JSON.parse(data.media)
data.sculpture = JSON.parse(data.sculpture)
@@ -102,7 +107,12 @@ var projects = {
_.extend(doc, data)
- doc.rooms = JSON.parse(data.rooms)
+ if (data.shapes) {
+ doc.shapes = JSON.parse(data.shapes)
+ }
+ else {
+ doc.rooms = JSON.parse(data.rooms)
+ }
doc.walls = JSON.parse(data.walls)
doc.colors = JSON.parse(data.colors)
doc.media = JSON.parse(data.media)
diff --git a/server/lib/schemas/Blueprint.js b/server/lib/schemas/Blueprint.js
index 76d0a09..3c3b0cc 100644
--- a/server/lib/schemas/Blueprint.js
+++ b/server/lib/schemas/Blueprint.js
@@ -51,6 +51,7 @@ var BlueprintSchema = new mongoose.Schema({
widthDimension: { type: Number },
heightDimension: { type: Number },
+ wallHeight: { type: Number },
units: { type: String },
line: { type: String },
diff --git a/server/lib/schemas/Project.js b/server/lib/schemas/Project.js
index 855d95a..687555d 100644
--- a/server/lib/schemas/Project.js
+++ b/server/lib/schemas/Project.js
@@ -28,6 +28,7 @@ var ProjectSchema = new mongoose.Schema({
type: String,
},
rooms: [mongoose.Schema.Types.Mixed],
+ shapes: [mongoose.Schema.Types.Mixed],
walls: [mongoose.Schema.Types.Mixed],
media: [mongoose.Schema.Types.Mixed],
sculpture: [mongoose.Schema.Types.Mixed],
@@ -35,6 +36,7 @@ var ProjectSchema = new mongoose.Schema({
startPosition: mongoose.Schema.Types.Mixed,
lastPosition: mongoose.Schema.Types.Mixed,
viewHeight: { type: Number },
+ units: { type: String, default: "ft" },
user_id: { type: mongoose.Schema.ObjectId, index: true },
created_at: { type: Date },
updated_at: { type: Date },
diff --git a/server/lib/util.js b/server/lib/util.js
index e3fd1ed..86fbdcc 100644
--- a/server/lib/util.js
+++ b/server/lib/util.js
@@ -5,6 +5,7 @@ var whitespace = new RegExp('\\s', 'g')
var whitespaceHead = /^\s+/
var whitespaceTail = /\s+$/
var nonAlphanumerics = new RegExp('[^-_a-zA-Z0-9]', 'g')
+var nonNumerics = new RegExp('[^0-9]', 'g')
var consecutiveDashes = new RegExp("-+", 'g')
var entities = new RegExp("[<>&]", 'g')
@@ -19,6 +20,9 @@ util.slugify = function (s){
util.sanitize = function (s){
return (s || "").replace(entities, "")
}
+util.sanitizeNumber = function (s){
+ return (s || "").replace(nonNumerics, "")
+}
util.escape = function (s){
return (s || "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")
}