From 10599ab2e789ffb93a19f6aa3c100f533c460315 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sun, 29 Oct 2023 11:32:06 -0400 Subject: generate, show, solve puzzles --- app/views/layouts/wittle/application.html.haml | 3 ++- app/views/wittle/puzzles/_handle_puzzle.html.erb | 33 ++++++++++++++++++++++++ app/views/wittle/puzzles/_submission.html.haml | 7 +++++ app/views/wittle/puzzles/about.html.haml | 3 +++ app/views/wittle/puzzles/index.html.haml | 13 ---------- app/views/wittle/puzzles/show.html.haml | 25 ++++++++++++++++++ app/views/wittle/puzzles/solve.js.erb | 1 + 7 files changed, 71 insertions(+), 14 deletions(-) create mode 100644 app/views/wittle/puzzles/_handle_puzzle.html.erb create mode 100644 app/views/wittle/puzzles/_submission.html.haml create mode 100644 app/views/wittle/puzzles/about.html.haml create mode 100644 app/views/wittle/puzzles/show.html.haml create mode 100644 app/views/wittle/puzzles/solve.js.erb (limited to 'app/views') diff --git a/app/views/layouts/wittle/application.html.haml b/app/views/layouts/wittle/application.html.haml index 945ffc0..80519f4 100644 --- a/app/views/layouts/wittle/application.html.haml +++ b/app/views/layouts/wittle/application.html.haml @@ -6,4 +6,5 @@ = csp_meta_tag = stylesheet_link_tag "wittle/application", media: "all" = javascript_include_tag "wittle/application" - %body= yield + %body + #wrap= yield diff --git a/app/views/wittle/puzzles/_handle_puzzle.html.erb b/app/views/wittle/puzzles/_handle_puzzle.html.erb new file mode 100644 index 0000000..3ac868e --- /dev/null +++ b/app/views/wittle/puzzles/_handle_puzzle.html.erb @@ -0,0 +1,33 @@ + diff --git a/app/views/wittle/puzzles/_submission.html.haml b/app/views/wittle/puzzles/_submission.html.haml new file mode 100644 index 0000000..744372a --- /dev/null +++ b/app/views/wittle/puzzles/_submission.html.haml @@ -0,0 +1,7 @@ +%h3 Congrats! +%p Would you like to submit your time? += form_with url: submit_puzzle_path(@puzzle) do |form| + %p + = form.label :name, "Name:" + = form.text_field :name + %p= form.submit "Submit" diff --git a/app/views/wittle/puzzles/about.html.haml b/app/views/wittle/puzzles/about.html.haml new file mode 100644 index 0000000..628ba0b --- /dev/null +++ b/app/views/wittle/puzzles/about.html.haml @@ -0,0 +1,3 @@ +%p by Hatkirby, with help from Sigma144 and jbzdarkid +%p= link_to "Normal", @normal_puzzle +%p= link_to "Hard", @hard_puzzle diff --git a/app/views/wittle/puzzles/index.html.haml b/app/views/wittle/puzzles/index.html.haml index 9e12e8b..e69de29 100644 --- a/app/views/wittle/puzzles/index.html.haml +++ b/app/views/wittle/puzzles/index.html.haml @@ -1,13 +0,0 @@ -%h1 Puzzles#index -%p Find me in app/views/wittle/puzzles/index.html.haml -:javascript - loadHeader("Unnamed Puzzle") -%div{ style: "display: flex; justify-content: center; align-items: center"} - %svg#puzzle{ style: "pointer-events: auto"} -:javascript - window.onload = function() { - //var puzzle = window.deserializePuzzle("_AAAAAA8PCQAAAEdlbmVyYXRlZAABAAAACAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAgAAQAAAAACAAAA/wABAAAAAAgAAQAAAAAIAAEAAAAACAABAAAAAAgAAQAAAAAIAAEAAQAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQABAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAAIAAEAAAAACAABAAAAAAgAAQAAAAAIAAEAAAAAAv////8AAQAAAAAIAAEAAAAAAv////8AAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAQEAAAAAAQAAAAABAAAAAAEAAQAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAIAAAD/AAEAAAAACAABAAAAAAgAAQAAAAAIAAEAAAAACAABAAAAAAgAAQAAAAAIAAEAAAAAAQAAAAEBAAAAAAEAAAAAAQAAAAABAAAAAQEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAAIAAEAAQAAAv////8AAQAAAAAIAAEAAAAAAv////8AAQAAAAACAAAA/wABAAAAAAIAAAD/AAEAAAAAAgAAAP8AAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAL/////AAEAAAAAAv////8AAQAAAAAIAAEAAAAACAABAAAAAAgAAQAAAAACAAAA/wABAAAAAAgAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAQAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAABAQAAAAABAAEAAAEAAAAAAQAAAAABAAAAAAL/////AAEAAAAAAgAAAP8AAQAAAAAIAAEAAAAAAv////8AAQAAAAACAAAA/wABAAAAAAIAAAD/AAEAAAAACAABAAEAAAEAAAAAAQABAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAgAAAP8AAQAAAAAIAAEAAAAAAv////8AAQAAAAAIAAEAAAAAAv////8AAQAAAAAIAAEAAAAACAABAAAAAAEAAAAIAQAAAAABAAAAAAEAAAAAAQABAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAAAAAQAAAAABAAAAAAEAAQAAAQAAAAABAAAAEAAAAAAN") - var puzzle = window.deserializePuzzle("#{@puzzle}") - draw(puzzle) - } - diff --git a/app/views/wittle/puzzles/show.html.haml b/app/views/wittle/puzzles/show.html.haml new file mode 100644 index 0000000..d5d8b00 --- /dev/null +++ b/app/views/wittle/puzzles/show.html.haml @@ -0,0 +1,25 @@ +%h1 Wittle ##{@puzzle.id} +#puzzle-container{ style: "display: flex; justify-content: center; align-items: center" } + %svg#puzzle{ style: "pointer-events: auto"} +#submission-form +- if @playable + %details#trace-settings + %summary Settings + .things + %label{ for: "sens" } Mouse Speed 2D + %input#sens{ type: "range", min: "0.1", max: "1.3", step: "0.1" } + %label{ for: "volume" } Volume + %input#volume{ type: "range", min: "0", max: "0.24", step: "0.02" } +- else + #scores + #by-time + %h2 Fastest Solves + %ol + - @puzzle.scores.where("seconds_taken IS NOT NULL").order(seconds_taken: :asc).each do |score| + %li= score.name + #by-when + %h2 Completion Order + %ol + - @puzzle.scores.order(created_at: :desc).each do |score| + %li= score.name += render partial: "handle_puzzle" diff --git a/app/views/wittle/puzzles/solve.js.erb b/app/views/wittle/puzzles/solve.js.erb new file mode 100644 index 0000000..12c2350 --- /dev/null +++ b/app/views/wittle/puzzles/solve.js.erb @@ -0,0 +1 @@ +$("#submission-form").html('<%= escape_javascript(render partial: "submission") %>'); -- cgit 1.4.1