diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index abc68d2a..a73edc4e 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AccountsController < ApplicationController +class AccountsController < ReactController PAGE_SIZE = 20 include AccountControllerConcern @@ -11,24 +11,7 @@ class AccountsController < ApplicationController respond_to do |format| format.html do mark_cacheable! unless user_signed_in? - - @body_classes = 'with-modals' - @pinned_statuses = [] - @endorsed_accounts = @account.endorsed_accounts.to_a.sample(4) - - if current_account && @account.blocking?(current_account) - @statuses = [] - return - end - - @pinned_statuses = cache_collection(@account.pinned_statuses, Status) if show_pinned_statuses? - @statuses = filtered_status_page(params) - @statuses = cache_collection(@statuses, Status) - - unless @statuses.empty? - @older_url = older_url if @statuses.last.id > filtered_statuses.last.id - @newer_url = newer_url if @statuses.first.id < filtered_statuses.first.id - end + return process(:react) end format.atom do diff --git a/app/controllers/concerns/account_controller_concern.rb b/app/controllers/concerns/account_controller_concern.rb index 4f28941a..d17560d1 100644 --- a/app/controllers/concerns/account_controller_concern.rb +++ b/app/controllers/concerns/account_controller_concern.rb @@ -6,8 +6,6 @@ module AccountControllerConcern FOLLOW_PER_PAGE = 12 included do - layout 'public' - before_action :set_account before_action :check_account_approval before_action :check_account_suspension @@ -18,7 +16,7 @@ module AccountControllerConcern private def set_account - @account = Account.find_local!(username_param) + @account = Account.find_acct!(username_param) end def set_instance_presenter @@ -26,6 +24,8 @@ module AccountControllerConcern end def set_link_headers + return if !@account.local? # TODO: Handle remote users + response.headers['Link'] = LinkHeader.new( [ webfinger_account_link, diff --git a/config/routes.rb b/config/routes.rb index e922cc87..5993bea1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -5,6 +5,8 @@ require 'sidekiq-scheduler/web' Sidekiq::Web.set :session_secret, Rails.application.secrets[:secret_key_base] +html_only = lambda { |req| req.format.nil? || req.format.html? } + Rails.application.routes.draw do mount LetterOpenerWeb::Engine, at: 'letter_opener' if Rails.env.development? @@ -41,7 +43,10 @@ Rails.application.routes.draw do confirmations: 'auth/confirmations', } - get '/users/:username', to: redirect('/%{username}'), constraints: lambda { |req| req.format.nil? || req.format.html? } + get '/users/:username', to: redirect('/%{username}'), constraints: html_only + get '/users/:username/followers', to: redirect('/%{username}/followers'), constraints: html_only + get '/users/:username/following', to: redirect('/%{username}/following'), constraints: html_only + get '/authorize_follow', to: redirect { |_, request| "/authorize_interaction?#{request.params.to_query}" } resources :accounts, path: 'users', only: [:show], param: :username do @@ -453,10 +458,10 @@ Rails.application.routes.draw do get '/about/sales', to: 'about#sales' get '/tags/:tag', to: 'react#react' - get '/:username', to: 'react#react', as: :short_account - get '/:username/with_replies', to: 'react#react', as: :short_account_with_replies - get '/:username/media', to: 'react#react', as: :short_account_media - get '/:username/tagged/:tag', to: 'react#react', as: :short_account_tag + get '/:username', to: 'accounts#show', as: :short_account + get '/:username/with_replies', to: 'accounts#show', as: :short_account_with_replies + get '/:username/media', to: 'accounts#show', as: :short_account_media + get '/:username/tagged/:tag', to: 'accounts#show', as: :short_account_tag get '/:username/posts/:statusId/reblogs', to: 'react#react' get '/:account_username/posts/:id', to: 'react#react', as: :short_account_status get '/:account_username/posts/:id/embed', to: 'statuses#embed', as: :embed_short_account_status