Files
fizzy/app/views/cards/show.html.erb
T
Mike Dalessio c78bb652d5 Clean up beacon on-visibility-change handling
The previous version was not posting the beacon when the page was
loaded and visible.
2025-08-09 14:09:34 -04:00

61 lines
2.6 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
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.
<% @page_title = @card.title %>
<%= turbo_stream_from @card %>
<% content_for :head do %>
<%= tag.meta property: "og:title", content: "#{@card.title} | #{@card.collection.name}" %>
<%= tag.meta property: "og:description", content: format_excerpt(@card&.description, length: 200) %>
<%= tag.meta property: "og:image", content: @card.image.attached? ? "#{request.base_url}#{url_for(@card.image)}" : "#{request.base_url}/app-icon.png" %>
<%= tag.meta property: "og:url", content: collection_card_path(@card.collection, @card) %>
<% end %>
<% content_for :header do %>
<% if @card.creating? && @card.can_recover_abandoned_creation? %>
<div class="fill-selected position-sticky flex align-center gap-half justify-center border-block margin-block-end"
style="view-transition-name: draft-banner; --card-color: <%= @card.color %>;">
You have an unsaved card. Would you like to continue where you left off?
<%= button_to card_recover_path(@card), class: "btn btn--reversed", data: { turbo_action: "replace" } do %>
<span>Restore</span>
<% end %>
</div>
<% end %>
<% if @card.drafted? %>
<div class="fill-selected position-sticky flex align-center gap-half fill-highlight justify-center border-block margin-block-end"
style="view-transition-name: draft-banner;">
This is a draft, its only visible to you.
<%= button_to card_publish_path(@card), class: "btn txt-small btn--link", style: "--btn-background: #{@card.color}" do %>
<span>Post to project</span>
<% end %>
</div>
<% end %>
<%= render "cards/show/header" %>
<% end %>
<header class="header card-perma__collection-header">
<%= link_to cards_path(collection_ids: [ @card.collection ]), class: "header__title btn borderless txt-large", style: "--btn-padding: 0.25ch 1ch 0.25ch 0.75ch; view-transistion-name: card-collection-title;", data: { controller: "hotkey", action: "keydown.esc@document->hotkey#click" } do %>
<span class="overflow-ellipsis">
&larr;
<strong class="font-black"><%= @card.collection.name %></strong>
</span>
<% end %>
</header>
<div data-controller="beacon lightbox" data-beacon-url-value="<%= card_reading_url(@card) %>">
<%= render "cards/container", card: @card %>
<% if @card.published? || @card.drafted? %>
<%= render "cards/messages", card: @card %>
<% end %>
<%= render "layouts/lightbox" do %>
<% if @card.image.attached? %>
<%= button_to card_image_path(@card), method: :delete, class: "btn" do %>
<%= icon_tag "trash" %>
<span class="for-screen-reader">Remove background image</span>
<% end %>
<% end %>
<% end %>
</div>