app.kluk.fr/app/views/moods/public.html.erb
Christophe Robillard 764cb542ac
Some checks are pending
CI / scan_ruby (push) Waiting to run
CI / scan_js (push) Waiting to run
CI / lint (push) Waiting to run
CI / test (push) Waiting to run
let visitors pick a day on the public page
Clicking a day shows its mode and illustration in the header, with a link
back to today. The journal stays private: the calendar helper now separates
interactivity from journal exposure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 07:54:25 +02:00

52 lines
2.7 KiB
Text
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<% content_for :title, "Comment ça Kluk chez #{@user.username} ?" %>
<% 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 %>
<% selected_date = Date.current unless selected %>
<% aujourdhui = selected_date == Date.current %>
<% mode_du_jour = @user.moods.last&.mode %>
<% mode = aujourdhui ? mode_du_jour : mode_for(selected, @user) %>
<% status = day_status(selected, @user) unless aujourdhui %>
<% since = @user.current_mode_since %>
<article class="public" data-controller="calendrier"
data-calendrier-nom-value="<%= @user.username %>"
data-calendrier-aujourdhui-value="<%= Date.current.iso8601 %>"
data-calendrier-aujourdhui-mode-value="<%= mode_du_jour&.label || "Pas de tasse posée" %>"
data-calendrier-aujourdhui-image-value="<%= (mode_du_jour || Mode.new).image_url %>"
data-calendrier-aujourdhui-couleur-value="<%= mode_du_jour&.color %>">
<figure class="carte-humeur carte-humeur-grande" data-calendrier-target="carte" style="<%= "--humeur: #{mode.color}" if mode %>">
<%= image_tag (mode || Mode.new).image_url, alt: "", data: { calendrier_target: "image" } %>
</figure>
<div class="public-texte" aria-live="polite">
<p class="public-qui" data-calendrier-target="qui">
<% if aujourdhui %>
Aujourd’hui chez <%= @user.username %>
<% else %>
Le <%= date_longue(selected_date) %> chez <%= @user.username %>
<% end %>
</p>
<h1 class="public-mode" data-calendrier-target="mode"><%= mode&.label || "Pas de tasse posée" %></h1>
<p class="public-depuis">
<span data-calendrier-target="depuis" <%= "hidden" unless aujourdhui %>>
<% if since == Date.current %>
Depuis ce matin.
<% elsif since %>
Depuis le <%= l(since, format: since.year == Date.current.year ? "%A %-d %B" : "%-d %B %Y") %>.
<% end %>
</span>
<span class="public-autre-jour" data-calendrier-target="retour" <%= "hidden" if aujourdhui %>>
<span class="detail-statut" data-calendrier-target="statut"><%= libelle_statut(status) if mode %></span>
<button type="button" class="lien" data-action="calendrier#revenir">Revenir à aujourd’hui</button>
</span>
</p>
<section class="public-historique" aria-labelledby="public-historique-titre">
<h2 id="public-historique-titre">Les derniers mois</h2>
<%= render "moods/legende", user: @user %>
<%= render "moods/calendrier", history: history, user: @user, par_annee: false,
interactive: true, selected_date: selected_date %>
</section>
</div>
</article>