From cac99716d0783fa482ea2c73bbfa0fe06ff615f6 Mon Sep 17 00:00:00 2001 From: drusepth Date: Wed, 19 Oct 2022 18:12:22 -0700 Subject: [PATCH] universe context sidebar tweaks --- app/models/page_types/universe.rb | 14 +++++++- app/views/content/show.html.erb | 2 +- .../_universe_context_sidenav.html.erb | 36 ++++++++----------- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/app/models/page_types/universe.rb b/app/models/page_types/universe.rb index 46bc0a76..93025280 100644 --- a/app/models/page_types/universe.rb +++ b/app/models/page_types/universe.rb @@ -9,7 +9,7 @@ class Universe < ApplicationRecord acts_as_paranoid include IsContentPage - # include HasContent + # include HasContent # can't do this because we generate cycles since HasContent relies on Universe already being initialized include Serendipitous::Concern @@ -94,4 +94,16 @@ class Universe < ApplicationRecord def self.content_name 'universe' end + + def content + # This is a worse version of the HasContent #content, but... dunno how to include + # that functionality in this class without duplicating it in two places and hard-coding + # the other content type names. TODO come back and fix this + content = {} + Rails.application.config.content_types[:all_non_universe].each do |content_type| + content[content_type.name] = send(content_type.name.downcase.pluralize) + end + + content + end end diff --git a/app/views/content/show.html.erb b/app/views/content/show.html.erb index b32f13e0..b9931ac5 100644 --- a/app/views/content/show.html.erb +++ b/app/views/content/show.html.erb @@ -4,7 +4,7 @@
-
+
<% if @serialized_content.class_name == Universe.name %> <%= render partial: 'content/tailwind_components/universe_context_sidenav', locals: { content: @serialized_content } %> <% else %> diff --git a/app/views/content/tailwind_components/_universe_context_sidenav.html.erb b/app/views/content/tailwind_components/_universe_context_sidenav.html.erb index 4d251ae0..4bfc40c4 100644 --- a/app/views/content/tailwind_components/_universe_context_sidenav.html.erb +++ b/app/views/content/tailwind_components/_universe_context_sidenav.html.erb @@ -1,4 +1,4 @@ -
+
@@ -6,15 +6,15 @@
- <%= link_to @universe_scope do %> - <%= image_tag @universe_scope.random_image_including_private, class: 'rounded-lg' %> + <%= link_to content.raw_model do %> + <%= image_tag content.raw_model.random_image_including_private, class: 'rounded-lg' %> <% end %>
-
<%= link_to @universe_scope.name, @universe_scope %>
- <%= link_to @universe_scope.user, class: 'group flex items-center text-xs' do %> +
<%= link_to content.name, content.raw_model %>
+ <%= link_to content.user, class: 'group flex items-center text-xs' do %> <%= User.icon %> - <%= @universe_scope.user.display_name %> + <%= content.user.display_name %> <% end %>
@@ -22,22 +22,14 @@

In this universe

- - - - + <% content.raw_model.content.each do |content_type, content_list| %> + <% next if content_list.count.zero? %> + + <% end %>