forked from cybrespace/mastodon
Fix #72 - add follow/unfollow button to public profiles
This commit is contained in:
parent
87ba52ad3f
commit
3554d638b3
|
@ -0,0 +1,2 @@
|
||||||
|
//= require jquery
|
||||||
|
//= require jquery_ujs
|
|
@ -58,6 +58,13 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.controls {
|
||||||
|
position: absolute;
|
||||||
|
top: 10px;
|
||||||
|
right: 10px;
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
|
||||||
.details {
|
.details {
|
||||||
display: flex;
|
display: flex;
|
||||||
margin-top: 30px;
|
margin-top: 30px;
|
||||||
|
|
|
@ -16,6 +16,16 @@ class AccountsController < ApplicationController
|
||||||
end
|
end
|
||||||
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
|
def followers
|
||||||
@followers = @account.followers.order('follows.created_at desc').paginate(page: params[:page], per_page: 6)
|
@followers = @account.followers.order('follows.created_at desc').paginate(page: params[:page], per_page: 6)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,11 @@
|
||||||
.card{ style: "background-image: url(#{@account.header.url(:medium)})" }
|
.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)
|
.avatar= image_tag @account.avatar.url(:large)
|
||||||
%h1.name
|
%h1.name
|
||||||
= display_name(@account)
|
= display_name(@account)
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
- content_for :header_tags do
|
||||||
|
= javascript_include_tag 'application_public'
|
||||||
|
|
||||||
- content_for :content do
|
- content_for :content do
|
||||||
.container= yield
|
.container= yield
|
||||||
.footer
|
.footer
|
||||||
|
|
|
@ -8,4 +8,4 @@ Rails.application.config.assets.version = '1.0'
|
||||||
|
|
||||||
# Precompile additional assets.
|
# Precompile additional assets.
|
||||||
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
||||||
Rails.application.config.assets.precompile += %w( cable.js )
|
Rails.application.config.assets.precompile += %w( application_public.js )
|
||||||
|
|
|
@ -25,6 +25,9 @@ Rails.application.routes.draw do
|
||||||
member do
|
member do
|
||||||
get :followers
|
get :followers
|
||||||
get :following
|
get :following
|
||||||
|
|
||||||
|
post :follow
|
||||||
|
post :unfollow
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue