Route account URLs back through AccountsController
This commit is contained in:
parent
a7955ad491
commit
d3ee46c328
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class AccountsController < ApplicationController
|
class AccountsController < ReactController
|
||||||
PAGE_SIZE = 20
|
PAGE_SIZE = 20
|
||||||
|
|
||||||
include AccountControllerConcern
|
include AccountControllerConcern
|
||||||
|
@ -11,24 +11,7 @@ class AccountsController < ApplicationController
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html do
|
format.html do
|
||||||
mark_cacheable! unless user_signed_in?
|
mark_cacheable! unless user_signed_in?
|
||||||
|
return process(:react)
|
||||||
@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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
format.atom do
|
format.atom do
|
||||||
|
|
|
@ -6,8 +6,6 @@ module AccountControllerConcern
|
||||||
FOLLOW_PER_PAGE = 12
|
FOLLOW_PER_PAGE = 12
|
||||||
|
|
||||||
included do
|
included do
|
||||||
layout 'public'
|
|
||||||
|
|
||||||
before_action :set_account
|
before_action :set_account
|
||||||
before_action :check_account_approval
|
before_action :check_account_approval
|
||||||
before_action :check_account_suspension
|
before_action :check_account_suspension
|
||||||
|
@ -18,7 +16,7 @@ module AccountControllerConcern
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_account
|
def set_account
|
||||||
@account = Account.find_local!(username_param)
|
@account = Account.find_acct!(username_param)
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_instance_presenter
|
def set_instance_presenter
|
||||||
|
@ -26,6 +24,8 @@ module AccountControllerConcern
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_link_headers
|
def set_link_headers
|
||||||
|
return if !@account.local? # TODO: Handle remote users
|
||||||
|
|
||||||
response.headers['Link'] = LinkHeader.new(
|
response.headers['Link'] = LinkHeader.new(
|
||||||
[
|
[
|
||||||
webfinger_account_link,
|
webfinger_account_link,
|
||||||
|
|
|
@ -5,6 +5,8 @@ require 'sidekiq-scheduler/web'
|
||||||
|
|
||||||
Sidekiq::Web.set :session_secret, Rails.application.secrets[:secret_key_base]
|
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
|
Rails.application.routes.draw do
|
||||||
mount LetterOpenerWeb::Engine, at: 'letter_opener' if Rails.env.development?
|
mount LetterOpenerWeb::Engine, at: 'letter_opener' if Rails.env.development?
|
||||||
|
|
||||||
|
@ -41,7 +43,10 @@ Rails.application.routes.draw do
|
||||||
confirmations: 'auth/confirmations',
|
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}" }
|
get '/authorize_follow', to: redirect { |_, request| "/authorize_interaction?#{request.params.to_query}" }
|
||||||
|
|
||||||
resources :accounts, path: 'users', only: [:show], param: :username do
|
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 '/about/sales', to: 'about#sales'
|
||||||
|
|
||||||
get '/tags/:tag', to: 'react#react'
|
get '/tags/:tag', to: 'react#react'
|
||||||
get '/:username', to: 'react#react', as: :short_account
|
get '/:username', to: 'accounts#show', as: :short_account
|
||||||
get '/:username/with_replies', to: 'react#react', as: :short_account_with_replies
|
get '/:username/with_replies', to: 'accounts#show', as: :short_account_with_replies
|
||||||
get '/:username/media', to: 'react#react', as: :short_account_media
|
get '/:username/media', to: 'accounts#show', as: :short_account_media
|
||||||
get '/:username/tagged/:tag', to: 'react#react', as: :short_account_tag
|
get '/:username/tagged/:tag', to: 'accounts#show', as: :short_account_tag
|
||||||
get '/:username/posts/:statusId/reblogs', to: 'react#react'
|
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', to: 'react#react', as: :short_account_status
|
||||||
get '/:account_username/posts/:id/embed', to: 'statuses#embed', as: :embed_short_account_status
|
get '/:account_username/posts/:id/embed', to: 'statuses#embed', as: :embed_short_account_status
|
||||||
|
|
Loading…
Reference in New Issue