diff --git a/app/assets/images/charte/partage.png b/app/assets/images/charte/partage.png new file mode 100644 index 0000000..bdc0ae9 Binary files /dev/null and b/app/assets/images/charte/partage.png differ diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 8abcd9d..5c5a51c 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -7,6 +7,20 @@ + <% 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." %> + + + + + + + + "> + + + + <%= csrf_meta_tags %> <%= csp_meta_tag %> diff --git a/app/views/moods/public.html.erb b/app/views/moods/public.html.erb index c3f6753..7104f0a 100644 --- a/app/views/moods/public.html.erb +++ b/app/views/moods/public.html.erb @@ -1,4 +1,5 @@ <% 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) %> <% selected_date = (Date.parse(params[:day]) rescue Date.current) %> <% selected = find_day(history, selected_date) if selected_date < Date.current %> diff --git a/spec/requests/home_spec.rb b/spec/requests/home_spec.rb new file mode 100644 index 0000000..84a01b0 --- /dev/null +++ b/spec/requests/home_spec.rb @@ -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