From ddac735a463278e245e566105ace3e32c723128c Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 1 Oct 2014 19:07:10 -0400 Subject: stubbing in text editor stuff --- server/lib/views/index.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'server/lib/views/index.js') diff --git a/server/lib/views/index.js b/server/lib/views/index.js index 29b84d8..ca48159 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -27,6 +27,7 @@ views.editor_new = function (req, res) { res.redirect('/') } else { + res.locals.opt.editing = true res.render('editor') } } @@ -36,6 +37,7 @@ views.editor = function (req, res) { res.redirect('/') } else if (req.isOwner || req.isCollaborator || req.isStaff) { + res.locals.opt.editing = true res.render('editor') } else { -- cgit v1.2.3-70-g09d2 From 583d213f22be93a1363c24ac2cdf9f083833703f Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 8 Oct 2014 14:47:47 -0400 Subject: projectList item formatting --- .../javascripts/rectangles/engine/map/draw.js | 19 ++++-- .../javascripts/rectangles/engine/rooms/_rooms.js | 2 - public/assets/stylesheets/app.css | 77 +++++++++++++++------- server/lib/views/index.js | 5 ++ views/projects/list-projects.ejs | 34 +++++----- 5 files changed, 88 insertions(+), 49 deletions(-) (limited to 'server/lib/views/index.js') diff --git a/public/assets/javascripts/rectangles/engine/map/draw.js b/public/assets/javascripts/rectangles/engine/map/draw.js index 6c27ff1..7eb6e7c 100644 --- a/public/assets/javascripts/rectangles/engine/map/draw.js +++ b/public/assets/javascripts/rectangles/engine/map/draw.js @@ -40,20 +40,29 @@ Map.Draw = function(map, opt){ // changes the ctx temporarily draw.render = function(){ - var thumbnail_side = 1000 + var thumbnail_width = 1000 + var thumbnail_height = 750 var extent = Rooms.extent() var center = extent.center() - var zoom = thumbnail_side / Math.max( extent.width(), extent.height() ) * 0.99 + var extent_width = extent.width() + var extent_height = extent.height() + var zoom + if (extent_width > extent_height) { + zoom = thumbnail_width / extent.width() * 0.9 + } + else { + zoom = thumbnail_height / extent.height() * 0.9 + } var canvas = document.createElement("canvas") ctx = canvas.getContext('2d') - canvas.width = thumbnail_side - canvas.height = thumbnail_side + canvas.width = thumbnail_width + canvas.height = thumbnail_height draw.clear() - ctx.translate( thumbnail_side * 1/2, thumbnail_side * 1/2) + ctx.translate( thumbnail_width * 1/2, thumbnail_height * 1/2) ctx.scale( zoom, zoom ) ctx.translate( center.a, -center.b ) ctx.scale( -1, 1 ) diff --git a/public/assets/javascripts/rectangles/engine/rooms/_rooms.js b/public/assets/javascripts/rectangles/engine/rooms/_rooms.js index 0c3cfd4..3603f0c 100644 --- a/public/assets/javascripts/rectangles/engine/rooms/_rooms.js +++ b/public/assets/javascripts/rectangles/engine/rooms/_rooms.js @@ -120,11 +120,9 @@ base.extent = function(){ var extent = new Rect ( new vec2(Infinity, -Infinity), new vec2(Infinity, -Infinity) ) - base.forEach(function(room){ extent.expand(room.rect) }) - return extent } diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css index d47b5a7..24ca772 100755 --- a/public/assets/stylesheets/app.css +++ b/public/assets/stylesheets/app.css @@ -327,27 +327,42 @@ iframe.embed { .projectList { display: inline-block; float: left; - width: 100%; + width: 98vw; + margin: 2vw; } +.projectList a { + width: 32vw; + float:left; + clear: right; + padding-bottom: 2vw; +} .projectList .room { - width: 50%; - height:40vh; + width: 30vw; + height: 23vw; + margin: 1vw; + border: 1vw solid white; display:table; position: relative; - float:left; - border-top:1px solid; + z-index: 1; } - -.projectList .room:nth-child(3n+2) { - border-right:1px solid black; +.projectList .holder { + position: absolute; + top: 50%; + z-index: 2; } -.projectList .room:nth-child(3n+1) { - width: 100%; - height: 50vh; +.room .mask { + position: absolute; + top: 0; left: 0; + z-index: 1; + width: 100%; + height: 100%; + text-align: center; + overflow: hidden; + background-size: cover; + background-repeat: no-repeat; } - .room .images { position: absolute; top: 0; left: 0; @@ -358,15 +373,28 @@ iframe.embed { overflow: hidden; } .room .images img { - max-height: 100%; - max-width: 100%; + width: 50%; + position: absolute; } +.room .images[data-mediacount='1'] img:nth-child(1) { left: 20%; top: 20%; } + +.room .images[data-mediacount='2'] img:nth-child(1) { left: 51%; bottom: 0%; width: auto; height: 100%; } +.room .images[data-mediacount='2'] img:nth-child(2) { right: 51%; bottom: 0%; width: auto; height: 100%; } + +.room .images[data-mediacount='3'] img:nth-child(1) { right: 51%; bottom: 41%; } +.room .images[data-mediacount='3'] img:nth-child(2) { left: 51%; bottom: 0%; width:auto; height:100%;} +.room .images[data-mediacount='3'] img:nth-child(3) { right: 51%; top: 61%; } + +.room .images[data-mediacount='4'] img:nth-child(1) { right: 51%; bottom: 41%; } +.room .images[data-mediacount='4'] img:nth-child(2) { left: 51%; bottom: 61%; } +.room .images[data-mediacount='4'] img:nth-child(3) { right: 51%; top: 61%; } +.room .images[data-mediacount='4'] img:nth-child(4) { left: 51%; top: 41%; } + .page .btn { clear: both; padding: 30px 0; border: 0; - } .page .viewMore { @@ -385,22 +413,21 @@ iframe.embed { vertical-align: middle; } -.page .room .holder a { - font-weight: 300; - font-size: 20px; - letter-spacing: 1px; +.page label { + font-weight: 500; + font-size: 15px; color: black; - background: white; - border: 1px solid; padding: 5px; - box-shadow: -3px 3px black; text-decoration:none; - max-width: 180px; display: inline-block; + cursor: pointer; } -.page .room .holder a:hover { - background:black; +.projectList a:hover { + background: linear-gradient( 0deg, blue, red ); +} + +.projectList a:hover label { color:white; } diff --git a/server/lib/views/index.js b/server/lib/views/index.js index ca48159..3f3880f 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -139,6 +139,11 @@ views.profile = function (req, res) { projects = projects.map(function(project){ project = project.toObject() project.date = moment(project.updated_at).format("M/DD/YYYY") + if (project.colors.wall && project.colors.wall[0] == project.colors.wall[1] && project.colors.wall[1] == project.colors.wall[2] && project.colors.wall[2] > 238) { + project.color = [238,238,238] + } else { + project.color = project.colors.wall + } return project }) done(err, user, projects) diff --git a/views/projects/list-projects.ejs b/views/projects/list-projects.ejs index a12f237..f469f5c 100644 --- a/views/projects/list-projects.ejs +++ b/views/projects/list-projects.ejs @@ -4,31 +4,31 @@ [[ projects.forEach(function(project, i) { ]] - - - + [[ if (String(user._id) == String(project.user_id)) { ]] + + [[ } else { ]] + + [[ } ]] + + + [[ mediaCount = 0 ]] [[ project.media.some(function(media){ ]] [[ if (media.media.type != "image") { return false } ]] - [[ if (++mediaCount > 3) { return true } ]] + [[ if (++mediaCount > 1) { return true } ]] [[ }) ]] - - + + + + + [[ }) ]] -- cgit v1.2.3-70-g09d2 From 4d4add72dec5d5f1db96430fe2de21c09451ebea Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 9 Oct 2014 17:26:24 -0400 Subject: feature projects, show featured projects on homepage, fix profile sort --- public/assets/javascripts/ui/site/StaffView.js | 23 ++++++++++++++ public/assets/stylesheets/app.css | 3 ++ server/lib/schemas/Project.js | 1 + server/lib/views/index.js | 42 +++++++++++++++++--------- server/lib/views/staff.js | 15 +++++++++ views/home.ejs | 5 ++- views/staff/projects/show.ejs | 13 ++++++++ 7 files changed, 84 insertions(+), 18 deletions(-) (limited to 'server/lib/views/index.js') diff --git a/public/assets/javascripts/ui/site/StaffView.js b/public/assets/javascripts/ui/site/StaffView.js index fdf39d2..0398f71 100644 --- a/public/assets/javascripts/ui/site/StaffView.js +++ b/public/assets/javascripts/ui/site/StaffView.js @@ -3,14 +3,19 @@ var StaffView = View.extend({ events: { "click #toggle-staff": "toggleStaff", + "click #toggle-featured": "toggleFeatured", }, initialize: function() { this.$toggleStaff = $("#toggle-staff") + this.$toggleFeatured = $("#toggle-featured") this.$mediaEmbed = $("#media-embed") if (this.$toggleStaff.length && this.$toggleStaff.data().isstaff) { this.$toggleStaff.html("Is Staff") } + if (this.$toggleFeatured.length && this.$toggleFeatured.data().featured) { + this.$toggleFeatured.html("Featured Project") + } if (this.$mediaEmbed.length) { var media = this.$mediaEmbed.data() this.$mediaEmbed.html( Parser.tag( media ) ) @@ -44,6 +49,24 @@ var StaffView = View.extend({ }.bind(this) }) }.bind(this)) + }, + + toggleFeatured: function(){ + var state = ! this.$toggleFeatured.data().featured + $.ajax({ + type: "put", + dataType: "json", + url: window.location.href + "/feature", + data: { + state: state, + _csrf: $("#_csrf").val(), + }, + success: function(data){ + this.$toggleFeatured.data("featured", data.state) + this.$toggleFeatured.html(data.state ? "Featured Project" : "Feature this project") + $("#isFeaturedProject").html(data.state ? "yes" : "no") + }.bind(this) + }) }, }) diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css index 9a2f6f8..85d14eb 100755 --- a/public/assets/stylesheets/app.css +++ b/public/assets/stylesheets/app.css @@ -357,6 +357,9 @@ iframe.embed { background-color: #ddd; background-size: cover; } +.projectList a:hover .room .mask { + background-color: rgba(238,238,238,0.1); +} .room .images { position: absolute; top: 0; left: 0; diff --git a/server/lib/schemas/Project.js b/server/lib/schemas/Project.js index abf34fb..dd50da6 100644 --- a/server/lib/schemas/Project.js +++ b/server/lib/schemas/Project.js @@ -35,6 +35,7 @@ var ProjectSchema = new mongoose.Schema({ user_id: { type: mongoose.Schema.ObjectId, index: true }, created_at: { type: Date }, updated_at: { type: Date }, + featured: { type: Boolean, default: false }, }); module.exports = exports = mongoose.model('project', ProjectSchema); diff --git a/server/lib/views/index.js b/server/lib/views/index.js index 3f3880f..1b547ef 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -79,10 +79,20 @@ views.modal = function (req, res) { views.home = function (req, res) { if (req.user) { - Project.find({ privacy: false }) + Project.find({ featured: true }) .sort('-created_at') - .limit(20) + .limit(6) .exec(function(err, projects){ + projects = projects.map(function(project){ + project = project.toObject() + project.date = moment(project.updated_at).format("M/DD/YYYY") + if (project.colors.wall && project.colors.wall[0] == project.colors.wall[1] && project.colors.wall[1] == project.colors.wall[2] && project.colors.wall[2] > 238) { + project.color = [238,238,238] + } else { + project.color = project.colors.wall + } + return project + }) res.render('home', { projects: projects || [] }) }) } @@ -135,19 +145,21 @@ views.profile = function (req, res) { if ( ! (req.user && req.user._id && req.user._id == user._id) ) { criteria.privacy = false } - Project.find(criteria, function(err, projects){ - projects = projects.map(function(project){ - project = project.toObject() - project.date = moment(project.updated_at).format("M/DD/YYYY") - if (project.colors.wall && project.colors.wall[0] == project.colors.wall[1] && project.colors.wall[1] == project.colors.wall[2] && project.colors.wall[2] > 238) { - project.color = [238,238,238] - } else { - project.color = project.colors.wall - } - return project - }) - done(err, user, projects) - }) + Project.find(criteria) + .sort('-created_at') + .exec(function(err, projects){ + projects = projects.map(function(project){ + project = project.toObject() + project.date = moment(project.updated_at).format("M/DD/YYYY") + if (project.colors.wall && project.colors.wall[0] == project.colors.wall[1] && project.colors.wall[1] == project.colors.wall[2] && project.colors.wall[2] > 238) { + project.color = [238,238,238] + } else { + project.color = project.colors.wall + } + return project + }) + done(err, user, projects) + }) } function done(err, user, projects){ diff --git a/server/lib/views/staff.js b/server/lib/views/staff.js index 41877c8..da09d83 100644 --- a/server/lib/views/staff.js +++ b/server/lib/views/staff.js @@ -389,6 +389,15 @@ var staff = module.exports = { staff.projects.show ); + app.put('/staff/projects/:slug/feature', + middleware.ensureAuthenticated, + middleware.ensureIsStaff, + + middleware.ensureProject, + staff.middleware.ensureProject, + + staff.projects.feature + ); // // media @@ -505,6 +514,12 @@ var staff = module.exports = { res.render('staff/projects/show_404') } }, + feature: function(req, res){ + res.locals.project.featured = req.body.state == "true" + res.locals.project.save(function(err, project){ + res.json({ state: project.featured }) + }) + }, }, media: { diff --git a/views/home.ejs b/views/home.ejs index 51d5a92..7ec8c1e 100755 --- a/views/home.ejs +++ b/views/home.ejs @@ -62,10 +62,9 @@

Room Showcase

- - + View More [[ include partials/confirm-modal ]] diff --git a/views/staff/projects/show.ejs b/views/staff/projects/show.ejs index 687f0c2..1034b31 100644 --- a/views/staff/projects/show.ejs +++ b/views/staff/projects/show.ejs @@ -41,8 +41,21 @@ "[[- project.description ]]" + + + featured? + + + [[- project.featured ? "yes" : "no" ]] + + +

+
+ +
+

-- cgit v1.2.3-70-g09d2 From 0ec3787487db41dd5f5b904b70f61fac3b7da491 Mon Sep 17 00:00:00 2001 From: Julie Lala Date: Thu, 9 Oct 2014 23:16:50 -0400 Subject: some css, set bg to white when noclipping into void --- public/assets/javascripts/rectangles/engine/rooms/_walls.js | 2 +- public/assets/javascripts/rectangles/engine/rooms/mover.js | 13 ++++--------- public/assets/stylesheets/app.css | 3 +++ public/assets/stylesheets/staff.css | 9 ++++++--- server/lib/views/index.js | 4 ++-- views/docs.ejs | 2 -- views/home.ejs | 2 +- 7 files changed, 17 insertions(+), 18 deletions(-) (limited to 'server/lib/views/index.js') diff --git a/public/assets/javascripts/rectangles/engine/rooms/_walls.js b/public/assets/javascripts/rectangles/engine/rooms/_walls.js index 71ddde9..7ff472d 100644 --- a/public/assets/javascripts/rectangles/engine/rooms/_walls.js +++ b/public/assets/javascripts/rectangles/engine/rooms/_walls.js @@ -137,7 +137,7 @@ $("#header").toggleClass("black", luminance < 128) $("body").css("background-color", rgbColor) - + Walls.colors.wall = rgb Walls.list.forEach(function(wall){ wall.outline(rgbaColor, null) diff --git a/public/assets/javascripts/rectangles/engine/rooms/mover.js b/public/assets/javascripts/rectangles/engine/rooms/mover.js index 5c7b4af..98f80c5 100644 --- a/public/assets/javascripts/rectangles/engine/rooms/mover.js +++ b/public/assets/javascripts/rectangles/engine/rooms/mover.js @@ -21,13 +21,6 @@ Rooms.mover = new function(){ base.update = function(pos){ var radius = scene.camera.radius - if (base.noclip) { - cam.x = pos.x - cam.y = pos.y - cam.z = pos.z - return - } - cam.y = pos.y // if we were in a room already.. @@ -42,14 +35,15 @@ Rooms.mover = new function(){ // check if we've breached one of the walls.. clamp position if so var collision = base.room.collidesDisc(pos.x, pos.z, radius) - if (collision) { + if (collision && ! base.noclip) { cam.x = (collision & LEFT_RIGHT) ? base.room.rect.x.clampDisc(pos.x, radius) : pos.x cam.z = (collision & FRONT_BACK) ? base.room.rect.y.clampDisc(pos.z, radius) : pos.z return } // in this case, we appear to have left the room.. - $(".face.active").removeClass("active") + // $(".face.active").removeClass("active") + $("body").css("background-color", "transparent") base.room = null } @@ -65,6 +59,7 @@ Rooms.mover = new function(){ // did we actually enter a room? if (intersects.length) { base.room = intersects[0] + $("body").css("background-color", rgb_string( Walls.colors.wall )) app.tube("change-room", { room: base.room }) } diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css index 6aab60c..a15ea39 100755 --- a/public/assets/stylesheets/app.css +++ b/public/assets/stylesheets/app.css @@ -482,6 +482,9 @@ iframe.embed { width: 100%; border-top: 1px solid; } +.page h1:nth-child(2) { + margin-top: 40px; +} .page p { margin: 20px; diff --git a/public/assets/stylesheets/staff.css b/public/assets/stylesheets/staff.css index aa21f9b..c75a9b1 100644 --- a/public/assets/stylesheets/staff.css +++ b/public/assets/stylesheets/staff.css @@ -28,15 +28,16 @@ nav { text-align: left; } nav a { - padding-left: 20px; + margin-left: 20px; } hr { border: 1px solid #bbb; - margin: 5px auto 10px; + margin: 10px auto 10px; + background: transparent; } .body { width: 80%; - margin: 0 auto; + margin: 40px auto; } .json { display: none; @@ -63,6 +64,8 @@ hr { .staff { font-size: 15px; } +.staff .body a { +} .staff .editLinks a { color: #00f; } diff --git a/server/lib/views/index.js b/server/lib/views/index.js index 1b547ef..fe2c988 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -86,7 +86,7 @@ views.home = function (req, res) { projects = projects.map(function(project){ project = project.toObject() project.date = moment(project.updated_at).format("M/DD/YYYY") - if (project.colors.wall && project.colors.wall[0] == project.colors.wall[1] && project.colors.wall[1] == project.colors.wall[2] && project.colors.wall[2] > 238) { + if (! project.colors || project.colors.wall && project.colors.wall[0] == project.colors.wall[1] && project.colors.wall[1] == project.colors.wall[2] && project.colors.wall[2] > 238) { project.color = [238,238,238] } else { project.color = project.colors.wall @@ -151,7 +151,7 @@ views.profile = function (req, res) { projects = projects.map(function(project){ project = project.toObject() project.date = moment(project.updated_at).format("M/DD/YYYY") - if (project.colors.wall && project.colors.wall[0] == project.colors.wall[1] && project.colors.wall[1] == project.colors.wall[2] && project.colors.wall[2] > 238) { + if (! project.colors || project.colors.wall && project.colors.wall[0] == project.colors.wall[1] && project.colors.wall[1] == project.colors.wall[2] && project.colors.wall[2] > 238) { project.color = [238,238,238] } else { project.color = project.colors.wall diff --git a/views/docs.ejs b/views/docs.ejs index 5662133..665190d 100644 --- a/views/docs.ejs +++ b/views/docs.ejs @@ -8,8 +8,6 @@
[[ include partials/header ]] -
- [[ if (! isNew) { ]]

[[- doc.displayName ]]

diff --git a/views/home.ejs b/views/home.ejs index e02ab0c..16b00e7 100755 --- a/views/home.ejs +++ b/views/home.ejs @@ -10,7 +10,7 @@ -
+
[[ include partials/header ]]
-- cgit v1.2.3-70-g09d2 From 81f10a23c2ab2bca5ee7a8d4bcc12c881cb04734 Mon Sep 17 00:00:00 2001 From: Julie Lala Date: Fri, 10 Oct 2014 11:50:27 -0400 Subject: change views code style --- server/lib/views/index.js | 284 +++++++++++++++++++++++----------------------- 1 file changed, 142 insertions(+), 142 deletions(-) (limited to 'server/lib/views/index.js') diff --git a/server/lib/views/index.js b/server/lib/views/index.js index fe2c988..637b061 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -11,164 +11,164 @@ var User = require('../schemas/User'), moment = require('moment'); marked.setOptions({ - renderer: new marked.Renderer(), - gfm: true, - sanitize: true, - smartLists: true, - smartypants: true, + renderer: new marked.Renderer(), + gfm: true, + sanitize: true, + smartLists: true, + smartypants: true, }); -var views = {} +var views = module.exports = { -views.staff = require('./staff') + staff: require('./staff'), -views.editor_new = function (req, res) { - if (! req.user) { - res.redirect('/') - } - else { - res.locals.opt.editing = true - res.render('editor') - } -} + editor_new: function (req, res) { + if (! req.user) { + res.redirect('/') + } + else { + res.locals.opt.editing = true + res.render('editor') + } + }, -views.editor = function (req, res) { - if (! req.project) { - res.redirect('/') - } - else if (req.isOwner || req.isCollaborator || req.isStaff) { - res.locals.opt.editing = true - res.render('editor') - } - else { - views.reader(req, res) - } -} + editor: function (req, res) { + if (! req.project) { + res.redirect('/') + } + else if (req.isOwner || req.isCollaborator || req.isStaff) { + res.locals.opt.editing = true + res.render('editor') + } + else { + views.reader(req, res) + } + }, -views.reader = function (req, res) { - if (! req.project) { - res.redirect('/') - return - } - User.findOne({ _id: req.project.user_id }, function(err, user) { - if (err || ! user) { - console.error(err) + reader: function (req, res) { + if (! req.project) { res.redirect('/') return } - res.render('reader', { - name: util.sanitize(req.project.name), - description: util.sanitize(req.project.description), - date: moment(req.project.updated_at).format("M/DD/YYYY"), - author: user.displayName, - authorlink: "/profile/" + user.username, - canEdit: req.isOwner || req.isCollaborator, - editlink: "/project/" + req.project.slug + "/edit", - noui: !! (req.query.noui === '1'), - }) - }) -} - -views.builder = function (req, res) { - res.render('builder') -} - -views.modal = function (req, res) { - res.render('modal'); -}; - -views.home = function (req, res) { - if (req.user) { - Project.find({ featured: true }) - .sort('-created_at') - .limit(6) - .exec(function(err, projects){ - projects = projects.map(function(project){ - project = project.toObject() - project.date = moment(project.updated_at).format("M/DD/YYYY") - if (! project.colors || project.colors.wall && project.colors.wall[0] == project.colors.wall[1] && project.colors.wall[1] == project.colors.wall[2] && project.colors.wall[2] > 238) { - project.color = [238,238,238] - } else { - project.color = project.colors.wall - } - return project - }) - res.render('home', { projects: projects || [] }) + User.findOne({ _id: req.project.user_id }, function(err, user) { + if (err || ! user) { + console.error(err) + res.redirect('/') + return + } + res.render('reader', { + name: util.sanitize(req.project.name), + description: util.sanitize(req.project.description), + date: moment(req.project.updated_at).format("M/DD/YYYY"), + author: user.displayName, + authorlink: "/profile/" + user.username, + canEdit: req.isOwner || req.isCollaborator, + editlink: "/project/" + req.project.slug + "/edit", + noui: !! (req.query.noui === '1'), }) - } - else { - res.send("") - } -} - -views.docs = function (req, res){ - var name = req.params.name || "index" - - if (name === "new") { - res.render('docs', { - doc: { name: "new" }, - content: null, - isNew: true }) - return - } - - Documentation.findOne({ name: name }, function(err, doc) { - if (err || ! doc) { - return res.render('docs', { - doc: { name: util.sanitize(name) }, + }, + + builder: function (req, res) { + res.render('builder') + }, + + modal: function (req, res) { + res.render('modal'); + }, + + home: function (req, res) { + if (req.user) { + Project.find({ featured: true }) + .sort('-created_at') + .limit(6) + .exec(function(err, projects){ + projects = projects.map(function(project){ + project = project.toObject() + project.date = moment(project.updated_at).format("M/DD/YYYY") + if (! project.colors || project.colors.wall && project.colors.wall[0] == project.colors.wall[1] && project.colors.wall[1] == project.colors.wall[2] && project.colors.wall[2] > 238) { + project.color = [238,238,238] + } else { + project.color = project.colors.wall + } + return project + }) + res.render('home', { projects: projects || [] }) + }) + } + else { + res.send("") + } + }, + + docs: function (req, res){ + var name = req.params.name || "index" + + if (name === "new") { + res.render('docs', { + doc: { name: "new" }, content: null, isNew: true }) + return } - res.render('docs', { - doc: doc, - content: marked(doc.body), - isNew: false - }) - }) -} - -views.profile = function (req, res) { - var username = req.params.username || (req.user && req.user.username) - if (username) { - User.findOne({ username: username }, function (err, user) { - user ? next(user) : done(err, {}, []) + + Documentation.findOne({ name: name }, function(err, doc) { + if (err || ! doc) { + return res.render('docs', { + doc: { name: util.sanitize(name) }, + content: null, + isNew: true + }) + } + res.render('docs', { + doc: doc, + content: marked(doc.body), + isNew: false + }) }) - } - else { - done() - } - - function next(user){ - var criteria = { user_id: user._id } - if ( ! (req.user && req.user._id && req.user._id == user._id) ) { - criteria.privacy = false + }, + + profile: function (req, res) { + var username = req.params.username || (req.user && req.user.username) + if (username) { + User.findOne({ username: username }, function (err, user) { + user ? next(user) : done(err, {}, []) + }) + } + else { + done() + } + + function next(user){ + var criteria = { user_id: user._id } + if ( ! (req.user && req.user._id && req.user._id == user._id) ) { + criteria.privacy = false + } + Project.find(criteria) + .sort('-created_at') + .exec(function(err, projects){ + projects = projects.map(function(project){ + project = project.toObject() + project.date = moment(project.updated_at).format("M/DD/YYYY") + if (! project.colors || project.colors.wall && project.colors.wall[0] == project.colors.wall[1] && project.colors.wall[1] == project.colors.wall[2] && project.colors.wall[2] > 238) { + project.color = [238,238,238] + } else { + project.color = project.colors.wall + } + return project + }) + done(err, user, projects) + }) + } + + function done(err, user, projects){ + if (! user) { return res.redirect('/') } + res.render('profile', { + profile: user, + projects: projects || [], + }) } - Project.find(criteria) - .sort('-created_at') - .exec(function(err, projects){ - projects = projects.map(function(project){ - project = project.toObject() - project.date = moment(project.updated_at).format("M/DD/YYYY") - if (! project.colors || project.colors.wall && project.colors.wall[0] == project.colors.wall[1] && project.colors.wall[1] == project.colors.wall[2] && project.colors.wall[2] > 238) { - project.color = [238,238,238] - } else { - project.color = project.colors.wall - } - return project - }) - done(err, user, projects) - }) - } - - function done(err, user, projects){ - if (! user) { return res.redirect('/') } - res.render('profile', { - profile: user, - projects: projects || [], - }) } -} -module.exports = views +} \ No newline at end of file -- 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/views/index.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 be603d871e7a0117698177405f98cd07be7d12ed Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 10 Oct 2014 18:50:32 -0400 Subject: load more --- public/assets/javascripts/ui/lib/Router.js | 1 + public/assets/javascripts/ui/site/ProjectList.js | 28 +++++- server/index.js | 1 + server/lib/views/index.js | 123 +++++++++++++++-------- views/projects/list-projects.ejs | 6 +- 5 files changed, 112 insertions(+), 47 deletions(-) (limited to 'server/lib/views/index.js') diff --git a/public/assets/javascripts/ui/lib/Router.js b/public/assets/javascripts/ui/lib/Router.js index 0b6385c..28905b2 100644 --- a/public/assets/javascripts/ui/lib/Router.js +++ b/public/assets/javascripts/ui/lib/Router.js @@ -16,6 +16,7 @@ var Router = View.extend({ if (pathname in routes) { this[this.routes[pathname]](null) + return } if (path[path.length-1] == null) { diff --git a/public/assets/javascripts/ui/site/ProjectList.js b/public/assets/javascripts/ui/site/ProjectList.js index ebb0a96..27c8aca 100644 --- a/public/assets/javascripts/ui/site/ProjectList.js +++ b/public/assets/javascripts/ui/site/ProjectList.js @@ -1,14 +1,17 @@ var projectListTimeout = null +window.fuck = 'suck' var ProjectList = View.extend({ el: ".projectList", events: { + "click .viewMore": 'viewMore', "mouseenter .room": 'enter', "mouseleave .room": 'leave', }, initialize: function(){ + this.$viewMore = this.$(".viewMore") this.$(".images").each(function(){ $divs = $(this).children("div") $divs.hide() @@ -41,7 +44,30 @@ var ProjectList = View.extend({ $divs.eq(index).hide() $divs.eq(nextIndex).show() $images.data("index", nextIndex) - } + }, + + viewMore: function(e){ + e.preventDefault() + var criteria = {} + criteria.offset = this.$(".projectItem").length + if (window.location.pathname == "/" || window.location.pathname.match("/home")) { + criteria.home = 1 + } + else { + criteria.user_id = this.$(".projectItem").first().data("userid") + } + + $.get("/api/project/paginate", criteria, function(data){ + var offset = this.$viewMore.offset() + var $data = $(data) + var $els = $data.find(".projectItem") + $els.insertBefore( this.$viewMore ) + if (! $data.find(".viewMore").length) { + this.$viewMore.hide() + } + $("body,html").animate({ scrollTop: offset.top - 80 }, 300) + }.bind(this)) + }, /* spinOn: function(e){ diff --git a/server/index.js b/server/index.js index f6636dd..8f66418 100644 --- a/server/index.js +++ b/server/index.js @@ -133,6 +133,7 @@ site.route = function () { app.delete('/api/layout/destroy', middleware.ensureAuthenticated, middleware.ensureIsStaff, api.layouts.destroy) app.get('/api/project', middleware.ensureAuthenticated, api.projects.index) + app.get('/api/project/paginate', views.projectsPaginate) app.get('/api/project/:slug', api.projects.show) app.get('/api/rooms/:slug', api.rooms.show) app.post('/api/project/new', middleware.ensureAuthenticated, api.projects.create) diff --git a/server/lib/views/index.js b/server/lib/views/index.js index 5b1a72e..eacff1f 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -78,27 +78,16 @@ var views = module.exports = { }, home: function (req, res) { - if (req.user) { - Project.find({ featured: true }) - .sort('-created_at') - .limit(6) - .exec(function(err, projects){ - projects = projects.map(function(project){ - project = project.toObject() - project.date = moment(project.updated_at).format("M/DD/YYYY") - if (! project.colors || project.colors.wall && project.colors.wall[0] == project.colors.wall[1] && project.colors.wall[1] == project.colors.wall[2] && project.colors.wall[2] > 238) { - project.color = [238,238,238] - } else { - project.color = project.colors.wall - } - return project - }) - res.render('home', { projects: projects || [] }) - }) - } - else { - res.send("") + // while in development, blank homepage if not logged in + if (! req.user) { + res.send("") + return } + views_middleware.fetchProjects({ featured: true }, null, null, function(err, projects){ + res.render('home', { + projects: projects || [] + }) + }) }, docs: function (req, res){ @@ -131,45 +120,93 @@ var views = module.exports = { profile: function (req, res) { var username = req.params.username || (req.user && req.user.username) + var user, isOwnProfile = false if (username) { - User.findOne({ username: username }, function (err, user) { - user ? next(user) : done(err, {}, []) + User.findOne({ username: username }, function (err, profileUser) { + if (profileUser) { + user = profileUser + isOwnProfile = (String(user._id) == (req.user && String(req.user._id))) + next() + } + else { + done(err, []) + } }) } else { done() } - function next(user){ + function next(){ var criteria = { user_id: user._id } - if ( ! (req.user && req.user._id && req.user._id == user._id) ) { + if ( ! isOwnProfile ) { criteria.privacy = false } - Project.find(criteria) - .sort('-created_at') - .exec(function(err, projects){ - projects = projects.map(function(project){ - project = project.toObject() - project.date = moment(project.updated_at).format("M/DD/YYYY") - if (! project.colors || project.colors.wall && project.colors.wall[0] == project.colors.wall[1] && project.colors.wall[1] == project.colors.wall[2] && project.colors.wall[2] > 238) { - project.color = [238,238,238] - } else { - project.color = project.colors.wall - } - return project - }) - done(err, user, projects) - }) + views_middleware.fetchProjects(criteria, null, null, done) } - function done(err, user, projects){ + function done(err, projects){ if (! user) { return res.redirect('/') } res.render('profile', { - isOwnProfile: String(user._id) == (req.user && String(req.user._id)), + isOwnProfile: isOwnProfile, profile: user, projects: projects || [], }) } - } + }, + + projectsPaginate: function(req, res) { + var criteria = {} + var offset = Number(req.query.offset || 0) + var user_id, isOwnProfile + + if (req.query.home) { + criteria.featured = true + criteria.privacy = false + } + else if (req.query.user_id) { + user_id = req.query.user_id + isOwnProfile = (String(user_id) == (req.user && String(req.user._id))) + + criteria.user_id = user_id + if ( ! isOwnProfile ) { + criteria.privacy = false + } + } + else { + res.end("") + return + } + + views_middleware.fetchProjects(criteria, null, offset, function(err, projects){ + res.render('projects/list-projects', { + projects: projects || [] + }) + }) + }, -} \ No newline at end of file +} + +var views_middleware = { + fetchProjects: function (criteria, limit, offset, next) { + limit = limit || 7 + offset = offset || 0 + Project.find(criteria) + .sort('-created_at') + .skip(offset) + .limit(limit) + .exec(function(err, projects){ + projects = projects.map(function(project){ + project = project.toObject() + project.date = moment(project.updated_at).format("M/D/YYYY") + if (! project.colors || project.colors.wall && project.colors.wall[0] == project.colors.wall[1] && project.colors.wall[1] == project.colors.wall[2] && project.colors.wall[2] > 238) { + project.color = [238,238,238] + } else { + project.color = project.colors.wall + } + return project + }) + next(err, projects) + }) + } +} diff --git a/views/projects/list-projects.ejs b/views/projects/list-projects.ejs index eb66449..5ecaec1 100644 --- a/views/projects/list-projects.ejs +++ b/views/projects/list-projects.ejs @@ -1,13 +1,13 @@ [[ if (projects.length) { ]] - +
[[ projects.forEach(function(project, i) { ]] [[ if (i > 5) { return } ]] [[ if (String(user._id) == String(project.user_id)) { ]] - + [[ } else { ]] - + [[ } ]] -- cgit v1.2.3-70-g09d2 From e92acfd9a8b7b60544c8b85ad856273c732a1935 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 27 Oct 2014 12:06:25 -0400 Subject: vvalls.com/home for testing --- public/assets/javascripts/ui/_router.js | 1 + public/assets/javascripts/ui/editor/WallpaperPicker.js | 2 +- server/index.js | 1 + server/lib/views/index.js | 8 ++++++++ 4 files changed, 11 insertions(+), 1 deletion(-) (limited to 'server/lib/views/index.js') diff --git a/public/assets/javascripts/ui/_router.js b/public/assets/javascripts/ui/_router.js index bda0960..c7b625a 100644 --- a/public/assets/javascripts/ui/_router.js +++ b/public/assets/javascripts/ui/_router.js @@ -46,6 +46,7 @@ var SiteRouter = Router.extend({ mobileRoutes: { "/": 'home', + "/home": 'home', "/profile": 'profile', "/project/:name": 'projectViewer', }, diff --git a/public/assets/javascripts/ui/editor/WallpaperPicker.js b/public/assets/javascripts/ui/editor/WallpaperPicker.js index d7d666c..c383489 100644 --- a/public/assets/javascripts/ui/editor/WallpaperPicker.js +++ b/public/assets/javascripts/ui/editor/WallpaperPicker.js @@ -54,7 +54,7 @@ var WallpaperPicker = UploadView.extend({ // toggle the class that makes the cursor a paintbucket // $("body").removeClass("pastePaper") }, - + load: function(){ $.get("/api/media/user", { tag: this.mediaTag }, this.populate.bind(this)) }, diff --git a/server/index.js b/server/index.js index 8f66418..90b724c 100644 --- a/server/index.js +++ b/server/index.js @@ -79,6 +79,7 @@ site.setup = function(){ site.route = function () { app.get('/', views.home); + app.get('/home', views.demoHome); app.get('/login', views.modal); app.get('/logout', auth.logout); app.get('/signup', views.modal); diff --git a/server/lib/views/index.js b/server/lib/views/index.js index eacff1f..5768ace 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -90,6 +90,14 @@ var views = module.exports = { }) }, + demoHome: function (req, res) { + views_middleware.fetchProjects({ featured: true }, null, null, function(err, projects){ + res.render('home', { + projects: projects || [] + }) + }) + }, + docs: function (req, res){ var name = req.params.name || "index" -- cgit v1.2.3-70-g09d2 From 503c1eb313d01d3a73fac1e31b774749893b55d4 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 29 Oct 2014 12:46:02 -0400 Subject: opengraph tags --- public/assets/javascripts/ui/reader/ReaderView.js | 2 +- public/assets/javascripts/ui/reader/ShareView.js | 4 ++-- server/lib/middleware.js | 7 ++++++- server/lib/views/index.js | 10 ++++++++++ views/projects/list-projects.ejs | 1 - 5 files changed, 19 insertions(+), 5 deletions(-) (limited to 'server/lib/views/index.js') diff --git a/public/assets/javascripts/ui/reader/ReaderView.js b/public/assets/javascripts/ui/reader/ReaderView.js index 4c53226..c132609 100644 --- a/public/assets/javascripts/ui/reader/ReaderView.js +++ b/public/assets/javascripts/ui/reader/ReaderView.js @@ -9,7 +9,7 @@ var ReaderView = View.extend({ initialize: function(){ this.mediaPlayer = new MediaPlayer ({ parent: this }) - this.shareView = new shareView ({ parent: this }) + this.shareView = new ShareView ({ parent: this }) }, load: function(name){ diff --git a/public/assets/javascripts/ui/reader/ShareView.js b/public/assets/javascripts/ui/reader/ShareView.js index ab358e3..35c23ca 100644 --- a/public/assets/javascripts/ui/reader/ShareView.js +++ b/public/assets/javascripts/ui/reader/ShareView.js @@ -4,7 +4,7 @@ var ShareView = View.extend({ events: { "click #share_facebook": "facebook", "click #share_twitter": "twitter", - } + }, initialize: function(opt){ this.parent = opt.parent @@ -24,4 +24,4 @@ var ShareView = View.extend({ window.open(url, "_blank") } -} +}) diff --git a/server/lib/middleware.js b/server/lib/middleware.js index 0bf16ce..870451a 100644 --- a/server/lib/middleware.js +++ b/server/lib/middleware.js @@ -40,10 +40,15 @@ var middleware = { res.locals.user = req.user || { _id: undefined } res.locals.config = config res.locals.profile = null + res.locals.ogImage = "" + res.locals.ogTitle = "Vvalls" + res.locals.ogUrl = "http://vvalls.com/" + res.locals.ogDescription = "3D gallery space, fully customizable" + res.locals.ogAuthor = "Vvalls" res.locals.opt = {} next() }, - + ensureProject: function (req, res, next) { if (req.params.slug) { Project.findOne({ slug: req.params.slug }, function(err, project){ diff --git a/server/lib/views/index.js b/server/lib/views/index.js index 5768ace..0b5a1fe 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -56,6 +56,10 @@ var views = module.exports = { res.redirect('/') return } + var ogImage + if (req.project.media.length && req.project.media[0].media.type == "image") { + ogImage = req.project.media[0].media.url + } res.render('reader', { name: util.sanitize(req.project.name), description: util.sanitize(req.project.description), @@ -65,6 +69,9 @@ var views = module.exports = { canEdit: req.isOwner || req.isCollaborator, editlink: "/project/" + req.project.slug + "/edit", noui: !! (req.query.noui === '1'), + ogTitle: req.project.name, + ogUrl: "http://vvalls.com/project/" + req.project.slug + "/", + ogImage: ogImage, }) }) }, @@ -159,6 +166,9 @@ var views = module.exports = { isOwnProfile: isOwnProfile, profile: user, projects: projects || [], + ogTitle: "Vvalls: Profile of " + user.displayName, + ogUrl: "http://vvalls.com/profile/" + user.username + "/", + ogImage: user.photo, }) } }, diff --git a/views/projects/list-projects.ejs b/views/projects/list-projects.ejs index 5ecaec1..2749b0e 100644 --- a/views/projects/list-projects.ejs +++ b/views/projects/list-projects.ejs @@ -9,7 +9,6 @@ [[ } else { ]] [[ } ]] - -- cgit v1.2.3-70-g09d2 From de6fa5bf0e7f0a55341d05f5a5b1dfb19330aeb0 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 29 Oct 2014 18:25:12 -0400 Subject: stub in fixes to mover --- .../javascripts/rectangles/engine/rooms/mover.js | 38 +++++++++++++++++++++- .../assets/javascripts/rectangles/models/room.js | 6 ++-- public/assets/javascripts/ui/reader/MediaPlayer.js | 2 +- server/lib/views/index.js | 6 ++-- 4 files changed, 44 insertions(+), 8 deletions(-) (limited to 'server/lib/views/index.js') diff --git a/public/assets/javascripts/rectangles/engine/rooms/mover.js b/public/assets/javascripts/rectangles/engine/rooms/mover.js index fae2ce6..121ecec 100644 --- a/public/assets/javascripts/rectangles/engine/rooms/mover.js +++ b/public/assets/javascripts/rectangles/engine/rooms/mover.js @@ -34,7 +34,43 @@ Rooms.mover = new function(){ } // check if we've breached one of the walls.. clamp position if so - var collision = base.room.collidesDisc(pos.x, pos.z, radius) + var collision = base.room.collidesDisc(cam, pos, radius) + +/* + var dz = new vec2( cam.z, pos.z ) + dz.normalize() + + var dx = new vec2( cam.x, pos.x ) + dx.normalize() + + Walls.list.forEach(function(wall){ + switch (wall.side) { + case FRONT: + break + case BACK: + break + case LEFT: + if (cam.x >= wall.edge + radius && wall.edge + radius >= pos.x && (wall.vec.intersects(dz) ) { + // intersects the wall.. next check if it intersects any of the surface frames + wall.surface.faces.some(function(face, i){ + // if we can pass through the wall at this point, we do not need to clamp + if (face.y.a === 0 && face.x.intersects(dz)) { + dz.a = pos.z = face.x.clamp(pos.z) + dz.b = cam.z + dz.normalize() + return true + } + }) + } + break + case RIGHT: + if (cam.x <= wall.edge - radius && wall.edge - radius <= pos.x && (wall.vec.contains(cam.z) || wall.vec.contains(pos.z)) ) { + // intersects + } + break + } + }) +*/ if (collision && ! base.noclip) { cam.x = (collision & LEFT_RIGHT) ? base.room.rect.x.clampDisc(pos.x, radius) : pos.x diff --git a/public/assets/javascripts/rectangles/models/room.js b/public/assets/javascripts/rectangles/models/room.js index b0344a1..26bf055 100644 --- a/public/assets/javascripts/rectangles/models/room.js +++ b/public/assets/javascripts/rectangles/models/room.js @@ -122,7 +122,8 @@ return collision } - Room.prototype.collidesDisc = function(x,y,radius){ + Room.prototype.collidesDisc = function(src, dest, radius){ + var x = dest.x, y = dest.z var collision = 0, wall_collision, contains_x, contains_y this.regions.forEach(function(r){ if (! r.sides) return @@ -152,9 +153,6 @@ if (contains_y) { collision |= wall_collision & LEFT_RIGHT } -// if (bitcount(wall_collision) > 1) { -// collision |= wall_collision -// } }) return collision } diff --git a/public/assets/javascripts/ui/reader/MediaPlayer.js b/public/assets/javascripts/ui/reader/MediaPlayer.js index 7f73e1b..e40c6ff 100644 --- a/public/assets/javascripts/ui/reader/MediaPlayer.js +++ b/public/assets/javascripts/ui/reader/MediaPlayer.js @@ -44,7 +44,7 @@ var MediaPlayer = FormView.extend({ this.unbind() } if (media.type == "image") { - if ((! media.title || ! media.title.length) && (! media.description || ! media.description.length) || (media.title == filenameFromUrl(media.url)) ) { + if ( ! media.description && (! media.title || media.title == filenameFromUrl(media.url)) ) { this.hide() return } diff --git a/server/lib/views/index.js b/server/lib/views/index.js index 0b5a1fe..7ffadb9 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -38,10 +38,12 @@ var views = module.exports = { } else if (req.isOwner || req.isCollaborator || req.isStaff) { res.locals.opt.editing = true - res.render('editor') + res.render('editor', { + ogUrl: "http://vvalls.com/project/" + req.project.slug + "/", + }) } else { - views.reader(req, res) + res.redirect("/project/" + req.project.slug + "/") } }, -- cgit v1.2.3-70-g09d2 From 5fd09fa0c6be63b708e57d171b35884fac4c9965 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 7 Nov 2014 18:09:36 -0500 Subject: redirect out of /edit if not signed in --- server/lib/views/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server/lib/views/index.js') diff --git a/server/lib/views/index.js b/server/lib/views/index.js index 7ffadb9..e37a01d 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -36,7 +36,7 @@ var views = module.exports = { if (! req.project) { res.redirect('/') } - else if (req.isOwner || req.isCollaborator || req.isStaff) { + else if (req.user && (req.isOwner || req.isCollaborator || req.isStaff)) { res.locals.opt.editing = true res.render('editor', { ogUrl: "http://vvalls.com/project/" + req.project.slug + "/", -- cgit v1.2.3-70-g09d2 From 17fabffafc8e0f9723db6e19ae2ff14012c56a63 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 10 Nov 2014 12:10:05 -0500 Subject: surface avatar --- public/assets/stylesheets/app.css | 13 +++++++++++-- server/lib/views/index.js | 1 + views/controls/reader/about-room.ejs | 8 +++++++- 3 files changed, 19 insertions(+), 3 deletions(-) (limited to 'server/lib/views/index.js') diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css index e6b5570..cb58ef6 100755 --- a/public/assets/stylesheets/app.css +++ b/public/assets/stylesheets/app.css @@ -2542,12 +2542,21 @@ a[data-role="forgot-password"] { .aboutRoom.vvbox .txt { padding: 5px 0 3px 0; } - -.aboutRoom h1 a{ +.aboutRoom h1 a { text-decoration: none; font-style: italic; font-weight:500; } +.aboutRoom .profilePic { + width: 34px; + height: 34px; + float: none; + display: inline-block; + vertical-align: middle; +} +.aboutRoom .authorName { + vertical-align: middle; +} .desktop .aboutRoom h1 a:hover { text-decoration:underline; diff --git a/server/lib/views/index.js b/server/lib/views/index.js index e37a01d..6e3b449 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -68,6 +68,7 @@ var views = module.exports = { date: moment(req.project.updated_at).format("M/DD/YYYY"), author: user.displayName, authorlink: "/profile/" + user.username, + authorpic: user.photo, canEdit: req.isOwner || req.isCollaborator, editlink: "/project/" + req.project.slug + "/edit", noui: !! (req.query.noui === '1'), diff --git a/views/controls/reader/about-room.ejs b/views/controls/reader/about-room.ejs index 2bd3f0c..974fe0f 100644 --- a/views/controls/reader/about-room.ejs +++ b/views/controls/reader/about-room.ejs @@ -1,6 +1,12 @@

- [[- name ]], + [[- name ]] +
+ [[ if (authorpic) { ]] +
+ [[ } else { ]] + + [[ } ]] [[- author ]]

[[ if (description) { ]] -- 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/views/index.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/views/index.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 4fed1541ff3ae153a219cb4deff304bce7b49c86 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 17 Nov 2014 12:16:33 -0500 Subject: about views --- server/lib/views/index.js | 7 +++++++ views/about/_blank.ejs | 24 ++++++++++++++++++++++++ views/about/index.ejs | 23 +++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 views/about/_blank.ejs create mode 100644 views/about/index.ejs (limited to 'server/lib/views/index.js') diff --git a/server/lib/views/index.js b/server/lib/views/index.js index 31cb1db..48b1c32 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -111,6 +111,13 @@ var views = module.exports = { docs: function (req, res){ var name = req.params.name || "index" + try { + res.render('about/' + name) + return + } + catch (e) { + } + if (name === "new") { res.render('docs', { doc: { name: "new" }, diff --git a/views/about/_blank.ejs b/views/about/_blank.ejs new file mode 100644 index 0000000..0e9ea7e --- /dev/null +++ b/views/about/_blank.ejs @@ -0,0 +1,24 @@ + + + + vvalls + [[ include ../partials/meta ]] + + +

+ [[ include ../partials/header ]] + + + + + + + [[ include ../partials/confirm-modal ]] + [[ include ../projects/layouts-modal ]] + [[ include ../partials/sign-in ]] + [[ include ../partials/footer ]] + +
+ +[[ include ../partials/scripts ]] + diff --git a/views/about/index.ejs b/views/about/index.ejs new file mode 100644 index 0000000..4d40a5c --- /dev/null +++ b/views/about/index.ejs @@ -0,0 +1,23 @@ + + + + vvalls + [[ include ../partials/meta ]] + + +
+ [[ include ../partials/header ]] + + + +

INDEX

+ + [[ include ../partials/confirm-modal ]] + [[ include ../projects/layouts-modal ]] + [[ include ../partials/sign-in ]] + [[ include ../partials/footer ]] + +
+ +[[ include ../partials/scripts ]] + -- cgit v1.2.3-70-g09d2 From ca061ffd724debf3068166addd72cca67f8943d4 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 17 Nov 2014 18:29:41 -0500 Subject: pushing it live --- server/lib/views/index.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'server/lib/views/index.js') diff --git a/server/lib/views/index.js b/server/lib/views/index.js index 48b1c32..6f1305a 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -89,10 +89,12 @@ var views = module.exports = { home: function (req, res) { // while in development, blank homepage if not logged in +/* if (! req.user) { res.send("") return } +*/ views_middleware.fetchProjects({ featured: true }, null, null, function(err, projects){ res.render('home', { projects: projects || [] -- cgit v1.2.3-70-g09d2 From dba52c100c5fa621c4c611effa8115dd7e6d10e6 Mon Sep 17 00:00:00 2001 From: Julie Lala Date: Tue, 18 Nov 2014 08:49:33 -0500 Subject: render howto explicitly --- Gruntfile.js | 2 +- server/lib/views/index.js | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'server/lib/views/index.js') diff --git a/Gruntfile.js b/Gruntfile.js index c99976d..59c2525 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -141,7 +141,7 @@ module.exports = function(grunt) { }, uglify: { options: { - banner: '/* vvalls by okfoc.us 2014 */\n' + banner: '/* vvalls by okfocus 2014 */\n' }, js: { src: 'public/assets/javascripts/app.concat.js', diff --git a/server/lib/views/index.js b/server/lib/views/index.js index 6f1305a..8ca2113 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -113,13 +113,11 @@ var views = module.exports = { docs: function (req, res){ var name = req.params.name || "index" - try { + if (name == "howto") { res.render('about/' + name) return } - catch (e) { - } - + if (name === "new") { res.render('docs', { doc: { name: "new" }, -- cgit v1.2.3-70-g09d2 From 3164203c0b196edee882e896adbd33fc65e32588 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 18 Nov 2014 12:33:51 -0500 Subject: add keyboard shortcuts to howto --- server/lib/views/index.js | 2 +- views/about/howto.ejs | 54 ++++++++++++++++++++++++++++++++++++++++++++--- views/about/index.ejs | 20 ------------------ views/home.ejs | 2 +- 4 files changed, 53 insertions(+), 25 deletions(-) delete mode 100644 views/about/index.ejs (limited to 'server/lib/views/index.js') diff --git a/server/lib/views/index.js b/server/lib/views/index.js index 8ca2113..145b5ac 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -111,7 +111,7 @@ var views = module.exports = { }, docs: function (req, res){ - var name = req.params.name || "index" + var name = req.params.name || "howto" if (name == "howto") { res.render('about/' + name) diff --git a/views/about/howto.ejs b/views/about/howto.ejs index 2e0f8ed..30497e1 100644 --- a/views/about/howto.ejs +++ b/views/about/howto.ejs @@ -8,8 +8,6 @@
[[ include ../partials/header ]] - -
@@ -73,7 +71,57 @@
- + +

Keyboard Shortcuts

+ +
+
+ + + +

Getting around VValls is easier with the keyboard.

+ + If you play video games, you should be familiar with using WASD to move -- left hand on the keyboard, right hand on the mouse. + We have added a few keys for pivoting and looking up and down. +
+
+
+ +
+ + + + + + + + + + +
WMove forward
AStrafe left
SMove backward
DStrafe right
 
QTurn left
ETurn right
 
RLook up
FLook down
+ + + + + + + + + + + +
Cmd-ZUndo
Shift-Cmd-ZRedo
Cmd-\Noclip mode
EscCancel
BackspaceDelete currently selected media
 
MousewheelMove forward/back
Shift-MousewheelTurn left/right
 
SpacebarJump
+ +
+ + diff --git a/views/about/index.ejs b/views/about/index.ejs deleted file mode 100644 index 2517225..0000000 --- a/views/about/index.ejs +++ /dev/null @@ -1,20 +0,0 @@ - - - - vvalls - [[ include ../partials/meta ]] - - -
- [[ include ../partials/header ]] - - - [[ include ../partials/confirm-modal ]] - [[ include ../projects/layouts-modal ]] - [[ include ../partials/sign-in ]] - [[ include ../partials/footer ]] - -
- -[[ include ../partials/scripts ]] - diff --git a/views/home.ejs b/views/home.ejs index cc108ba..8fc248e 100755 --- a/views/home.ejs +++ b/views/home.ejs @@ -48,7 +48,7 @@ -

Cutting Edge Presentations

+

Make Cutting Edge Presentations

There's no cooler way than VValls for displaying your images online. Take your pix out of that drab Tumblr theme and present them in the freshest way online!
-- cgit v1.2.3-70-g09d2 From b4de393c30ab2540ce8961b394be1915729d8df6 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 1 Dec 2014 16:30:27 -0500 Subject: about.ejs --- server/lib/views/index.js | 6 +++++- views/about/about.ejs | 27 +++++++++++++++++++++++++++ views/partials/footer.ejs | 3 ++- 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 views/about/about.ejs (limited to 'server/lib/views/index.js') diff --git a/server/lib/views/index.js b/server/lib/views/index.js index 145b5ac..6ceef7e 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -111,12 +111,16 @@ var views = module.exports = { }, docs: function (req, res){ - var name = req.params.name || "howto" + var name = req.params.name || "about" if (name == "howto") { res.render('about/' + name) return } + if (name == "about" || name == "index") { + res.render('about/' + name) + return + } if (name === "new") { res.render('docs', { diff --git a/views/about/about.ejs b/views/about/about.ejs new file mode 100644 index 0000000..e600a3d --- /dev/null +++ b/views/about/about.ejs @@ -0,0 +1,27 @@ + + + + vvalls + [[ include ../partials/meta ]] + + +
+ [[ include ../partials/header ]] + + +
+
+
+
+

About VValls

+ + + [[ include ../partials/confirm-modal ]] + [[ include ../projects/layouts-modal ]] + [[ include ../partials/sign-in ]] + [[ include ../partials/footer ]] + +
+ +[[ include ../partials/scripts ]] + diff --git a/views/partials/footer.ejs b/views/partials/footer.ejs index 7b01162..e3c572f 100644 --- a/views/partials/footer.ejs +++ b/views/partials/footer.ejs @@ -13,7 +13,8 @@

- How To + About + How To Terms Privacy Contact -- cgit v1.2.3-70-g09d2 From 6b665588eaf1690d6717edabe64882e091731117 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 10 Dec 2014 14:20:52 -0500 Subject: get accurate project count --- server/lib/views/index.js | 16 +++++++++++++--- views/profile.ejs | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'server/lib/views/index.js') diff --git a/server/lib/views/index.js b/server/lib/views/index.js index 6ceef7e..8c3e63d 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -171,15 +171,20 @@ var views = module.exports = { if ( ! isOwnProfile ) { criteria.privacy = false } - views_middleware.fetchProjects(criteria, null, null, done) + views_middleware.fetchProjects(criteria, null, null, function(err, projects){ + views_middleware.fetchUserProjectCount(criteria, function(projectCount){ + done(err, projects, projectCount) + }) + }) } - function done(err, projects){ + function done(err, projects, projectCount){ if (! user) { return res.redirect('/') } res.render('profile', { isOwnProfile: isOwnProfile, profile: user, projects: projects || [], + projectCount: projectCount, ogTitle: "VValls: Profile of " + user.displayName, ogUrl: "http://vvalls.com/profile/" + user.username + "/", ogImage: user.photo, @@ -240,5 +245,10 @@ var views_middleware = { }) next(err, projects) }) - } + }, + fetchUserProjectCount: function(criteria, next){ + Project.count(criteria, function(err, count){ + next(count || 0) + }) + }, } diff --git a/views/profile.ejs b/views/profile.ejs index 5043df6..a62652c 100644 --- a/views/profile.ejs +++ b/views/profile.ejs @@ -46,7 +46,7 @@ [[ if (projects.length) { ]] -

[[- profile.username ]] has [[- projects.length ]] project[[- projects.length != 1 ? "s" : "" ]]

+

[[- profile.username ]] has [[- projectCount ]] project[[- projectCount != 1 ? "s" : "" ]]

[[ include projects/list-projects ]] [[ } else { ]] -- cgit v1.2.3-70-g09d2 From 2d4ed7d888727e1b973c2581b694d900e30c2ebd Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 7 Jan 2015 13:53:27 -0500 Subject: plan/subscription schemas --- server/lib/schemas/Plan.js | 36 +++++++++++++++++++++++++++ server/lib/schemas/Subscription.js | 25 +++++++++++++++++++ server/lib/views/index.js | 8 +----- server/lib/views/subscription.js | 51 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 113 insertions(+), 7 deletions(-) create mode 100644 server/lib/schemas/Plan.js create mode 100644 server/lib/schemas/Subscription.js create mode 100644 server/lib/views/subscription.js (limited to 'server/lib/views/index.js') diff --git a/server/lib/schemas/Plan.js b/server/lib/schemas/Plan.js new file mode 100644 index 0000000..3e74997 --- /dev/null +++ b/server/lib/schemas/Plan.js @@ -0,0 +1,36 @@ +/* jshint node: true */ + +var mongoose = require('mongoose'), + _ = require('lodash'), + crypto = require('crypto'), + config = require('../../../config.json'), + util = require('../util'); + +var PlanSchema = new mongoose.Schema({ + name: { type: String }, + slug: { type: String }, + + monthly_price: { type: Number }, + yearly_price: { type: Number }, + + basic_layout_limit: { type: Number }, + pro_layout_limit: { type: Number }, + + stock_layout_project_limit: { type: Number }, + basic_layout_project_limit: { type: Number }, + pro_layout_project_limit: { type: Number }, + + permissions: { + basic_editor: { type: Boolean, default: false }, + pro_editor: { type: Boolean, default: false }, + solids: { type: Boolean, default: false }, + collaborators: { type: Boolean, default: false }, + no_logo: { type: Boolean, default: false }, + }, + + created_at: { type: Date, default: Date.now }, + updated_at: { type: Date, default: Date.now }, +}) + +module.exports = exports = mongoose.model('plan', PlanSchema); +exports.schema = PlanSchema; diff --git a/server/lib/schemas/Subscription.js b/server/lib/schemas/Subscription.js new file mode 100644 index 0000000..8d0b10e --- /dev/null +++ b/server/lib/schemas/Subscription.js @@ -0,0 +1,25 @@ +/* jshint node: true */ + +var mongoose = require('mongoose'), + _ = require('lodash'), + crypto = require('crypto'), + config = require('../../../config.json'), + util = require('../util'); + +var SubscriptionSchema = new mongoose.Schema({ + user_id: { type: mongoose.Schema.ObjectId, index: true }, + + monthly_total: { type: Number }, + yearly_total: { type: Number }, + + plans: [{ + tier: { type: String }, + monthly: { type: Boolean }, + }] + + created_at: { type: Date, default: Date.now }, + updated_at: { type: Date, default: Date.now }, +}) + +module.exports = exports = mongoose.model('subscription', SubscriptionSchema); +exports.schema = SubscriptionSchema; diff --git a/server/lib/views/index.js b/server/lib/views/index.js index 8c3e63d..3326499 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -21,6 +21,7 @@ marked.setOptions({ var views = module.exports = { staff: require('./staff'), + subscription: require('./subscription'), editor_new: function (req, res) { if (! req.user) { @@ -88,13 +89,6 @@ var views = module.exports = { }, home: function (req, res) { - // while in development, blank homepage if not logged in -/* - if (! req.user) { - res.send("") - return - } -*/ views_middleware.fetchProjects({ featured: true }, null, null, function(err, projects){ res.render('home', { projects: projects || [] diff --git a/server/lib/views/subscription.js b/server/lib/views/subscription.js new file mode 100644 index 0000000..77db1a0 --- /dev/null +++ b/server/lib/views/subscription.js @@ -0,0 +1,51 @@ +/* jshint node: true */ + +var User = require('../schemas/User'), + Subscription = require('../schemas/Subscription'), + config = require('../../../config'), + middleware = require('../middleware'), + util = require('../util'), + _ = require('lodash'), + moment = require('moment'); + +var subscription = module.exports = { + + fields: { + user: "_id username displayName photo created_at updated_at last_seen created_ip last_ip", + project: "_id name slug user_id privacy created_at updated_at", + }, + + defaults: { + user: { + _id: "", username: "", displayName: "", + created_at: "", updated_at: "", created_ip: "", last_ip: "", + }, + }, + + middleware: { + }, + + helpers: { + project: function(project){ + project = project.toObject() + project.date = moment( project.updated_at || project.created_at ).format("M/DD/YYYY hh:mm a") + project.user = {} + return project + }, + }, + + route: function(app){ + app.get('/staff', + middleware.ensureAuthenticated, + middleware.ensureIsStaff, + + staff.middleware.ensureRecentUsers, + staff.middleware.ensureUsersCount, + staff.middleware.ensureProjectsCount, + staff.middleware.ensureMediaCount, + + staff.index + ); + }, + +} -- cgit v1.2.3-70-g09d2 From 9c6f8f8568d20d75eb22955dbf2752ea777e59f8 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 7 Jan 2015 14:34:41 -0500 Subject: stub in brochure page --- public/assets/stylesheets/app.css | 14 +++++++ server/lib/schemas/Plan.js | 6 +++ server/lib/schemas/Subscription.js | 2 +- server/lib/views/index.js | 5 +++ server/lib/views/subscription.js | 1 - views/about/_blank.ejs | 2 +- views/about/about.ejs | 16 +------- views/about/brochure.ejs | 79 ++++++++++++++++++++++++++++++++++++++ views/about/howto.ejs | 2 +- views/builder.ejs | 2 +- views/docs.ejs | 2 +- views/editor.ejs | 2 +- views/home.ejs | 2 +- views/modal.ejs | 2 +- views/profile.ejs | 2 +- views/reader.ejs | 2 +- views/staff/_header.ejs | 2 +- 17 files changed, 116 insertions(+), 27 deletions(-) create mode 100644 views/about/brochure.ejs (limited to 'server/lib/views/index.js') diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css index aecd6be..0463e26 100755 --- a/public/assets/stylesheets/app.css +++ b/public/assets/stylesheets/app.css @@ -673,7 +673,21 @@ iframe.embed { font-weight: 300; } +.aboutintro { + text-align: center; + line-height: 43px; + font-size: 24px; + padding: 5% 0; + font-weight: 300; +} +.aboutintro .inner { + max-width: 800px; + margin: 0 auto; + text-align: center; +} + /* PROFILE PAGE */ + .profilePic { background-size: cover; background-position: center; diff --git a/server/lib/schemas/Plan.js b/server/lib/schemas/Plan.js index 3e74997..1057bb2 100644 --- a/server/lib/schemas/Plan.js +++ b/server/lib/schemas/Plan.js @@ -13,6 +13,12 @@ var PlanSchema = new mongoose.Schema({ monthly_price: { type: Number }, yearly_price: { type: Number }, + basic_layout_monthly_price: { type: Number }, + basic_layout_yearly_price: { type: Number }, + + pro_layout_monthly_price: { type: Number }, + pro_layout_yearly_price: { type: Number }, + basic_layout_limit: { type: Number }, pro_layout_limit: { type: Number }, diff --git a/server/lib/schemas/Subscription.js b/server/lib/schemas/Subscription.js index 8d0b10e..8315009 100644 --- a/server/lib/schemas/Subscription.js +++ b/server/lib/schemas/Subscription.js @@ -15,7 +15,7 @@ var SubscriptionSchema = new mongoose.Schema({ plans: [{ tier: { type: String }, monthly: { type: Boolean }, - }] + }], created_at: { type: Date, default: Date.now }, updated_at: { type: Date, default: Date.now }, diff --git a/server/lib/views/index.js b/server/lib/views/index.js index 3326499..5f9088b 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -111,6 +111,11 @@ var views = module.exports = { res.render('about/' + name) return } + if (name == "brochure") { + // TODO: fetch plans + res.render('about/' + name) + return + } if (name == "about" || name == "index") { res.render('about/' + name) return diff --git a/server/lib/views/subscription.js b/server/lib/views/subscription.js index 77db1a0..ba54bb4 100644 --- a/server/lib/views/subscription.js +++ b/server/lib/views/subscription.js @@ -12,7 +12,6 @@ var subscription = module.exports = { fields: { user: "_id username displayName photo created_at updated_at last_seen created_ip last_ip", - project: "_id name slug user_id privacy created_at updated_at", }, defaults: { diff --git a/views/about/_blank.ejs b/views/about/_blank.ejs index 0e9ea7e..3c23fa7 100644 --- a/views/about/_blank.ejs +++ b/views/about/_blank.ejs @@ -1,7 +1,7 @@ - vvalls + VValls [[ include ../partials/meta ]] diff --git a/views/about/about.ejs b/views/about/about.ejs index dd536be..2aec982 100644 --- a/views/about/about.ejs +++ b/views/about/about.ejs @@ -1,7 +1,7 @@ - vvalls + About VValls [[ include ../partials/meta ]] @@ -50,17 +50,3 @@ [[ include ../partials/scripts ]] - \ No newline at end of file diff --git a/views/about/brochure.ejs b/views/about/brochure.ejs new file mode 100644 index 0000000..00083cf --- /dev/null +++ b/views/about/brochure.ejs @@ -0,0 +1,79 @@ + + + + VValls Subscriptions + [[ include ../partials/meta ]] + + +
+ [[ include ../partials/header ]] + +

Subscriptions

+ +
+
+ Want to get more out of VValls? Consider becoming a subscription user. +
+
+ +
+

[[- plans.free.name ]]

+
    +
  • One exhibition with pre-designed template floor plan +
+
+ +
+

[[- plans.premium.name ]]

+
    +
  • $[[- plans.premium.monthly_price ]]/mo or $[[- plans.premium.yearly_price ]]/year +
  • [[- plans.premium.stock_layout_project_limit ]] exhibitions included with pre-designed template floor plans +
  • Each new basic floor plan costs $[[- plans.premium.basic_layout_monthly_price ]]/mo + or $[[- plans.premium.basic_layout_yearly_price ]]/year, minimum 3 months +
  • Each new basic floor plan can have up to [[- plans.premium.basic_layout_project_limit ]] exhibitions +
  • VValls logo appears when embedding an exhibition on a web page +
+
+ +
+

[[- plans.pro.name ]]

+
    +
  • $[[- plans.pro.monthly_price ]]/mo or $[[- plans.pro.yearly_price ]]/year +
  • Comes with [[- plans.premium.pro_layout_limit ]] pro floor plan and [[- plans.premium.pro_layout_project_limit ]] exhibitions +
  • Each new pro floor plan costs $[[- plans.pro.pro_layout_monthly_price ]]/mo + or $[[- plans.pro.pro_layout_yearly_price ]]/year, minimum 3 months +
  • Each new pro floor plan can have up to [[- plans.pro.pro_layout_project_limit ]] exhibitions +
  • Includes planning for 3D objects in the room +
  • No VValls logo on embed +
+
+ +
+ Buying any extra floor plan unlocks collaboration. Invite an artist or curator to work on the exhibition with you. +
+ +
+ Basic Floor plan: Rectangle-based design of any dimension. +
+ +
+ Pro Floor plan: Trace an arbitrary floorplan. +
+ + +
+

Custom

+ We offer many types of customizations and white-label options for business and educational uses. + Contact us for more information +
+ + + [[ include ../partials/confirm-modal ]] + [[ include ../projects/layouts-modal ]] + [[ include ../partials/sign-in ]] + [[ include ../partials/footer ]] + +
+ +[[ include ../partials/scripts ]] + diff --git a/views/about/howto.ejs b/views/about/howto.ejs index 5278a40..914c3b3 100644 --- a/views/about/howto.ejs +++ b/views/about/howto.ejs @@ -1,7 +1,7 @@ - vvalls + How to Use VValls [[ include ../partials/meta ]] diff --git a/views/builder.ejs b/views/builder.ejs index afb8c66..0ba4238 100644 --- a/views/builder.ejs +++ b/views/builder.ejs @@ -1,7 +1,7 @@ - vvalls + VValls [[ include partials/meta ]] diff --git a/views/docs.ejs b/views/docs.ejs index b3ead82..a1f081f 100644 --- a/views/docs.ejs +++ b/views/docs.ejs @@ -1,7 +1,7 @@ - vvalls + VValls [[ include partials/meta ]] diff --git a/views/editor.ejs b/views/editor.ejs index 656615c..74e4d6d 100755 --- a/views/editor.ejs +++ b/views/editor.ejs @@ -1,7 +1,7 @@ - vvalls + VValls [[ include partials/meta ]] diff --git a/views/home.ejs b/views/home.ejs index 36fc2fc..ffb0976 100755 --- a/views/home.ejs +++ b/views/home.ejs @@ -1,7 +1,7 @@ - vvalls + VValls [[ include partials/meta ]] diff --git a/views/modal.ejs b/views/modal.ejs index 7ca869c..732953d 100644 --- a/views/modal.ejs +++ b/views/modal.ejs @@ -1,7 +1,7 @@ - vvalls + VValls [[ include partials/meta ]] diff --git a/views/profile.ejs b/views/profile.ejs index a62652c..88af6b0 100644 --- a/views/profile.ejs +++ b/views/profile.ejs @@ -1,7 +1,7 @@ - vvalls + VValls | [[- profile.displayName ]] [[ include partials/meta ]] diff --git a/views/reader.ejs b/views/reader.ejs index 6c9856a..7035356 100644 --- a/views/reader.ejs +++ b/views/reader.ejs @@ -1,7 +1,7 @@ - vvalls + VValls [[ include partials/meta ]] diff --git a/views/staff/_header.ejs b/views/staff/_header.ejs index 3bbf4f1..a73c12e 100644 --- a/views/staff/_header.ejs +++ b/views/staff/_header.ejs @@ -1,7 +1,7 @@ - vvalls | staff + VValls | staff [[ include ../partials/meta ]] -- cgit v1.2.3-70-g09d2 From 372b8eb7f2a34902c72f5a831404070b5bd761c1 Mon Sep 17 00:00:00 2001 From: Julie Lala Date: Fri, 9 Jan 2015 07:53:23 -0500 Subject: edit brochure --- server/lib/views/index.js | 20 ++++++++++++++++++-- views/about/brochure.ejs | 12 ++++++------ 2 files changed, 24 insertions(+), 8 deletions(-) (limited to 'server/lib/views/index.js') diff --git a/server/lib/views/index.js b/server/lib/views/index.js index 5f9088b..2a8f921 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -4,6 +4,7 @@ var User = require('../schemas/User'), Project = require('../schemas/Project'), Documentation = require('../schemas/Documentation'), Collaborator = require('../schemas/Collaborator'), + Plan = require('../schemas/Plan'), config = require('../../../config'), marked = require('marked'), util = require('../util'), @@ -111,9 +112,11 @@ var views = module.exports = { res.render('about/' + name) return } - if (name == "brochure") { + if (name == "brochure" || name == "plans") { // TODO: fetch plans - res.render('about/' + name) + views_middleware.ensurePlans(req, res, function(){ + res.render('about/' + name) + }) return } if (name == "about" || name == "index") { @@ -224,6 +227,19 @@ var views = module.exports = { } var views_middleware = { + ensurePlans: function(req, res, next){ + Plan.find(function (err, plans) { + res.locals.plans = {} + plans.forEach(function(plan){ + res.locals.plans[ plan.slug ] = plan + "monthly_price yearly_price basic_layout_monthly_price basic_layout_yearly_price pro_layout_monthly_price pro_layout_yearly_price".split(" ").forEach(function(key){ + plan[key] = (plan[key]/100).toFixed(2)+"" + }) + }) + next() + }) + }, + fetchProjects: function (criteria, limit, offset, next) { limit = limit || 7 offset = offset || 0 diff --git a/views/about/brochure.ejs b/views/about/brochure.ejs index d816dc4..4ce558a 100644 --- a/views/about/brochure.ejs +++ b/views/about/brochure.ejs @@ -19,7 +19,7 @@

[[- plans.free.name ]]

    -
  • One exhibition with pre-designed template floor plan +
  • [[- plans.free.stock_project_limit ]] exhibition with pre-designed template floor plan
@@ -27,10 +27,10 @@

[[- plans.premium.name ]]

  • $[[- plans.premium.monthly_price ]]/mo or $[[- plans.premium.yearly_price ]]/year -
  • [[- plans.premium.stock_layout_project_limit ]] exhibitions included with pre-designed template floor plans +
  • [[- plans.premium.stock_project_limit ]] exhibitions included with pre-designed template floor plans
  • Each new basic floor plan costs $[[- plans.premium.basic_layout_monthly_price ]]/mo or $[[- plans.premium.basic_layout_yearly_price ]]/year, minimum 3 months -
  • Each new basic floor plan can have up to [[- plans.premium.basic_layout_project_limit ]] exhibitions +
  • Each new basic floor plan can have up to [[- plans.premium.basic_project_limit ]] exhibitions
  • VValls logo appears when embedding an exhibition on a web page
@@ -39,10 +39,10 @@

[[- plans.pro.name ]]

  • $[[- plans.pro.monthly_price ]]/mo or $[[- plans.pro.yearly_price ]]/year -
  • Comes with [[- plans.premium.pro_layout_limit ]] pro floor plan and [[- plans.premium.pro_layout_project_limit ]] exhibitions +
  • Comes with [[- plans.premium.pro_layout_limit ]] pro floor plan and [[- plans.premium.pro_project_limit ]] exhibitions
  • Each new pro floor plan costs $[[- plans.pro.pro_layout_monthly_price ]]/mo or $[[- plans.pro.pro_layout_yearly_price ]]/year, minimum 3 months -
  • Each new pro floor plan can have up to [[- plans.pro.pro_layout_project_limit ]] exhibitions +
  • Each new pro floor plan can have up to [[- plans.pro.pro_project_limit ]] exhibitions
  • Includes planning for 3D objects in the room
  • No VValls logo on embed
@@ -57,7 +57,7 @@
- Pro Floor plan: Trace an arbitrary floor plan. + Pro Floor plan: Trace an arbitrary floor plan from image.
-- cgit v1.2.3-70-g09d2 From 717e87b7422db8e1eda655fbf04e45fe5f877c9b Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 20 Jan 2015 00:10:23 -0500 Subject: combining webhook stuff --- package.json | 1 + server/index.js | 3 -- server/lib/api/profile.js | 1 + server/lib/schemas/Subscription.js | 1 + server/lib/schemas/User.js | 4 +- server/lib/views/index.js | 1 - server/lib/views/subscription.js | 105 ------------------------------------- server/lib/webhook/config.js | 6 +++ server/lib/webhook/index.js | 88 +++++++++++++++++++++++++++++++ 9 files changed, 100 insertions(+), 110 deletions(-) delete mode 100644 server/lib/views/subscription.js create mode 100644 server/lib/webhook/config.js create mode 100644 server/lib/webhook/index.js (limited to 'server/lib/views/index.js') diff --git a/package.json b/package.json index 34e0c4c..8afb96e 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "mongoose-unique-validator": "~0.3.0", "monk": "~0.7.1", "multer": "~0.1.0", + "node-recurly": "^2.1.0", "node-restful": "~0.1.14", "passport": "~0.2.0", "passport-facebook": "~1.0.3", diff --git a/server/index.js b/server/index.js index 0f4941a..9a9323c 100644 --- a/server/index.js +++ b/server/index.js @@ -70,9 +70,6 @@ site.setup = function(){ app.all('*', middleware.ensureLocals); app.all('*', middleware.ensureIP); - // where should this live? - app.get('/subscribe/webhook', views.subscription.webhook); - server = http.createServer(app) server.listen(app.get('port'), function () { console.log('Express server listening on port ' + app.get('port')); diff --git a/server/lib/api/profile.js b/server/lib/api/profile.js index 996505f..d72a2c3 100644 --- a/server/lib/api/profile.js +++ b/server/lib/api/profile.js @@ -32,6 +32,7 @@ var profile = { delete data.old_password delete data.new_password delete data.isStaff + delete data.plan_level data.updated_at = new Date () if (req.files.avatar) { diff --git a/server/lib/schemas/Subscription.js b/server/lib/schemas/Subscription.js index 8315009..7f2579b 100644 --- a/server/lib/schemas/Subscription.js +++ b/server/lib/schemas/Subscription.js @@ -15,6 +15,7 @@ var SubscriptionSchema = new mongoose.Schema({ plans: [{ tier: { type: String }, monthly: { type: Boolean }, + projects: [{ type: mongoose.Schema.ObjectId }], }], created_at: { type: Date, default: Date.now }, diff --git a/server/lib/schemas/User.js b/server/lib/schemas/User.js index 180a140..ae1d912 100644 --- a/server/lib/schemas/User.js +++ b/server/lib/schemas/User.js @@ -54,7 +54,9 @@ var UserSchema = new mongoose.Schema({ type: String, default: "", }, - + + plan_level: { type: Number, default: 0 }, + location: { type: String, default: "" }, photo: { type: String, default: "" }, bio: { type: String, default: "" }, diff --git a/server/lib/views/index.js b/server/lib/views/index.js index 2a8f921..0ce0357 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -22,7 +22,6 @@ marked.setOptions({ var views = module.exports = { staff: require('./staff'), - subscription: require('./subscription'), editor_new: function (req, res) { if (! req.user) { diff --git a/server/lib/views/subscription.js b/server/lib/views/subscription.js deleted file mode 100644 index b9c79cb..0000000 --- a/server/lib/views/subscription.js +++ /dev/null @@ -1,105 +0,0 @@ -/* jshint node: true */ - -var User = require('../schemas/User'), - Subscription = require('../schemas/Subscription'), - config = require('../../../config'), - middleware = require('../middleware'), - util = require('../util'), - _ = require('lodash'), - moment = require('moment'), - xml2js = require('xml2js'); - -var parser = new xml2js.Parser(); -// fs.readFile('./foo.xml', function(err, data) { -// parser.parseString(data, function (err, result) { -// console.log(inspect(result, { colors: true, depth: Infinity })); -// }); -// }); - -var subscription = module.exports = { - - fields: [ - // accounts - "new_account_notification", - "canceled_account_notification", - "billing_info_updated_notification", - "reactivated_account_notification", - - // invoices - "new_invoice_notification", - "closed_invoice_notification", - "past_due_invoice_notification", - - // subscriptions - "new_subscription_notification", - "updated_subscription_notification", - "canceled_subscription_notification", - "expired_subscription_notification", - "renewed_subscription_notification", - - // payments - "successful_payment_notification", - "failed_payment_notification", - "successful_refund_notification", - "void_payment_notification", - ], - - middleware: { - }, - - callbacks: { - // accounts - new_account_notification: function(data){ - }, - canceled_account_notification: function(data){ - }, - billing_info_updated_notification: function(data){ - }, - reactivated_account_notification: function(data){ - }, - - // invoices - new_invoice_notification: function(data){ - }, - closed_invoice_notification: function(data){ - }, - past_due_invoice_notification: function(data){ - }, - - // subscriptions - new_subscription_notification: function(data){ - }, - updated_subscription_notification: function(data){ - }, - canceled_subscription_notification: function(data){ - }, - expired_subscription_notification: function(data){ - }, - renewed_subscription_notification: function(data){ - }, - - // payments - successful_payment_notification: function(data){ - }, - failed_payment_notification: function(data){ - }, - successful_refund_notification: function(data){ - }, - void_payment_notification: function(data){ - }, - }, - - // need a route for the webhook, - // then calls to get appropriate info from the recurly api - webhook: function(req, res){ - res.status(200).end() - parser.parseString(data, function (err, result) { - console.log(inspect(result, { colors: true, depth: Infinity })); - for (var i in data) { - if (subscription.callbacks[i]) { - subscription.callbacks[i](data) - } - } - }); - }, -} diff --git a/server/lib/webhook/config.js b/server/lib/webhook/config.js new file mode 100644 index 0000000..ecafeb3 --- /dev/null +++ b/server/lib/webhook/config.js @@ -0,0 +1,6 @@ +module.exports = { + API_KEY: require('process').env['VVALLS_RECURLY_SECRET'], + SUBDOMAIN: 'vvalls', + ENVIRONMENT: 'sandbox', + DEBUG: true, +}; diff --git a/server/lib/webhook/index.js b/server/lib/webhook/index.js new file mode 100644 index 0000000..c4b4b76 --- /dev/null +++ b/server/lib/webhook/index.js @@ -0,0 +1,88 @@ +// // where should this live? +// app.get('/subscribe/webhook', views.subscription.webhook); + +/* jshint node: true */ + +var User = require('../schemas/User'), + Subscription = require('../schemas/Subscription'), + config = require('../../../config'), + middleware = require('../middleware'), + util = require('../util'), + _ = require('lodash'), + moment = require('moment'), + xml2js = require('xml2js'), + Recurly = require('node-recurly'), + recurly = new Recurly(require('./config')); + +var parser = new xml2js.Parser(); +// fs.readFile('./foo.xml', function(err, data) { +// parser.parseString(data, function (err, result) { +// console.log(inspect(result, { colors: true, depth: Infinity })); +// }); +// }); + +/* +app.use(express.basicAuth(function(user, pass, callback) { + var result = (user === 'testUser' && pass === 'testPass'); + callback(null, result); +})); +*/ + +var subscription = module.exports = { + + callbacks: { + // accounts + new_account_notification: function(data){ + }, + canceled_account_notification: function(data){ + }, + billing_info_updated_notification: function(data){ + }, + reactivated_account_notification: function(data){ + }, + + // invoices + new_invoice_notification: function(data){ + }, + closed_invoice_notification: function(data){ + }, + past_due_invoice_notification: function(data){ + }, + + // subscriptions + new_subscription_notification: function(data){ + }, + updated_subscription_notification: function(data){ + }, + canceled_subscription_notification: function(data){ + }, + expired_subscription_notification: function(data){ + }, + renewed_subscription_notification: function(data){ + }, + + // payments + successful_payment_notification: function(data){ + }, + failed_payment_notification: function(data){ + }, + successful_refund_notification: function(data){ + }, + void_payment_notification: function(data){ + }, + }, + + // need a route for the webhook, + // then calls to get appropriate info from the recurly api + webhook: function(req, res){ + res.status(200).end() + parser.parseString(data, function (err, result) { + console.log(inspect(result, { colors: true, depth: Infinity })); + for (var i in data) { + if (subscription.callbacks[i]) { + subscription.callbacks[i](data[i]) + } + } + }); + }, +} -- cgit v1.2.3-70-g09d2 From d86d15c60c06843f8f22cdcf5b809c3a48e6a628 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 30 Jan 2015 17:05:15 -0500 Subject: plans partial, min on number fields --- .../javascripts/ui/site/EditSubscriptionModal.js | 32 +++--- public/assets/stylesheets/app.css | 60 ++++++++++- server/index.js | 2 + server/lib/api/subscription.js | 10 +- server/lib/views/index.js | 9 ++ views/about/brochure.ejs | 113 +-------------------- views/partials/edit-subscription.ejs | 17 ++-- views/staff/plans/_form.ejs | 24 ++--- 8 files changed, 114 insertions(+), 153 deletions(-) (limited to 'server/lib/views/index.js') diff --git a/public/assets/javascripts/ui/site/EditSubscriptionModal.js b/public/assets/javascripts/ui/site/EditSubscriptionModal.js index 8952e42..d5eb9ac 100644 --- a/public/assets/javascripts/ui/site/EditSubscriptionModal.js +++ b/public/assets/javascripts/ui/site/EditSubscriptionModal.js @@ -47,22 +47,28 @@ var EditSubscriptionModal = ModalFormView.extend({ basic: 1, pro: 2, }, + + sync: function(){ + $.put(this.syncAction, this.didLoad.bind(this)) + }, loaded: false, load: function(){ this.reset() if (this.loaded) { return this.show() } - $.get(this.action, function(data){ - this.loaded = true - if (data.subscriber) { - this.subscriber = data.subscription - this.plans = data.plans - } - else if (data.error) { - // ...no subscription found - } - return this.show() - }.bind(this)) + $.get(this.action, this.didLoad.bind(this)) + }, + didLoad: function(data){ + this.loaded = true + this.plans = data.plans + if (data.subscription) { + this.subscriber = data.subscription + } + else if (data.error) { + // ...no subscription found + this.subscriber = null + } + return this.show() }, show: function(){ @@ -122,20 +128,18 @@ var EditSubscriptionModal = ModalFormView.extend({ type: "put", data: { _csrf: this.$csrf.val() }, success: function(data){ - window.location.href = "/profile" } }) }, destroy: function(){ - var msg = "Are you sure you want to cancel your subscription " + sanitize(this.$name.val()) + "?" + var msg = "Are you sure you want to cancel your subscription?" ConfirmModal.confirm(msg, function(){ $.ajax({ url: this.destroyAction, type: "delete", data: { _csrf: this.$csrf.val() }, success: function(data){ - window.location.href = "/profile" } }) }.bind(this)) diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css index 0ce2c5e..5d7199c 100755 --- a/public/assets/stylesheets/app.css +++ b/public/assets/stylesheets/app.css @@ -156,7 +156,7 @@ a{ display: none; border-right:0px!important; } -.editProfile, .profileLink { +.profileLink { border-right:0px!important; } .editing #help-button { @@ -849,6 +849,7 @@ iframe.embed { } + .projectList.about.gopro { padding:6% 0; } @@ -900,6 +901,57 @@ iframe.embed { background:black; color:white; } + +/* PLANS BROCHURE */ +/* nb these styles should be fixed for narrower screens/mobile layout */ +.about_plan { + width: 28vw; + margin: 2vw; + float: left; + min-height: 28vw; + position: relative; +} +.about_plan button { + position: absolute; + bottom: 5%; + left: 5%; + width: 90%; +} +.about_custom { + clear: both; + width: 76vw; + margin: 2vw 10vw; +} +.planbox { + padding: 2vw; + border: 1px solid #ddd; + background: white; + border-radius: 25px; + font-size: 15px; + line-height: 23px; + text-align: center; +} +.planbox h3 { + text-align: center; + margin-bottom: 10px; +} +.about_plan ul { + margin-bottom: 60px; +} +.planbox li { + list-style-type: none; + margin-bottom: 5px; +} +.planbox.miscbox { + border: 0; + background: #f8f8f8; +} +.about_custom a { + border-bottom: 1px solid; +} + +/* LAYOUTS MODAL */ + .templates { overflow: auto; max-height: 100%; @@ -918,8 +970,8 @@ iframe.embed { } .templates::-webkit-scrollbar-thumb { -background-color: white; -border-left: 1px solid black; + background-color: white; + border-left: 1px solid black; } .templates::-webkit-scrollbar-track { @@ -990,6 +1042,8 @@ border-left: 1px solid black; float:right; } +/* MX SCENE STUFF */ + .mx-scene { position:fixed; top:0; diff --git a/server/index.js b/server/index.js index 2f6cb2d..fa7044b 100644 --- a/server/index.js +++ b/server/index.js @@ -156,6 +156,8 @@ site.route = function () { app.put('/api/subscription', middleware.ensureAuthenticated, api.subscription.middleware.ensureSubscription, api.subscription.update) app.delete('/api/subscription', middleware.ensureAuthenticated, api.subscription.middleware.ensureSubscription, api.subscription.destroy) + app.get('/partials/plans', views.partials.plans) + app.get('/test/*', middleware.ensureAuthenticated, middleware.ensureIsStaff, views.modal) views.staff.route(app) diff --git a/server/lib/api/subscription.js b/server/lib/api/subscription.js index 9478d78..b7b3434 100644 --- a/server/lib/api/subscription.js +++ b/server/lib/api/subscription.js @@ -84,7 +84,10 @@ var subscription = module.exports = { subscriber.save(function(){ user.save(function(){ - res.render(subscriber) + res.render({ + subscription: req.subscription, + plans: res.locals.plans + }) }) }) }) @@ -98,7 +101,10 @@ var subscription = module.exports = { }) } else { - res.json({ error: "no subscription" }) + res.json({ + error: "no subscription", + plans: res.locals.plans, + }) } }, diff --git a/server/lib/views/index.js b/server/lib/views/index.js index 0ce0357..89167f7 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -104,6 +104,15 @@ var views = module.exports = { }) }, + partials: { + plans: function (req, res){ + views_middleware.ensurePlans(req, res, function(){ + console.log("<<<<
-
-

[[- plans.free.name ]]

-
    -
  • [[- plans.free.stock_project_limit ]] exhibition with pre-designed template floor plan -
-
- -
-

[[- plans.basic.name ]]

-
    -
  • $[[- plans.basic.monthly_price ]]/mo or $[[- plans.basic.yearly_price ]]/year -
  • Comes with [[- plans.basic.basic_layout_limit ]] basic floor plan and [[- plans.basic.basic_project_limit ]] exhibitions -
  • Each new basic floor plan costs $[[- plans.basic.basic_layout_monthly_price ]]/mo - or $[[- plans.basic.basic_layout_yearly_price ]]/year, minimum 3 months -
  • Each new floor plan can have up to [[- plans.basic.basic_project_limit ]] exhibitions -
  • VValls logo appears when embedding an exhibition on a web page -
  • - [[ if (! logged_in) { ]] - - [[ } else if (! user.plan_level) { ]] - - [[ } else if (user.plan_level == plan.level) { ]] - Current Level - [[ } ]] -
-
- -
-

[[- plans.pro.name ]]

-
    -
  • $[[- plans.pro.monthly_price ]]/mo or $[[- plans.pro.yearly_price ]]/year -
  • Comes with [[- plans.pro.pro_layout_limit ]] pro floor plan and [[- plans.pro.pro_project_limit ]] exhibitions -
  • Each new pro floor plan costs $[[- plans.pro.pro_layout_monthly_price ]]/mo - or $[[- plans.pro.pro_layout_yearly_price ]]/year, minimum 3 months -
  • Each new pro floor plan can have up to [[- plans.pro.pro_project_limit ]] exhibitions -
  • Includes planning for 3D objects in the room -
  • No VValls logo on embed -
  • - [[ if (! logged_in) { ]] - - [[ } else if (! user.plan_level) { ]] - - [[ } else if (user.plan_level == plan.level) { ]] - Current Level - [[ } else if (user.plan_level < plan.level) { ]] - - [[ } ]] -
-
- -
-
    -
  • Buying any extra floor plan unlocks collaboration. Invite an artist or curator to work on the exhibition with you. -
  • Basic Floor plan: Rectangle-based design of any dimension. -
  • Pro Floor plan: Trace an arbitrary floor plan from image. -
-
- -
-

Want Something Custom?

-
  • We offer customized white-label options for business and educational uses. -
  • Contact us for more information. -
  • + [[ include _plans ]] - [[ include ../partials/confirm-modal ]] [[ include ../projects/layouts-modal ]] [[ include ../partials/sign-in ]] @@ -91,51 +28,3 @@ [[ include ../partials/scripts ]] - \ No newline at end of file diff --git a/views/partials/edit-subscription.ejs b/views/partials/edit-subscription.ejs index bb7cc27..2f6e4c1 100644 --- a/views/partials/edit-subscription.ejs +++ b/views/partials/edit-subscription.ejs @@ -7,15 +7,14 @@
  • Edit Subscription

  • -
    - You are currently using the free plan. For access to all of Vvalls features, +
  • + You are currently using the free version of Vvalls. For access to all of Vvalls features, consider upgrading to a paid plan. -

    - View the Plans -

  • - + +
    +

    [[- plans.basic.name ]]

    +
      +
    • $[[- plans.basic.monthly_price ]]/mo or $[[- plans.basic.yearly_price ]]/year +
    • Comes with [[- plans.basic.basic_layout_limit ]] basic floor plan and [[- plans.basic.basic_project_limit ]] exhibitions +
    • Each new basic floor plan costs $[[- plans.basic.basic_layout_monthly_price ]]/mo + or $[[- plans.basic.basic_layout_yearly_price ]]/year, minimum 3 months +
    • Each new floor plan can have up to [[- plans.basic.basic_project_limit ]] exhibitions +
    • VValls logo appears when embedding an exhibition on a web page +
    • + [[ if (! logged_in) { ]] + + [[ } else if (! user.plan_level) { ]] + + [[ } else if (user.plan_level == plan.level) { ]] + Current Level + [[ } ]] +
    +
    + +
    +

    [[- plans.pro.name ]]

    +
      +
    • $[[- plans.pro.monthly_price ]]/mo or $[[- plans.pro.yearly_price ]]/year +
    • Comes with [[- plans.pro.pro_layout_limit ]] pro floor plan and [[- plans.pro.pro_project_limit ]] exhibitions +
    • Each new pro floor plan costs $[[- plans.pro.pro_layout_monthly_price ]]/mo + or $[[- plans.pro.pro_layout_yearly_price ]]/year, minimum 3 months +
    • Each new pro floor plan can have up to [[- plans.pro.pro_project_limit ]] exhibitions +
    • Includes planning for 3D objects in the room +
    • No VValls logo on embed +
    • + [[ if (! logged_in) { ]] + + [[ } else if (! user.plan_level) { ]] + + [[ } else if (user.plan_level == plan.level) { ]] + Current Level + [[ } else if (user.plan_level < plan.level) { ]] + + [[ } ]] +
    +
    + +
    +
      +
    • Buying any extra floor plan unlocks collaboration.
      Invite an artist or curator to work on the exhibition with you. +
    • Basic Floor plan: Rectangle-based design of any dimension. +
    • Pro Floor plan: Trace an arbitrary floor plan from image. +
    +
    + +
    +

    Want Something Custom?

    +
  • We offer customized white-label options for business and educational uses. +
  • Contact us for more information. +
  • diff --git a/views/partials/edit-subscription.ejs b/views/partials/edit-subscription.ejs index 2f6e4c1..cc296f6 100644 --- a/views/partials/edit-subscription.ejs +++ b/views/partials/edit-subscription.ejs @@ -1,19 +1,19 @@
    X
    - +
    • Edit Subscription

    • -
    • +
    • You are currently using the free version of Vvalls. For access to all of Vvalls features, consider upgrading to a paid plan.

      - +
    • -
    • Your current plan level is diff --git a/views/staff/_users.ejs b/views/staff/_users.ejs index 053e289..46811b6 100644 --- a/views/staff/_users.ejs +++ b/views/staff/_users.ejs @@ -12,7 +12,8 @@
      [[- user.last_seen ]] -- cgit v1.2.3-70-g09d2 From 03842d65cc018f9a718b2408d19e978f3d08e042 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 2 Feb 2015 13:23:51 -0500 Subject: sanity --- server/lib/views/index.js | 2 +- server/lib/webhook/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'server/lib/views/index.js') diff --git a/server/lib/views/index.js b/server/lib/views/index.js index 9f244c8..be46cc6 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -107,7 +107,7 @@ var views = module.exports = { partials: { plans: function (req, res){ views_middleware.ensurePlans(req, res, function(){ - res.render('about/_plans') + res.render('about/_plans', { logged_in: res.locals.logged_in || false }) }) }, }, diff --git a/server/lib/webhook/index.js b/server/lib/webhook/index.js index 11419c2..798e4be 100644 --- a/server/lib/webhook/index.js +++ b/server/lib/webhook/index.js @@ -37,7 +37,7 @@ site.ready = function(){ console.log('Webhook server listening on port ' + app.get('port')); }); - app.get('/', function(req,res){ res.send('HI THERE') }) + app.get('/', function(req,res){ res.send('hello@vvalls.com') }) webhook.route(app) } -- cgit v1.2.3-70-g09d2 From 8ae88bc8540c0b2265748cb0df452c0370630289 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 20 Jul 2015 14:53:38 -0400 Subject: show plans on homepage --- server/lib/views/index.js | 16 ++++++++++------ views/about/_plans.ejs | 6 +++--- views/home.ejs | 15 ++++++--------- 3 files changed, 19 insertions(+), 18 deletions(-) (limited to 'server/lib/views/index.js') diff --git a/server/lib/views/index.js b/server/lib/views/index.js index be46cc6..5241ddb 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -89,17 +89,21 @@ var views = module.exports = { }, home: function (req, res) { - views_middleware.fetchProjects({ featured: true }, null, null, function(err, projects){ - res.render('home', { - projects: projects || [] + views_middleware.ensurePlans(req, res, function(err){ + views_middleware.fetchProjects({ featured: true }, null, null, function(err, projects){ + res.render('home', { + projects: projects || [], + }) }) }) }, demoHome: function (req, res) { - views_middleware.fetchProjects({ featured: true }, null, null, function(err, projects){ - res.render('home', { - projects: projects || [] + views_middleware.ensurePlans(req, res, function(err){ + views_middleware.fetchProjects({ featured: true }, null, null, function(err, projects){ + res.render('home', { + projects: projects || [], + }) }) }) }, diff --git a/views/about/_plans.ejs b/views/about/_plans.ejs index af2a050..ba42e28 100644 --- a/views/about/_plans.ejs +++ b/views/about/_plans.ejs @@ -1,4 +1,3 @@ -
      +

      Want Something Custom?

    • We offer customized white-label options for business and educational uses. diff --git a/views/home.ejs b/views/home.ejs index b83e3e9..2bf5662 100755 --- a/views/home.ejs +++ b/views/home.ejs @@ -62,15 +62,12 @@ [[ include projects/list-projects ]] -
      - - -

      Ready To Go Pro?

      - Use VValls as part of your product, service, or marketing campaign. - We offer many types of customizations, including automation of layouts, more elaborate floor plans, enhanced video, interactivity, and other features. - Contact -
      -
      +

      Sign Up

      + +
      + [[ include about/_plans ]] +
      + [[ include partials/confirm-modal ]] [[ include projects/layouts-modal ]] [[ include partials/sign-in ]] -- cgit v1.2.3-70-g09d2 From 599b43df07f092b35d25e7adac11db3c3b3d9c76 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 17 Aug 2015 12:23:39 -0400 Subject: BlueprintEditor --- public/assets/javascripts/ui/_router.js | 7 +- .../javascripts/ui/blueprint/BlueprintEditor.js | 155 +++++++++++++++++++++ .../javascripts/ui/blueprint/BlueprintView.js | 18 +-- server/index.js | 3 + server/lib/views/index.js | 4 + views/blueprint.ejs | 1 + views/controls/blueprint/editor.ejs | 53 ------- views/controls/blueprint/scaler.ejs | 48 +++++++ views/partials/scripts.ejs | 1 + 9 files changed, 227 insertions(+), 63 deletions(-) create mode 100644 public/assets/javascripts/ui/blueprint/BlueprintEditor.js create mode 100644 views/controls/blueprint/scaler.ejs (limited to 'server/lib/views/index.js') diff --git a/public/assets/javascripts/ui/_router.js b/public/assets/javascripts/ui/_router.js index 857377c..177e86f 100644 --- a/public/assets/javascripts/ui/_router.js +++ b/public/assets/javascripts/ui/_router.js @@ -38,6 +38,9 @@ var SiteRouter = Router.extend({ "/layout": 'layoutPicker', "/layout/:name": 'layoutEditor', + "/blueprint": 'blueprintEditor', + "/blueprint/:name": 'blueprintEditor', + "/project": 'projectPicker', "/project/new": 'newProject', "/project/new/:layout": 'projectNewWithLayout', @@ -160,13 +163,13 @@ var SiteRouter = Router.extend({ this.readerView.load(name) }, - blueprintEditor: function(e){ + blueprintEditor: function(e, name){ environment.init = environment.minimal app.launch() if (app.unsupported) return this.blueprintView = app.controller = new BlueprintView () - this.blueprintView.load() + this.blueprintView.load(name) }, signup: function(e){ diff --git a/public/assets/javascripts/ui/blueprint/BlueprintEditor.js b/public/assets/javascripts/ui/blueprint/BlueprintEditor.js new file mode 100644 index 0000000..c781495 --- /dev/null +++ b/public/assets/javascripts/ui/blueprint/BlueprintEditor.js @@ -0,0 +1,155 @@ + +var wall_height = 180 +var shapes = new ShapeList +var last_point = new vec2 (0,0) + +var BlueprintEditor = View.extend(AnimatedView.prototype).extend({ + + initialize: function(opt){ + this.parent = opt.parent + + map = new Map ({ + type: "ortho", + el: document.querySelector("#orthographic"), + width: window.innerWidth/2, + height: window.innerHeight, + zoom: -2, + zoom_min: -6.2, + zoom_max: 1, + }) + map.ui.add_tool("arrow", new ArrowTool) + map.ui.add_tool("polyline", new PolylineTool) + map.ui.add_tool("ortho-polyline", new OrthoPolylineTool) + map.ui.add_tool("eraser", new EraserTool) + map.ui.add_tool("position", new PositionTool) + map.ui.placing = false + +/* + $(window).resize(function(){ + scene.width = window.innerWidth/2 + scene.height = window.innerHeight + map.canvas.width = map.dimensions.a = window.innerWidth/2 + map.canvas.height = map.dimensions.b = window.innerHeight/2 + }) +*/ + + var PerspectiveToolbar = new Toolbar (".persp-hud") + PerspectiveToolbar.add("orbit-mode", function(){ + controls.toggle(true) + movements.lock() + }) + PerspectiveToolbar.add("keyboard-mode", function(){ + controls.toggle(false) + movements.unlock() + movements.gravity(true) + cam.rotationX = 0 + cam.rotationY = -cam.rotationY + cam.x = 0 + cam.y = viewHeight + 100 + cam.z = 0 + }) + + var OrthographicToolbar = new Toolbar (".ortho-hud") + OrthographicToolbar.add("arrow-mode", function(){ + map.ui.set_tool("arrow") + }) + OrthographicToolbar.add("polyline-mode", function(){ + map.ui.set_tool("polyline") + }) + OrthographicToolbar.add("ortho-polyline-mode", function(){ + map.ui.set_tool("ortho-polyline") + }) + OrthographicToolbar.add("eraser-mode", function(){ + map.ui.set_tool("eraser") + }) + OrthographicToolbar.pick("ortho-polyline-mode") + }, + + animate: function(t, dt){ + map.update(t) + + movements.update(dt) + controls.update() + scene.update() + + map.draw.ctx.save() + map.draw.translate() + + floorplan.draw(map.draw.ctx, true) + + map.draw.coords() + + if (shapes.workline) { + shapes.workline.draw(map.draw.ctx) + if (map.ui.placing && last_point) { + shapes.workline.draw_line( map.draw.ctx, last_point ) + } + } + + shapes.forEach(function(shape){ + shape.draw(map.draw.ctx) + }) + + map.draw.ctx.strokeStyle = "#f00"; + map.draw.x_at(0,0) + map.draw.mouse(map.ui.mouse.cursor) + map.draw.camera(scene.camera) + + map.draw.ctx.restore() + }, + +}) + +function build () { + scene = new MX.Scene().addTo("#perspective") + scene.camera.radius = 20 + + viewHeight = 100 + + scene.width = window.innerWidth/2 + scene.height = window.innerHeight + scene.perspective = window.innerHeight + + cam = scene.camera + movements = new MX.Movements(cam, viewHeight) + movements.init() + movements.lock() + movements.velocity(8) + app.on("move", function(pos){ + cam.x = pos.x + cam.y = pos.y + cam.z = pos.z + }) + + floorplan = new MX.Image({ + src: "https://s3.amazonaws.com/luckyplop/fbf4295da80f1f66c5e4a248f2ea3e1ce7a22c3d.jpg", + keepImage: true, + rotationX: -PI/2, + rotationY: PI, + }) + scene.add(floorplan) + + // recenter perspective view by rightclicking map + floorplan.el.addEventListener("contextmenu", function(e){ + e.preventDefault() + var offset = offsetFromPoint(e, this) + var x = (offset.left - 0.5) * floorplan.width * floorplan.scale + var z = (offset.top - 0.5) * floorplan.height * floorplan.scale + controls.opt.center.x = -x + controls.opt.center.y = 0 + controls.opt.center.z = -z + }, true) + + scene.update() + + controls = new MX.OrbitCamera({ + el: scene.el, + radius: 3000, + radiusRange: [ 10, 10000 ], + rotationX: PI/4, + rotationY: PI/2, + }) + controls.init() + + animate(0) +} diff --git a/public/assets/javascripts/ui/blueprint/BlueprintView.js b/public/assets/javascripts/ui/blueprint/BlueprintView.js index 6b204e5..0a06fda 100644 --- a/public/assets/javascripts/ui/blueprint/BlueprintView.js +++ b/public/assets/javascripts/ui/blueprint/BlueprintView.js @@ -1,7 +1,9 @@ var BlueprintView = View.extend({ el: "#blueprintView", - + + action: "/api/layout/", + events: { }, @@ -16,14 +18,14 @@ var BlueprintView = View.extend({ }, load: function(name){ -// if (! name || name == "new") { + if (! name || name == "new") { // this.ready({ isNew: true, _id: "new", name: "" }) -// return -// } -// -// name = sanitize(name) -// -// $.get(this.action + name, this.ready.bind(this)) + return + } + + name = sanitize(name) + + $.get(this.action + name, this.ready.bind(this)) }, ready: function(data){ diff --git a/server/index.js b/server/index.js index 0028888..078db8e 100644 --- a/server/index.js +++ b/server/index.js @@ -127,6 +127,9 @@ site.route = function () { app.get('/layout', middleware.ensureAuthenticated, middleware.ensureIsStaff, views.modal) app.get('/layout/:name', middleware.ensureAuthenticated, middleware.ensureIsStaff, views.builder) + app.get('/blueprint', middleware.ensureAuthenticated, middleware.ensureIsStaff, views.blueprint) + app.get('/blueprint/:name', middleware.ensureAuthenticated, middleware.ensureIsStaff, views.blueprint) + app.get('/join/:nonce', middleware.ensureAuthenticated, api.collaborator.join) app.get('/api/collaborator/:slug/index', middleware.ensureAuthenticated, middleware.ensureProject, api.collaborator.index) app.post('/api/collaborator/:slug/create', middleware.ensureAuthenticated, middleware.ensureProject, api.collaborator.create) diff --git a/server/lib/views/index.js b/server/lib/views/index.js index 5241ddb..523f628 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -84,6 +84,10 @@ var views = module.exports = { res.render('builder') }, + blueprint: function (req, res) { + res.render('blueprint') + }, + modal: function (req, res) { res.render('modal'); }, diff --git a/views/blueprint.ejs b/views/blueprint.ejs index 371d66f..7e13318 100644 --- a/views/blueprint.ejs +++ b/views/blueprint.ejs @@ -16,6 +16,7 @@ [[ include controls/builder/toolbar ]] [[ include controls/builder/settings ]] [[ include controls/blueprint/editor ]] + [[ include controls/blueprint/scaler ]]
    • diff --git a/views/controls/blueprint/editor.ejs b/views/controls/blueprint/editor.ejs index e18f501..5334f85 100644 --- a/views/controls/blueprint/editor.ejs +++ b/views/controls/blueprint/editor.ejs @@ -1,8 +1,4 @@