summary refs log tree commit diff stats
path: root/rails
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2022-12-10 11:38:57 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2022-12-10 11:39:29 -0500
commit0b4d3fbc200e646eed48a1a919dde9ee03678688 (patch)
tree123fed7ecf90a22618a8814ecca60d0e48567fb6 /rails
parent0380a97230023a78ad08b738c4520e901485ed63 (diff)
downloadlingo-0b4d3fbc200e646eed48a1a919dde9ee03678688.tar.gz
lingo-0b4d3fbc200e646eed48a1a919dde9ee03678688.tar.bz2
lingo-0b4d3fbc200e646eed48a1a919dde9ee03678688.zip
Bot can submit to scoreboard now
Also updated the scoreboard styling

refs #13
Diffstat (limited to 'rails')
-rw-r--r--rails/app/assets/stylesheets/lingo/main.css.scss37
-rw-r--r--rails/app/controllers/lingo/scores_controller.rb10
-rw-r--r--rails/app/views/lingo/scores/index.html.haml9
3 files changed, 48 insertions, 8 deletions
diff --git a/rails/app/assets/stylesheets/lingo/main.css.scss b/rails/app/assets/stylesheets/lingo/main.css.scss index c5bdad0..a65cd94 100644 --- a/rails/app/assets/stylesheets/lingo/main.css.scss +++ b/rails/app/assets/stylesheets/lingo/main.css.scss
@@ -1,11 +1,12 @@
1body { 1body {
2 background-color: black; 2 background-color: black;
3 color: white; 3 color: white;
4 font-family: sans-serif;
4} 5}
5 6
6#header { 7#header {
7 width: 100%; 8 width: 100%;
8 9
9 img { 10 img {
10 max-width: 80%; 11 max-width: 80%;
11 margin: 0 auto; 12 margin: 0 auto;
@@ -15,10 +16,40 @@ body {
15 16
16h2 { 17h2 {
17 text-align: center; 18 text-align: center;
18 font-family: sans-serif;
19} 19}
20 20
21#scores { 21#scores {
22 width: 50%;
23 margin: 0 auto; 22 margin: 0 auto;
23 border-spacing: 0px;
24 tr {
25 &.even {
26 background-color: gray;
27 }
28 &.odd {
29 background-color: purple;
30 }
31 th {
32 text-align: left;
33 padding-left: 0.5em;
34 padding-bottom: 0.5em;
35 }
36 td {
37 padding-right: 1em;
38 padding-top: 0.5em;
39 padding-bottom: 0.5em;
40 border-collapse: collapse;
41 &:first-child {
42 padding-left: 1em;
43 }
44 img {
45 width: 2em;
46 }
47 &.score-pfp {
48 width: 2em;
49 }
50 &.score-value {
51 text-align: center;
52 }
53 }
54 }
24} \ No newline at end of file 55} \ No newline at end of file
diff --git a/rails/app/controllers/lingo/scores_controller.rb b/rails/app/controllers/lingo/scores_controller.rb index 63fd0f9..59bbd9d 100644 --- a/rails/app/controllers/lingo/scores_controller.rb +++ b/rails/app/controllers/lingo/scores_controller.rb
@@ -1,5 +1,7 @@
1module Lingo 1module Lingo
2 class ScoresController < ApplicationController 2 class ScoresController < ApplicationController
3 skip_before_action :verify_authenticity_token, only: [:update]
4
3 def index 5 def index
4 @scores = Score.order(score: :desc) 6 @scores = Score.order(score: :desc)
5 end 7 end
@@ -8,13 +10,15 @@ module Lingo
8 if params[:secret_code] != Lingo.secret_code then 10 if params[:secret_code] != Lingo.secret_code then
9 head :unauthorized 11 head :unauthorized
10 else 12 else
11 score = Score.find_or_create_by(user_id: params[:user_id]) 13 score = Score.find_or_create_by(user_id: params[:user_id]) do |score|
14 score.score = 0
15 end
12 score.username = params[:username] 16 score.username = params[:username]
13 score.avatar_url = params[:avatar_url] 17 score.avatar_url = CGI.unescape(params[:avatar_url])
14 score.score += 1 18 score.score += 1
15 score.save! 19 score.save!
16 20
17 render :blank 21 head :created
18 end 22 end
19 end 23 end
20 end 24 end
diff --git a/rails/app/views/lingo/scores/index.html.haml b/rails/app/views/lingo/scores/index.html.haml index f0f681d..afcd0c7 100644 --- a/rails/app/views/lingo/scores/index.html.haml +++ b/rails/app/views/lingo/scores/index.html.haml
@@ -1,7 +1,12 @@
1%h2 Bot Puzzles Scoreboard 1%h2 Bot Puzzles Scoreboard
2%table#scores 2%table#scores
3 - @scores.each do |score| 3 %tr.scores-header
4 %tr 4 %th
5 %th{colspan: 2} Player
6 %th Score
7 - @scores.each_with_index do |score,index|
8 %tr{class: cycle("even", "odd")}
9 %td.score-index #{index+1}.
5 %td.score-pfp 10 %td.score-pfp
6 - if !score.avatar_url.nil? 11 - if !score.avatar_url.nil?
7 = image_tag score.avatar_url 12 = image_tag score.avatar_url