From 7bc149549d53bbbeb45075d7529ad8b36048d2c8 Mon Sep 17 00:00:00 2001 From: drusepth Date: Tue, 6 Sep 2022 15:26:18 -0700 Subject: [PATCH] timelines#index --- app/controllers/timelines_controller.rb | 4 + app/views/timelines/index.html.erb | 500 ++++++++++++++++-------- 2 files changed, 345 insertions(+), 159 deletions(-) diff --git a/app/controllers/timelines_controller.rb b/app/controllers/timelines_controller.rb index 2c67807d..fa94f0d5 100644 --- a/app/controllers/timelines_controller.rb +++ b/app/controllers/timelines_controller.rb @@ -1,4 +1,6 @@ class TimelinesController < ApplicationController + layout 'tailwind', only: [:index] + before_action :authenticate_user!, except: [:show] before_action :set_timeline, only: [:show, :edit, :update, :destroy] @@ -27,8 +29,10 @@ class TimelinesController < ApplicationController else # Add in all timelines from shared universes also @timelines += Timeline.where(universe_id: current_user.contributable_universe_ids) + .where.not(id: @timelines.pluck(:id)) end + @filtered_page_tags = [] @page_tags = PageTag.where( page_type: Timeline.name, page_id: @timelines.pluck(:id) diff --git a/app/views/timelines/index.html.erb b/app/views/timelines/index.html.erb index 8389bbd9..34d35819 100644 --- a/app/views/timelines/index.html.erb +++ b/app/views/timelines/index.html.erb @@ -1,188 +1,370 @@ -<%= content_for :full_width_page_header do %> - <%= render partial: 'content/components/parallax_header', locals: { content_type: 'Timeline', content_class: Timeline } %> -<% end %> - -<% if @timelines.any? %> - -
- -
- <%= render partial: 'content/components/list_filter_bar', locals: { content_type: Timeline } %> -
+
+
+ <%= image_tag asset_path("card-headers/timelines.webp"), class: 'h-32 w-full object-cover lg:h-48' %>
-
- <% @timelines.each do |timeline| %> -
- - <%= link_to edit_timeline_path(timeline) do %> -
-
- - <%= Timeline.icon %> - <%= timeline.name.presence || 'Untitled Timeline' %> - - +
+
+
+ <% if @universe_scope %> + <%= link_to @universe_scope do %> + <%= image_tag @universe_scope.random_image_including_private(format: :hero), class: 'h-24 w-24 rounded-full ring-4 ring-purple-800 sm:h-32 sm:w-32' %> + <% end %> + <% else %> + <%= image_tag current_user.image_url, class: 'h-24 w-24 rounded-full ring-4 ring-green-800 sm:h-32 sm:w-32' %> + <% end %> +
+
+
+

+ Showing <%= pluralize @timelines.count, "timeline" %> +

+ <% if @universe_scope %> +
+ in <%= link_to @universe_scope.name, @universe_scope, class: Universe.text_color %>
-
- <% if timeline.universe %> -

- <%= link_to timeline.universe, class: "#{Universe.text_color}" do %> - <%= Universe.icon %> - <%= timeline.universe.name %> - <% end %> -

- <% end %> -

- <%= timeline.subtitle %> -

-

- <%= timeline.description %> -

-

- Last edited <%= time_ago_in_words timeline.updated_at %> ago -

+ <% end %> +
+
+ <% if current_user.can_create?(Timeline) || PermissionService.user_has_active_promotion_for_this_content_type(user: current_user, content_type: "Timeline") %> + <%= link_to new_polymorphic_path(Timeline) do %> + + <% end %> + <% else %> + <%= link_to subscription_path do %> + + <% end %> + <% end %> +
+
+
+ +
+
-
- <% timeline.page_tags.each do |page_tag| %> - <%= link_to params.permit(:tag).merge({ tag: PageTagService.slug_for(page_tag.tag) }) do %> - - <% end %> - <% end %> + +
+ + - - <% if @show_scope_notice %> -

- Only showing timelines - in the <%= link_to @universe_scope.name, @universe_scope, class: Universe.color + '-text' %> universe. - <%= link_to( - "See timelines from all universes.", - '?universe=all', - class: Timeline.color + '-text') - %> -

- <% end %> +
+

+ + +

+ +
+
+
+ + +
-
- <% if false && @current_user_content.fetch('Timeline', []).count > 0 %> -
- <%# render partial: 'content/components/list_filter_bar', locals: { content_type: Timeline } %> -
- <% end %> +
+ + +
-
-
-

- You haven't created any timelines - <% if @universe_scope %> - in the <%= link_to @universe_scope.name, @universe_scope %> universe - <% end %> - <% if params.key?(:favorite_only) || params.key?(:slug) %> - that match these filters - <% end %> - yet! -

-

- - <%= Timeline.icon %> - -

-

- <%= t("content_descriptions.timeline") %> -

+
+ + +
+
+
+
- <% if current_user.can_create?(Timeline) || PermissionService.user_has_active_promotion_for_this_content_type(user: current_user, content_type: 'Timeline') %> - <%= link_to "Create your first timeline", new_timeline_path(), class: "btn-large #{Timeline.color} darken-1" %> - <% else %> - <%= link_to "Upgrade to Premium to create your first timeline", subscription_path %> - <% end %> +
+

+ + +

+ +
+
+
+ + +
+ +
+ + +
+ +
+ + +
+
+
+
+
-
- <% if @universe_scope %> -
-
-
-
- Focus on another universe + +
+

Filters

+ +
+
+
+
+ +
+ + +
+ + + + + +
+
+ + + <% if @filtered_page_tags.any? %> +
+
+

+ Showing only timelines with <%= 'tag'.pluralize(@filtered_page_tags.count) %> + , active +

+ + + +
+
+ <% @filtered_page_tags.each do |page_tag| %> + + <%= page_tag.tag %> + <%= link_to(polymorphic_path(@content_type_class, { slug: params.fetch(:slug, []) - [page_tag.slug] })) do %> + + <% end %> + + <% end %>
-

- You're currently focused on the - <%= link_to @universe_scope.name, @universe_scope, class: Universe.color + '-text' %> - universe and only seeing timelines in that - universe. -

-
-

- You can change what universe you're focused on by selecting a different one in the sidebar. -

<% end %> +
+
+ +<%# to be made into new card list partial? %> +<% if @timelines.any? %> +
+ <% @timelines.each do |content| %> +
+ <%= link_to edit_timeline_path(content) do %> +
+ <%= image_tag content.random_image_including_private(format: :small), class: 'h-64 rounded-t w-full object-cover object-center mb-6' %> +
+ star_outline +

+ <%= content.page_type %> +

+

+ <%= content.name %> +

+
+
+ <% end %> +
+ <% end %>
<% end %> -
-
-

About the timeline editor

-
-
- -
-
-

- Create and manage timelines for your worlds and stories in the new Notebook.ai Timeline Editor. When you get started, you'll have a blank timeline that you can - add an unlimited number of events to. Each event can have a title, description, and notes — and you can link any of your worldbuilding pages to specific events. -

-
-

- Events can be reordered however you'd like and you can add custom time labels on each event, meaning you can be as specific or as vague as you'd like when creating your - timeline. Perfect for getting a general timeline built and then coming back to make things more specific afterwards! -

-
+<% if @timelines.empty? %> +
+
+ +
+
+
-
\ No newline at end of file +<% end %>