From 04eb66b2e6c5786b9a2964e041e3275f4d64ae64 Mon Sep 17 00:00:00 2001 From: danielvincent <danielgrippi@gmail.com> Date: Fri, 16 Jul 2010 23:02:24 -0700 Subject: [PATCH] user has a image url field for user picture --- app/helpers/application_helper.rb | 16 ++++++++-------- app/models/photo.rb | 2 +- app/models/profile.rb | 1 + app/views/comments/_comment.html.haml | 1 + app/views/layouts/application.html.haml | 2 +- .../status_messages/_status_message.html.haml | 3 +++ app/views/users/edit.html.haml | 3 +++ public/stylesheets/application.css | 19 ++++++++++++------- public/stylesheets/sass/application.sass | 19 ++++++++++++------- 9 files changed, 42 insertions(+), 24 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 734961773b..0176892a6c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -37,15 +37,15 @@ module ApplicationHelper link_to person.real_name, person_url(person) end - def owner_picture - default = "/images/user/default.jpg" - image = "/images/user/#{User.owner.profile.last_name.gsub(/ /,'').downcase}.jpg" + def owner_image_tag + person_image_tag(User.owner) + end - if File.exist?("public/images/user/#{User.owner.profile.last_name.gsub(/ /,'').downcase}.jpg") - image_tag image, :id => "user_picture" - else - image_tag default, :id => "user_picture" - end + def person_image_tag(person) + image_location = person.profile.image_url + image_location ||= "/images/user/default.jpg" + + image_tag image_location, :class => "person_picture" end def new_request(request_count) diff --git a/app/models/photo.rb b/app/models/photo.rb index 3e8407a811..8de0e993a0 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -1,4 +1,4 @@ -class Photo +class Photo < Post require 'carrierwave/orm/mongomapper' include MongoMapper::Document diff --git a/app/models/profile.rb b/app/models/profile.rb index 165d6a18f7..d5e371fec3 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -7,6 +7,7 @@ class Profile key :first_name, String key :last_name, String + key :image_url, String validates_presence_of :first_name, :last_name diff --git a/app/views/comments/_comment.html.haml b/app/views/comments/_comment.html.haml index 6ae6e41a44..8783b4502f 100644 --- a/app/views/comments/_comment.html.haml +++ b/app/views/comments/_comment.html.haml @@ -1,4 +1,5 @@ %li.comment{:id => post.id} + = person_image_tag(post.person) %span.from = link_to_person post.person = auto_link post.text diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 12380d796a..b3a6d713b1 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -43,7 +43,7 @@ .container .span-24.last .span-3.append-1.last - = link_to owner_picture, root_path + = link_to person_image_tag(User.owner), root_path = link_to "Edit your profile", edit_user_path(current_user) %br %br diff --git a/app/views/status_messages/_status_message.html.haml b/app/views/status_messages/_status_message.html.haml index 1434ca0d2c..c2a0f4195e 100644 --- a/app/views/status_messages/_status_message.html.haml +++ b/app/views/status_messages/_status_message.html.haml @@ -1,4 +1,7 @@ %li.message{:id => post.id, :class => ("mine" if mine?(post))} + + = person_image_tag(post.person) + %span.from = link_to post.person.real_name, post.person = auto_link post.message diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index e7da247288..fb5b15766a 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -10,6 +10,9 @@ %p = p.label :last_name = p.text_field :last_name, :value => @profile.last_name + %p + = p.label :image_url + = p.text_field :image_url, :value => @profile.image_url %p = f.label :email diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 5c9e754e2f..61039aeb80 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -118,7 +118,7 @@ ul#stream, ul#friend_stream { color: #666666; } ul#stream > li, ul#friend_stream > li { list-style: none; - padding: 1em 0; + padding: 15px 0; border-bottom: 1px solid #f1f1f1; margin-bottom: 5px; } @@ -190,13 +190,18 @@ ul.comment_set { margin-top: -5px; padding-bottom: 8px; } -img#profile_picture { - width: 100%; } - -img#user_picture { - width: 100%; +img.person_picture { + max-width: 100%; border-radius: 3px; - -moz-border-radius: 3px; } + -moz-border-radius: 3px; + display: inline block; } + +li.message > img.person_picture, +li.comment > img.person_picture { + height: 30px; + display: absolute; + float: left; + margin-right: 10px; } .pagination a { padding: 3px; } diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index b37dc54e88..0e64172c23 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -130,7 +130,7 @@ ul#stream, ul#friend_stream :color #666 > li :list-style none - :padding 1em 0 + :padding 15px 0 :border :bottom 1px solid #f1f1f1 :margin-bottom 5px @@ -227,14 +227,19 @@ ul.comment_set :padding :bottom 8px - -img#profile_picture - :width 100% - -img#user_picture - :width 100% +img.person_picture + :max-width 100% :border-radius 3px :-moz-border-radius 3px + :display inline block + +li.message > img.person_picture, +li.comment > img.person_picture + :height 30px + :display absolute + :float left + :margin + :right 10px .pagination a -- GitLab