Skip to content

Commit db056fb

Browse files
authored
404 and like button changes (#5)
1 parent 592bf26 commit db056fb

File tree

10 files changed

+63
-5
lines changed

10 files changed

+63
-5
lines changed

app/controllers/application_controller.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@ class ApplicationController < ActionController::Base
44
before_action :set_current_user
55
before_action :set_current_request_details
66
before_action :authenticate
7+
rescue_from ActiveRecord::RecordNotFound, with: :render_not_found
8+
rescue_from ActionController::RoutingError, with: :render_not_found
9+
10+
def render_not_found
11+
render template: "errors/not_found", status: :not_found
12+
end
713

814
private
915

16+
1017
def set_current_user
1118
if session_record = Session.find_by_id(cookies.signed[:session_token])
1219
Current.session = session_record

app/controllers/static_pages_controller.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ class StaticPagesController < ApplicationController
33
def privacy
44
end
55

6+
def how_it_works
7+
end
8+
69
def terms
710
end
811
end

app/helpers/style_helper.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
module StyleHelper
22
def button_classes
33
class_variants(
4-
base: "inline-flex items-center rounded-sm bg-white text-sm font-semibold text-black border hover:bg-black hover:border-white hover:text-white focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-black",
4+
base: "inline-flex items-center rounded-sm text-sm font-semibold border focus-visible:outline-2 focus-visible:outline-offset-2 bg-black focus-visible:outline-black",
55
variants: {
6+
variant: {
7+
base: "bg-white text-black hover:bg-black hover:border-white hover:text-white",
8+
invert: "bg-black text-white hover:bg-white hover:border-black hover:text-black"
9+
},
610
size: {
711
sm: "px-2.5 py-1.5 text-xs",
812
md: "px-3 py-2 text-sm",
@@ -12,6 +16,7 @@ def button_classes
1216
full: "w-full"
1317
},
1418
defaults: {
19+
base: true,
1520
size: :md,
1621
full: false
1722
}

app/models/startup.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,8 @@ class Startup < ApplicationRecord
1919
def self.ransackable_attributes(auth_object = nil)
2020
%w[name description created_at]
2121
end
22+
23+
def liked_by?(user)
24+
user && likes.exists?(user_id: user.id)
25+
end
2226
end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div class="container mx-auto p-6 lg:px-8">
2+
<div class="md:flex md:items-center md:justify-between">
3+
<div class="min-w-0 flex-1">
4+
<h2 class="text-2xl/7 font-bold sm:truncate sm:text-3xl sm:tracking-tight">Uhhhhh... This is awkward.</h2>
5+
<p class="mt-2 text-base/6 text-black">
6+
We couldn't find the page you were looking for. It might have been removed, had its name changed, or is temporarily unavailable.
7+
</p>
8+
<div class="text-center mt-4">
9+
<%= link_to "Take me back!", root_path, class: button_classes.render %>
10+
</div>
11+
</div>
12+
</div>
13+
</div>

app/views/shared/_nav_bar.html.erb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
</svg>
1010
<% end %>
1111
<div class="flex flex-1 gap-2 items-center md:gap-5 justify-end">
12-
<%= link_to 'Explore Startups', search_path, class: "text-sm/6 font-semibold" %>
13-
<%= link_to 'Submit Startup', new_startup_path, class: "text-sm/6 font-semibold" %>
12+
<%= link_to 'How it works', how_it_works_path, class: "text-sm/6 font-semibold hover:underline" %>
13+
<%= link_to 'Explore Startups', search_path, class: "text-sm/6 font-semibold hover:underline" %>
14+
<%= link_to 'Submit Startup', new_startup_path, class: "text-sm/6 font-semibold hover:underline" %>
1415
<% if Current.user %>
1516
<%= button_to 'Logout', session_path(Current.session.id), method: :delete, class: button_classes.render %>
1617
<% else %>

app/views/startups/_apply_button.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<% if role.taken? %>
22
<span class="font-semibold">Taken</span>
33
<% elsif Current.user && role.startup.user == Current.user %>
4-
<span class="font-semibold">You own this guy</span>
4+
<span class="font-semibold"><%= pluralize(role.applicants.count, "applicant") %></span>
55
<% elsif Current.user && role.applicants.include?(Current.user) %>
66
<span class="font-semibold">Applied</span>
77
<% else %>

app/views/startups/_like.html.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<turbo-frame id="like_frame_<%= startup.id %>">
2+
<% liked = startup.liked_by?(Current.user) %>
23
<%= button_to(
34
like_startup_path(startup),
45
method: :post,
56
form: { data: { turbo: "true" } },
6-
class: button_classes.render
7+
class: button_classes.render(variant: (liked ? :invert : :base))
78
) do %>
89
<%= raw "&#128077;" %>
910
<span class="ml-2"><%= startup.likes.count %> likes</span>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<div class="container mx-auto p-6 lg:px-8">
2+
<div class="md:flex md:items-center md:justify-between">
3+
<div class="min-w-0 flex-1 prose text-black max-w-none">
4+
<h2>How It Works</h2>
5+
<p>
6+
Hunterr helps founders build their dream teams by sharing open roles at early-stage startups. Whether you're a founder looking for collaborators or a builder searching for something meaningful to join, Startup Board makes the connection easy.
7+
</p>
8+
<ol>
9+
<li>Founders sign in and post their startup, including roles they need help with.</li>
10+
<li>Visitors can browse startups and see what roles are open, taken, or already applied for.</li>
11+
<li>If a role interests you, sign in and click "Apply" to let the founder know you're interested.</li>
12+
<li>The founder gets an email about your application and can confirm you with a single click.</li>
13+
<li>Once confirmed, you're officially part of the startup—go build something awesome together!</li>
14+
</ol>
15+
<h3>Want to help improve Hunterr?</h3>
16+
<p>
17+
Got an idea, feature request, or want to collaborate on this project? I'd love to hear from you. Reach out anytime at <a href="https://drewszoo.ca" target="_blank" rel="noopener noreferrer">drewszoo.ca</a>.
18+
</p>
19+
</div>
20+
</div>
21+
</div>

config/routes.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Rails.application.routes.draw do
22
get "/privacy", to: "static_pages#privacy"
33
get "/terms", to: "static_pages#terms"
4+
get "/how-it-works", to: "static_pages#how_it_works"
45
get "sign_in", to: "sessions#new"
56
post "sign_in", to: "sessions#create"
67
get "sign_up", to: "registrations#new"
@@ -29,4 +30,6 @@
2930
end
3031
resources :applications, only: [ :create ]
3132
end
33+
34+
match "*path", to: "application#render_not_found", via: :all
3235
end

0 commit comments

Comments
 (0)