diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-10-06 21:27:58 +0200 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-10-06 21:27:58 +0200 |
commit | 3554d638b31aa5ace2aa524db0165932c15d9a71 (patch) | |
tree | d20d71469f6077daf83a6996f4143dd393924b68 /app | |
parent | 87ba52ad3f1e32b0608bb6c6ffb226c1988267a3 (diff) |
Fix #72 - add follow/unfollow button to public profiles
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/application_public.js | 2 | ||||
-rw-r--r-- | app/assets/stylesheets/accounts.scss | 7 | ||||
-rw-r--r-- | app/controllers/accounts_controller.rb | 10 | ||||
-rw-r--r-- | app/views/accounts/_header.html.haml | 7 | ||||
-rw-r--r-- | app/views/layouts/public.html.haml | 3 |
5 files changed, 29 insertions, 0 deletions
diff --git a/app/assets/javascripts/application_public.js b/app/assets/javascripts/application_public.js new file mode 100644 index 000000000..31a96fd2d --- /dev/null +++ b/app/assets/javascripts/application_public.js @@ -0,0 +1,2 @@ +//= require jquery +//= require jquery_ujs diff --git a/app/assets/stylesheets/accounts.scss b/app/assets/stylesheets/accounts.scss index f2be0fcf7..e1d5043db 100644 --- a/app/assets/stylesheets/accounts.scss +++ b/app/assets/stylesheets/accounts.scss @@ -58,6 +58,13 @@ } } + .controls { + position: absolute; + top: 10px; + right: 10px; + z-index: 2; + } + .details { display: flex; margin-top: 30px; diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 9f4751771..b16938845 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -16,6 +16,16 @@ class AccountsController < ApplicationController end end + def follow + FollowService.new.call(current_user.account, @account.acct) + redirect_to account_path(@account) + end + + def unfollow + UnfollowService.new.call(current_user.account, @account) + redirect_to account_path(@account) + end + def followers @followers = @account.followers.order('follows.created_at desc').paginate(page: params[:page], per_page: 6) end diff --git a/app/views/accounts/_header.html.haml b/app/views/accounts/_header.html.haml index 371bc62c3..fb9abd691 100644 --- a/app/views/accounts/_header.html.haml +++ b/app/views/accounts/_header.html.haml @@ -1,4 +1,11 @@ .card{ style: "background-image: url(#{@account.header.url(:medium)})" } + - if user_signed_in? && current_account.id != @account.id + .controls + - if current_account.following?(@account) + = link_to 'Unfollow', unfollow_account_path(@account), data: { method: :post }, class: 'button' + - else + = link_to 'Follow', follow_account_path(@account), data: { method: :post }, class: 'button' + .avatar= image_tag @account.avatar.url(:large) %h1.name = display_name(@account) diff --git a/app/views/layouts/public.html.haml b/app/views/layouts/public.html.haml index 056393bba..0e56bef1f 100644 --- a/app/views/layouts/public.html.haml +++ b/app/views/layouts/public.html.haml @@ -1,3 +1,6 @@ +- content_for :header_tags do + = javascript_include_tag 'application_public' + - content_for :content do .container= yield .footer |