Basic rendering for public collections
This commit is contained in:
@@ -41,14 +41,6 @@ class CardsController < ApplicationController
|
||||
end
|
||||
|
||||
private
|
||||
def page_and_filter_for_closed_cards
|
||||
if @filter.indexed_by.stalled?
|
||||
page_and_filter_for(@filter, per_page: PAGE_SIZE) { |cards| cards.recently_closed_first }
|
||||
else
|
||||
page_and_filter_for(@filter.with(indexed_by: "closed"), per_page: PAGE_SIZE) { |cards| cards.recently_closed_first }
|
||||
end
|
||||
end
|
||||
|
||||
def set_card
|
||||
@card = @collection.cards.find params[:id]
|
||||
end
|
||||
@@ -61,6 +53,14 @@ class CardsController < ApplicationController
|
||||
filter: filter
|
||||
end
|
||||
|
||||
def page_and_filter_for_closed_cards
|
||||
if @filter.indexed_by.stalled?
|
||||
page_and_filter_for(@filter, per_page: PAGE_SIZE) { |cards| cards.recently_closed_first }
|
||||
else
|
||||
page_and_filter_for(@filter.with(indexed_by: "closed"), per_page: PAGE_SIZE) { |cards| cards.recently_closed_first }
|
||||
end
|
||||
end
|
||||
|
||||
def card_params
|
||||
params.expect(card: [ :status, :title, :description, :image, tag_ids: [] ])
|
||||
end
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
class Public::CollectionsController < ApplicationController
|
||||
allow_unauthenticated_access only: :show
|
||||
|
||||
before_action :set_collection
|
||||
|
||||
layout "public"
|
||||
|
||||
PAGE_SIZE = 50
|
||||
|
||||
def show
|
||||
@filter = Current.user.filters.build
|
||||
|
||||
@considering = page_and_filter_for @filter.with(engagement_status: "considering"), per_page: PAGE_SIZE
|
||||
@doing = page_and_filter_for @filter.with(engagement_status: "doing"), per_page: PAGE_SIZE
|
||||
@closed = page_and_filter_for_closed_cards
|
||||
end
|
||||
|
||||
private
|
||||
def set_collection
|
||||
@collection = Collection.find_by_published_key(params[:id])
|
||||
end
|
||||
|
||||
def page_and_filter_for(filter, per_page: nil)
|
||||
cards = block_given? ? yield(filter.cards) : filter.cards
|
||||
|
||||
OpenStruct.new \
|
||||
page: GearedPagination::Recordset.new(cards, per_page:).page(1),
|
||||
filter: filter
|
||||
end
|
||||
|
||||
def page_and_filter_for_closed_cards
|
||||
if @filter.indexed_by.stalled?
|
||||
page_and_filter_for(@filter, per_page: PAGE_SIZE) { |cards| cards.recently_closed_first }
|
||||
else
|
||||
page_and_filter_for(@filter.with(indexed_by: "closed"), per_page: PAGE_SIZE) { |cards| cards.recently_closed_first }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -6,6 +6,12 @@ module Collection::Publishable
|
||||
scope :published, ->{ joins(:publication) }
|
||||
end
|
||||
|
||||
class_methods do
|
||||
def find_by_published_key(key)
|
||||
Collection::Publication.find_by!(key: key).collection
|
||||
end
|
||||
end
|
||||
|
||||
def published?
|
||||
publication.present?
|
||||
end
|
||||
|
||||
@@ -1,29 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%= page_title_tag %>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<meta name="view-transition" content="same-origin">
|
||||
<meta name="color-scheme" content="light dark">
|
||||
<meta name="theme-color" content="#ffffff" media="(prefers-color-scheme: light)">
|
||||
<meta name="theme-color" content="#000000" media="(prefers-color-scheme: dark)">
|
||||
<%= csrf_meta_tags %>
|
||||
<%= csp_meta_tag %>
|
||||
<%= tag.meta name: "current-user-id", content: Current.user.id if Current.user %>
|
||||
|
||||
<% turbo_refreshes_with method: :morph, scroll: :preserve %>
|
||||
|
||||
<%= stylesheet_link_tag :app, "data-turbo-track": "reload" %>
|
||||
<%= javascript_importmap_tags %>
|
||||
|
||||
<%= yield :head %>
|
||||
|
||||
<link rel="manifest" href="/manifest.json">
|
||||
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
|
||||
<link rel="icon" href="/favicon.png" type="image/png">
|
||||
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
|
||||
</head>
|
||||
<%= render "layouts/shared/head" %>
|
||||
|
||||
<body data-controller="lightbox local-time timezone-cookie" data-action="turbo:morph@window->local-time#refreshAll">
|
||||
<header id="header">
|
||||
@@ -47,7 +24,7 @@
|
||||
<%= yield :footer %>
|
||||
|
||||
<% if Current.user && !@hide_footer_frames %>
|
||||
<div id="footer_frames" data-turbo-permanent="true" >
|
||||
<div id="footer_frames" data-turbo-permanent="true">
|
||||
<%= render "my/pins/tray" %>
|
||||
<%= render "commands/terminal" %>
|
||||
<%= render "notifications/tray" %>
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<%= render "layouts/shared/head" %>
|
||||
|
||||
<body data-controller="lightbox local-time timezone-cookie" data-action="turbo:morph@window->local-time#refreshAll">
|
||||
<main id="main">
|
||||
<%= yield %>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,24 @@
|
||||
<head>
|
||||
<%= page_title_tag %>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<meta name="view-transition" content="same-origin">
|
||||
<meta name="color-scheme" content="light dark">
|
||||
<meta name="theme-color" content="#ffffff" media="(prefers-color-scheme: light)">
|
||||
<meta name="theme-color" content="#000000" media="(prefers-color-scheme: dark)">
|
||||
<%= csrf_meta_tags %>
|
||||
<%= csp_meta_tag %>
|
||||
<%= tag.meta name: "current-user-id", content: Current.user.id if Current.user %>
|
||||
|
||||
<% turbo_refreshes_with method: :morph, scroll: :preserve %>
|
||||
|
||||
<%= stylesheet_link_tag :app, "data-turbo-track": "reload" %>
|
||||
<%= javascript_importmap_tags %>
|
||||
|
||||
<%= yield :head %>
|
||||
|
||||
<link rel="manifest" href="/manifest.json">
|
||||
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
|
||||
<link rel="icon" href="/favicon.png" type="image/png">
|
||||
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
|
||||
</head>
|
||||
@@ -0,0 +1,8 @@
|
||||
<% @page_title = @collection.name %>
|
||||
|
||||
<div class="card-columns">
|
||||
<%= render "cards/index/engagement/considering", **@considering.to_h %>
|
||||
<%= render "cards/index/engagement/doing", **@doing.to_h %>
|
||||
</div>
|
||||
|
||||
<%= render "cards/index/engagement/closed", **@closed.to_h %>
|
||||
Reference in New Issue
Block a user