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 --- server/lib/views/index.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'server') 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) -- 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') 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') 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') 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