notebook/app/views/content/references.html.erb
Andrew Brown 8aceca03a4 fix jumps
2023-05-25 09:56:31 -07:00

413 lines
24 KiB
Plaintext

<%
page_description = "#{@content.name}, #{@content.description} — a fictional #{@content.class.name.downcase} on Notebook.ai"
page_description ||= @content.description
page_description ||= "#{@content.name} is a fictional #{@content.class.name.downcase} on Notebook.ai"
set_meta_tags title: @content.name,
description: page_description.truncate(160),
image_src: @content.first_public_image,
og: { type: 'website' },
twitter: { card: 'photo', image: @content.first_public_image }
%>
<div
x-data="{ showEditMode: <%= params.fetch('editing', false) %> }"
>
<nav class="bg-white h-16 border-b border-gray-200 flex sticky top-14 z-40" aria-label="Breadcrumb">
<ol role="list" class="flex-1 mx-auto px-4 flex space-x-4 sm:px-6 lg:px-8">
<li class="flex">
<div class="flex items-center">
<%= link_to root_path, class: 'text-gray-400 hover:text-gray-500' do %>
<i class="material-icons flex-shrink-0 text-2xl relative top-1">dashboard</i>
<span class="sr-only">Home</span>
<% end %>
</div>
</li>
<li class="flex">
<div class="flex items-center">
<svg class="flex-shrink-0 w-6 h-full text-gray-200" viewBox="0 0 24 44" preserveAspectRatio="none" fill="currentColor" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
<path d="M.293 0l22 22-22 22h1.414l22-22-22-22H.293z" />
</svg>
<%= link_to @serialized_content.class_name.pluralize, send("#{@serialized_content.class_name.downcase.pluralize}_path"), class: 'ml-4 text-sm font-medium text-gray-500 hover:text-gray-700' %>
</div>
</li>
<li class="flex">
<div class="flex items-center">
<svg class="flex-shrink-0 w-6 h-full text-gray-200" viewBox="0 0 24 44" preserveAspectRatio="none" fill="currentColor" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
<path d="M.293 0l22 22-22 22h1.414l22-22-22-22H.293z" />
</svg>
<%= link_to @serialized_content.name, @serialized_content.raw_model, class: 'ml-4 text-sm font-medium text-gray-500 hover:text-gray-700', aria: { current: 'page' } %>
</div>
</li>
</ol>
<div class="flex flex-row pt-3">
<% if @content.updatable_by?(current_user) %>
<div class="mr-3" x-show="showEditMode">
<%= link_to @content do %>
<button type="button" class="w-full bg-notebook-blue border border-notebook-blue rounded-md shadow-sm px-4 py-2 inline-flex items-center text-sm font-medium text-gray-200 hover:bg-blue-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
<i class="material-icons text-2xl leading-3 mr-3">visibility</i>
Read Mode
</button>
<% end %>
</div>
<div class="mr-3" x-show="!showEditMode">
<button type="button" class="w-full bg-notebook-blue border border-notebook-blue rounded-md shadow-sm px-4 py-2 inline-flex items-center text-sm font-medium text-gray-200 hover:bg-blue-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
@click="showEditMode = true"
>
<i class="material-icons text-2xl leading-3 mr-3">edit</i>
Edit Mode
</button>
</div>
<% end %>
<div data-controller="dropdown" class="mr-3">
<button type="button" data-action="dropdown#toggle click@window->dropdown#hide" class="w-full bg-white border border-gray-300 rounded-md shadow-sm px-4 py-2 inline-flex justify-center text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-notebook-blue" id="page-index-button" aria-expanded="false" aria-haspopup="true">
<!-- Heroicon name: solid/sort-descending -->
<svg xmlns="http://www.w3.org/2000/svg" class="mr-3 h-5 w-5 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M3 4h13M3 8h9m-9 4h9m5-4v12m0 0l-4-4m4 4l4-4" />
</svg>
Jump to...
<!-- Heroicon name: solid/chevron-down -->
<svg class="ml-2.5 -mr-1.5 h-5 w-5 text-gray-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
</svg>
</button>
<!-- Dropdown menu, show/hide based on menu state. -->
<div data-dropdown-target="menu" class="origin-top-right z-10 absolute right-4 -mt-6 w-56 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none" role="menu" aria-orientation="vertical" aria-labelledby="page-index-button" tabindex="-1">
<div class="py-1" role="none">
<%= link_to "#documents", class: "text-gray-700 block px-4 py-2 text-sm font-medium bg-white hover:bg-gray-100 border-b border-gray-100", id: "documents-jump", data: { action: "dropdown#toggle" } do %>
<i class="material-icons float-left <%= Document.text_color %> mr-3"><%= Document.icon %></i>
Documents
<% end %>
<%= link_to "#mentions", class: "text-gray-700 block px-4 py-2 text-sm font-medium bg-white hover:bg-gray-100 border-b border-gray-100", id: "mentions-jump", data: { action: "dropdown#toggle" } do %>
<i class="material-icons float-left text-notebook-blue mr-3">book</i>
Mentions
<% end %>
</div>
<%#
DEV NOTE: This dropdown menu makes the following elements wrap; however, nesting it under the <button> also introduces weird interaction bugs.
For example, jumping to a section will work, but then the button needs clicked *twice* before you can open the menu again.
%>
</div>
<!--
<% if @content.updatable_by?(current_user) %>
<div class="mr-3">
<button type="button" class="bg-white border rounded-md shadow-sm px-4 py-2 inline-flex items-center text-sm font-medium focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
@click=""
>
<i class="material-icons text-2xl leading-3 mr-3 text-gray-400">dashboard</i>
Tools
</button>
</div>
<% end %>
-->
</div>
</nav>
<div class="relative min-h-full flex flex-col">
<!-- 3 column wrapper -->
<div class="flex-grow w-full lg:flex min-h-screen">
<!-- Left sidebar & main wrapper -->
<div class="flex-1 min-w-0 xl:flex">
<% if @serialized_content.class_name == Universe.name %>
<%= render partial: 'content/tailwind_components/universe_context_sidenav', locals: { content: @serialized_content } %>
<% else %>
<%= render partial: 'content/tailwind_components/content_context_sidenav', locals: { content: @serialized_content } %>
<% end %>
<div class="bg-white lg:min-w-0 lg:flex-1 border-b border-gray-200 shadow">
<div class="pl-4 pr-6 pt-4 pb-4 border-b border-t border-gray-200 sm:pl-6 lg:pl-8 xl:pl-6 xl:pt-6 xl:border-t-0">
<%= render partial: 'content/tailwind_components/content_header', locals: { content: @serialized_content } %>
</div>
<div class="p-6">
<div class="max-w-xl">
<h1 id="your-orders-heading" class="text-3xl font-extrabold tracking-tight text-gray-900">References</h1>
<p class="mt-2 text-sm text-gray-500">Explore the larger world this <%= @serialized_content.class_name.downcase %> is a part of!</p>
</div>
<div class="mt-12 space-y-16 sm:mt-16">
<section aria-labelledby="documents">
<div class="space-y-1 md:flex md:items-baseline md:space-y-0 md:space-x-4">
<div id="documents" class="anchor-offset relative -top-8"></div>
<h2 class="text-lg font-medium text-gray-900 md:flex-shrink-0">Documents</h2>
<div class="space-y-5 md:flex-1 md:min-w-0 sm:flex sm:items-baseline sm:justify-between sm:space-y-0">
<p class="text-sm font-medium text-gray-500">Read the stories this character appears in.</p>
<div class="flex text-sm font-medium">
<!--
<a href="#" class="<%= Document.text_color %>">Visibility details</a>
-->
</div>
</div>
</div>
<div class="mt-6 -mb-6 flow-root border-t border-gray-200 divide-y divide-gray-200">
<% @documents.each do |document| %>
<div class="py-6 sm:flex">
<div class="flex space-x-4 sm:min-w-0 sm:flex-1 sm:space-x-6 lg:space-x-8">
<%= image_tag document.random_image_including_private, class: "#{Document.color} flex-none w-20 h-20 rounded-md object-center object-cover sm:w-48 sm:h-48" %>
<div class="pt-1.5 min-w-0 flex-1 sm:pt-0">
<h3 class="text-sm font-medium text-gray-900">
<%= link_to document.title, document %>
</h3>
<p class="text-sm text-gray-500 truncate">
<!--
<span>Genre</span>
-->
<% if document.cached_word_count %>
<!--
<span class="mx-1 text-gray-400" aria-hidden="true">&middot;</span>
-->
<span>
<%= number_with_delimiter document.cached_word_count %>
<%= 'word'.pluralize document.cached_word_count %>
</span>
<% end %>
</p>
<p class="mt-1 font-medium text-gray-900">
<%= document.synopsis %>
</p>
</div>
</div>
<div class="mt-6 space-y-4 sm:mt-0 sm:ml-6 sm:flex-none sm:w-40">
<%= link_to document do %>
<button type="button" class="w-full flex items-center justify-center <%= Document.color %> py-2 px-2.5 border border-transparent rounded-md shadow-sm text-sm font-medium text-white hover:bg-teal-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-teal-500 sm:w-full sm:flex-grow-0">
Read
</button>
<% end %>
<!--
<button type="button" class="w-full flex items-center justify-center bg-white py-2 px-2.5 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-teal-500 sm:w-full sm:flex-grow-0">
Bookmark
</button>
-->
</div>
</div>
<% end %>
</div>
</section>
</div>
<div class="mt-12 space-y-16 sm:mt-16">
<section aria-labelledby="mentions">
<div class="space-y-1 md:flex md:items-baseline md:space-y-0 md:space-x-4">
<div id="mentions" class="anchor-offset relative -top-8"></div>
<h2 class="text-lg font-medium text-gray-900 md:flex-shrink-0">Mentions</h2>
<div class="space-y-5 md:flex-1 md:min-w-0 sm:flex sm:items-baseline sm:justify-between sm:space-y-0">
<p class="text-sm font-medium text-gray-500">See which other pages mention this <%= @serialized_content.class_name.downcase %>.</p>
<div class="flex text-sm font-medium">
<!--
<a href="#" class="text-notebook-blue">Visibility details</a>
-->
</div>
</div>
</div>
<div class="mt-6 -mb-6 flow-root border-t border-gray-200 divide-y divide-gray-200">
<table class="mt-4 w-full text-gray-500 sm:mt-6">
<caption class="sr-only">
Mentions
</caption>
<thead class="sr-only text-sm text-gray-500 text-left sm:not-sr-only">
<tr>
<th scope="col" class="sm:w-2/5 lg:w-1/3 pr-8 py-3 font-normal">Page</th>
<th scope="col" class="hidden w-1/5 pr-8 py-3 font-normal sm:table-cell">Field</th>
<th scope="col" class="hidden pr-8 py-3 font-normal sm:table-cell">Text</th>
<th scope="col" class="w-0 py-3 font-normal text-right"></th>
</tr>
</thead>
<tbody class="border-b border-gray-200 divide-y divide-gray-200 text-sm sm:border-t">
<% @references.each do |reference| %>
<tr>
<td class="py-6 pr-8">
<div class="flex items-center">
<%= link_to reference.referencing_page do %>
<%= image_tag reference.referencing_page.random_image_including_private(format: :thumb), class: "w-16 h-16 object-center object-cover rounded mr-6 #{reference.referencing_page.class.color}", alt: reference.referencing_page.name %>
<% end %>
<div>
<div class="font-medium text-gray-900">
<%= link_to reference.referencing_page do %>
<i class="material-icons float-left mr-1 <%= content_class_from_name(reference.referencing_page_type).text_color %>">
<%= content_class_from_name(reference.referencing_page_type).icon %>
</i>
<%= reference.referencing_page.name %>
<% end %>
</div>
</div>
</div>
</td>
<td class="hidden py-6 pr-8 sm:table-cell">
<i class="material-icons float-left mr-1">
<%=
case reference.reference_type
when 'linked'
'link'
when 'mentioned'
'text_fields'
end
%>
</i>
<%= reference.cached_relation_title %>
</td>
<td class="hidden py-6 pr-8 sm:table-cell">
<%=
relevant_attribute = @mentioning_attributes.find do |attribute|
attribute.attribute_field_id == reference.attribute_field_id && \
attribute.entity_id == reference.referencing_page_id
end
case reference.reference_type
when 'linked'
render partial: 'content/tailwind_components/fields/link', locals: { field: {
value: JSON.parse(relevant_attribute.value)
} }
when 'mentioned'
render partial: 'content/tailwind_components/fields/text', locals: { field: {
value: relevant_attribute.value
} }
end
%>
</td>
<td class="py-6 font-medium text-right whitespace-nowrap">
<%= link_to reference.referencing_page, class: content_class_from_name(reference.referencing_page_type).text_color do%>
View
<span class="hidden lg:inline"> <%= reference.referencing_page_type %></span>
<span class="sr-only">, <%= reference.referencing_page.name %></span>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</section>
</div>
</div>
</div>
</div>
<!-- Right pane -->
<div class="bg-gray-50 pr-4 sm:pr-6 lg:pr-8 lg:flex-shrink-0 lg:border-l lg:border-gray-200 xl:pr-0">
<div class="pl-6 lg:w-80 hidden px-6 pt-6">
<div class="lg:flex lg:items-center lg:justify-between">
<div class="flex-1 min-w-0 mb-8">
<h2 class="font-bold leading-tight text-gray-900">Page customization</h2>
<div class="flex flex-col sm:flex-row sm:flex-wrap sm:mt-0 sm:space-x-6">
<div class="flex items-center text-sm text-gray-500">
<svg xmlns="http://www.w3.org/2000/svg" class="flex-shrink-0 mr-1.5 h-5 w-5 text-gray-400" viewBox="0 0 20 20" fill="currentColor">
<path d="M10 12a2 2 0 100-4 2 2 0 000 4z" />
<path fill-rule="evenodd" d="M.458 10C1.732 5.943 5.522 3 10 3s8.268 2.943 9.542 7c-1.274 4.057-5.064 7-9.542 7S1.732 14.057.458 10zM14 10a4 4 0 11-8 0 4 4 0 018 0z" clip-rule="evenodd" />
</svg>
Only visible to you (maybe its own page?) (maybe slide in/out from Edit mode button?)
</div>
</div>
</div>
</div>
<div class="mb-8">
<div class="flex items-center mb-4">
<!-- Enabled: "bg-indigo-600", Not Enabled: "bg-gray-200" -->
<button type="button" class="bg-gray-200 relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" role="switch" aria-checked="false" aria-labelledby="annual-billing-label">
<!-- Enabled: "translate-x-5", Not Enabled: "translate-x-0" -->
<span aria-hidden="true" class="translate-x-0 pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow transform ring-0 transition ease-in-out duration-200"></span>
</button>
<span class="ml-3" id="annual-billing-label">
<span class="text-sm font-medium text-gray-900">Enable Gallery</span>
<span class="text-sm text-gray-500">to others</span>
</span>
</div>
<div class="flex items-center mb-4">
<!-- Enabled: "bg-indigo-600", Not Enabled: "bg-gray-200" -->
<button type="button" class="bg-gray-200 relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" role="switch" aria-checked="false" aria-labelledby="annual-billing-label">
<!-- Enabled: "translate-x-5", Not Enabled: "translate-x-0" -->
<span aria-hidden="true" class="translate-x-0 pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow transform ring-0 transition ease-in-out duration-200"></span>
</button>
<span class="ml-3" id="annual-billing-label">
<span class="text-sm font-medium text-gray-900">Enable Comments</span>
<span class="text-sm text-gray-500">something</span>
</span>
</div>
</div>
<!-- Action buttons -->
<div class="flex flex-col sm:flex-row xl:flex-col space-y-1">
<button type="button" class="inline-flex items-center justify-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white <%= Universe.color %> hover:bg-purple-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 xl:w-full">
</button>
Create page
<br />Privacy settings [page controls visible only to you!]
<button type="button" class="mt-3 inline-flex items-center justify-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 sm:mt-0 sm:ml-3 xl:ml-0 xl:mt-3 xl:w-full">
Share universe
</button>
</div>
<div class="pt-6 pb-2">
<h2 class="text-sm font-semibold">Recent Activity</h2>
</div>
<div>
<ul role="list" class="divide-y divide-gray-200">
<% 4.times do %>
<li class="py-4">
<div class="flex space-x-3">
<img class="h-10 w-10 rounded-lg" src="https://images.unsplash.com/photo-1517365830460-955ce3ccd263?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=256&h=256&q=80" alt="">
<div class="flex-1 space-y-1">
<div class="flex items-center justify-between">
<h3 class="text-sm font-medium">Sarah Cena</h3>
<p class="text-sm text-gray-500">1h</p>
</div>
<p class="text-sm text-gray-500 group">
Character updated by <%= link_to @content.user.display_name, @content.user, class: "group-hover:#{User.text_color}" %>.
</p>
</div>
</div>
</li>
<% end %>
<!-- More items... -->
</ul>
<!--
<div class="py-4 text-sm border-t border-gray-200">
<a href="#" class="text-indigo-600 font-semibold hover:text-indigo-900">View all activity <span aria-hidden="true">&rarr;</span></a>
</div>
-->
<div class="pt-6 pb-2">
<h2 class="text-sm font-semibold">Contributors to this page</h2>
</div>
<div class="mt-4 flex-shrink-0 sm:mt-0">
<div class="flex overflow-hidden -space-x-1">
<img class="inline-block h-10 w-10 rounded-full ring-2 ring-white" src="https://images.unsplash.com/photo-1502685104226-ee32379fefbe?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80" alt="Emily Selman">
<img class="inline-block h-10 w-10 rounded-full ring-2 ring-white" src="https://images.unsplash.com/photo-1500917293891-ef795e70e1f6?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80" alt="Kristin Watson">
<img class="inline-block h-10 w-10 rounded-full ring-2 ring-white" src="https://images.unsplash.com/photo-1505840717430-882ce147ef2d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80" alt="Emma Dorsey">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>