Commit 9a16560d authored by Florian Staudacher's avatar Florian Staudacher
Browse files

* rename profile header view to make name more accurate

* include 'js-routes' for rails routes in javascript
  (TODO: config options?)
* add handlebars helper for rails routes
parent 0092c9c4
......@@ -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
......
......@@ -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)
......
......@@ -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 = "<a href=\"/people/" + context.guid + "\" class=\"author-name ";
......
// TODO: update the aspect_membership dropdown, too, every time we render the view...
app.pages.Profile = app.views.Base.extend({
events: {
'click #block_user_button': 'blockPerson',
......@@ -8,7 +7,7 @@ app.pages.Profile = app.views.Base.extend({
subviews: {
'#profile .badge': 'sidebarView',
'.stream_container': 'streamView'
'.profile_header': 'headerView'
},
tooltipSelector: '.profile_button div, .sharing_message_container',
......@@ -30,8 +29,8 @@ app.pages.Profile = app.views.Base.extend({
return new app.views.ProfileSidebar({model: this.model});
},
streamView: function() {
return new app.views.ProfileStream({model: this.model});
headerView: function() {
return new app.views.ProfileHeader({model: this.model});
},
blockPerson: function(evt) {
......
......@@ -119,6 +119,7 @@ app.views.Hovercard = app.views.Base.extend({
})) );
// set aspect dropdown
// TODO render me client side!!!
var href = this.href();
href += "/aspect_membership_button";
if(gon.bootstrap == true){
......
app.views.ProfileHeader = app.views.Base.extend({
templateName: 'profile_header',
presenter: function() {
return _.extend({}, this.defaultPresenter(), {
is_blocked: this.model.isBlocked()
});
},
postRenderTemplate: function() {
var self = this;
var dropdownEl = this.$('.aspect_membership_dropdown.placeholder');
if( dropdownEl.length == 0 ) return;
// TODO render me client side!!!
var href = this.model.url() + '/aspect_membership_button?create=true';
if( gon.bootstrap ) href += '&bootstrap=true';
$.get(href, function(resp) {
dropdownEl.html(resp);
new app.views.AspectMembership({el: dropdownEl});
})
}
});
......@@ -15,4 +15,9 @@ app.views.ProfileSidebar = app.views.Base.extend({
_shouldDoProfileBtns: function() {
return (app.currentUser.authenticated() && !this.model.get('is_own_profile'));
},
postRenderTemplate: function() {
// UGLY (re-)attach the facebox
this.$('a[rel*=facebox]').facebox();
}
});
app.views.ProfileStream = app.views.Base.extend({
templateName: 'profile_stream',
presenter: function() {
return _.extend({}, this.defaultPresenter(), {
is_blocked: this.model.isBlocked()
});
}
});
......@@ -3,6 +3,7 @@
* the COPYRIGHT file.
*/
//= require js_image_paths
//= require js-routes
//= require underscore
//= require backbone
//= require jquery.hotkeys
......
......@@ -3,13 +3,12 @@
{{#if loggedIn}}
{{#if is_own_profile}}
{{!-- can't block myself, so don't check it here --}}
<a href="TODO" class="button creation">{{t 'people.edit_my_profile'}}</a>
{{/if}}
{{#if is_blocked}}
<a href="{{urlTo 'edit_profile'}}" class="button creation">{{t 'people.edit_my_profile'}}</a>
{{else}} {{#if is_blocked}}
<a href="#" id="unblock_user_button" class="button">{{t 'people.stop_ignoring'}}</a>
{{else}}
<div class="placeholder aspect_membership_dropdown"></div>
{{/if}}
{{/if}}{{/if}}
{{/if}}
</div>
......@@ -17,6 +16,10 @@
<span class="diaspora_handle">{{diaspora_id}}</span>
<div class="description">
{{#if loggedIn}}
TODO
{{/if}}
</div>
</div>
<hr />
......@@ -10,22 +10,25 @@
{{{sharingBadge this}}}
{{#if is_receiving}}
{{!-- create status message with mention --}}
<div class="profile_button">
<a href="TODO" rel="facebox">
<a href="{{urlTo 'new_status_message' person_id=id}}" rel="facebox">
<div id="mention_button" class="icons-mention" title="{{t 'people.mention'}}" data-placement="bottom"></div>
</a>
</div>
{{/if}}
{{#if is_mutual}}
{{!-- create private conversation with person --}}
<div class="profile_button">
<a href="TODO" rel="facebox">
<a href="{{urlTo 'new_conversation' contact_id=contact.id name=name facebox=true}}" rel="facebox">
<div id="message_button" class="icons-message" title="{{t 'people.message'}}" data-placement="bottom"></div>
</a>
</div>
{{/if}}
{{#if is_not_blocked}}
{{!-- ignore the person --}}
<div class="profile_button">
<a href="#" rel="nofollow">
<div id="block_user_button" class="icons-ignoreuser block_user" title="{{t 'ignore'}}" data-placement="bottom"></div>
......
......@@ -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
......
......@@ -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
......
......@@ -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
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment