Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@
}
}

.bg-mountains-fixed {
.bg-mountains {
background-color: #0C2866;
background-size: 1800px auto;
background-repeat: no-repeat;
background-position: 50% 0%;
background-attachment: fixed;
}

@media screen and (min-width: 1800px) {
.bg-mountains-fixed {
.bg-mountains {
background-size: 100% auto;
}
}
4 changes: 1 addition & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ def set_current_user
end

def require_authentication
set_current_user
redirect_to root_path, alert: "Please sign in first." unless Current.user
redirect_to root_path, alert: "Please log in first." unless Current.user
end

def require_admin
require_authentication
redirect_to root_path, alert: "Not authorized." unless Current.admin?
end

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class SessionsController < ApplicationController
def create
auth = request.env["omniauth.auth"]
user = User.find_or_create_from_omniauth(auth)
user = User.find_or_create_from_omniauth!(auth)
session[:user_id] = user.id
redirect_to root_path, notice: "Signed in!"
redirect_to root_path, notice: "Logged in!"
end

def destroy
Expand Down
17 changes: 7 additions & 10 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ class User < ApplicationRecord
has_one :submission
has_many :votes

def self.find_or_create_from_omniauth(auth)
find_or_create_by(github_uid: auth.uid) do |user|
user.github_username = auth.info.nickname
user.github_email = auth.info.email
end.tap do |user|
user.update(
github_username: auth.info.nickname,
github_email: auth.info.email
)
end
def self.find_or_create_from_omniauth!(auth)
user = find_or_initialize_by(github_uid: auth.uid)
user.update!(
github_username: auth.info.nickname,
github_email: auth.info.email
)
user
end
end
10 changes: 5 additions & 5 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
<%= javascript_include_tag "application", "data-turbo-track": "reload", type: "module" %>
</head>

<body class="bg-mountains-fixed" style="background-image: url('<%= image_path('mountains.jpg') %>')">
<nav class="max-w-5xl mx-auto px-8 py-10">
<div class="flex items-center justify-between">
<%= link_to root_path, class: "flex items-center" do %>
<body class="bg-mountains" style="background-image: url('<%= image_path('mountains.jpg') %>')">
<nav class="max-w-5xl mx-auto px-8 pt-10 pb-6">
<div class="flex-row sm:flex gap-y-4 items-center justify-between">
<%= link_to root_path, class: "flex items-center mb-4" do %>
<div class="shrink-0 mr-0.5">
<%= image_tag "logo.svg", alt: "Blue Ridge Ruby", class: "h-10" %>
</div>
<% end %>

<div class="flex items-center gap-x-3">
<div class="flex items-center gap-x-3 mb-4">
<% if Current.user %>
<% if Current.admin? %>
<%= link_to "Admin", admin_path, class: "text-[#2672B5] px-3 py-1 font-medium" %>
Expand Down
6 changes: 3 additions & 3 deletions app/views/pages/home.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<section>
<div class="max-w-5xl mx-auto px-8">
<div class="flex-row md:flex justify-center justify-items-center gap-2 mb-20">
<div class="flex-row md:flex justify-center justify-items-center gap-2 mb-10">
<div>
<%= image_tag "typesense.svg", alt: "Typesense", class: "h-10" %>
</div>

<div class="text-3xl leading-tight font-medium text-center text-[#0C2866]">
<div class="text-3xl leading-tight font-medium text-[#0C2866]">
Haiku Ticket Giveaway
</div>
</div>
Expand Down Expand Up @@ -66,7 +66,7 @@
<% if Current.user && submission.user_id != Current.user.id %>
<% if @voted_submission_ids.include?(submission.id) %>
<%= button_to submission_vote_path(submission), method: :delete, class: "inline-flex items-center gap-1 text-sm px-3 py-1 rounded-full cursor-pointer bg-gray-400 bg-linear-to-t from-gray-500 to-gray-400 text-white" do %>
Voted
Clear Vote
<% end %>
<% else %>
<%= button_to submission_vote_path(submission), method: :post, class: "inline-flex items-center gap-1 text-sm px-3 py-1 rounded-full cursor-pointer bg-[#C41C1C] bg-linear-to-t from-[#C41C1C] to-[#DD423E] text-white" do %>
Expand Down
1 change: 0 additions & 1 deletion app/views/submissions/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
A haiku is a three-line, unrhymed poetic form typically consisting of 17 syllables in a 5-7-5 pattern. Our theme is “search,” however you would like to interpret that.
</p>


<%= form_with(model: @submission, url: @submission.persisted? ? submission_path(@submission) : submissions_path) do |f| %>
<% if @submission.errors.any? %>
<div class="mb-4 p-3 bg-red-100 text-red-800 rounded-lg">
Expand Down
Loading