Commit 1b0e90fa authored by Eugen Rochko's avatar Eugen Rochko

Improve page when no friends found

parent 8087b7f8
......@@ -553,3 +553,7 @@ h4 {
}
}
}
.empty-message {
margin-bottom: 20px;
}
......@@ -24,13 +24,33 @@ class FriendsController < ApplicationController
end
def set_top_instances
@top_instances = @friends.collect { |user| user&.mastodon&.uid }
.compact
.map { |uid| uid.split('@').last }
.inject(Hash.new(0)) { |h, k| h[k] += 1; h }
.sort_by { |k, v| -v }
.map { |k, _| fetch_instance_info(k) }
.compact
@top_instances = friends_domains.map { |k, _| fetch_instance_info(k) }.compact
end
def friends_domains
return default_domains.sample(4) if @friends.empty?
@friends.collect { |user| user&.mastodon&.uid }
.compact
.map { |uid| uid.split('@').last }
.inject(Hash.new(0)) { |h, k| h[k] += 1; h }
.sort_by { |k, v| -v }
end
def default_domains
%w(
octodon.social
mastodon.art
niu.moe
todon.nl
soc.ialis.me
scifi.fyi
hostux.social
mstdn.maud.io
mastodon.sdf.org
x0r.be
toot.cafe
)
end
def twitter_friend_ids
......
.grid
- friends.each do |user|
= link_to user.mastodon.info['url'] || user.mastodon.profile_url, class: 'user-card', title: "@#{user.twitter.display_name} on Twitter" do
.avatar
= image_tag user.mastodon.info['avatar'] unless user.mastodon.info['avatar'].blank?
- if user.following
.following-indicator= fa_icon('check')
.name
%span.display-name= user.mastodon.info['display_name'].presence || user.mastodon.info['username'] || user.mastodon.display_name
%span.username= "@#{user.mastodon.uid}"
.grid
- instances.each do |instance_info|
= link_to "https://#{instance_info['uri']}/about", class: 'instance-card', style: "background-image: url(#{instance_info['thumbnail']})" do
.info
%span.title= instance_info['title']
%span.uri= instance_info['uri']
- if instance_info['stats'].is_a?(Hash)
%span.users
= surround '(', ')' do
= number_with_delimiter instance_info['stats']['user_count']
= 'person'.pluralize(instance_info['stats']['user_count'])
- collection.each do |user|
.user-map
.twitter
- if user.twitter.display_name.present?
= link_to "@#{user.twitter.display_name}", "https://twitter.com/#{user.twitter.display_name}"
- else
= link_to user.twitter.uid, "https://twitter.com/intent/user?user_id=#{user.twitter.uid}"
.to= fa_icon('chevron-right')
- if user.mastodon
.mastodon= link_to user.mastodon.uid, mastodon_profile_url(user.mastodon.uid)
.follow= link_to "Follow", follow_friend_path(user), class: 'button'
- else
.mastodon Unknown, yet
.page-heading
%h3
Your friends
%small Here are your Twitter friends who are on Mastodon
%small Here are your Twitter friends who are on Mastodon:
- if @friends.empty?
%p.lead Well, this is unfortunate. Looks like none of your Twitter friends are on Mastodon yet. Or maybe they are, but haven't signed in to this bridge service.
%p.empty-message Well, this is unfortunate. Looks like none of your Twitter friends are on Mastodon yet. Or maybe they are, but haven't signed in to this bridge service.
- if current_user.mastodon.nil?
%p.empty-message Here are some instances you could choose to make your account on:
- else
%p.empty-message Here are some instances you could recommend to your friends:
- else
.grid
- @friends.each do |user|
= link_to user.mastodon.info['url'] || user.mastodon.profile_url, class: 'user-card' do
.avatar
= image_tag user.mastodon.info['avatar'] unless user.mastodon.info['avatar'].blank?
- if user.following
.following-indicator= fa_icon('check')
.name
%span.display-name= user.mastodon.info['display_name'].presence || user.mastodon.info['username'] || user.mastodon.display_name
%span.username= "@#{user.mastodon.uid}"
= render 'friends_grid', friends: @friends
.page-heading
%h3
Your friends' instances
%small Here are the instances your friends are using:
.grid
- @top_instances.each do |instance_info|
= link_to "https://#{instance_info['uri']}/about", class: 'instance-card', style: "background-image: url(#{instance_info['thumbnail']})" do
.info
%span.title= instance_info['title']
%span.uri= instance_info['uri']
- if instance_info['stats'].is_a?(Hash)
%span.users
= surround '(', ')' do
= number_with_delimiter instance_info['stats']['user_count']
= 'person'.pluralize(instance_info['stats']['user_count'])
= render 'instances_grid', instances: @top_instances
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