about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/components/features/account/components/header.jsx4
-rw-r--r--app/assets/stylesheets/components.scss8
-rw-r--r--app/controllers/remote_follow_controller.rb47
-rw-r--r--app/models/remote_follow.rb13
-rw-r--r--app/views/accounts/_header.html.haml7
-rw-r--r--app/views/authorize_follow/_card.html.haml11
-rw-r--r--app/views/authorize_follow/new.html.haml12
-rw-r--r--app/views/remote_follow/new.html.haml13
8 files changed, 99 insertions, 16 deletions
diff --git a/app/assets/javascripts/components/features/account/components/header.jsx b/app/assets/javascripts/components/features/account/components/header.jsx
index adf9ab5ae..6ae5ac002 100644
--- a/app/assets/javascripts/components/features/account/components/header.jsx
+++ b/app/assets/javascripts/components/features/account/components/header.jsx
@@ -61,10 +61,10 @@ const Header = React.createClass({
     const displayNameHTML = { __html: emojify(escapeTextContentForBrowser(displayName)) };
 
     return (
-      <div style={{ flex: '0 0 auto', background: '#2f3441', textAlign: 'center', backgroundImage: `url(${account.get('header')})`, backgroundSize: 'cover', backgroundPosition: 'center', position: 'relative' }}>
+      <div className='account__header' style={{ flex: '0 0 auto', background: '#2f3441', textAlign: 'center', backgroundImage: `url(${account.get('header')})`, backgroundSize: 'cover', backgroundPosition: 'center', position: 'relative' }}>
         <div style={{ background: 'rgba(47, 52, 65, 0.9)', padding: '20px 10px' }}>
           <a href={account.get('url')} target='_blank' rel='noopener' style={{ display: 'block', color: 'inherit', textDecoration: 'none' }}>
-            <div style={{ width: '90px', margin: '0 auto', marginBottom: '10px' }}>
+            <div className='account__header__avatar' style={{ width: '90px', margin: '0 auto', marginBottom: '10px' }}>
               <img src={account.get('avatar')} alt='' style={{ display: 'block', width: '90px', height: '90px', borderRadius: '90px' }} />
             </div>
 
diff --git a/app/assets/stylesheets/components.scss b/app/assets/stylesheets/components.scss
index 88808b085..290b370a9 100644
--- a/app/assets/stylesheets/components.scss
+++ b/app/assets/stylesheets/components.scss
@@ -147,6 +147,12 @@
   }
 }
 
+@media screen and (max-height: 800px) {
+  .account__header__avatar, .account__header__content {
+    display: none;
+  }
+}
+
 .account__header__content {
   word-wrap: break-word;
   font-weight: 300;
@@ -585,4 +591,4 @@
   pointer-events: none;
   bottom: 0;
   left: 0;
-}
\ No newline at end of file
+}
diff --git a/app/controllers/remote_follow_controller.rb b/app/controllers/remote_follow_controller.rb
new file mode 100644
index 000000000..5e923c88f
--- /dev/null
+++ b/app/controllers/remote_follow_controller.rb
@@ -0,0 +1,47 @@
+# frozen_string_literal: true
+
+class RemoteFollowController < ApplicationController
+  layout 'public'
+
+  before_action :set_account
+  before_action :check_account_suspension
+
+  def new
+    @remote_follow = RemoteFollow.new
+  end
+
+  def create
+    @remote_follow = RemoteFollow.new(resource_params)
+
+    if @remote_follow.valid?
+      resource          = Goldfinger.finger("acct:#{@remote_follow.acct}")
+      redirect_url_link = resource&.link('http://ostatus.org/schema/1.0/subscribe')
+
+      if redirect_url_link.nil? || redirect_url_link.template.nil?
+        @remote_follow.errors.add(:acct, I18n.t('remote_follow.missing_resource'))
+        render(:new) && return
+      end
+
+      redirect_to Addressable::Template.new(redirect_url_link.template).expand(uri: "acct:#{@account.username}@#{Rails.configuration.x.local_domain}").to_s
+    else
+      render :new
+    end
+  rescue Goldfinger::Error
+    @remote_follow.errors.add(:acct, I18n.t('remote_follow.missing_resource'))
+    render :new
+  end
+
+  private
+
+  def resource_params
+    params.require(:remote_follow).permit(:acct)
+  end
+
+  def set_account
+    @account = Account.find_local!(params[:account_username])
+  end
+
+  def check_account_suspension
+    head 410 if @account.suspended?
+  end
+end
diff --git a/app/models/remote_follow.rb b/app/models/remote_follow.rb
new file mode 100644
index 000000000..13281a4fc
--- /dev/null
+++ b/app/models/remote_follow.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class RemoteFollow
+  include ActiveModel::Validations
+
+  attr_accessor :acct
+
+  validates :acct, presence: true
+
+  def initialize(attrs = {})
+    @acct = attrs[:acct]
+  end
+end
diff --git a/app/views/accounts/_header.html.haml b/app/views/accounts/_header.html.haml
index 01e639205..1c6b5f0f6 100644
--- a/app/views/accounts/_header.html.haml
+++ b/app/views/accounts/_header.html.haml
@@ -5,8 +5,11 @@
         = link_to t('accounts.unfollow'), unfollow_account_path(@account), data: { method: :post }, class: 'button'
       - else
         = link_to t('accounts.follow'), follow_account_path(@account), data: { method: :post }, class: 'button'
-
-  .avatar= image_tag @account.avatar.url( :original)
+  - else
+    .controls
+      .remote-follow
+        = link_to t('accounts.remote_follow'), account_remote_follow_path(@account), class: 'button'
+  .avatar= image_tag @account.avatar.url(:original)
   %h1.name
     = display_name(@account)
     %small
diff --git a/app/views/authorize_follow/_card.html.haml b/app/views/authorize_follow/_card.html.haml
new file mode 100644
index 000000000..a9b02c746
--- /dev/null
+++ b/app/views/authorize_follow/_card.html.haml
@@ -0,0 +1,11 @@
+.account-card
+  .detailed-status__display-name
+    %div
+      = image_tag account.avatar.url(:original), alt: '', width: 48, height: 48, class: 'avatar'
+
+    %span.display-name
+      %strong= display_name(account)
+      %span= "@#{account.acct}"
+
+  - unless account.note.blank?
+    .account__header__content= Formatter.instance.simplified_format(account)
diff --git a/app/views/authorize_follow/new.html.haml b/app/views/authorize_follow/new.html.haml
index 44bf575ff..95601253e 100644
--- a/app/views/authorize_follow/new.html.haml
+++ b/app/views/authorize_follow/new.html.haml
@@ -5,17 +5,7 @@
   .follow-prompt
     %h2= t('authorize_follow.prompt_html', self: current_account.username)
 
-    .account-card
-      .detailed-status__display-name
-        %div
-          = image_tag @account.avatar.url(:original), alt: '', width: 48, height: 48, class: 'avatar'
-
-        %span.display-name
-          %strong= display_name(@account)
-          %span= "@#{@account.acct}"
-
-      - unless @account.note.blank?
-        .account__header__content= Formatter.instance.simplified_format(@account)
+    = render partial: 'card', locals: { account: @account }
 
   = form_tag authorize_follow_path, method: :post, class: 'simple_form' do
     = hidden_field_tag :acct, @account.acct
diff --git a/app/views/remote_follow/new.html.haml b/app/views/remote_follow/new.html.haml
new file mode 100644
index 000000000..e88ccccce
--- /dev/null
+++ b/app/views/remote_follow/new.html.haml
@@ -0,0 +1,13 @@
+.form-container
+  .follow-prompt
+    %h2= t('remote_follow.prompt')
+
+    = render partial: 'authorize_follow/card', locals: { account: @account }
+
+  = simple_form_for @remote_follow, as: :remote_follow, url: account_remote_follow_path(@account) do |f|
+    = render 'shared/error_messages', object: @remote_follow
+
+    = f.input :acct, placeholder: t('remote_follow.acct')
+
+    .actions
+      = f.button :button, t('remote_follow.proceed'), type: :submit