Skip to content

Commit f42e739

Browse files
authored
Restore public event show page (#104)
1 parent e217980 commit f42e739

4 files changed

Lines changed: 142 additions & 21 deletions

File tree

app/controllers/events_controller.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ def all
1414
end
1515
end
1616

17+
def show
18+
@event = Event.with_all_rich_text.find_by!(slug: params[:slug])
19+
rescue ActiveRecord::RecordNotFound
20+
redirect_to all_events_path, error: 'Event not found'
21+
end
22+
1723
def past
1824
@events = Event.with_all_rich_text.past
1925
end

app/views/events/_event.html.erb

Lines changed: 90 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,115 @@
11
<div id="<%= dom_id event %>" class="card group">
22
<% future = Time.zone.now < event.start_at %>
3-
3+
44
<div class="p-8">
55
<!-- Event Header -->
6-
<div class="flex flex-col md:flex-row md:items-start md:justify-between gap-4 mb-8">
6+
<div
7+
class="
8+
flex flex-col md:flex-row md:items-start md:justify-between gap-4 mb-8
9+
"
10+
>
711
<div>
812
<h2 class="mb-3">
9-
<%= event.name %>
13+
<%= link_to event.name, event_path(event) %>
1014
</h2>
1115
<div class="flex flex-wrap items-center gap-4 text-sm">
1216
<div class="flex items-center gap-2 text-gray-600">
13-
<svg class="w-5 h-5 text-ruby-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
14-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"></path>
17+
<svg
18+
class="w-5 h-5 text-ruby-400"
19+
fill="none"
20+
stroke="currentColor"
21+
viewBox="0 0 24 24"
22+
>
23+
<path
24+
stroke-linecap="round"
25+
stroke-linejoin="round"
26+
stroke-width="2"
27+
d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"
28+
></path>
1529
</svg>
1630
<span class="font-medium"><%= event.start_time %></span>
1731
</div>
1832
<% if future %>
19-
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-green-100 text-green-800">
33+
<span
34+
class="
35+
inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-green-100
36+
text-green-800
37+
"
38+
>
2039
Upcoming
2140
</span>
2241
<% else %>
23-
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-gray-100 text-gray-800">
42+
<span
43+
class="
44+
inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-gray-100
45+
text-gray-800
46+
"
47+
>
2448
Past Event
2549
</span>
2650
<% end %>
2751
</div>
2852
</div>
29-
53+
3054
<% if future %>
3155
<%= link_to event.rsvp_link, class: "btn-primary", target: "_blank", rel: "noopener" do %>
3256
Join the event
3357
<svg class="w-4 h-4 ml-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
34-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"></path>
58+
<path
59+
stroke-linecap="round"
60+
stroke-linejoin="round"
61+
stroke-width="2"
62+
d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"
63+
></path>
3564
</svg>
3665
<% end %>
3766
<% end %>
3867
</div>
39-
4068
<!-- Event Content Grid -->
4169
<div class="grid md:grid-cols-2 gap-8">
4270
<!-- Location -->
4371
<div>
4472
<h3 class="text-lg font-semibold mb-3 flex items-center gap-2">
45-
<svg class="w-5 h-5 text-ruby-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
46-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"></path>
47-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 11a3 3 0 11-6 0 3 3 0 016 0z"></path>
73+
<svg
74+
class="w-5 h-5 text-ruby-400"
75+
fill="none"
76+
stroke="currentColor"
77+
viewBox="0 0 24 24"
78+
>
79+
<path
80+
stroke-linecap="round"
81+
stroke-linejoin="round"
82+
stroke-width="2"
83+
d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"
84+
></path>
85+
<path
86+
stroke-linecap="round"
87+
stroke-linejoin="round"
88+
stroke-width="2"
89+
d="M15 11a3 3 0 11-6 0 3 3 0 016 0z"
90+
></path>
4891
</svg>
4992
Location
5093
</h3>
5194
<div class="prose prose-sm text-gray-600">
5295
<%= event.location %>
5396
</div>
5497
</div>
55-
5698
<!-- Agenda -->
5799
<div>
58100
<h3 class="text-lg font-semibold mb-3 flex items-center gap-2">
59-
<svg class="w-5 h-5 text-ruby-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
60-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01"></path>
101+
<svg
102+
class="w-5 h-5 text-ruby-400"
103+
fill="none"
104+
stroke="currentColor"
105+
viewBox="0 0 24 24"
106+
>
107+
<path
108+
stroke-linecap="round"
109+
stroke-linejoin="round"
110+
stroke-width="2"
111+
d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01"
112+
></path>
61113
</svg>
62114
Agenda
63115
</h3>
@@ -68,22 +120,39 @@
68120
</div>
69121
</div>
70122
</div>
71-
72123
<!-- Sponsor Section -->
73124
<% if event.sponsor %>
74125
<div class="mt-8 pt-8 border-t border-gray-100">
75126
<div class="flex items-center justify-between">
76127
<h3 class="text-lg font-semibold">Event Sponsor</h3>
77128
<%= link_to event.sponsor_link, class: "group flex items-center gap-4 hover:opacity-80 transition-opacity", target: "_blank", rel: "noopener" do %>
78129
<% if event.sponsor_logo.present? %>
79-
<%= image_tag "sponsors/#{event.sponsor_logo}", class: "max-h-16 max-w-[200px] object-contain", alt: event.sponsor %>
130+
<%= image_tag "sponsors/#{event.sponsor_logo}",
131+
class: "max-h-16 max-w-[200px] object-contain",
132+
alt: event.sponsor %>
80133
<% else %>
81-
<span class="text-lg font-medium text-gray-700 group-hover:text-ruby-500 transition-colors">
134+
<span
135+
class="
136+
text-lg font-medium text-gray-700 group-hover:text-ruby-500 transition-colors
137+
"
138+
>
82139
<%= event.sponsor.titleize %>
83140
</span>
84141
<% end %>
85-
<svg class="w-5 h-5 text-gray-400 group-hover:text-ruby-500 transition-colors" fill="none" stroke="currentColor" viewBox="0 0 24 24">
86-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path>
142+
<svg
143+
class="
144+
w-5 h-5 text-gray-400 group-hover:text-ruby-500 transition-colors
145+
"
146+
fill="none"
147+
stroke="currentColor"
148+
viewBox="0 0 24 24"
149+
>
150+
<path
151+
stroke-linecap="round"
152+
stroke-linejoin="round"
153+
stroke-width="2"
154+
d="M9 5l7 7-7 7"
155+
></path>
87156
</svg>
88157
<% end %>
89158
</div>

app/views/events/show.html.erb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<div class="py-8">
2+
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
3+
<!-- Breadcrumb -->
4+
<nav class="flex mb-8" aria-label="Breadcrumb">
5+
<ol class="inline-flex items-center space-x-1 md:space-x-3">
6+
<li class="inline-flex items-center">
7+
<%= link_to all_events_path, class: "inline-flex items-center text-sm font-medium text-gray-700 hover:text-ruby-600" do %>
8+
<svg class="w-4 h-4 mr-2" fill="currentColor" viewBox="0 0 20 20">
9+
<path
10+
d="M10.707 2.293a1 1 0 00-1.414 0l-7 7a1 1 0 001.414 1.414L4 10.414V17a1 1 0 001 1h2a1 1 0 001-1v-2a1 1 0 011-1h2a1 1 0 011 1v2a1 1 0 001 1h2a1 1 0 001-1v-6.586l.293.293a1 1 0 001.414-1.414l-7-7z"
11+
></path>
12+
</svg>
13+
Events
14+
<% end %>
15+
</li>
16+
<li>
17+
<div class="flex items-center">
18+
<svg class="w-6 h-6 text-gray-400" fill="currentColor" viewBox="0 0 20 20">
19+
<path
20+
fill-rule="evenodd"
21+
d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"
22+
clip-rule="evenodd"
23+
></path>
24+
</svg>
25+
<span class="ml-1 text-sm font-medium text-gray-500 md:ml-2"><%= @event.name %></span>
26+
</div>
27+
</li>
28+
</ol>
29+
</nav>
30+
<!-- Event Preview -->
31+
<div class="mb-8">
32+
<%= render partial: "events/event", locals: { event: @event } %>
33+
</div>
34+
</div>
35+
</div>
36+
37+
<% content_for :page_title do %>
38+
<%== @event.name %>
39+
<% end %>

test/controllers/events_controller_test.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,11 @@ def setup
5252

5353
assert_equal 0, events.count
5454
end
55+
56+
test 'should redirect to events page if event is not found' do
57+
get :show, params: { slug: 'nonexistent-event' }
58+
59+
assert_response :found
60+
assert_redirected_to all_events_path
61+
end
5562
end

0 commit comments

Comments
 (0)