summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
Diffstat (limited to 'public')
-rw-r--r--public/assets/css/bucky.css20
-rwxr-xr-xpublic/assets/img/profile.jpgbin0 -> 35057 bytes
-rw-r--r--public/assets/js/lib/router.js8
-rw-r--r--public/assets/js/lib/views/details/comments.js3
-rw-r--r--public/assets/js/lib/views/index/hootbox.js3
-rw-r--r--public/assets/js/lib/views/profile/profile.js8
-rw-r--r--public/assets/js/lib/views/profile/profile_edit.js50
-rw-r--r--public/assets/js/util/format.js3
8 files changed, 89 insertions, 6 deletions
diff --git a/public/assets/css/bucky.css b/public/assets/css/bucky.css
index ce55bfa..a85ac21 100644
--- a/public/assets/css/bucky.css
+++ b/public/assets/css/bucky.css
@@ -96,6 +96,9 @@ input[type=password] {
border: 1px solid #888;
padding: 3px;
}
+input[type=file] {
+ cursor: pointer;
+}
#menu {
margin: 7px 0 14px;
}
@@ -852,13 +855,26 @@ header .search_form {
/* LOGIN */
-#login div,
-#signup div {
+#login form > div,
+#signup form > div,
+#profile_form form > div {
margin: 2px;
+ display: flex;
+ flex-direction: row;
}
#login .errors {
display: inline-block;
}
+#login label,
+#signup label,
+#profile_form label {
+ margin-top: 4px;
+}
+#profile_form #profile-pic-embed {
+ display: block;
+ margin-bottom: 5px;
+ max-width: 100px;
+}
/* 404 */
#error_404 {
diff --git a/public/assets/img/profile.jpg b/public/assets/img/profile.jpg
new file mode 100755
index 0000000..b8327bb
--- /dev/null
+++ b/public/assets/img/profile.jpg
Binary files differ
diff --git a/public/assets/js/lib/router.js b/public/assets/js/lib/router.js
index 7b0fbb6..c16e58e 100644
--- a/public/assets/js/lib/router.js
+++ b/public/assets/js/lib/router.js
@@ -23,10 +23,11 @@ var SiteRouter = Router.extend({
"/comment/:id/edit": 'editComment',
"/profile": 'profile',
"/profile/:username": 'profile',
+ "/profile/:username/edit": 'editProfile',
},
initialize: function(){
- $("#logout").click(() => this.logout())
+ $(".logout").click(() => this.logout())
},
index: function(keyword){
@@ -82,6 +83,11 @@ var SiteRouter = Router.extend({
app.view.load(username || auth.user.username)
},
+ editProfile: function(username){
+ app.view = new ProfileForm ()
+ app.view.load(username || auth.user.username)
+ },
+
compose: function(username){
app.view = new ComposeView ()
app.view.load(username)
diff --git a/public/assets/js/lib/views/details/comments.js b/public/assets/js/lib/views/details/comments.js
index 4c217a4..0c2cdcc 100644
--- a/public/assets/js/lib/views/details/comments.js
+++ b/public/assets/js/lib/views/details/comments.js
@@ -27,7 +27,8 @@ var CommentsView = FormView.extend({
parse: function(comment){
if (! comment.comment.length) return $('')
var datetime = verbose_date(comment.date, true)
- var t = this.template.replace(/{{username}}/g, comment.username)
+ var t = this.template.replace(/{{image}}/g, profile_image(comment.username))
+ .replace(/{{username}}/g, comment.username)
.replace(/{{id}}/g, comment.id)
.replace(/{{comment}}/g, tidy_urls(comment.comment))
.replace(/{{date}}/g, datetime[0])
diff --git a/public/assets/js/lib/views/index/hootbox.js b/public/assets/js/lib/views/index/hootbox.js
index 6be9596..85fd51e 100644
--- a/public/assets/js/lib/views/index/hootbox.js
+++ b/public/assets/js/lib/views/index/hootbox.js
@@ -23,7 +23,8 @@ var HootBox = FormView.extend({
},
parse: function(comment){
- var t = this.template.replace(/{{username}}/g, comment.username)
+ var t = this.template.replace(/{{username}}/g, profile_image(comment.username))
+ .replace(/{{username}}/g, comment.username)
.replace(/{{comment}}/g, tidy_urls(comment.comment, true))
return t
},
diff --git a/public/assets/js/lib/views/profile/profile.js b/public/assets/js/lib/views/profile/profile.js
index d8bc535..1b3e496 100644
--- a/public/assets/js/lib/views/profile/profile.js
+++ b/public/assets/js/lib/views/profile/profile.js
@@ -19,7 +19,13 @@ var ProfileView = View.extend({
$("body").removeClass('loading')
var $table = this.$("table")
var username = sanitize(user.username)
- this.$("img").attr("src", "/data/profile/" + username + ".jpg")
+ var is_own_profile = (username === auth.user.username)
+ if (is_own_profile) {
+ $(".edit_profile a").attr("href", "/profile/" + username + "/edit")
+ } else {
+ $(".edit_profile").hide()
+ }
+ this.$("img").attr("src", profile_image(username))
var fields = "username realname phone location".split(" ").map((key) => {
if (! user[key]) return;
var t = this.template.replace(/{{key}}/, sanitize(key))
diff --git a/public/assets/js/lib/views/profile/profile_edit.js b/public/assets/js/lib/views/profile/profile_edit.js
new file mode 100644
index 0000000..a6ff211
--- /dev/null
+++ b/public/assets/js/lib/views/profile/profile_edit.js
@@ -0,0 +1,50 @@
+var ProfileForm = FormView.extend({
+
+ el: "#profile_form",
+
+ events: {
+ "change #profile-pic": 'changeProfilePic',
+ },
+
+ action: "/api/user",
+ method: "POST",
+
+ initialize: function(){
+ this.__super__.initialize.call(this)
+ this.template = this.$(".template").html()
+ },
+
+ load: function(username){
+ console.log('hi')
+ this.action = "/api/user/" + username;
+ "realname location email phone website fb twitter".split(" ").forEach((field) => {
+ this.$('[name=' + field + ']').val( sanitize(auth.user[field]) )
+ })
+ if (! auth.user.pic) {
+ $("#profile-pic-embed").hide()
+ } else {
+ $("#profile-pic-embed").attr("src", sanitize(auth.user.pic))
+ }
+ $("body").removeClass('loading')
+ },
+
+ changeProfilePic: function(){
+ // $("#profile-pic-embed").show().attr("src", sanitize(auth.user.pic))
+ },
+
+ validate: function(){
+ var errors = []
+ var title = this.$("[name=title]").val()
+ if (! title || ! title.length) {
+ errors.push("Please title your post.")
+ }
+ return errors.length ? errors : null
+ },
+
+ success: function(data){
+ if (data.error) {
+ return alert(data.error)
+ }
+ window.location.href = "/details/" + data.id
+ }
+}) \ No newline at end of file
diff --git a/public/assets/js/util/format.js b/public/assets/js/util/format.js
index fcc1df0..7dee404 100644
--- a/public/assets/js/util/format.js
+++ b/public/assets/js/util/format.js
@@ -217,6 +217,9 @@ function make_link(file){
}
return file.filename
}
+function profile_image(username){
+ return "//s3.amazonaws.com/i.asdf.us/bucky/data/profile/" + username + ".jpg"
+}
function make_thumb(file){
if (file.storage) {
return "//s3.amazonaws.com/" + file.storage + "/bucky/data/" + file.thread + "/" + encodeURIComponent(file.filename)