File tree Expand file tree Collapse file tree 4 files changed +52
-38
lines changed Expand file tree Collapse file tree 4 files changed +52
-38
lines changed Original file line number Diff line number Diff line change 1
1
class TopicsController < ApplicationController
2
2
def index
3
3
@topics = Topic . approved . with_pages . order ( name : :asc )
4
- @topics = @topics . where ( "lower(slug) LIKE ?" , "#{ params [ :letter ] . downcase } %" ) if params [ :letter ] . present?
5
4
end
6
5
7
6
def show
7
+ @topics = Topic . approved . with_pages . order ( name : :asc )
8
8
@topic = Topic . find_by! ( slug : params [ :slug ] )
9
9
end
10
10
end
Original file line number Diff line number Diff line change
1
+ <%# locals: (topics:, topic: nil) %>
2
+
3
+ <% title = topic ? "Topic: #{topic.name}" : "Topics" %>
4
+
5
+ <%= render Pages::Header.new(title: title) %>
6
+
7
+ <div class ="column-content container py-gap mb-3xl ">
8
+ < nav class ="sidebar ">
9
+ <% topics . each do |topic | %>
10
+ <%= tag . div id : dom_id ( topic ) , class : "mb-4" do %>
11
+ <%= link_to topic . name , topic_path ( topic ) , data : { turbo_frame : :topic_articles } %>
12
+ < span class ="text-faint "> (<%= topic . pages_count %> )</ span >
13
+ <% end %>
14
+ <% end %>
15
+ </ nav >
16
+ < div class ="mainbar w-full ">
17
+ <% if !topic %>
18
+ < div >
19
+ < h2 > Welcome!</ h2 >
20
+ < div >
21
+ < p > Here you‘ll find topics currently covered at Joy of Rails.</ p >
22
+ < p > Choose a topic from the sidebar to view articles.</ p >
23
+ </ div >
24
+ </ div >
25
+ <% elsif topic . pages . blank? %>
26
+ < div >
27
+ < h2 > No articles have been added for this topic yet!</ h2 >
28
+ < div >
29
+ < p > Coming soon. Maybe ;)</ p >
30
+ </ div >
31
+ </ div >
32
+ <% else %>
33
+ <% topic . pages . as_published_articles . each do |page | %>
34
+ <%= tag . div id : dom_id ( page ) do %>
35
+ <%= render Pages ::Info . new (
36
+ title : page . title ,
37
+ request_path : page . request_path ,
38
+ description : page . description ,
39
+ image : page . image
40
+ ) %>
41
+ <% end %>
42
+ <% end %>
43
+ <% end %>
44
+ </ div >
45
+ </ div >
Original file line number Diff line number Diff line change 1
-
2
- <%= render Pages::Header.new(title: "Topics") %>
3
- <div class ="section-content container py-gap mb-3xl ">
4
- <% if @topics . blank? %>
5
- < div class ="only:inherit grid grid-row-mid ">
6
- < h2 > No topics have been created yet!</ h2 >
7
- < div >
8
- < p > Coming soon ;)</ p >
9
- </ div >
10
- </ div >
11
- <% else %>
12
- <% @topics . each do |topic | %>
13
- <%= tag . div id : dom_id ( topic ) do %>
14
- < h3 >
15
- <%= link_to topic . name , topic_path ( topic ) %>
16
- < span class ="text-faint "> (<%= topic . pages_count %> )</ span >
17
- </ h3 >
18
- <% end %>
19
- <% end %>
20
- <% end %>
21
- </ div >
1
+ <%= turbo_frame_tag :topic_articles, class: "row-gap-none", data: {turbo_action: "advance"} do %>
2
+ <%= render "topic", topics: @topics %>
3
+ <% end %>
Original file line number Diff line number Diff line change 1
-
2
- <%= render Pages::Header.new(title: "Topic: #{@topic.name}") %>
3
- <div class ="section-content container py-gap mb-3xl ">
4
- <% if @topic . pages . blank? %>
5
- < div class ="only:inherit grid grid-row-mid ">
6
- < h2 > No articles have been added for this topic yet!</ h2 >
7
- < div >
8
- < p > Coming soon. Maybe ;)</ p >
9
- </ div >
10
- </ div >
11
- <% else %>
12
- <%= render Pages ::List . new ( @topic . pages . as_published_articles ) %>
13
- <% end %>
14
-
15
- < div > <%= link_to "Back to Topics list" , topics_path %> </ div >
16
- </ div >
1
+ <%= turbo_frame_tag :topic_articles, class: "row-gap-none", data: {turbo_action: "advance"} do %>
2
+ <%= render @topic, topics: @topics %>
3
+ <% end %>
You can’t perform that action at this time.
0 commit comments