diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index d912fda6..3b1a28cc 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -123,6 +123,14 @@ class ContentController < ApplicationController return if ENV.key?('CONTENT_BLACKLIST') && ENV['CONTENT_BLACKLIST'].split(',').include?(@content.user.try(:email)) @serialized_content = ContentSerializer.new(@content) + + @primary_image = @content.primary_image + @other_images = @content.image_uploads.where.not(id: @primary_image.try(:id)) + @basil_images = @content.basil_commissions.where.not(saved_at: nil) + end + + def references + end def new diff --git a/app/models/concerns/has_image_uploads.rb b/app/models/concerns/has_image_uploads.rb index 684bb79a..adccccfd 100644 --- a/app/models/concerns/has_image_uploads.rb +++ b/app/models/concerns/has_image_uploads.rb @@ -8,6 +8,11 @@ module HasImageUploads # todo: dependent: :destroy_async # todo: destroy from s3 on destroy + def primary_image + # self.image_uploads.find_by(primary: true) || self.image_uploads.first + self.image_uploads.first + end + def public_image_uploads self.image_uploads.where(privacy: 'public').presence || [header_asset_for(self.class.name)] end diff --git a/app/views/content/gallery.html.erb b/app/views/content/gallery.html.erb index 1e2a5162..5c24121a 100644 --- a/app/views/content/gallery.html.erb +++ b/app/views/content/gallery.html.erb @@ -36,29 +36,32 @@ - -
-
- <%# "highlighted" images %> - <% 1.times do %> + + <% if @primary_image %> +
+
<%# we should probably scale size/dimensions based on actual image data (which we have here) %>
- gallery + <%= link_to @primary_image.src.url do %> + <%= image_tag @primary_image.src.url, class: 'block object-cover object-center w-full h-full rounded hover:opacity-90', alt: "Primary image for #{@content.name}" %> + <% end %>
-

Image title

+

<%= @content.name %>

- Uploaded by - @andrew + A <%= @content.class.name.downcase %> + by <%= link_to @content.user.name, @content.user, class: User.text_color %>
+ + +
- <% end %> +
-
+ <% end %> +
-
-
- gallery + <% @other_images.each do |image| %> +
+
+ <%= link_to image.src.url do %> + <%= image_tag image.src.url, class: 'block object-cover object-center w-full h-full rounded-lg hover:opacity-90' %> + <% end %> +
-
-
-
- gallery + <% end %> + <% @basil_images.each do |commission| %> +
+
+ <%= link_to commission.image do %> + <%= image_tag commission.image, class: 'block object-cover object-center w-full h-full rounded-lg hover:opacity-90' %> + <% end %> +
-
-
-
- gallery -
-
-
-
- gallery -
-
-
-
- gallery -
-
-
-
- gallery -
-
+ <% end %>
-
diff --git a/app/views/content/references.html.erb b/app/views/content/references.html.erb new file mode 100644 index 00000000..598959ca --- /dev/null +++ b/app/views/content/references.html.erb @@ -0,0 +1,7 @@ +documents + +Timelines + +Mentions + +[field] references \ No newline at end of file diff --git a/app/views/content/tailwind_components/_content_context_sidenav.html.erb b/app/views/content/tailwind_components/_content_context_sidenav.html.erb index d1048827..39ffd027 100644 --- a/app/views/content/tailwind_components/_content_context_sidenav.html.erb +++ b/app/views/content/tailwind_components/_content_context_sidenav.html.erb @@ -1,98 +1,88 @@
-
-
+
+
<% image = content.raw_model.random_image_including_private %> - <%# DEV NOTE TODO - this should probably link to the gallery tab instead if there are any images %> - <%= link_to image, target: '_blank' do %> - <%= image_tag image, class: 'rounded-lg bg-notebook-blue h-64 hover:shadow hover:opacity-90' %> + <%= link_to send("gallery_#{content.class_name.downcase}_path") do %> + <%= image_tag image, class: 'rounded-lg bg-notebook-blue h-64 object-cover object-center hover:shadow hover:opacity-90' %> <% end %>
-
+
<%= content.class_icon %> <%= content.name %>
- <% if content.universe %> - <%= link_to content.universe, class: 'group flex items-center text-xs' do %> - <%= Universe.icon %> - in   - <%= content.universe.name %> - <% end %> - <% end %> <%= link_to content.user, class: 'group flex items-center text-xs' do %> <%= User.icon %> by   <%= content.user.display_name %> <% end %>
+ +
+ <%= link_to content.raw_model, class: 'block my-0' do %> + + <% end %> + <%= link_to send("gallery_#{content.class_name.downcase}_path") do %> + + <% end %> + <%= link_to send("references_#{content.class_name.downcase}_path") do %> + + <% end %> +
-
-

Go deeper

+ <% if content.universe %> +
+ <%= link_to content.universe, class: 'flex items-center text-xs mb-1' do %> + <%= Universe.icon %> + In the + <%= content.universe.name %> + universe + <% end %> + <%= image_tag content.universe.random_image_including_private, class: "#{Universe.color} w-full h-24 border border-purple-800 object-center object-cover rounded-md shadow hover:opacity-90" %> +
+ <% end %> - <%= link_to content.raw_model do %> - - <% end %> - <%= link_to send("gallery_#{content.class_name.downcase}_path") do %> - - <% end %> - <%= link_to send("documents_#{content.class_name.downcase}_path") do %> - - <% end %> - <%# DEV NOTE - maybe combine Documents + Timelines into "Stories" ? %> - - - -
-
- - -
-
- spellcheck - - <%= number_with_delimiter content.cached_word_count %> - <%= 'word'.pluralize content.cached_word_count %> - -
-
- date_range - - Created <%= time_ago_in_words content.created_at %> ago - -
-
- date_range - - Updated <%= time_ago_in_words content.updated_at %> ago - + +
+

+ Page stats +

+
+ spellcheck + + <%= number_with_delimiter content.cached_word_count %> + <%= 'word'.pluralize content.cached_word_count %> + +
+
+ date_range + + Created <%= time_ago_in_words content.created_at %> ago + +
+
+ date_range + + Last updated <%= time_ago_in_words content.updated_at %> ago + +
diff --git a/config/routes.rb b/config/routes.rb index ec334730..0286240b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -267,7 +267,7 @@ Rails.application.routes.draw do # Browsable pages get :gallery, on: :member - get :documents, on: :member + get :references, on: :member get :changelog, on: :member get '/tagged/:slug', on: :collection, action: :index, as: :page_tag