From ceba70c68d899ba4e30467832e46bcc5e867b553 Mon Sep 17 00:00:00 2001 From: Gabriel Silva Date: Tue, 7 Jun 2016 18:58:33 +0000 Subject: [PATCH] Creates follow and unfollow views --- app/controllers/my_profile/followed_people_controller.rb | 8 ++++++++ app/controllers/public/profile_controller.rb | 4 ++++ app/views/blocks/profile_info_actions/_person.html.erb | 9 +++++++++ app/views/followed_people/_profile_list.html.erb | 16 ++++++++++++++++ app/views/followed_people/index.html.erb | 25 +++++++++++++++++++++++++ app/views/profile/following.html.erb | 24 ++++++++++++++++++++++++ app/views/profile_editor/edit.html.erb | 5 +++++ 7 files changed, 91 insertions(+), 0 deletions(-) create mode 100644 app/controllers/my_profile/followed_people_controller.rb create mode 100644 app/views/followed_people/_profile_list.html.erb create mode 100644 app/views/followed_people/index.html.erb create mode 100644 app/views/profile/following.html.erb diff --git a/app/controllers/my_profile/followed_people_controller.rb b/app/controllers/my_profile/followed_people_controller.rb new file mode 100644 index 0000000..6be0587 --- /dev/null +++ b/app/controllers/my_profile/followed_people_controller.rb @@ -0,0 +1,8 @@ +class FollowedPeopleController < MyProfileController + + def index + @followed_people = [].paginate(:per_page => 5, :page => params[:npage], :total_entries => profile.friends.count) + end + + +end diff --git a/app/controllers/public/profile_controller.rb b/app/controllers/public/profile_controller.rb index cccc352..0540690 100644 --- a/app/controllers/public/profile_controller.rb +++ b/app/controllers/public/profile_controller.rb @@ -65,6 +65,10 @@ class ProfileController < PublicController end end + def following + @followed_people = [].paginate(:per_page => per_page, :page => params[:npage], :total_entries => profile.friends.count) + end + def members if is_cache_expired?(profile.members_cache_key(params)) sort = (params[:sort] == 'desc') ? params[:sort] : 'asc' diff --git a/app/views/blocks/profile_info_actions/_person.html.erb b/app/views/blocks/profile_info_actions/_person.html.erb index c655b4e..4e329d7 100644 --- a/app/views/blocks/profile_info_actions/_person.html.erb +++ b/app/views/blocks/profile_info_actions/_person.html.erb @@ -7,6 +7,15 @@ <% end %> +
  • + <% if profile.follows?(user) %> + <%= button(:unfollow, content_tag('span', _('Unfollow')), "#", :class => 'add-friend', :title => _("Unfollow"), :style => 'position: relative;') %> + <% else %> + <%= button(:follow, content_tag('span', _('Follow')), "#", :class => 'add-friend', :title => _("Follow"), :style => 'position: relative;') %> + <% end %> +
  • + + <% if user.is_a_friend?(profile) && profile.enable_contact? %>
  • <%= button(:back, _('Send an e-mail'), {:profile => profile.identifier, :controller => 'contact', :action => 'new'}) %>
  • <% end %> diff --git a/app/views/followed_people/_profile_list.html.erb b/app/views/followed_people/_profile_list.html.erb new file mode 100644 index 0000000..7351f40 --- /dev/null +++ b/app/views/followed_people/_profile_list.html.erb @@ -0,0 +1,16 @@ + diff --git a/app/views/followed_people/index.html.erb b/app/views/followed_people/index.html.erb new file mode 100644 index 0000000..c496b67 --- /dev/null +++ b/app/views/followed_people/index.html.erb @@ -0,0 +1,25 @@ +
    + +

    <%= _("%s following") % profile.name %>

    + +<% cache_timeout(profile.manage_friends_cache_key(params), 4.hours) do %> + <% if @followed_people.empty? %> +

    + + <%= _("You don't follow anybody yet.") %> + +

    + <% end %> + + <%= button_bar do %> + <%= button(:back, _('Back to control panel'), :controller => 'profile_editor') %> + <%= button(:search, _('Find people'), :controller => 'search', :action => 'assets', :asset => 'people') %> + <% end %> + + <%= render :partial => 'profile_list', :locals => { :profiles => @followed_people } %> + +
    + <%= pagination_links @followed_people, :param_name => 'npage' %> +<% end %> + +
    diff --git a/app/views/profile/following.html.erb b/app/views/profile/following.html.erb new file mode 100644 index 0000000..3492e78 --- /dev/null +++ b/app/views/profile/following.html.erb @@ -0,0 +1,24 @@ +
    + +

    <%= _("%s is following") % profile.name %>

    + +<% cache_timeout(profile.friends_cache_key(params), 4.hours) do %> + + +
    + <%= pagination_links @followed_people, :param_name => 'npage' %> +
    +<% end %> + +<%= button_bar do %> + <%= button :back, _('Go back'), { :controller => 'profile' } %> + <% if user == profile %> + <%= button :edit, _('Manage followed people'), :controller => 'friends', :action => 'index', :profile => profile.identifier %> + <% end %> +<% end %> + +
    diff --git a/app/views/profile_editor/edit.html.erb b/app/views/profile_editor/edit.html.erb index 2bc3c45..f6e4d0e 100644 --- a/app/views/profile_editor/edit.html.erb +++ b/app/views/profile_editor/edit.html.erb @@ -26,6 +26,11 @@ <% if profile.person? %>
    + + <%= labelled_check_box _("Allow other users to follow me"), 'profile_data[can_be_followed]', true, profile.secret, :class => "person-can-be-followed" %> +
    +
    +
    <%= labelled_radio_button _('Public — show my contents to all internet users').html_safe, 'profile_data[public_profile]', true, @profile.public_profile? %>
    -- libgit2 0.21.2