From 489583486bd9d31de5bec8751d7e63997c325fd3 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 30 Oct 2023 00:18:04 -0400 Subject: added archive page and some expert puzzles --- app/assets/stylesheets/wittle/general.css.scss | 26 ++++++++++++++++++++++++++ app/controllers/wittle/puzzles_controller.rb | 3 ++- app/views/wittle/puzzles/about.html.haml | 1 + app/views/wittle/puzzles/index.html.haml | 25 +++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/assets/stylesheets/wittle/general.css.scss b/app/assets/stylesheets/wittle/general.css.scss index c258734..a0eb980 100644 --- a/app/assets/stylesheets/wittle/general.css.scss +++ b/app/assets/stylesheets/wittle/general.css.scss @@ -143,3 +143,29 @@ input[type="range"]::-ms-thumb { padding-left: 1em; text-align: right; } + +#archive { + width: 50%; + margin: 0 auto; + border-spacing: 0; + text-align: center; + + tr { + &.odd { + background-color: #fff; + } + + &.even { + background-color: #edf; + } + } + + th, td { + padding: 0.5em; + } + + ul { + list-style-type: none; + padding: 0; + } +} diff --git a/app/controllers/wittle/puzzles_controller.rb b/app/controllers/wittle/puzzles_controller.rb index 2949f94..3c3c8a6 100644 --- a/app/controllers/wittle/puzzles_controller.rb +++ b/app/controllers/wittle/puzzles_controller.rb @@ -3,10 +3,11 @@ module Wittle def about @normal_puzzle = Puzzle.normal.order(created_at: :desc).first @hard_puzzle = Puzzle.hard.order(created_at: :desc).first + @expert_puzzle = Puzzle.expert.order(created_at: :desc).first end def index - #@puzzle = WittleGenerator.new.generate_medium + @puzzles = Puzzle.select(:id, :created_at, :category).order(created_at: :asc).all.chunk { |puzzle| puzzle.created_at.localtime.to_date }.to_h.transform_values { |by_date| by_date.sort_by(&:category).chunk { |puzzle| puzzle.category }.to_h } end def show diff --git a/app/views/wittle/puzzles/about.html.haml b/app/views/wittle/puzzles/about.html.haml index 628ba0b..6a47972 100644 --- a/app/views/wittle/puzzles/about.html.haml +++ b/app/views/wittle/puzzles/about.html.haml @@ -1,3 +1,4 @@ %p by Hatkirby, with help from Sigma144 and jbzdarkid %p= link_to "Normal", @normal_puzzle %p= link_to "Hard", @hard_puzzle +%p= link_to "Expert", @expert_puzzle diff --git a/app/views/wittle/puzzles/index.html.haml b/app/views/wittle/puzzles/index.html.haml index e69de29..097eb87 100644 --- a/app/views/wittle/puzzles/index.html.haml +++ b/app/views/wittle/puzzles/index.html.haml @@ -0,0 +1,25 @@ +%h1 Archive +%table#archive + %tr + %th + %th Normal + %th Hard + %th Expert + - @puzzles.each do |date, dps| + %tr{ class: cycle("even", "odd") } + %td= date.strftime("%B %-d, %Y") + %td + - if dps.has_key? "normal" + %ul + - dps["normal"].each do |puzzle| + %li= link_to "\##{puzzle.id}", puzzle + %td + - if dps.has_key? "hard" + %ul + - dps["hard"].each do |puzzle| + %li= link_to "\##{puzzle.id}", puzzle + %td + - if dps.has_key? "expert" + %ul + - dps["expert"].each do |puzzle| + %li= link_to "\##{puzzle.id}", puzzle -- cgit 1.4.1