diff --git a/Gemfile b/Gemfile index 9f348605e..213b31301 100644 --- a/Gemfile +++ b/Gemfile @@ -81,6 +81,7 @@ gem 'handlebars_assets', '0.18.0' gem 'jquery-rails', '3.1.2' gem 'rails-assets-jquery', '1.11.1' # Should be kept in sync with jquery-rails gem 'js_image_paths', '0.0.1' +gem 'js-routes', '0.9.9' # jQuery plugins diff --git a/Gemfile.lock b/Gemfile.lock index 483a6fc24..b13a4a6d0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -238,6 +238,9 @@ GEM thor (>= 0.14, < 2.0) jquery-ui-rails (4.2.1) railties (>= 3.2.16) + js-routes (0.9.9) + railties (>= 3.2) + sprockets-rails js_image_paths (0.0.1) rails (~> 4.0) json (1.8.1) @@ -533,6 +536,7 @@ DEPENDENCIES jasmine (= 2.0.2) jasmine-jquery-rails (= 2.0.3) jquery-rails (= 3.1.2) + js-routes (= 0.9.9) js_image_paths (= 0.0.1) json (= 1.8.1) markerb (= 1.0.2) diff --git a/app/assets/javascripts/app/helpers/handlebars-helpers.js b/app/assets/javascripts/app/helpers/handlebars-helpers.js index fd8bd0657..ebb1e132b 100644 --- a/app/assets/javascripts/app/helpers/handlebars-helpers.js +++ b/app/assets/javascripts/app/helpers/handlebars-helpers.js @@ -6,6 +6,15 @@ Handlebars.registerHelper('imageUrl', function(path){ return ImagePaths.get(path); }); +Handlebars.registerHelper('urlTo', function(path_helper, id, data){ + if( !data ) { + // only one argument given to helper, mangle parameters + data = id; + return Routes[path_helper+'_path'](data.hash); + } + return Routes[path_helper+'_path'](id, data.hash); +}); + Handlebars.registerHelper('linkToPerson', function(context, block) { if( !context ) context = this; var html = "{{t 'people.edit_my_profile'}} - {{/if}} - {{#if is_blocked}} + {{t 'people.edit_my_profile'}} + {{else}} {{#if is_blocked}} {{t 'people.stop_ignoring'}} {{else}}
- {{/if}} + {{/if}}{{/if}} {{/if}} @@ -17,6 +16,10 @@ {{diaspora_id}}
- + {{#if loggedIn}} + TODO + {{/if}}
+ +
diff --git a/app/assets/templates/profile_sidebar_tpl.jst.hbs b/app/assets/templates/profile_sidebar_tpl.jst.hbs index a3a3b7bea..4d0bba7cc 100644 --- a/app/assets/templates/profile_sidebar_tpl.jst.hbs +++ b/app/assets/templates/profile_sidebar_tpl.jst.hbs @@ -10,22 +10,25 @@ {{{sharingBadge this}}} {{#if is_receiving}} + {{!-- create status message with mention --}}
- +
{{/if}} {{#if is_mutual}} + {{!-- create private conversation with person --}}
- +
{{/if}} {{#if is_not_blocked}} + {{!-- ignore the person --}}
diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 59f8c5862..e8d569ec3 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -82,8 +82,8 @@ class PeopleController < ApplicationController mark_corresponding_notifications_read if user_signed_in? - @aspect = :profile # what does this do? - @post_type = :all # for mobile + @aspect = :profile # let aspect dropdown create new aspects + @post_type = :all # for mobile @person_json = PersonPresenter.new(@person, current_user).full_hash_with_profile respond_to do |format| @@ -179,7 +179,9 @@ class PeopleController < ApplicationController return render :text => I18n.t('people.person.thats_you') if @person == current_user.person @contact = current_user.contact_for(@person) || Contact.new + @aspect = :profile if params[:create] # let aspect dropdown create new aspects bootstrap = params[:bootstrap] || false + render :partial => 'aspect_membership_dropdown', :locals => {:contact => @contact, :person => @person, :hang => 'left', :bootstrap => bootstrap} end diff --git a/app/presenters/person_presenter.rb b/app/presenters/person_presenter.rb index cb48f5b20..7c0f30466 100644 --- a/app/presenters/person_presenter.rb +++ b/app/presenters/person_presenter.rb @@ -11,6 +11,7 @@ class PersonPresenter < BasePresenter base_hash.merge({ relationship: relationship, block: is_blocked? ? BlockPresenter.new(current_user_person_block).base_hash : false, + contact: { id: current_user_person_contact.id }, is_own_profile: own_profile? }) end @@ -44,7 +45,7 @@ class PersonPresenter < BasePresenter end def relationship - contact = current_user.contact_for(@presentable) + contact = current_user_person_contact is_mutual = contact ? contact.mutual? : false is_sharing = contact ? contact.sharing? : false @@ -68,6 +69,10 @@ class PersonPresenter < BasePresenter @block ||= current_user.blocks.where(person_id: id).limit(1).first end + def current_user_person_contact + @contact ||= current_user.contact_for(@presentable) + end + def is_blocked? current_user_person_block.present? end diff --git a/app/views/people/_profile_sidebar.html.haml b/app/views/people/_profile_sidebar.html.haml index d84c79c1c..f94dd9aec 100644 --- a/app/views/people/_profile_sidebar.html.haml +++ b/app/views/people/_profile_sidebar.html.haml @@ -27,64 +27,64 @@ .profile_button = link_to content_tag(:div, nil, :class => 'icons-ignoreuser block_user', :title => t('ignore'), :id => 'block_user_button', :data => { :person_id => @person.id }), '#', :rel => "nofollow" if @block.blank? - -if contact.sharing? || person == current_user.person - %ul#profile_information + -if contact.sharing? || person == current_user.person + %ul#profile_information - - unless person.bio.blank? - %li - %h4 - =t('.bio') - %div{ :class => direction_for(person.bio) } - = person.profile.bio_message.markdownified - - unless person.profile.location.blank? - %li - %h4 - =t('.location') - %div{ :class => direction_for(person.location) } - = person.profile.location_message.markdownified + - unless person.bio.blank? + %li + %h4 + =t('.bio') + %div{ :class => direction_for(person.bio) } + = person.profile.bio_message.markdownified + - unless person.profile.location.blank? + %li + %h4 + =t('.location') + %div{ :class => direction_for(person.location) } + = person.profile.location_message.markdownified - - unless person.gender.blank? - %li - %h4 - =t('.gender') - = person.gender + - unless person.gender.blank? + %li + %h4 + =t('.gender') + = person.gender - - unless person.birthday.blank? - %li - %h4 - =t('.born') - = birthday_format(person.birthday) - - if @photos.present? - %li.image_list - %h4 - = t('.photos') - .item_count - = "#{@photos.count(:all)}" - - @photos.limit(8).each do |photo| - = image_tag(photo.url(:thumb_small)) - %br - = link_to t('layouts.header.view_all'), person_photos_path(person) + - unless person.birthday.blank? + %li + %h4 + =t('.born') + = birthday_format(person.birthday) + - if @photos.present? + %li.image_list + %h4 + = t('.photos') + .item_count + = "#{@photos.count(:all)}" + - @photos.limit(8).each do |photo| + = image_tag(photo.url(:thumb_small)) + %br + = link_to t('layouts.header.view_all'), person_photos_path(person) - - if person == current_user.person - %li.image_list - %h4 - = t('_contacts') - .item_count - = all_contacts_count - .section.contact_pictures - - current_user.contacts.limit(8).each do |contact| - = person_image_link contact.person, :size => :thumb_small - %p.see_all= link_to t('layouts.header.view_all'), contacts_path - - elsif @contact.persisted? && @contacts_of_contact_count > 0 - %li.image_list - %h4 - = t('_contacts') - .item_count - = @contacts_of_contact_count - .section.contact_pictures - -@contacts_of_contact.limit(8).each do |person| - = person_image_link person, :size => :thumb_small - %p.see_all= link_to t('layouts.header.view_all'), person_contacts_path(@person) + - if person == current_user.person + %li.image_list + %h4 + = t('_contacts') + .item_count + = all_contacts_count + .section.contact_pictures + - current_user.contacts.limit(8).each do |contact| + = person_image_link contact.person, :size => :thumb_small + %p.see_all= link_to t('layouts.header.view_all'), contacts_path + - elsif @contact.persisted? && @contacts_of_contact_count > 0 + %li.image_list + %h4 + = t('_contacts') + .item_count + = @contacts_of_contact_count + .section.contact_pictures + -@contacts_of_contact.limit(8).each do |person| + = person_image_link person, :size => :thumb_small + %p.see_all= link_to t('layouts.header.view_all'), person_contacts_path(@person) - %br - %br + %br + %br diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml index b0999b504..54a37c870 100644 --- a/app/views/people/show.html.haml +++ b/app/views/people/show.html.haml @@ -15,9 +15,11 @@ = render :partial => 'people/profile_sidebar', :locals => {:person => @person, :contact => @contact } .span-18.last - .stream_container + .profile_header = render 'people/sub_header', :person => @person, :contact => @contact + .stream_container + #main_stream.stream - if @block.present? .dull