add OpenGraph tags and a share image
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
a484f8ffd9
commit
279a31f7ce
4 changed files with 38 additions and 0 deletions
BIN
app/assets/images/charte/partage.png
Normal file
BIN
app/assets/images/charte/partage.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 63 KiB |
|
|
@ -7,6 +7,20 @@
|
||||||
<meta name="theme-color" content="#F5F6F0">
|
<meta name="theme-color" content="#F5F6F0">
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
<meta name="mobile-web-app-capable" content="yes">
|
<meta name="mobile-web-app-capable" content="yes">
|
||||||
|
<% titre_partage = content_for(:title) || "Comment ça Kluk ?" %>
|
||||||
|
<% description = content_for(:description) || "Pas besoin de demander comment ça va : il suffit de regarder la tasse." %>
|
||||||
|
<meta name="description" content="<%= description %>">
|
||||||
|
<meta property="og:type" content="website">
|
||||||
|
<meta property="og:site_name" content="Kluk">
|
||||||
|
<meta property="og:locale" content="fr_FR">
|
||||||
|
<meta property="og:title" content="<%= titre_partage %>">
|
||||||
|
<meta property="og:description" content="<%= description %>">
|
||||||
|
<meta property="og:url" content="<%= request.base_url + request.path %>">
|
||||||
|
<meta property="og:image" content="<%= image_url "charte/partage.png" %>">
|
||||||
|
<meta property="og:image:width" content="1200">
|
||||||
|
<meta property="og:image:height" content="630">
|
||||||
|
<meta property="og:image:alt" content="Trois tasses de couleur alignées sur une table, et une quatrième posée sur la Kluk, fumante.">
|
||||||
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
<%= csrf_meta_tags %>
|
<%= csrf_meta_tags %>
|
||||||
<%= csp_meta_tag %>
|
<%= csp_meta_tag %>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<% content_for :title, "Comment ça Kluk chez #{@user.username} ?" %>
|
<% content_for :title, "Comment ça Kluk chez #{@user.username} ?" %>
|
||||||
|
<% content_for :description, "Les humeurs #{de_nom(@user.username)}, jour après jour, au rythme des tasses posées sur la Kluk." %>
|
||||||
<% history = MoodCalendarService.generate_calendar(@user, start_date: 5.months.ago.beginning_of_month, end_date: Date.current) %>
|
<% history = MoodCalendarService.generate_calendar(@user, start_date: 5.months.ago.beginning_of_month, end_date: Date.current) %>
|
||||||
<% selected_date = (Date.parse(params[:day]) rescue Date.current) %>
|
<% selected_date = (Date.parse(params[:day]) rescue Date.current) %>
|
||||||
<% selected = find_day(history, selected_date) if selected_date < Date.current %>
|
<% selected = find_day(history, selected_date) if selected_date < Date.current %>
|
||||||
|
|
|
||||||
23
spec/requests/home_spec.rb
Normal file
23
spec/requests/home_spec.rb
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
describe "Home", type: :request do
|
||||||
|
describe "GET / on a public user's subdomain" do
|
||||||
|
let(:user) { create(:user, username: "alice", public: true) }
|
||||||
|
|
||||||
|
before { host! "#{user.username}.example.com" }
|
||||||
|
|
||||||
|
it "exposes OpenGraph tags for sharing" do
|
||||||
|
get root_path, params: { day: "2026-01-15" }
|
||||||
|
|
||||||
|
expect(response).to have_http_status(:ok)
|
||||||
|
page = Nokogiri::HTML(response.body)
|
||||||
|
meta = ->(attr, name) { page.at_css("meta[#{attr}='#{name}']")&.[]("content") }
|
||||||
|
|
||||||
|
expect(meta.("property", "og:title")).to eq("Comment ça Kluk chez alice\u202F?")
|
||||||
|
expect(meta.("property", "og:description")).to start_with("Les humeurs d’alice")
|
||||||
|
expect(meta.("property", "og:url")).to eq("http://alice.example.com/")
|
||||||
|
expect(meta.("property", "og:image")).to match(%r{\Ahttp://alice\.example\.com/assets/charte/partage-\h+\.png\z})
|
||||||
|
expect(meta.("name", "twitter:card")).to eq("summary_large_image")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Add table
Reference in a new issue