From fce902821b431b49c9a2c5625a09709369a7ebda Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 19 Oct 2010 11:06:43 -0700 Subject: [PATCH 1/8] Remove downcasing of diaspora_handle, verify that diaspora_handle querying and validation is case insensitive. --- app/models/person.rb | 13 +++---------- app/models/user.rb | 2 +- spec/models/person_spec.rb | 31 +++++++++++++++++++------------ spec/models/user_spec.rb | 5 ----- 4 files changed, 23 insertions(+), 28 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index c44203e1e..8a9011fa4 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -27,21 +27,12 @@ class Person timestamps! - before_save :strip_and_downcase_diaspora_handle before_destroy :remove_all_traces before_validation :clean_url validates_presence_of :url, :profile, :serialized_public_key validates_format_of :url, :with => /^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix - - def strip_and_downcase_diaspora_handle - if self.diaspora_handle - self.diaspora_handle.strip! - self.diaspora_handle.downcase! - end - end - def self.search(query) return Person.all if query.to_s.empty? query_tokens = query.to_s.strip.split(" ") @@ -95,12 +86,14 @@ class Person def self.by_webfinger(identifier, opts = {}) #need to check if this is a valid email structure, maybe should do in JS - local_person = Person.first(:diaspora_handle => identifier.gsub('acct:', '').to_s) + query = /#{Regexp.escape(identifier.gsub('acct:', '').to_s)}/i + local_person = Person.first(:diaspora_handle => query) if local_person Rails.logger.info("Do not need to webfinger, found a local person #{local_person.real_name}") local_person elsif !identifier.include?("localhost") && !opts[:local] + #Get remote profile begin Rails.logger.info("Webfingering #{identifier}") f = Redfinger.finger(identifier) diff --git a/app/models/user.rb b/app/models/user.rb index 9351e34ef..1593ee29c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -388,7 +388,7 @@ class User end def diaspora_handle - "#{self.username}@#{APP_CONFIG[:terse_pod_url]}".downcase + "#{self.username}@#{APP_CONFIG[:terse_pod_url]}" end def as_json(opts={}) diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index a77aee76b..fd5ea0162 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -14,11 +14,6 @@ describe Person do end describe '#diaspora_handle' do - it 'should downcase and strip the handle before it saves' do - p = Factory.build(:person, :diaspora_handle => " FOOBaR@example.com ") - p.save - p.diaspora_handle.should == "foobar@example.com" - end context 'local people' do it 'uses the pod config url to set the diaspora_handle' do @user.person.diaspora_handle.should == @user.username + "@" + APP_CONFIG[:terse_pod_url] @@ -30,14 +25,20 @@ describe Person do @person.diaspora_handle.include?(APP_CONFIG[:terse_pod_url]).should be false end end + describe 'validation' do + it 'is unique' do + person_two = Factory.build(:person, :url => @person.diaspora_handle) + person_two.valid?.should be_false + end + + it 'is case insensitive' do + person_two = Factory.build(:person, :url => @person.diaspora_handle.upcase) + person_two.valid?.should be_false + end + end end - it 'should not allow two people with the same diaspora_handle' do - person_two = Factory.build(:person, :url => @person.diaspora_handle) - person_two.valid?.should == false - end - - describe 'xml' do + describe 'xml' do before do @xml = @person.to_xml.to_s end @@ -52,7 +53,7 @@ describe Person do end end - it 'should know when a post belongs to it' do + it '#owns? posts' do person_message = Factory.create(:status_message, :person => @person) person_two = Factory.create(:person) @@ -188,6 +189,12 @@ describe Person do person = Person.by_webfinger(user.person.diaspora_handle) person.should == user.person end + + it "is case insensitive" do + user = Factory(:user, :username => "SaMaNtHa") + person = Person.by_webfinger(user.person.diaspora_handle.upcase) + person.should == user.person + end end it 'creates a stub for a remote user' do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index d190fc27b..61e37b3aa 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -83,11 +83,6 @@ describe User do it 'uses the pod config url to set the diaspora_handle' do user.diaspora_handle.should == user.username + "@" + APP_CONFIG[:terse_pod_url] end - - it 'should be lowercase, even if username is uppercase' do - user.username = "fooBAR" - user.diaspora_handle.should == (user.username + "@" + APP_CONFIG[:terse_pod_url]).downcase - end end context 'profiles' do From 7e9585c5f0f027e173db32e3229c86484c344620 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 19 Oct 2010 11:29:29 -0700 Subject: [PATCH 2/8] default user picture change. stream link on all aspects page fix. layout view is not fragmented. --- app/helpers/application_helper.rb | 2 +- app/views/albums/index.html.haml | 25 ++++---- app/views/albums/show.html.haml | 38 ++++++------- app/views/aspects/index.html.haml | 21 +++---- app/views/aspects/manage.html.haml | 54 +++++++++--------- app/views/aspects/show.html.haml | 18 +++--- app/views/layouts/application.html.haml | 5 +- app/views/people/index.html.haml | 26 +++------ app/views/people/show.html.haml | 21 +++---- app/views/photos/show.html.haml | 69 ++++++++++++----------- app/views/shared/_aspect_friends.haml | 6 +- app/views/users/edit.html.haml | 22 ++++---- public/images/user/default.png | Bin 0 -> 2243 bytes public/stylesheets/sass/application.sass | 20 ++++--- 14 files changed, 160 insertions(+), 167 deletions(-) create mode 100644 public/images/user/default.png diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e6fadfef3..1b52892f3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -50,7 +50,7 @@ module ApplicationHelper def person_image_tag(person) image_location = person.profile.image_url - image_location ||= "/images/user/default.jpg" + image_location ||= "/images/user/default.png" image_tag image_location, :class => "avatar", :alt => person.real_name, :title => person.real_name end diff --git a/app/views/albums/index.html.haml b/app/views/albums/index.html.haml index b6fd490d6..81455b85b 100644 --- a/app/views/albums/index.html.haml +++ b/app/views/albums/index.html.haml @@ -8,20 +8,23 @@ $("#add_album_button").fancybox(); }); -- content_for :left_pane do +.span-4.append-1.last = render "shared/aspect_friends" -%h3 Albums -= link_to t('.new_album'), '#new_album_pane', {:class => "button", :id => "add_album_button"} +.span-15.last + %h3 + = @aspect + Albums + = link_to t('.new_album'), '#new_album_pane', {:class => "button", :id => "add_album_button"} -.fancybox_content - #new_album_pane - = render "albums/new_album", :aspect => params[:aspect] + .fancybox_content + #new_album_pane + = render "albums/new_album", :aspect => params[:aspect] -%div - - for album in @albums - = render "album", :post => album + %div + - for album in @albums + = render "album", :post => album -#pagination - = will_paginate @albums + #pagination + = will_paginate @albums diff --git a/app/views/albums/show.html.haml b/app/views/albums/show.html.haml index f26a514f3..866a266e6 100644 --- a/app/views/albums/show.html.haml +++ b/app/views/albums/show.html.haml @@ -9,29 +9,27 @@ }); }); -= content_for :page_title do - = link_to "◂ #{t('.albums')}", albums_path(:aspect => @aspect) - -- content_for :left_pane do +.span-4.append-1.last = render "shared/aspect_friends" -%h3 - = @album.name -="#{t('.updated')} #{how_long_ago(@album)}" --if current_user.owns? @album - =render 'photos/new_photo' - = link_to t('.edit_album'), edit_album_path(@album), :class => 'button' +.span-19.last + %h3 + = link_to "#{@aspect} Albums", albums_path(:aspect => @aspect) -.album_id{:id => @album.id, :style => "display:hidden;"} + = @album.name + ="#{t('.updated')} #{how_long_ago(@album)}" + .right + -if current_user.owns? @album + =render 'photos/new_photo' + = link_to t('.edit_album'), edit_album_path(@album), :class => 'button' --unless current_user.owns? @album - %h4= "#{t('.by')} #{@album.person.real_name}" + .album_id{:id => @album.id, :style => "display:hidden;"} -#thumbnails - - for photo in @album_photos - .image_thumb - = link_to (image_tag photo.url(:thumb_medium)), object_path(photo) + -unless current_user.owns? @album + %h4= "#{t('.by')} #{@album.person.real_name}" + + #thumbnails + - for photo in @album_photos + .image_thumb + = link_to (image_tag photo.url(:thumb_medium)), object_path(photo) -#content_bottom - .back - = link_to "⇧ #{t('.albums')}", albums_path(:aspect => @aspect) diff --git a/app/views/aspects/index.html.haml b/app/views/aspects/index.html.haml index 8b651bf9a..e61aa4d42 100644 --- a/app/views/aspects/index.html.haml +++ b/app/views/aspects/index.html.haml @@ -2,19 +2,16 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. -- content_for :left_pane do +.span-4.append-1.last = render "shared/aspect_friends" -- content_for :publish do - = render "shared/publisher", :aspect_ids => :all, :broadcast => true +.span-15.last + = render 'aspects/empty_messages' + = render "shared/publisher" + %ul#stream + - for post in @posts + = render type_partial(post), :post => post unless post.class == Album -= render 'aspects/empty_messages' - -= render "shared/publisher" -%ul#stream - - for post in @posts - = render type_partial(post), :post => post unless post.class == Album - -#pagination - = will_paginate @posts + #pagination + = will_paginate @posts diff --git a/app/views/aspects/manage.html.haml b/app/views/aspects/manage.html.haml index dba34ad24..6c0e0150c 100644 --- a/app/views/aspects/manage.html.haml +++ b/app/views/aspects/manage.html.haml @@ -6,7 +6,11 @@ = javascript_include_tag 'jquery-ui-1.8.4.custom.min.js' = javascript_include_tag 'aspect-edit.js' -- content_for :left_pane do +%h2 + Manage aspects + = link_to(t('.add_a_new_aspect'), "#add_aspect_pane", :id => "add_aspect_button", :class => "new_aspect button", :title => t('.add_a_new_aspect')) + +.span-4.append-1.last %h3=t('.requests') .requests @@ -27,36 +31,34 @@ = render 'shared/invitations', :invites => @invites -%h2 Manage aspects -= link_to(t('.add_a_new_aspect'), "#add_aspect_pane", :id => "add_aspect_button", :class => "new_aspect button", :title => t('.add_a_new_aspect')) +.span-19.last + %ul#aspect_list + - for aspect in @aspects + %li.aspect -%ul#aspect_list - - for aspect in @aspects - %li.aspect + .aspect_name + %span.edit_name_field + %h3{:contenteditable => true}= aspect.name + %span.tip click to edit - .aspect_name - %span.edit_name_field - %h3{:contenteditable => true}= aspect.name - %span.tip click to edit + %ul.tools + %li= link_to t('.add_a_new_friend'), "#add_request_pane_#{aspect.id}", :class => 'add_request_button' + %li!= remove_link(aspect) - %ul.tools - %li= link_to t('.add_a_new_friend'), "#add_request_pane_#{aspect.id}", :class => 'add_request_button' - %li!= remove_link(aspect) + %ul.dropzone{:id => aspect.id} - %ul.dropzone{:id => aspect.id} + -if aspect.people.size < 1 + %li.grey Drag to add people - -if aspect.people.size < 1 - %li.grey Drag to add people + -else + -for person in aspect.people - -else - -for person in aspect.people + %li.person{:id => person.id, :from_aspect_id => aspect.id} + = person_image_tag(person) + .name + = link_to person.real_name, person - %li.person{:id => person.id, :from_aspect_id => aspect.id} - = person_image_tag(person) - .name - = link_to person.real_name, person - - .fancybox_content - %div{:id => "add_request_pane_#{aspect.id}"} - = render "requests/new_request", :aspect => aspect + .fancybox_content + %div{:id => "add_request_pane_#{aspect.id}"} + = render "requests/new_request", :aspect => aspect diff --git a/app/views/aspects/show.html.haml b/app/views/aspects/show.html.haml index ebe66cf41..e61aa4d42 100644 --- a/app/views/aspects/show.html.haml +++ b/app/views/aspects/show.html.haml @@ -2,16 +2,16 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. -- content_for :left_pane do +.span-4.append-1.last = render "shared/aspect_friends" -= render 'aspects/empty_messages' +.span-15.last + = render 'aspects/empty_messages' + = render "shared/publisher" + %ul#stream + - for post in @posts + = render type_partial(post), :post => post unless post.class == Album -= render "shared/publisher" -%ul#stream - - for post in @posts - = render type_partial(post), :post => post unless post.class == Album - -#pagination - = will_paginate @posts + #pagination + = will_paginate @posts diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 7bf4c106f..0defb3463 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -59,10 +59,7 @@ = render "shared/aspect_nav" .container - .span-4.append-1.last - = yield :left_pane - - .span-15.last + .span-24.last = yield .span-19.prepend-5.last diff --git a/app/views/people/index.html.haml b/app/views/people/index.html.haml index 4ad7a93af..e2d4e2656 100644 --- a/app/views/people/index.html.haml +++ b/app/views/people/index.html.haml @@ -2,23 +2,13 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. -- content_for :publish do - %h1 - Search +.span-15.prepend-5.last + %h2 + search results for + %u= params[:q] - =form_tag '/people', :method => "get" do - = text_field_tag :q, params[:q] - = submit_tag "search" + %ul#stream + - for person in @people + = render 'people/person', :person => person -- content_for :left_pane do - \. - -%h1 - search results for - %u= params[:q] - -%ul#stream - - for person in @people - = render 'people/person', :person => person - -= will_paginate @people + = will_paginate @people diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml index 1038d7d94..83e7cf50d 100644 --- a/app/views/people/show.html.haml +++ b/app/views/people/show.html.haml @@ -5,7 +5,8 @@ - content_for :page_title do profile -- content_for :left_pane do +.span-4.append-1.last + %h2= @person.real_name #profile .profile_photo = person_image_link(@person) @@ -26,12 +27,12 @@ - if @person != current_user.person && current_user.friends.include?(@person) = link_to t('.remove_friend'), @person, :confirm => t('.are_you_sure'), :method => :delete, :class => "button" -.span-20.last - .span-19.last - - if @posts - %ul#stream - - for post in @posts - = render type_partial(post), :post => post unless post.class == Album - = will_paginate @posts - - else - %h3=t('no posts to display!') +.span-15.last + - if @posts.count > 0 + %ul#stream + - for post in @posts + = render type_partial(post), :post => post unless post.class == Album + = will_paginate @posts + - else + %h3=t('no posts to display!') + diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index 8d0e66471..8fe22cc9b 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -54,14 +54,12 @@ });//end document ready -= content_for :page_title do - = link_to "◂ #{@photo.album.name}", @photo.album - -- content_for :left_pane do +.span-4.append-1.last = render "shared/aspect_friends" -- content_for :publish do - %h1 +.span-19.last + %h3 + = link_to @photo.album.name, @photo.album = @photo.image = link_to "<< #{t('.prev')}", url_to_prev(@photo, @album), :rel => 'prefetch' @@ -70,39 +68,42 @@ | = link_to "#{t('.next')} >>", url_to_next(@photo, @album), :rel => 'prefetch' - .right - -if current_user.owns? @album - = link_to t('.edit_photo'), edit_photo_path(@photo), :class => "button" + -if current_user.owns? @album + = link_to t('.edit_photo'), edit_photo_path(@photo), :class => "button" + + %br + %br + + %div{:id => @photo.id} + #show_photo + = linked_scaled_photo @photo, @album + .caption + -if current_user.owns? @photo + -if @photo.caption and @photo.caption != "" + = link_to 'Edit','javascript:void(0)', :id => "edit-desc", :class => "edit-desc" + .description + = @photo.caption -%div{:id => @photo.id} - #show_photo - = linked_scaled_photo @photo, @album - .caption -if current_user.owns? @photo - -if @photo.caption and @photo.caption != "" - = link_to 'Edit','javascript:void(0)', :id => "edit-desc", :class => "edit-desc" - .description - = @photo.caption + %div{:class => 'clear'} + -if !@photo.caption or @photo.caption == "" + = link_to 'Add a description','javascript:void(0)', :id => "add-description", :class => "edit-desc" - -if current_user.owns? @photo - %div{:class => 'clear'} - -if !@photo.caption or @photo.caption == "" - = link_to 'Add a description','javascript:void(0)', :id => "add-description", :class => "edit-desc" + = form_for @photo do |p| + = p.text_field :caption, :value => @photo.caption + = p.submit + %div{:class => 'clear'} - = form_for @photo do |p| - = p.text_field :caption, :value => @photo.caption - = p.submit - %div{:class => 'clear'} + %h4{:class => "show_post_comments"} + = "#{t('.comments')} (#{@photo.comments.count})" + = render "comments/comments", :post => @photo - #content_bottom - .back - = link_to "⇧ #{@album.name}", album_path(@album) + #content_bottom + .back + = link_to "⇧ #{@album.name}", album_path(@album) - -if current_user.owns? @album - .right - = link_to t('.delete_photo'), @photo, :confirm => t('.are_you_sure'), :method => :delete, :class => 'button' + -if current_user.owns? @album + .right + = link_to t('.delete_photo'), @photo, :confirm => t('.are_you_sure'), :method => :delete, :class => 'button' - %h4{:class => "show_post_comments"} - = "#{t('.comments')} (#{@photo.comments.count})" - = render "comments/comments", :post => @photo diff --git a/app/views/shared/_aspect_friends.haml b/app/views/shared/_aspect_friends.haml index 876da05e7..61deef919 100644 --- a/app/views/shared/_aspect_friends.haml +++ b/app/views/shared/_aspect_friends.haml @@ -28,7 +28,11 @@ %br %br %ul - %li= link_to 'stream', aspect_path(@aspect) + - if @aspect == :all + %li= link_to 'stream', root_path + - else + %li= link_to 'stream', aspect_path(@aspect) + %li= link_to t('.photos'), albums_path(:aspect => @aspect) %br diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index 397035a80..984be9a53 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -3,7 +3,7 @@ -# the COPYRIGHT file. :javascript - $("#settings_nav li > a").click( function() { + $("#settings_nav li > a").live("click", function() { var target = "#"+$(this).attr('class'); if( !$(target).is(":visible") ) { $(".settings_pane").fadeOut(200, function() { @@ -12,22 +12,20 @@ } }); - -- content_for :publish do - %h2="#{t('.editing_profile')}" - -- content_for :left_pane do +%h2 + Settings %ul#settings_nav %li=link_to 'Profile', '#', :class => 'profile' %li=link_to 'Account', '#', :class => 'account' %li=link_to 'Services', '#', :class => 'services' -#profile.settings_pane{:style=>"display:block;"} - = render 'users/profile' +.span-19.prepend-5.last + #profile.settings_pane{:style=>"display:block;"} + = render 'users/profile' -#account.settings_pane - = render 'users/account' + #account.settings_pane + = render 'users/account' -#services.settings_pane - = render 'users/services' + #services.settings_pane + = render 'users/services' diff --git a/public/images/user/default.png b/public/images/user/default.png new file mode 100644 index 0000000000000000000000000000000000000000..cd0b9059f97721141d8e402b35810bc84992e30a GIT binary patch literal 2243 zcma);c{J4h7soBXN;8%ghJ;9?m>HwTNKub%tdoi~<|`91UrST?714u`7>sS08CodI zv@lU$BN|y!m?hgJTO~sa)1pm^=$V}J`~UYk=kvbz-1ENo+;ji>WFFY(ss_`ADJUqY zxx3-L6%-WF@~5YwEU$QsoRP^x;DNn9&i?-Xq07WBLtCb3nH$U8T}H6X&@!@R3JNL)?sx~ExXT|(;5Dg+Yn+jtI>D;bOV$g=-cc77g2c_r(LJ!K)&8{oW%s}? zoOQH zjU(-2H`^%9>2oV$Ew%#>W2@Neot_D%K)~th2J<&jOa@4{Y}1&IOZCDJY70M}BR(St z=5GY59Ca%p*b}Q7{hm#1(GEbgJ=GV5GR)zVS;2G+{B>3M%7jTF6jh^hw-G8xT4mjK zu+)rto`1|Qdf@_O!bK&-h?uOq5wVH}8F)Yt6<{$O&{oKzc)n46Z(k{dRDIRHzwM)} zT`5)N<%bHDeATd5Un>(3ON7Q`|64}F^2!C}S39=|%VW?}bNR+}7D;UfZzr_wxdJaDbXdeKyZyZ2GU{%fO zA3Z>_Vng%6GW7FY=QJqlok&a6eyiVS8{F4+U>h9aXC*opgW;j)tG=k3)mJgo=DlJ> zN?M=g;(TAkw=aS0pE$8%6j?DTHlWtLmFCTH!mTw*t@`hDUC6&q9nq^7#hkC4*d)coI5z_z~7IVSTPSpk zUR+T=%Z9fTuCDO|^3HP_+s4di#a*I($7nKGcd2WQ33#F;BeWYHx`l$o)Q7!Z@N^+c zI>4Y7vA_e^bDO9af~Rn@<0iTexDnfDy+i6i3KCsk+|6dNEO^Ty%9XqH*n<@Q6pNB_ zP_sqqtEn^@>IZXA_4j*H42L`Ft1sEd$t*jRP|~4C`wJ>44WEp`tOdfYQn!@K>Z`V|{_La?4ZvWBKv2e;{Y02P+ zFXQ{B@XnVr{h@d_$fO6OGv3m{aBj-JcCINbV<^(`V5t%PpF^e+gacwO9sjD?=tsQA zND)f;L>ZX#3)SM*HC+h)a9B}uTWOjuT6|Mjux%(qXcDW1(?l}+0dMg7GtgNdKOFj?kw zp<35}pyMH_Gj6t(pJzGTa6tp%gxk7+D`F`4N_^gEAis9YYUS4U&Bx=pXB%ebz!&_hrC7d(Fm}Rlm=G{dZ5xIp}zOIl^4swUzq| z{#DaoH}`K~5?lPwIy=1=P)08dbf8#C*{p6QgPa@EDW>yT5WBv|mskRw-CBG1vVQt0 z;e2Y}T{6o@%|DZvoQkN^8A`bHcF3mBw!rhGC~!ZC z?J~G>BNO?8|G3x@;)zE8I!_62iJW$Va4#EpM!>}xTSut!8C$b8IeS|PjkQgKwf(_0GpA_paj96%0nmi zn|RGdCw4RnR(1)TrfgNWl&_RWVRH&g+}@Mf`%Z7Z@bS+GVO$aNMS9RwWKNH2@N~o< z4Ufzrs^2L-T)}d}HMm^w?;my%bHi|B*sGt li + :display inline + :margin + :right 1em a - :font - :size smaller - :display block - :height 100% - :border - :bottom 1px solid #eee :padding 2px @@ -1036,3 +1034,7 @@ header .edit_photo :display none + +#section_header + :background + :color #aaa From de0b240dbbe0429133f11b739f25d406d5113def Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 19 Oct 2010 11:36:33 -0700 Subject: [PATCH 3/8] Remove unused helper method --- app/helpers/aspects_helper.rb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/helpers/aspects_helper.rb b/app/helpers/aspects_helper.rb index c19fb4ac4..d627b3e69 100644 --- a/app/helpers/aspects_helper.rb +++ b/app/helpers/aspects_helper.rb @@ -14,12 +14,4 @@ module AspectsHelper "#{I18n.t('aspects.helper.remove')}" end end - - def aspect_id(aspect) - if aspect.class == Aspect - aspect.id - else - :all - end - end end From 9f653e39f135dfa68295e60b57f33c2c58a3c080 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 19 Oct 2010 11:39:52 -0700 Subject: [PATCH 4/8] Fix bug 376 --- app/helpers/application_helper.rb | 8 ++++++++ app/views/shared/_aspect_friends.haml | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e6fadfef3..830fe2dff 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -7,6 +7,14 @@ module ApplicationHelper !@aspect.is_a?(Symbol) && @aspect.id == aspect.id end + def aspect_or_all_path aspect + if @aspect.is_a? Aspect + aspect_path @aspect + else + aspects_path + end + end + def object_path(object, opts = {}) object = object.person if object.is_a? User eval("#{object.class.to_s.underscore}_path(object, opts)") diff --git a/app/views/shared/_aspect_friends.haml b/app/views/shared/_aspect_friends.haml index 876da05e7..e185dc306 100644 --- a/app/views/shared/_aspect_friends.haml +++ b/app/views/shared/_aspect_friends.haml @@ -28,7 +28,7 @@ %br %br %ul - %li= link_to 'stream', aspect_path(@aspect) + %li= link_to 'stream', aspect_or_all_path(@aspect) %li= link_to t('.photos'), albums_path(:aspect => @aspect) %br From d68644c3584f92a81c78adf0b6be7b21aecef289 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 19 Oct 2010 11:47:43 -0700 Subject: [PATCH 5/8] Resolve #387 --- app/views/js/_websocket_js.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/js/_websocket_js.haml b/app/views/js/_websocket_js.haml index 9bf801e0a..3c88de453 100644 --- a/app/views/js/_websocket_js.haml +++ b/app/views/js/_websocket_js.haml @@ -4,7 +4,7 @@ = javascript_include_tag 'FABridge', 'swfobject', 'web_socket' :javascript - WebSocket.__swfLocation = "/javascripts/WebSocketMain.swf"; + WebSocket.__swfLocation = "#{javascript_path 'WebSocketMain.swf'}"; $(document).ready(function(){ function debug(str){ $("#debug").append("

" + str); }; From ea00d35f1fc4743972b0b2c6c12d6228d8dc2c88 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 19 Oct 2010 12:10:22 -0700 Subject: [PATCH 6/8] padding on stream fix. added add aspect button in aspect nav. --- app/controllers/aspects_controller.rb | 2 +- app/views/aspects/manage.html.haml | 8 +++-- app/views/people/_person.html.haml | 25 ++++++++------- app/views/photos/_photo.haml | 4 +++ app/views/shared/_aspect_nav.haml | 4 ++- .../status_messages/_status_message.html.haml | 2 +- app/views/users/edit.html.haml | 5 +-- config/locales/diaspora/en.yml | 2 ++ public/javascripts/view.js | 2 +- public/stylesheets/sass/application.sass | 32 +++++++++++-------- 10 files changed, 52 insertions(+), 34 deletions(-) diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 26aafb771..35ddbaec9 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -23,7 +23,7 @@ class AspectsController < ApplicationController else flash[:error] = I18n.t('aspects.create.failure') end - respond_with :location => aspects_manage_path + respond_with @aspect end def new diff --git a/app/views/aspects/manage.html.haml b/app/views/aspects/manage.html.haml index 6c0e0150c..6cd67166d 100644 --- a/app/views/aspects/manage.html.haml +++ b/app/views/aspects/manage.html.haml @@ -6,9 +6,11 @@ = javascript_include_tag 'jquery-ui-1.8.4.custom.min.js' = javascript_include_tag 'aspect-edit.js' -%h2 - Manage aspects - = link_to(t('.add_a_new_aspect'), "#add_aspect_pane", :id => "add_aspect_button", :class => "new_aspect button", :title => t('.add_a_new_aspect')) +#section_header + %h2 + Manage aspects + .right + = link_to(t('.add_a_new_aspect'), "#add_aspect_pane", :class => "new_aspect add_aspect_button button", :title => t('.add_a_new_aspect')) .span-4.append-1.last %h3=t('.requests') diff --git a/app/views/people/_person.html.haml b/app/views/people/_person.html.haml index 3e20a658a..b08a2db61 100644 --- a/app/views/people/_person.html.haml +++ b/app/views/people/_person.html.haml @@ -10,18 +10,19 @@ %span.from = link_to person.real_name, person_path(person) + .right{:style=>"display:inline;"} + - if person.id == current_user.person.id + thats you! + - elsif current_user.friends.include?(person) + Already friends + - elsif current_user.pending_requests.find_by_person_id(person.id) + = link_to =t('.pending_request'), aspects_manage_path + - else + = form_for Request.new do |f| + = f.select(:aspect_id, @aspects_dropdown_array) + = f.hidden_field :destination_url, :value => person.diaspora_handle + = f.submit t('.add_friend') + .info = person.diaspora_handle - .right{ :style => "display:inline;top:0;" } - - if person.id == current_user.person.id - thats you! - - elsif current_user.friends.include?(person) - Already friends - - elsif current_user.pending_requests.find_by_person_id(person.id) - = link_to =t('.pending_request'), aspects_manage_path - - else - = form_for Request.new do |f| - = f.select(:aspect_id, @aspects_dropdown_array) - = f.hidden_field :destination_url, :value => person.diaspora_handle - = f.submit t('.add_friend') diff --git a/app/views/photos/_photo.haml b/app/views/photos/_photo.haml index 9d48ac8b6..01baaf74e 100644 --- a/app/views/photos/_photo.haml +++ b/app/views/photos/_photo.haml @@ -18,6 +18,10 @@ - for aspect in current_user.aspects_with_post( post.id ) %li= link_to aspect.name, aspect + - if current_user.owns?(post) + .right + = link_to t('.delete'), status_message_path(post), :confirm => t('.are_you_sure'), :method => :delete, :remote => true, :class => "delete" + =t('.posted_a_new_photo_to') = link_to post.album.name, object_path(post.album) diff --git a/app/views/shared/_aspect_nav.haml b/app/views/shared/_aspect_nav.haml index d4e4e404f..11d836d89 100644 --- a/app/views/shared/_aspect_nav.haml +++ b/app/views/shared/_aspect_nav.haml @@ -9,12 +9,14 @@ - for aspect in @aspects %li{:class => ("selected" if current_aspect?(aspect))} = link_for_aspect aspect + %li + = link_to '+', '#add_aspect_pane', :class => "add_aspect_button" %ul{ :style => "position:absolute;right:0;bottom:0.01em;"} %li{ :style => "margin-right:0;", :class => ("selected" if @aspect == :manage)} = link_to ( (@request_count == 0)? t('.manage') : "#{t('.manage')} (#{@request_count})"), {:controller => :aspects, :action => :manage}, :class => "edit_aspect_button", :class => new_request(@request_count), :title => t('.manage_your_aspects') - .yo{ :style => "display:none;"} + .fancybox_content #add_aspect_pane = render "aspects/new_aspect" diff --git a/app/views/status_messages/_status_message.html.haml b/app/views/status_messages/_status_message.html.haml index 8b2437ae9..47485d685 100644 --- a/app/views/status_messages/_status_message.html.haml +++ b/app/views/status_messages/_status_message.html.haml @@ -19,7 +19,7 @@ %li= link_to aspect.name, aspect - if current_user.owns?(post) - .destroy_link + .right = render "shared/reshare", :post => post, :current_user => current_user = link_to t('.delete'), status_message_path(post), :confirm => t('.are_you_sure'), :method => :delete, :remote => true, :class => "delete" diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index 984be9a53..48b266c09 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -12,8 +12,9 @@ } }); -%h2 - Settings +#section_header + %h2 + Settings %ul#settings_nav %li=link_to 'Profile', '#', :class => 'profile' %li=link_to 'Account', '#', :class => 'account' diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 2e41d0891..2b4aff4c4 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -149,6 +149,8 @@ en: photo: show_comments: "show comments" posted_a_new_photo_to: "posted a new photo to" + delete: "Delete" + are_you_sure: "Are you sure?" new: new_photo: "New Photo" back_to_list: "Back to List" diff --git a/public/javascripts/view.js b/public/javascripts/view.js index 7d903d1e8..677a36979 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -26,7 +26,7 @@ $(document).ready(function(){ }); //buttons////// - $("#add_aspect_button").fancybox({ 'titleShow' : false , 'hideOnOverlayClick' : false }); + $(".add_aspect_button").fancybox({ 'titleShow' : false , 'hideOnOverlayClick' : false }); $("#add_request_button").fancybox({ 'titleShow': false , 'hideOnOverlayClick' : false }); $(".invite_user_button").fancybox({ 'titleShow': false , 'hideOnOverlayClick' : false }); $(".add_request_button").fancybox({ 'titleShow': false , 'hideOnOverlayClick' : false }); diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 8e330790b..360d64967 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -187,6 +187,7 @@ ul#stream :min-height 50px :list-style none :padding 12px 0 + :right 12px :border :bottom 1px solid #eee @@ -195,12 +196,9 @@ ul#stream :color #fafafa :border :bottom 1px solid #ddd - .destroy_link + .right :display inline - .right - :top 0 - .avatar :border-radius 5px @@ -216,9 +214,6 @@ li.message :margin :right 15px - .delete:hover - :background #eee - .content :margin :top -4px @@ -292,14 +287,14 @@ li.message :color #005D9C -.destroy_link .reshare_pane .reshare_button a.inactive +.right .reshare_pane .reshare_button a.inactive :color #ccc &:hover :text :decoration none :cursor default -.destroy_link .reshare_pane +.right .reshare_pane :margin :left 5px :right 5px @@ -495,12 +490,13 @@ ul.comment_set a :padding 3px -li.message .from .destroy_link +li.message .from .right :display none :position absolute - :right 0 + :right 12px :font :size 12px + :color #999 a :color #999 :font @@ -1036,5 +1032,15 @@ header :display none #section_header - :background - :color #aaa + :width 100% + :border + :bottom 2px solid #777 + :position relative + + :margin + :bottom 2em + :padding + :bottom 1em + + h2 + :display inline From 962f282cbc2ed0b03e88d21faada7eb5b21848a5 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 19 Oct 2010 12:23:24 -0700 Subject: [PATCH 7/8] Validate uniqueness of aspect name, 359 --- app/models/aspect.rb | 1 + spec/models/aspect_spec.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/app/models/aspect.rb b/app/models/aspect.rb index 2e6dca694..e58318569 100644 --- a/app/models/aspect.rb +++ b/app/models/aspect.rb @@ -17,6 +17,7 @@ class Aspect belongs_to :user, :class_name => 'User' validates_presence_of :name + validates_uniqueness_of :name, :scope => :user_id timestamps! diff --git a/spec/models/aspect_spec.rb b/spec/models/aspect_spec.rb index b3acbd028..e91d4a258 100644 --- a/spec/models/aspect_spec.rb +++ b/spec/models/aspect_spec.rb @@ -39,6 +39,21 @@ describe Aspect do end end + describe 'validation' do + before do + @aspect = @user.aspect(:name => 'losers') + end + it 'has a unique name for one user' do + aspect2 = @user.aspect(:name => @aspect.name) + aspect2.valid?.should be_false + end + + it 'has no uniqueness between users' do + aspect2 = @user2.aspect(:name => @aspect.name) + aspect2.valid?.should be_true + end + end + describe 'querying' do before do @aspect = @user.aspect(:name => 'losers') From 0621aa2f6c9b5ea74c002a5f318aa3e9d7ac4813 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 19 Oct 2010 12:28:54 -0700 Subject: [PATCH 8/8] fixed no friends/posts message positioning --- .../{_empty_messages.haml => _no_friends_message.haml} | 6 ------ app/views/aspects/_no_posts_message.haml | 8 ++++++++ app/views/aspects/index.html.haml | 5 +++-- app/views/aspects/show.html.haml | 5 +++-- config/locales/diaspora/en.yml | 5 +++-- 5 files changed, 17 insertions(+), 12 deletions(-) rename app/views/aspects/{_empty_messages.haml => _no_friends_message.haml} (86%) create mode 100644 app/views/aspects/_no_posts_message.haml diff --git a/app/views/aspects/_empty_messages.haml b/app/views/aspects/_no_friends_message.haml similarity index 86% rename from app/views/aspects/_empty_messages.haml rename to app/views/aspects/_no_friends_message.haml index 734ee5b12..eb450cf99 100644 --- a/app/views/aspects/_empty_messages.haml +++ b/app/views/aspects/_no_friends_message.haml @@ -2,12 +2,7 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. -#no_posts.empty_message{:style => ("display:none" unless @posts.count == 0)} - .null_arrow ⇧ - %h3=t('.start_talking') - #no_friends.empty_message{:style => ("display:none" unless @friends.count == 0)} - - if (@aspect == :all) || (@aspect == :public) %h3=t('.nobody') %h4= link_to t('.add_friend'), aspects_manage_path @@ -17,4 +12,3 @@ %h4= link_to t('.add_friend_to', :aspect_name => @aspect.name), "#add_request_pane", :class => "add_request_button" %h4= link_to t('.invite', :aspect_name => @aspect.name), "#invite_user_pane", :class => "invite_user_button", :class => "invite_user_button", :title => t('.invite') - diff --git a/app/views/aspects/_no_posts_message.haml b/app/views/aspects/_no_posts_message.haml new file mode 100644 index 000000000..c555ab0cd --- /dev/null +++ b/app/views/aspects/_no_posts_message.haml @@ -0,0 +1,8 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3 or later. See +-# the COPYRIGHT file. + +#no_posts.empty_message{:style => ("display:none" unless @posts.count == 0)} + .null_arrow ⇧ + %h3=t('.start_talking') + diff --git a/app/views/aspects/index.html.haml b/app/views/aspects/index.html.haml index e61aa4d42..8ffe1a519 100644 --- a/app/views/aspects/index.html.haml +++ b/app/views/aspects/index.html.haml @@ -6,8 +6,9 @@ = render "shared/aspect_friends" .span-15.last - = render 'aspects/empty_messages' - = render "shared/publisher" + = render 'aspects/no_friends_message' + = render 'shared/publisher' + = render 'aspects/no_posts_message' %ul#stream - for post in @posts = render type_partial(post), :post => post unless post.class == Album diff --git a/app/views/aspects/show.html.haml b/app/views/aspects/show.html.haml index e61aa4d42..8ffe1a519 100644 --- a/app/views/aspects/show.html.haml +++ b/app/views/aspects/show.html.haml @@ -6,8 +6,9 @@ = render "shared/aspect_friends" .span-15.last - = render 'aspects/empty_messages' - = render "shared/publisher" + = render 'aspects/no_friends_message' + = render 'shared/publisher' + = render 'aspects/no_posts_message' %ul#stream - for post in @posts = render type_partial(post), :post => post unless post.class == Album diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 2b4aff4c4..45d80437a 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -79,13 +79,14 @@ en: friends_albums: "Friends Albums" your_albums: "Your Albums" aspects: - empty_messages: - start_talking: "Nobody has said anything yet. Get the conversation started!" + no_friends_message: nobody: "We know you have friends, bring them to Diaspora!" nobody_in_aspect: "Your aspect '%{aspect_name}' is empty." add_friend: "Add a friend" add_friend_to: "Add someone to %{aspect_name}" invite: "Invite someone to join Diaspora!" + no_posts_message: + start_talking: "Nobody has said anything yet. Get the conversation started!" manage: add_a_new_aspect: "Add a new aspect" add_a_new_friend: "Add a new friend"