summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2014-10-10 16:00:01 -0400
committerJules Laplace <jules@okfoc.us>2014-10-10 16:00:01 -0400
commitb35bda803440233b68389603bbaced53f8bb18ba (patch)
treed1ca48fb651307799cb33cb766b0988a5613043f
parent12b7f63b9d6687b3177bf30a212fdf856864b4f5 (diff)
parent8990307ff8f90007b59cf778d2b3da0372dedf14 (diff)
merge
-rw-r--r--public/assets/javascripts/ui/site/ProfileView.js19
-rwxr-xr-xpublic/assets/stylesheets/app.css28
-rw-r--r--public/assets/stylesheets/staff.css2
-rw-r--r--server/lib/api/projects.js21
-rw-r--r--server/lib/views/index.js1
-rw-r--r--views/profile.ejs8
-rw-r--r--views/projects/list-projects.ejs4
7 files changed, 59 insertions, 24 deletions
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 d6a231f..fc7512a 100755
--- a/public/assets/stylesheets/app.css
+++ b/public/assets/stylesheets/app.css
@@ -332,18 +332,16 @@ iframe.embed {
.projectList a {
- width: 32vw;
- float:left;
- clear: right;
- padding-bottom: 2vw;
+ padding: 4%;
+ display: inline-block;
}
.projectList .room {
- width: 30vw;
- height: 23vw;
+ width: 22vw;
+ height: 17vw;
margin: 1vw 1vw 0 1vw;
- display:table;
+ display: table;
position: relative;
- z-index: 1;
+ z-index: 1;
}
.projectList .holder {
position: absolute;
@@ -359,8 +357,9 @@ iframe.embed {
height: 100%;
text-align: center;
overflow: hidden;
- background-color: rgba(128,128,128,0.2);
- background-size: cover;
+ background-color: rgba(128,128,128,0.1);
+ background-size: contain;
+ background-position: center;
}
.projectList a:hover .room .mask {
background-color: rgba(128,128,128,0.1);
@@ -429,7 +428,7 @@ iframe.embed {
text-decoration: none;
display: inline-block;
cursor: pointer;
- border: 1px solid transparent;
+ border: 1px solid black;
line-height: 18px;
padding:0 5px;
}
@@ -502,6 +501,12 @@ iframe.embed {
margin: 0 auto;
display: block;
}
+.docs a {
+ border-bottom: 1px dashed;
+}
+.docs #header a, .docs .footer a {
+ border-bottom: 0;
+}
.docs .options {
margin: 50px auto 0 auto;
@@ -673,6 +678,7 @@ iframe.embed {
}
.profilepage .about h2 .btn {
+ float: none;
border: 1px solid;
font-weight: 500;
padding: 10px;
diff --git a/public/assets/stylesheets/staff.css b/public/assets/stylesheets/staff.css
index c75a9b1..720eb0a 100644
--- a/public/assets/stylesheets/staff.css
+++ b/public/assets/stylesheets/staff.css
@@ -65,9 +65,11 @@ hr {
font-size: 15px;
}
.staff .body a {
+ border-bottom: 1px dotted;
}
.staff .editLinks a {
color: #00f;
+ border-bottom: 1px solid;
}
#iframe-embed, #iframe-embed tr, #iframe-embed td {
width: 79vw;
diff --git a/server/lib/api/projects.js b/server/lib/api/projects.js
index 61a6e10..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)
@@ -67,14 +67,6 @@ var projects = {
return docs.create(req, res)
}
- var data = util.cleanQuery(req.body)
-
- // data.user_id = req.user._id
- data.name = util.sanitize(data.name)
- data.slug = util.slugify(data.name)
- data.description = util.sanitize(data.description)
- data.updated_at = new Date ()
-
if (req.files.thumbnail) {
upload.put("projects", req.files.thumbnail, {
unacceptable: function(err){
@@ -93,6 +85,17 @@ var projects = {
function done() {
Project.findOne({ _id: _id }, function(err, doc){
if (err || ! doc) { return res.json({ error: err }) }
+
+ var data = util.cleanQuery(req.body)
+
+ // data.user_id = req.user._id
+ data.name = util.sanitize(data.name)
+ if (data.name != doc.name) {
+ data.slug = util.slugify(data.name) + "-" + (+new Date)
+ }
+ data.description = util.sanitize(data.description)
+ data.updated_at = new Date ()
+
_.extend(doc, data)
doc.rooms = JSON.parse(data.rooms)
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 @@
<div class="profilePic noPic">
<span class="holder">
<span class="ion-ios7-person-outline"></span>
- <div>click to add profile pic</div>
- <input id="profile_avatar" name="avatar" class="element file" type="file">
+ [[ if (isOwnProfile) { ]]
+ <div>click to add profile pic</div>
+ <input id="profile_avatar" name="avatar" class="element file" type="file">
+ [[ } ]]
</span>
</div>
[[ } ]]
@@ -57,12 +59,14 @@
VValls lets you create awesome 3D rooms.
</h2>
+ [[ if (isOwnProfile) { ]]
<h2>
You don't have any projects yet.
</h2>
<h2>
<a href="#"class="btn" data-role="new-project-modal">Create a New Project</a>
</h2>
+ [[ } ]]
</div>
[[ } ]]
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)) { ]]
- <a href="/project/[[- project.slug ]]/edit">
+ <a href="/project/[[- project.slug ]]/edit" class="projectItem">
[[ } else { ]]
- <a href="/project/[[- project.slug ]]" class="roomName">
+ <a href="/project/[[- project.slug ]]" class="projectItem">
[[ } ]]
<span class="room" style="background-color: rgb([[- project.color ]]);">