From 5573df77417e3cf0199d9275afefca68e396c71f Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Wed, 7 Aug 2024 08:18:43 +0300 Subject: [PATCH 1/1] Set OpenGraph properties hash in diary entry show action --- app/controllers/diary_entries_controller.rb | 6 ++++-- app/views/layouts/_meta.html.erb | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/diary_entries_controller.rb b/app/controllers/diary_entries_controller.rb index 9962c7efd..1f47e2588 100644 --- a/app/controllers/diary_entries_controller.rb +++ b/app/controllers/diary_entries_controller.rb @@ -68,8 +68,10 @@ class DiaryEntriesController < ApplicationController @entry = entries.find_by(:id => params[:id]) if @entry @title = t ".title", :user => params[:display_name], :title => @entry.title - @og_image = @entry.body.image - @og_image_alt = @entry.body.image_alt + @opengraph_properties = { + "og:image" => @entry.body.image, + "og:image:alt" => @entry.body.image_alt + } @comments = can?(:unhide, DiaryComment) ? @entry.comments : @entry.visible_comments else @title = t "diary_entries.no_such_entry.title", :id => params[:id] diff --git a/app/views/layouts/_meta.html.erb b/app/views/layouts/_meta.html.erb index 822238894..790d13fc3 100644 --- a/app/views/layouts/_meta.html.erb +++ b/app/views/layouts/_meta.html.erb @@ -21,7 +21,7 @@ <% end -%> <%= tag.link :rel => "search", :type => "application/opensearchdescription+xml", :title => "OpenStreetMap Search", :href => asset_path("osm.xml") %> <%= tag.meta :name => "description", :content => "OpenStreetMap is the free wiki world map." %> -<%= opengraph_tags(@title, "og:image" => @og_image, "og:image:alt" => @og_image_alt) %> +<%= opengraph_tags(@title, @opengraph_properties || {}) %> <% if flash[:matomo_goal] -%> <%= tag.meta :name => "matomo-goal", :content => flash[:matomo_goal] %> <% end -%> -- 2.39.5