summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--public/assets/javascripts/ui/site/ProfileView.js19
-rwxr-xr-xpublic/assets/stylesheets/app.css1
-rw-r--r--server/lib/api/projects.js4
-rw-r--r--server/lib/util.js2
-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, 32 insertions, 7 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 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 @@
<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 ]]);">