From e75bf50727b3ebdd142953c09117de38d3a5b174 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 10 Oct 2014 14:55:19 -0400 Subject: stuff date in url slugs --- server/lib/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server/lib/util.js') diff --git a/server/lib/util.js b/server/lib/util.js index 791d3e2..2841cc5 100644 --- a/server/lib/util.js +++ b/server/lib/util.js @@ -13,7 +13,7 @@ var util = {} util.trim = function (s){ return (s || "").replace(whitespaceHead,"").replace(whitespaceTail,"") } util.slugify = function (s){ - return (s || "").toLowerCase().replace(whitespace,"-").replace(nonAlphanumerics, '-').replace(consecutiveDashes,"-") + return (s + "-" + (+new Date) || "").toLowerCase().replace(whitespace,"-").replace(nonAlphanumerics, '-').replace(consecutiveDashes,"-") } util.sanitize = function (s){ return (s || "").replace(entities, "") -- cgit v1.2.3-70-g09d2 From e35d5df30c8106bc1f4bfcbd1ba0094d8e6bc642 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 10 Oct 2014 15:59:50 -0400 Subject: change profile avatar --- public/assets/javascripts/ui/site/ProfileView.js | 19 +++++++++++++++++++ public/assets/stylesheets/app.css | 1 + server/lib/api/projects.js | 4 ++-- server/lib/util.js | 2 +- server/lib/views/index.js | 1 + views/profile.ejs | 8 ++++++-- views/projects/list-projects.ejs | 4 ++-- 7 files changed, 32 insertions(+), 7 deletions(-) (limited to 'server/lib/util.js') diff --git a/public/assets/javascripts/ui/site/ProfileView.js b/public/assets/javascripts/ui/site/ProfileView.js index 76d733c..8471abc 100644 --- a/public/assets/javascripts/ui/site/ProfileView.js +++ b/public/assets/javascripts/ui/site/ProfileView.js @@ -21,6 +21,25 @@ var ProfileView = View.extend({ }, uploadAvatar: function(){ + var fd = new FormData(), hasCSRF = false + var files = this.$("#profile_avatar")[0].files + if (! files.length) return + + fd.append("avatar", files[0]); + fd.append("_csrf", $("[name=_csrf]").val()) + + var request = $.ajax({ + url: "/api/profile", + type: "put", + data: fd, + dataType: "json", + processData: false, + contentType: false, + }) + + request.done($.proxy(function (response) { + window.location.href = "/profile" + }, this)); } }) diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css index 57cb8fc..29f7888 100755 --- a/public/assets/stylesheets/app.css +++ b/public/assets/stylesheets/app.css @@ -679,6 +679,7 @@ iframe.embed { } .profilepage .about h2 .btn { + float: none; border: 1px solid; font-weight: 500; padding: 10px; diff --git a/server/lib/api/projects.js b/server/lib/api/projects.js index 5bd3d0f..c04f4f6 100644 --- a/server/lib/api/projects.js +++ b/server/lib/api/projects.js @@ -34,7 +34,7 @@ var projects = { data.user_id = req.user._id data.name = util.sanitize(data.name) - data.slug = util.slugify(data.name) + data.slug = util.slugify(data.name) + "-" + (+new Date) data.description = util.sanitize(data.description) data.rooms = JSON.parse(data.rooms) data.walls = JSON.parse(data.walls) @@ -91,7 +91,7 @@ var projects = { // data.user_id = req.user._id data.name = util.sanitize(data.name) if (data.name != doc.name) { - data.slug = util.slugify(data.name) + data.slug = util.slugify(data.name) + "-" + (+new Date) } data.description = util.sanitize(data.description) data.updated_at = new Date () diff --git a/server/lib/util.js b/server/lib/util.js index 2841cc5..791d3e2 100644 --- a/server/lib/util.js +++ b/server/lib/util.js @@ -13,7 +13,7 @@ var util = {} util.trim = function (s){ return (s || "").replace(whitespaceHead,"").replace(whitespaceTail,"") } util.slugify = function (s){ - return (s + "-" + (+new Date) || "").toLowerCase().replace(whitespace,"-").replace(nonAlphanumerics, '-').replace(consecutiveDashes,"-") + return (s || "").toLowerCase().replace(whitespace,"-").replace(nonAlphanumerics, '-').replace(consecutiveDashes,"-") } util.sanitize = function (s){ return (s || "").replace(entities, "") diff --git a/server/lib/views/index.js b/server/lib/views/index.js index 637b061..5b1a72e 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -165,6 +165,7 @@ var views = module.exports = { function done(err, user, projects){ if (! user) { return res.redirect('/') } res.render('profile', { + isOwnProfile: String(user._id) == (req.user && String(req.user._id)), profile: user, projects: projects || [], }) diff --git a/views/profile.ejs b/views/profile.ejs index 5ff2eb0..2909fb8 100644 --- a/views/profile.ejs +++ b/views/profile.ejs @@ -16,8 +16,10 @@
-
click to add profile pic
- + [[ if (isOwnProfile) { ]] +
click to add profile pic
+ + [[ } ]]
[[ } ]] @@ -57,12 +59,14 @@ VValls lets you create awesome 3D rooms. + [[ if (isOwnProfile) { ]]

You don't have any projects yet.

Create a New Project

+ [[ } ]] [[ } ]] diff --git a/views/projects/list-projects.ejs b/views/projects/list-projects.ejs index c47dee0..9dbd7d2 100644 --- a/views/projects/list-projects.ejs +++ b/views/projects/list-projects.ejs @@ -5,9 +5,9 @@ [[ projects.forEach(function(project, i) { ]] [[ if (String(user._id) == String(project.user_id)) { ]] - + [[ } else { ]] - + [[ } ]] -- cgit v1.2.3-70-g09d2 From 28ade7d7f9e1c8e35de713a04303538140e22ea9 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 13 Nov 2014 12:00:59 -0500 Subject: use plain html and \n ->
formatting on docs --- public/assets/stylesheets/app.css | 8 +++++++- server/lib/util.js | 4 +++- server/lib/views/index.js | 2 +- views/docs.ejs | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) (limited to 'server/lib/util.js') diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css index 7b53cca..48c6e97 100755 --- a/public/assets/stylesheets/app.css +++ b/public/assets/stylesheets/app.css @@ -633,7 +633,7 @@ iframe.embed { border-top:1px solid black; } -.footer a, .footer span{ +.footer a, .footer span { margin: 15px; font-weight: 300; font-size: 13px; @@ -643,6 +643,12 @@ iframe.embed { text-decoration:underline; } +.docs .content.doc-privacy p, +.docs .content.doc-terms p { + font-size: 15px; + line-height: 25px; + font-weight: 300; +} /* PROFILE PAGE */ .profilePic { diff --git a/server/lib/util.js b/server/lib/util.js index 791d3e2..0a71cb7 100644 --- a/server/lib/util.js +++ b/server/lib/util.js @@ -30,7 +30,9 @@ util.capitalizeWord = function (s) { util.escapeRegExp = function (s) { return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&") } - +util.htmlize = function(s) { + return ("

" + s.replace(/\n/g,"

") + "

").replace(/

<\/p>/, "
") +} util.cleanQuery = function (query) { var update = _.extend({}, query); diff --git a/server/lib/views/index.js b/server/lib/views/index.js index 6e3b449..b3a15c2 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -130,7 +130,7 @@ var views = module.exports = { } res.render('docs', { doc: doc, - content: marked(doc.body), + content: util.htmlize(doc.body), isNew: false }) }) diff --git a/views/docs.ejs b/views/docs.ejs index 741cff7..b3ead82 100644 --- a/views/docs.ejs +++ b/views/docs.ejs @@ -11,7 +11,7 @@ [[ if (! isNew) { ]]

[[- doc.displayName ]]

-
+
[[- content ]]
-- cgit v1.2.3-70-g09d2 From 9ef3f0ec50c965396a2271182dd27dc5b6539081 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 13 Nov 2014 12:21:23 -0500 Subject: correct style Vvalls -> VValls everywhere --- public/assets/stylesheets/app.css | 5 ++--- server/lib/auth/mail.js | 4 ++-- server/lib/middleware.js | 4 ++-- server/lib/util.js | 2 +- server/lib/views/index.js | 2 +- views/controls/editor/collaborators.ejs | 2 +- views/controls/reader/embed.ejs | 2 +- views/mail/collaborator.html.ejs | 2 +- views/mail/collaborator.text.ejs | 2 +- views/mail/welcome.html.ejs | 2 +- views/mail/welcome.text.ejs | 2 +- views/partials/meta.ejs | 2 +- 12 files changed, 15 insertions(+), 16 deletions(-) (limited to 'server/lib/util.js') diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css index 48c6e97..57c7197 100755 --- a/public/assets/stylesheets/app.css +++ b/public/assets/stylesheets/app.css @@ -596,7 +596,6 @@ iframe.embed { border-top: 0px solid; font-weight: 500; font-size: 40px; - text-transform:capitalize; } .docs .content img { max-width: 90%; @@ -643,8 +642,8 @@ iframe.embed { text-decoration:underline; } -.docs .content.doc-privacy p, -.docs .content.doc-terms p { +.docs .content.doc-privacy, +.docs .content.doc-terms { font-size: 15px; line-height: 25px; font-weight: 300; diff --git a/server/lib/auth/mail.js b/server/lib/auth/mail.js index 0ba6d5d..eac4007 100644 --- a/server/lib/auth/mail.js +++ b/server/lib/auth/mail.js @@ -6,7 +6,7 @@ var email = require("emailjs"), var mail = { - from: 'Vvalls ', + from: 'VValls ', templates: {}, init: function(){ @@ -40,7 +40,7 @@ var mail = { text: mail.templates.welcome.text(user), from: mail.from, to: user.email, - subject: "Welcome to Vvalls", + subject: "Welcome to VValls", attachment: [ { data: mail.templates.welcome.html(user), alternative: true }, ] diff --git a/server/lib/middleware.js b/server/lib/middleware.js index 870451a..60f2e46 100644 --- a/server/lib/middleware.js +++ b/server/lib/middleware.js @@ -41,10 +41,10 @@ var middleware = { res.locals.config = config res.locals.profile = null res.locals.ogImage = "" - res.locals.ogTitle = "Vvalls" + res.locals.ogTitle = "VValls" res.locals.ogUrl = "http://vvalls.com/" res.locals.ogDescription = "3D gallery space, fully customizable" - res.locals.ogAuthor = "Vvalls" + res.locals.ogAuthor = "VValls" res.locals.opt = {} next() }, diff --git a/server/lib/util.js b/server/lib/util.js index 0a71cb7..1f63a30 100644 --- a/server/lib/util.js +++ b/server/lib/util.js @@ -31,7 +31,7 @@ util.escapeRegExp = function (s) { return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&") } util.htmlize = function(s) { - return ("

" + s.replace(/\n/g,"

") + "

").replace(/

<\/p>/, "
") + return s.replace(/\n/g,"
") } util.cleanQuery = function (query) { diff --git a/server/lib/views/index.js b/server/lib/views/index.js index b3a15c2..31cb1db 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -169,7 +169,7 @@ var views = module.exports = { isOwnProfile: isOwnProfile, profile: user, projects: projects || [], - ogTitle: "Vvalls: Profile of " + user.displayName, + ogTitle: "VValls: Profile of " + user.displayName, ogUrl: "http://vvalls.com/profile/" + user.username + "/", ogImage: user.photo, }) diff --git a/views/controls/editor/collaborators.ejs b/views/controls/editor/collaborators.ejs index 8ad8c00..5de7d25 100644 --- a/views/controls/editor/collaborators.ejs +++ b/views/controls/editor/collaborators.ejs @@ -7,7 +7,7 @@

Collaborators

- To invite others to contribute to this project, submit their email address below. They'll receive an email with instructions to join this project and register if they're not a Vvalls user yet. + To invite others to contribute to this project, submit their email address below. They'll receive an email with instructions to join this project and register if they're not a VValls user yet.

diff --git a/views/controls/reader/embed.ejs b/views/controls/reader/embed.ejs index cc21c74..814644d 100644 --- a/views/controls/reader/embed.ejs +++ b/views/controls/reader/embed.ejs @@ -4,7 +4,7 @@
-

Embed Vvalls

+

Embed VValls

This code generates an iframe which will embed this room in your website or blog. diff --git a/views/mail/collaborator.html.ejs b/views/mail/collaborator.html.ejs index 2a08a1c..c4832d1 100644 --- a/views/mail/collaborator.html.ejs +++ b/views/mail/collaborator.html.ejs @@ -7,7 +7,7 @@

[[- username ]] has invited you to join the project - [[- projectName ]] on Vvalls. + [[- projectName ]] on VValls.

diff --git a/views/mail/collaborator.text.ejs b/views/mail/collaborator.text.ejs index 52d39b6..2de78ad 100644 --- a/views/mail/collaborator.text.ejs +++ b/views/mail/collaborator.text.ejs @@ -1,5 +1,5 @@ -[[- username ]] has invited you to join the project [[- projectName ]] on Vvalls. +[[- username ]] has invited you to join the project [[- projectName ]] on VValls. Accept the invitation below: diff --git a/views/mail/welcome.html.ejs b/views/mail/welcome.html.ejs index b2c329f..1d45faf 100644 --- a/views/mail/welcome.html.ejs +++ b/views/mail/welcome.html.ejs @@ -6,7 +6,7 @@

- Welcome to Vvalls, [[- username ]] + Welcome to VValls, [[- username ]]

diff --git a/views/mail/welcome.text.ejs b/views/mail/welcome.text.ejs index 02b449b..5c0b51d 100644 --- a/views/mail/welcome.text.ejs +++ b/views/mail/welcome.text.ejs @@ -1,4 +1,4 @@ -Welcome to Vvalls, [[- username ]] +Welcome to VValls, [[- username ]] http://www.vvalls.com diff --git a/views/partials/meta.ejs b/views/partials/meta.ejs index f1b6f48..defb187 100644 --- a/views/partials/meta.ejs +++ b/views/partials/meta.ejs @@ -25,7 +25,7 @@ - + -- cgit v1.2.3-70-g09d2 From 9d5c4dcc8e45e96ee9a976ca337a9d389750fb8a Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 24 Nov 2014 17:10:03 -0500 Subject: sanity check --- server/lib/util.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'server/lib/util.js') diff --git a/server/lib/util.js b/server/lib/util.js index 1f63a30..273d7d1 100644 --- a/server/lib/util.js +++ b/server/lib/util.js @@ -45,7 +45,9 @@ util.cleanQuery = function (query) { } util.ip2num = function(dot) { - var d = dot.split('.'); + console.log(dot); + + var d = (dot || "127.0.0.1").split('.'); return ((((((+d[0])*256)+(+d[1]))*256)+(+d[2]))*256)+(+d[3]); } -- cgit v1.2.3-70-g09d2 From f9be43e4cce6b57f41a4e2242f019e969b081d37 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 1 Dec 2014 12:43:28 -0500 Subject: view project button in settings --- public/assets/javascripts/ui/editor/EditorSettings.js | 15 +++++++++++++++ server/lib/util.js | 10 +++------- views/controls/editor/settings.ejs | 6 ++++++ 3 files changed, 24 insertions(+), 7 deletions(-) (limited to 'server/lib/util.js') diff --git a/public/assets/javascripts/ui/editor/EditorSettings.js b/public/assets/javascripts/ui/editor/EditorSettings.js index 026607a..b319404 100644 --- a/public/assets/javascripts/ui/editor/EditorSettings.js +++ b/public/assets/javascripts/ui/editor/EditorSettings.js @@ -18,6 +18,7 @@ var EditorSettings = FormView.extend({ "click [data-role='clear-project']": 'clear', "click [data-role='destroy-project']": 'destroy', "click [data-role='toggle-map']": 'toggleMap', + "click [data-role='view-project']": 'viewProject', "click #startText": "setStartPosition", "click #moveText": "confirmStartPosition", "click #confirmText": "setStartPosition", @@ -217,11 +218,25 @@ var EditorSettings = FormView.extend({ this.isVisible = true }, + viewAfterSave: false, + viewProject: function(e){ + e.preventDefault() + Minotaur.unwatch(this) + Minotaur.hide() + this.viewAfterSave = true + this.save() + }, + success: function(data){ this.$id.val(data._id) this.$name.val(data.name) this.action = this.updateAction + if (this.viewAfterSave) { + window.location.pathname = "/project/" + data.slug + return + } + Minotaur.unwatch(this) Minotaur.hide() diff --git a/server/lib/util.js b/server/lib/util.js index 273d7d1..e3fd1ed 100644 --- a/server/lib/util.js +++ b/server/lib/util.js @@ -10,8 +10,9 @@ var entities = new RegExp("[<>&]", 'g') var util = {} -util.trim = function (s){ return (s || "").replace(whitespaceHead,"").replace(whitespaceTail,"") } - +util.trim = function (s){ + return (s || "").replace(whitespaceHead,"").replace(whitespaceTail,"") +} util.slugify = function (s){ return (s || "").toLowerCase().replace(whitespace,"-").replace(nonAlphanumerics, '-').replace(consecutiveDashes,"-") } @@ -33,7 +34,6 @@ util.escapeRegExp = function (s) { util.htmlize = function(s) { return s.replace(/\n/g,"
") } - util.cleanQuery = function (query) { var update = _.extend({}, query); delete update._id; @@ -43,14 +43,10 @@ util.cleanQuery = function (query) { delete update.created_by; return update; } - util.ip2num = function(dot) { - console.log(dot); - var d = (dot || "127.0.0.1").split('.'); return ((((((+d[0])*256)+(+d[1]))*256)+(+d[2]))*256)+(+d[3]); } - util.num2ip = function(num) { if (! num) return "" var d = num % 256; diff --git a/views/controls/editor/settings.ejs b/views/controls/editor/settings.ejs index cd17382..cd915c5 100644 --- a/views/controls/editor/settings.ejs +++ b/views/controls/editor/settings.ejs @@ -27,6 +27,12 @@ Edit map + + + + View project + +

-- cgit v1.2.3-70-g09d2 From 630c08b712a2ace833217428f1ef20bddc0b975d Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 25 Aug 2015 18:32:14 -0400 Subject: blueprint integration into project editor --- .../javascripts/rectangles/engine/rooms/_rooms.js | 32 +++++++++ public/assets/javascripts/ui/_router.js | 75 +++++++++++++--------- .../javascripts/ui/blueprint/BlueprintSettings.js | 3 + .../javascripts/ui/blueprint/BlueprintView.js | 2 +- .../assets/javascripts/ui/builder/BuilderInfo.js | 4 +- .../assets/javascripts/ui/editor/EditorSettings.js | 7 +- public/assets/javascripts/ui/editor/EditorView.js | 5 ++ server/lib/api/blueprint.js | 3 + server/lib/api/projects.js | 14 +++- server/lib/schemas/Blueprint.js | 1 + server/lib/schemas/Project.js | 2 + server/lib/util.js | 4 ++ 12 files changed, 117 insertions(+), 35 deletions(-) (limited to 'server/lib/util.js') diff --git a/public/assets/javascripts/rectangles/engine/rooms/_rooms.js b/public/assets/javascripts/rectangles/engine/rooms/_rooms.js index 46c1d7f..d4281ad 100644 --- a/public/assets/javascripts/rectangles/engine/rooms/_rooms.js +++ b/public/assets/javascripts/rectangles/engine/rooms/_rooms.js @@ -37,6 +37,7 @@ base.list = {} base.regions = [] + base.shapesMode = false base.uid = new UidGenerator(base.list) @@ -95,6 +96,7 @@ } base.rebuild = function(walls_data){ + if (base.shapesMode) return walls_data = walls_data || Walls.serialize() Rooms.clipper.update() Rooms.builder.rebuild() @@ -124,6 +126,36 @@ }) Rooms.rebuild(walls_data) } + + base.deserializeFromShapes = function(shapes_data, walls_data) { + base.shapesMode = true + window.viewHeight = data.viewHeight || app.defaults.viewHeight + window.wallHeight = data.wallHeight || app.defaults.wallHeight + $(".units").val( data.units ) + + shapes.deserialize( data.shapes ) + shapes.build() + + regions.forEach(function(region){ + var room = new Room({ + rect: region, + regions: [region], + height: wallHeight, + }) + room.sides = region.sides + region.id = Rooms.uid("room_") + Rooms.list[ region.id ] = room + Rooms.builder.build(region) + room.mx_floor = Rooms.builder.make_floor(room, region) + room.mx_ceiling = Rooms.builder.make_ceiling(room, region) + }) + + Rooms.grouper.build() + + Walls.paint() + Walls.deserialize(walls_data) + app.tube("rooms-built") + } base.report = function(){ var data = [] diff --git a/public/assets/javascripts/ui/_router.js b/public/assets/javascripts/ui/_router.js index e5e46e5..61b1d1b 100644 --- a/public/assets/javascripts/ui/_router.js +++ b/public/assets/javascripts/ui/_router.js @@ -18,35 +18,36 @@ var SiteRouter = Router.extend({ }, routes: { - "/": 'home', - "/home": 'home', - "/login": 'signin', - "/signin": 'signin', - "/signup": 'signup', - - "/auth/usernameTaken": 'usernameTaken', - "/auth/password": 'passwordReset', - "/auth/forgotPassword": 'passwordForgot', - - "/profile": 'profile', - "/profile/edit": 'editProfile', - "/profile/billing": 'editSubscription', - "/profile/:name": 'profile', - "/about/:name/edit": 'editDocument', - "/about/new": 'newDocument', - - "/layout": 'layoutPicker', - "/layout/:name": 'layoutEditor', - - "/blueprint": 'blueprintEditor', - "/blueprint/:name": 'blueprintEditor', - - "/project": 'projectPicker', - "/project/new": 'newProject', - "/project/new/:layout": 'projectNewWithLayout', - "/project/:name": 'projectViewer', - "/project/:name/edit": 'projectEditor', - "/project/:name/view": 'projectViewer', + "/": 'home', + "/home": 'home', + "/login": 'signin', + "/signin": 'signin', + "/signup": 'signup', + + "/auth/usernameTaken": 'usernameTaken', + "/auth/password": 'passwordReset', + "/auth/forgotPassword": 'passwordForgot', + + "/profile": 'profile', + "/profile/edit": 'editProfile', + "/profile/billing": 'editSubscription', + "/profile/:name": 'profile', + "/about/:name/edit": 'editDocument', + "/about/new": 'newDocument', + + "/layout": 'layoutPicker', + "/layout/:name": 'layoutEditor', + + "/blueprint": 'blueprintEditor', + "/blueprint/:name": 'blueprintEditor', + + "/project": 'projectPicker', + "/project/new": 'newProject', + "/project/blueprint/:blueprint": 'projectNewWithBlueprint', + "/project/new/:layout": 'projectNewWithLayout', + "/project/:name": 'projectViewer', + "/project/:name/edit": 'projectEditor', + "/project/:name/view": 'projectViewer', "/test/blueprint": 'blueprintEditor', }, @@ -123,6 +124,22 @@ var SiteRouter = Router.extend({ window.history.pushState(null, document.title, "/project/new") this.newProjectModal.load() }, + + projectNewWithBlueprint: function(e, blueprint){ + e && e.preventDefault() + + Rooms.shapesMode = true + + app.mode.editor = true + app.launch() + if (app.unsupported) return + + blueprint = slugify(blueprint) + + window.history.pushState(null, document.title, "/project/blueprint/" + blueprint) + this.editorView = app.controller = new EditorView() + this.editorView.loadBlueprint(blueprint) + }, projectNewWithLayout: function(e, layout){ e && e.preventDefault() diff --git a/public/assets/javascripts/ui/blueprint/BlueprintSettings.js b/public/assets/javascripts/ui/blueprint/BlueprintSettings.js index 9c8808a..0870a11 100644 --- a/public/assets/javascripts/ui/blueprint/BlueprintSettings.js +++ b/public/assets/javascripts/ui/blueprint/BlueprintSettings.js @@ -95,6 +95,9 @@ var BlueprintSettings = FormView.extend(ToggleableView.prototype).extend({ fd.append( "name", this.$name.val() ) fd.append( "shapes", JSON.stringify( shapes.serialize() ) ) fd.append( "startPosition", JSON.stringify( app.position(scene.camera) ) ) + fd.append( "wallHeight", this.parent.info.$height.unitVal() ) + fd.append( "units", this.parent.info.$units.val() ) + return fd }, diff --git a/public/assets/javascripts/ui/blueprint/BlueprintView.js b/public/assets/javascripts/ui/blueprint/BlueprintView.js index e1d360f..3095cfe 100644 --- a/public/assets/javascripts/ui/blueprint/BlueprintView.js +++ b/public/assets/javascripts/ui/blueprint/BlueprintView.js @@ -48,8 +48,8 @@ var BlueprintView = View.extend({ }, ready: function(data){ - this.settings.load(data) this.info.load(data) + this.settings.load(data) this.editor.loadFloorplan(data) }, diff --git a/public/assets/javascripts/ui/builder/BuilderInfo.js b/public/assets/javascripts/ui/builder/BuilderInfo.js index 9a7dbf9..aa58d6e 100644 --- a/public/assets/javascripts/ui/builder/BuilderInfo.js +++ b/public/assets/javascripts/ui/builder/BuilderInfo.js @@ -40,8 +40,8 @@ var BuilderInfo = View.extend({ load: function(data){ this.$viewHeight.unitVal( window.viewHeight = data.viewHeight || app.defaults.viewHeight ) - this.$units.val( "ft" ) - this.$unitName.html( "ft" ) + this.$units.val( data.units || "ft" ) + this.$unitName.html( data.units || "ft" ) if (Rooms.regions.length == 0) { this.changeHeightGlobal(true) diff --git a/public/assets/javascripts/ui/editor/EditorSettings.js b/public/assets/javascripts/ui/editor/EditorSettings.js index 460863e..000852e 100644 --- a/public/assets/javascripts/ui/editor/EditorSettings.js +++ b/public/assets/javascripts/ui/editor/EditorSettings.js @@ -41,7 +41,12 @@ var EditorSettings = FormView.extend({ this.action = data.isNew ? this.createAction : this.updateAction this.parent.data = data - data.rooms && Rooms.deserialize(data.rooms, data.walls) + if (data.rooms) { + Rooms.deserialize(data.rooms, data.walls) + } + else if (data.shapes) { + Rooms.deserializeFromShapes(data.shapes, data.walls) + } if (data.startPosition) { scene.camera.move(data.startPosition) this.startPosition = data.startPosition diff --git a/public/assets/javascripts/ui/editor/EditorView.js b/public/assets/javascripts/ui/editor/EditorView.js index a2d84a6..879c963 100644 --- a/public/assets/javascripts/ui/editor/EditorView.js +++ b/public/assets/javascripts/ui/editor/EditorView.js @@ -2,6 +2,7 @@ var EditorView = View.extend({ el: "#editorView", + blueprintAction: "/api/blueprint/", projectAction: "/api/project/", layoutAction: "/api/layout/", @@ -41,6 +42,10 @@ var EditorView = View.extend({ $.get(this.layoutAction + layout, this.readyLayout.bind(this)) }, + loadBlueprint: function(blueprint){ + $.get(this.blueprintAction + blueprint, this.readyLayout.bind(this)) + }, + ready: function(data){ $("#map").hide() 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, "&").replace(//g, ">") } -- cgit v1.2.3-70-g09d2