From 94f4bcecfb6f3e13ec3823d1ddffe7a239a14dfd Mon Sep 17 00:00:00 2001 From: Jeremy Smith Date: Sun, 22 Mar 2026 21:51:42 -0400 Subject: [PATCH 1/3] Attempt to center header again --- app/views/pages/home.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/pages/home.html.erb b/app/views/pages/home.html.erb index bfe6448..d0de4d0 100644 --- a/app/views/pages/home.html.erb +++ b/app/views/pages/home.html.erb @@ -1,11 +1,11 @@
-
-
+
+
<%= image_tag "typesense.svg", alt: "Typesense", class: "h-10" %>
-
+
Haiku Ticket Giveaway
From c6f50daa9930d75d4bf02ca3858ee15c9cf6215f Mon Sep 17 00:00:00 2001 From: Jeremy Smith Date: Sun, 22 Mar 2026 21:52:05 -0400 Subject: [PATCH 2/3] Allow editing up to one hour after creation --- app/controllers/submissions_controller.rb | 5 +++++ app/models/submission.rb | 6 ++++++ app/views/submissions/new.html.erb | 10 ++++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index d96f4c5..837e8fa 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -19,6 +19,11 @@ def create def update @submission = Current.user.submission + unless @submission.editable? + redirect_to root_path, alert: "Submissions can only be edited within an hour of creation." + return + end + if @submission.update(submission_params) redirect_to root_path, notice: "Haiku updated!" else diff --git a/app/models/submission.rb b/app/models/submission.rb index d507e7a..180d49f 100644 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -18,4 +18,10 @@ def restore def discarded? discarded_at.present? end + + def editable? + return true unless persisted? + + created_at > 1.hour.ago + end end diff --git a/app/views/submissions/new.html.erb b/app/views/submissions/new.html.erb index f1817f8..5903fef 100644 --- a/app/views/submissions/new.html.erb +++ b/app/views/submissions/new.html.erb @@ -18,7 +18,7 @@
<% end %> -
+
<%= f.label :line1, "Line 1", class: "block font-medium text-[#0C2866] mb-1" %> <%= f.text_field :line1, class: "w-full border border-gray-300 rounded px-3 py-2 focus:outline-none focus:ring-2 focus:ring-[#2672B5]", autofocus: true %> @@ -34,8 +34,14 @@ <%= f.text_field :line3, class: "w-full border border-gray-300 rounded px-3 py-2 focus:outline-none focus:ring-2 focus:ring-[#2672B5]" %>
- <%= f.submit @submission.persisted? ? "Update Haiku" : "Submit Haiku", class: "bg-[#C41C1C] bg-linear-to-t from-[#C41C1C] to-[#DD423E] text-white font-medium py-3 px-6 shadow-sm rounded-sm cursor-pointer text-lg" %> + <% if @submission.editable? %> + <%= f.submit @submission.persisted? ? "Update Haiku" : "Submit Haiku", class: "bg-[#C41C1C] bg-linear-to-t from-[#C41C1C] to-[#DD423E] text-white font-medium py-3 px-6 shadow-sm rounded-sm cursor-pointer text-lg" %> + <% end %>
+ +

+ You can edit your haiku up to an hour after creation. +

<% end %>
From 7b72681566fb0aba35c52d72d095423a9de602a2 Mon Sep 17 00:00:00 2001 From: Jeremy Smith Date: Sun, 22 Mar 2026 21:56:04 -0400 Subject: [PATCH 3/3] Add export page --- app/controllers/admin_controller.rb | 15 +++++++++++++++ config/routes.rb | 1 + 2 files changed, 16 insertions(+) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 64627e7..7d24380 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -5,6 +5,21 @@ def index @submissions = Submission.includes(:user, :votes).order(created_at: :desc) end + def export + submissions = Submission.kept.includes(:user, :votes).map do |submission| + { + github_username: submission.user.github_username, + github_email: submission.user.github_email, + line1: submission.line1, + line2: submission.line2, + line3: submission.line3, + total_votes: submission.votes.size + } + end + + render json: submissions + end + def toggle_discard submission = Submission.find(params[:id]) diff --git a/config/routes.rb b/config/routes.rb index aeb1c5a..a4f037d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -10,6 +10,7 @@ end get "admin", to: "admin#index" + get "admin/export", to: "admin#export" post "admin/:id/toggle_discard", to: "admin#toggle_discard", as: :admin_toggle_discard get "up" => "rails/health#show", as: :rails_health_check