From 0380a97230023a78ad08b738c4520e901485ed63 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 10 Dec 2022 09:29:30 -0500 Subject: Added Rails engine for scoreboard refs #13 --- rails/app/assets/config/lingo_manifest.js | 2 ++ rails/app/assets/images/lingo/.keep | 0 rails/app/assets/images/lingo/header.png | Bin 0 -> 1213722 bytes rails/app/assets/stylesheets/lingo/application.css | 15 +++++++++++++ rails/app/assets/stylesheets/lingo/main.css.scss | 24 +++++++++++++++++++++ rails/app/controllers/concerns/.keep | 0 .../controllers/lingo/application_controller.rb | 4 ++++ rails/app/controllers/lingo/scores_controller.rb | 21 ++++++++++++++++++ rails/app/helpers/lingo/application_helper.rb | 4 ++++ rails/app/helpers/lingo/scores_helper.rb | 4 ++++ rails/app/jobs/lingo/application_job.rb | 4 ++++ rails/app/mailers/lingo/application_mailer.rb | 6 ++++++ rails/app/models/concerns/.keep | 0 rails/app/models/lingo/application_record.rb | 5 +++++ rails/app/models/lingo/score.rb | 4 ++++ .../app/views/layouts/lingo/application.html.haml | 9 ++++++++ rails/app/views/lingo/scores/index.html.haml | 9 ++++++++ 17 files changed, 111 insertions(+) create mode 100644 rails/app/assets/config/lingo_manifest.js create mode 100644 rails/app/assets/images/lingo/.keep create mode 100644 rails/app/assets/images/lingo/header.png create mode 100644 rails/app/assets/stylesheets/lingo/application.css create mode 100644 rails/app/assets/stylesheets/lingo/main.css.scss create mode 100644 rails/app/controllers/concerns/.keep create mode 100644 rails/app/controllers/lingo/application_controller.rb create mode 100644 rails/app/controllers/lingo/scores_controller.rb create mode 100644 rails/app/helpers/lingo/application_helper.rb create mode 100644 rails/app/helpers/lingo/scores_helper.rb create mode 100644 rails/app/jobs/lingo/application_job.rb create mode 100644 rails/app/mailers/lingo/application_mailer.rb create mode 100644 rails/app/models/concerns/.keep create mode 100644 rails/app/models/lingo/application_record.rb create mode 100644 rails/app/models/lingo/score.rb create mode 100644 rails/app/views/layouts/lingo/application.html.haml create mode 100644 rails/app/views/lingo/scores/index.html.haml (limited to 'rails/app') diff --git a/rails/app/assets/config/lingo_manifest.js b/rails/app/assets/config/lingo_manifest.js new file mode 100644 index 0000000..32c12fb --- /dev/null +++ b/rails/app/assets/config/lingo_manifest.js @@ -0,0 +1,2 @@ +//= link_directory ../stylesheets/lingo .css +//= link lingo/header.png diff --git a/rails/app/assets/images/lingo/.keep b/rails/app/assets/images/lingo/.keep new file mode 100644 index 0000000..e69de29 diff --git a/rails/app/assets/images/lingo/header.png b/rails/app/assets/images/lingo/header.png new file mode 100644 index 0000000..9384865 Binary files /dev/null and b/rails/app/assets/images/lingo/header.png differ diff --git a/rails/app/assets/stylesheets/lingo/application.css b/rails/app/assets/stylesheets/lingo/application.css new file mode 100644 index 0000000..0ebd7fe --- /dev/null +++ b/rails/app/assets/stylesheets/lingo/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/rails/app/assets/stylesheets/lingo/main.css.scss b/rails/app/assets/stylesheets/lingo/main.css.scss new file mode 100644 index 0000000..c5bdad0 --- /dev/null +++ b/rails/app/assets/stylesheets/lingo/main.css.scss @@ -0,0 +1,24 @@ +body { + background-color: black; + color: white; +} + +#header { + width: 100%; + + img { + max-width: 80%; + margin: 0 auto; + display: block; + } +} + +h2 { + text-align: center; + font-family: sans-serif; +} + +#scores { + width: 50%; + margin: 0 auto; +} \ No newline at end of file diff --git a/rails/app/controllers/concerns/.keep b/rails/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/rails/app/controllers/lingo/application_controller.rb b/rails/app/controllers/lingo/application_controller.rb new file mode 100644 index 0000000..33f4567 --- /dev/null +++ b/rails/app/controllers/lingo/application_controller.rb @@ -0,0 +1,4 @@ +module Lingo + class ApplicationController < ActionController::Base + end +end diff --git a/rails/app/controllers/lingo/scores_controller.rb b/rails/app/controllers/lingo/scores_controller.rb new file mode 100644 index 0000000..63fd0f9 --- /dev/null +++ b/rails/app/controllers/lingo/scores_controller.rb @@ -0,0 +1,21 @@ +module Lingo + class ScoresController < ApplicationController + def index + @scores = Score.order(score: :desc) + end + + def update + if params[:secret_code] != Lingo.secret_code then + head :unauthorized + else + score = Score.find_or_create_by(user_id: params[:user_id]) + score.username = params[:username] + score.avatar_url = params[:avatar_url] + score.score += 1 + score.save! + + render :blank + end + end + end +end diff --git a/rails/app/helpers/lingo/application_helper.rb b/rails/app/helpers/lingo/application_helper.rb new file mode 100644 index 0000000..4d30003 --- /dev/null +++ b/rails/app/helpers/lingo/application_helper.rb @@ -0,0 +1,4 @@ +module Lingo + module ApplicationHelper + end +end diff --git a/rails/app/helpers/lingo/scores_helper.rb b/rails/app/helpers/lingo/scores_helper.rb new file mode 100644 index 0000000..53b0031 --- /dev/null +++ b/rails/app/helpers/lingo/scores_helper.rb @@ -0,0 +1,4 @@ +module Lingo + module ScoresHelper + end +end diff --git a/rails/app/jobs/lingo/application_job.rb b/rails/app/jobs/lingo/application_job.rb new file mode 100644 index 0000000..1dfcb44 --- /dev/null +++ b/rails/app/jobs/lingo/application_job.rb @@ -0,0 +1,4 @@ +module Lingo + class ApplicationJob < ActiveJob::Base + end +end diff --git a/rails/app/mailers/lingo/application_mailer.rb b/rails/app/mailers/lingo/application_mailer.rb new file mode 100644 index 0000000..b86b722 --- /dev/null +++ b/rails/app/mailers/lingo/application_mailer.rb @@ -0,0 +1,6 @@ +module Lingo + class ApplicationMailer < ActionMailer::Base + default from: "from@example.com" + layout "mailer" + end +end diff --git a/rails/app/models/concerns/.keep b/rails/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/rails/app/models/lingo/application_record.rb b/rails/app/models/lingo/application_record.rb new file mode 100644 index 0000000..21a1824 --- /dev/null +++ b/rails/app/models/lingo/application_record.rb @@ -0,0 +1,5 @@ +module Lingo + class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true + end +end diff --git a/rails/app/models/lingo/score.rb b/rails/app/models/lingo/score.rb new file mode 100644 index 0000000..6df7dfb --- /dev/null +++ b/rails/app/models/lingo/score.rb @@ -0,0 +1,4 @@ +module Lingo + class Score < ApplicationRecord + end +end diff --git a/rails/app/views/layouts/lingo/application.html.haml b/rails/app/views/layouts/lingo/application.html.haml new file mode 100644 index 0000000..6731e5a --- /dev/null +++ b/rails/app/views/layouts/lingo/application.html.haml @@ -0,0 +1,9 @@ +!!! 5 +%html + %head + %title LINGO Bot Scoreboard + = stylesheet_link_tag "lingo/application", media: "all" + = csrf_meta_tags + %body + #header= image_tag "lingo/header.png" + #content= yield diff --git a/rails/app/views/lingo/scores/index.html.haml b/rails/app/views/lingo/scores/index.html.haml new file mode 100644 index 0000000..f0f681d --- /dev/null +++ b/rails/app/views/lingo/scores/index.html.haml @@ -0,0 +1,9 @@ +%h2 Bot Puzzles Scoreboard +%table#scores + - @scores.each do |score| + %tr + %td.score-pfp + - if !score.avatar_url.nil? + = image_tag score.avatar_url + %td.score-name= score.username + %td.score-value= score.score -- cgit 1.4.1