From 5b27b6b646214ed7763f41a9eddd5bc7fff6ab8e Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Sat, 17 Aug 2019 01:22:27 -0400 Subject: [PATCH] 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 --- app/controllers/home_controller.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index b498a1ed..64de0d20 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -4,6 +4,7 @@ class HomeController < ApplicationController before_action :authenticate_user! before_action :set_referrer_policy_header before_action :set_initial_state_json + before_action :set_data_for_meta def index @body_classes = 'app-body' @@ -11,6 +12,25 @@ class HomeController < ApplicationController 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! return if user_signed_in?