Updated home_controller.rb to check for meta data for accounts, statuses, tags

if route is account/profile page, status page or tags page, set data to send to application.html.haml to render meta tag content
This commit is contained in:
mgabdev 2019-08-17 01:22:27 -04:00
parent 499bf9eb69
commit 5b27b6b646

View File

@ -4,6 +4,7 @@ class HomeController < ApplicationController
before_action :authenticate_user! before_action :authenticate_user!
before_action :set_referrer_policy_header before_action :set_referrer_policy_header
before_action :set_initial_state_json before_action :set_initial_state_json
before_action :set_data_for_meta
def index def index
@body_classes = 'app-body' @body_classes = 'app-body'
@ -11,6 +12,25 @@ class HomeController < ApplicationController
private private
def set_data_for_meta
if params[:username].present?
@account = Account.find_local!(params[:username])
elsif params[:account_username].present?
@account = Account.find_local!(params[:account_username])
if params[:id].present?
@status = @account.statuses.find(params[:id])
@stream_entry = @status.stream_entry
@type = @stream_entry.activity_type.downcase
end
end
if request.path.starts_with?('/tags') && params[:tag].present?
@tag = Tag.find_normalized!(params[:tag])
end
end
def authenticate_user! def authenticate_user!
return if user_signed_in? return if user_signed_in?