Commit ceba70c68d899ba4e30467832e46bcc5e867b553

Authored by Gabriel Silva
1 parent e697a141

Creates follow and unfollow views

Signed-off-by: Artur Bersan de Faria <arturbersan@gmail.com>
Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com>
app/controllers/my_profile/followed_people_controller.rb 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +class FollowedPeopleController < MyProfileController
  2 +
  3 + def index
  4 + @followed_people = [].paginate(:per_page => 5, :page => params[:npage], :total_entries => profile.friends.count)
  5 + end
  6 +
  7 +
  8 +end
... ...
app/controllers/public/profile_controller.rb
... ... @@ -65,6 +65,10 @@ class ProfileController &lt; PublicController
65 65 end
66 66 end
67 67  
  68 + def following
  69 + @followed_people = [].paginate(:per_page => per_page, :page => params[:npage], :total_entries => profile.friends.count)
  70 + end
  71 +
68 72 def members
69 73 if is_cache_expired?(profile.members_cache_key(params))
70 74 sort = (params[:sort] == 'desc') ? params[:sort] : 'asc'
... ...
app/views/blocks/profile_info_actions/_person.html.erb
... ... @@ -7,6 +7,15 @@
7 7 </li>
8 8 <% end %>
9 9  
  10 + <li>
  11 + <% if profile.follows?(user) %>
  12 + <%= button(:unfollow, content_tag('span', _('Unfollow')), "#", :class => 'add-friend', :title => _("Unfollow"), :style => 'position: relative;') %>
  13 + <% else %>
  14 + <%= button(:follow, content_tag('span', _('Follow')), "#", :class => 'add-friend', :title => _("Follow"), :style => 'position: relative;') %>
  15 + <% end %>
  16 + </li>
  17 +
  18 +
10 19 <% if user.is_a_friend?(profile) && profile.enable_contact? %>
11 20 <li><%= button(:back, _('Send an e-mail'), {:profile => profile.identifier, :controller => 'contact', :action => 'new'}) %></li>
12 21 <% end %>
... ...
app/views/followed_people/_profile_list.html.erb 0 → 100644
... ... @@ -0,0 +1,16 @@
  1 +<ul class="profile-list">
  2 + <% profiles.each do |profile| %>
  3 + <li>
  4 + <%= link_to_profile profile_image(profile) + tag('br') + profile.short_name,
  5 + profile.identifier, :class => 'profile-link' %>
  6 + <div class="controll">
  7 + <%= button_without_text :remove, content_tag('span',_('remove')),
  8 + { :action => 'remove', :id => profile.id },
  9 + :title => _('remove') %>
  10 + <%= button_without_text 'menu-mail', content_tag('span',_('contact')),
  11 + profile.url.merge(:controller => 'contact', :action => 'new', :profile => profile.identifier),
  12 + :title => _('contact') %>
  13 + </div><!-- end class="controll" -->
  14 + </li>
  15 + <% end %>
  16 +</ul>
... ...
app/views/followed_people/index.html.erb 0 → 100644
... ... @@ -0,0 +1,25 @@
  1 +<div id="manage_followed people">
  2 +
  3 +<h1><%= _("%s following") % profile.name %></h1>
  4 +
  5 +<% cache_timeout(profile.manage_friends_cache_key(params), 4.hours) do %>
  6 + <% if @followed_people.empty? %>
  7 + <p>
  8 + <em>
  9 + <%= _("You don't follow anybody yet.") %>
  10 + </em>
  11 + </p>
  12 + <% end %>
  13 +
  14 + <%= button_bar do %>
  15 + <%= button(:back, _('Back to control panel'), :controller => 'profile_editor') %>
  16 + <%= button(:search, _('Find people'), :controller => 'search', :action => 'assets', :asset => 'people') %>
  17 + <% end %>
  18 +
  19 + <%= render :partial => 'profile_list', :locals => { :profiles => @followed_people } %>
  20 +
  21 + <br style="clear:both" />
  22 + <%= pagination_links @followed_people, :param_name => 'npage' %>
  23 +<% end %>
  24 +
  25 +</div>
... ...
app/views/profile/following.html.erb 0 → 100644
... ... @@ -0,0 +1,24 @@
  1 +<div class="common-profile-list-block">
  2 +
  3 +<h1><%= _("%s is following") % profile.name %></h1>
  4 +
  5 +<% cache_timeout(profile.friends_cache_key(params), 4.hours) do %>
  6 +<ul class='profile-list'>
  7 + <% @followed_people.each do |followed_person| %>
  8 + <%= profile_image_link(followed_person) %>
  9 + <% end%>
  10 +</ul>
  11 +
  12 + <div id='pagination-profiles'>
  13 + <%= pagination_links @followed_people, :param_name => 'npage' %>
  14 + </div>
  15 +<% end %>
  16 +
  17 +<%= button_bar do %>
  18 + <%= button :back, _('Go back'), { :controller => 'profile' } %>
  19 + <% if user == profile %>
  20 + <%= button :edit, _('Manage followed people'), :controller => 'friends', :action => 'index', :profile => profile.identifier %>
  21 + <% end %>
  22 +<% end %>
  23 +
  24 +</div>
... ...
app/views/profile_editor/edit.html.erb
... ... @@ -26,6 +26,11 @@
26 26  
27 27 <% if profile.person? %>
28 28 <div>
  29 + <!-- TODO: chagen to correct attributes after finishing the backend-->
  30 + <%= labelled_check_box _("Allow other users to follow me"), 'profile_data[can_be_followed]', true, profile.secret, :class => "person-can-be-followed" %>
  31 + </div>
  32 + <br>
  33 + <div>
29 34 <%= labelled_radio_button _('Public &mdash; show my contents to all internet users').html_safe, 'profile_data[public_profile]', true, @profile.public_profile? %>
30 35 </div>
31 36 <div>
... ...