-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from tamu-edu-students/SCRUM-9-and-4
[SCRUM-9+4] basic stubbed landing page for integration to begin
- Loading branch information
Showing
27 changed files
with
468 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* app/assets/stylesheets/pages.css */ | ||
|
||
.container { | ||
padding: 20px; | ||
} | ||
|
||
.header { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
} | ||
|
||
h2 { | ||
font-size: 24px; | ||
} | ||
|
||
.btn-login { | ||
background-color: #4caf50; | ||
color: white; | ||
padding: 10px 20px; | ||
text-align: center; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
} | ||
|
||
.btn-admin { | ||
background-color: red; | ||
} | ||
|
||
.dropdown { | ||
position: relative; | ||
display: inline-block; | ||
} | ||
|
||
.dropbtn { | ||
background-color: #4caf50; | ||
color: white; | ||
padding: 10px 20px; | ||
font-size: 16px; | ||
border: none; | ||
cursor: pointer; | ||
border-radius: 5px; | ||
} | ||
|
||
.dropdown-content { | ||
display: none; | ||
position: absolute; | ||
background-color: #f9f9f9; | ||
min-width: 160px; | ||
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2); | ||
z-index: 1; | ||
} | ||
|
||
.dropdown-content a { | ||
color: black; | ||
padding: 12px 16px; | ||
text-decoration: none; | ||
display: block; | ||
} | ||
|
||
.dropdown-content a:hover { | ||
background-color: #f1f1f1; | ||
} | ||
|
||
.dropdown:hover .dropdown-content { | ||
display: block; | ||
} | ||
|
||
.dropdown:hover .dropbtn { | ||
background-color: #3e8e41; | ||
} | ||
|
||
.game-list { | ||
display: grid; | ||
grid-template-columns: repeat(3, 1fr); | ||
gap: 20px; | ||
margin-top: 20px; | ||
max-width: 1600px; | ||
margin: 0 auto; | ||
} | ||
|
||
.game-item { | ||
padding: 15px; | ||
border: 1px solid #ddd; | ||
text-align: center; | ||
border-radius: 8px; | ||
} | ||
|
||
.btn-play { | ||
background-color: #4caf50; | ||
color: white; | ||
padding: 10px 20px; | ||
text-align: center; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
class GamesController < ApplicationController | ||
before_action :set_game, only: %i[ show edit update destroy ] | ||
|
||
# GET /games or /games.json | ||
def index | ||
@games = Game.all | ||
end | ||
|
||
# GET /games/1 or /games/1.json | ||
def show | ||
@game = Game.find(params[:id]) | ||
redirect_to send(@game.game_path) | ||
end | ||
|
||
def demo_game | ||
end | ||
|
||
# GET /games/new | ||
def new | ||
@game = Game.new | ||
end | ||
|
||
# GET /games/1/edit | ||
def edit | ||
end | ||
|
||
# POST /games or /games.json | ||
def create | ||
@game = Game.new(game_params) | ||
|
||
respond_to do |format| | ||
if @game.save | ||
format.html { redirect_to @game, notice: "Game was successfully created." } | ||
format.json { render :show, status: :created, location: @game } | ||
else | ||
format.html { render :new, status: :unprocessable_entity } | ||
format.json { render json: @game.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /games/1 or /games/1.json | ||
def update | ||
respond_to do |format| | ||
if @game.update(game_params) | ||
format.html { redirect_to @game, notice: "Game was successfully updated." } | ||
format.json { render :show, status: :ok, location: @game } | ||
else | ||
format.html { render :edit, status: :unprocessable_entity } | ||
format.json { render json: @game.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /games/1 or /games/1.json | ||
def destroy | ||
@game.destroy! | ||
|
||
respond_to do |format| | ||
format.html { redirect_to games_path, status: :see_other, notice: "Game was successfully destroyed." } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_game | ||
@game = Game.find(params[:id]) | ||
end | ||
|
||
# Only allow a list of trusted parameters through. | ||
def game_params | ||
params.require(:game).permit(:name, :game_path) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module GamesHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class Game < ApplicationRecord | ||
validates :name, presence: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<%= form_with(model: game) do |form| %> | ||
<% if game.errors.any? %> | ||
<div style="color: red"> | ||
<h2><%= pluralize(game.errors.count, "error") %> prohibited this game from being saved:</h2> | ||
|
||
<ul> | ||
<% game.errors.each do |error| %> | ||
<li><%= error.full_message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div> | ||
<%= form.label :name, style: "display: block" %> | ||
<%= form.text_field :name %> | ||
</div> | ||
|
||
<div> | ||
<%= form.label :game_path, style: "display: block" %> | ||
<%= form.text_field :game_path %> | ||
</div> | ||
|
||
<div> | ||
<%= form.submit %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div id="<%= dom_id game %>"> | ||
<p> | ||
<strong>Name:</strong> | ||
<%= game.name %> | ||
</p> | ||
|
||
<p> | ||
<strong>Game path:</strong> | ||
<%= game.game_path %> | ||
</p> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
json.extract! game, :id, :name, :game_path, :created_at, :updated_at | ||
json.url game_url(game, format: :json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<p style="color: green"><%= notice %></p> | ||
<% content_for :title, "Games" %> | ||
|
||
<h1>Games</h1> | ||
|
||
<div class="game-list"> | ||
<% @games.each do |game| %> | ||
<div class="game-item"> | ||
<h3><%= game.name %></h3> | ||
<%= link_to 'Play', game_path(game), class: 'btn btn-play' %> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<p style="color: green"><%= notice %></p> | ||
|
||
<div> | ||
Demo Game Page | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<% content_for :title, "Editing game" %> | ||
|
||
<h1>Editing game</h1> | ||
|
||
<%= render "form", game: @game %> | ||
|
||
<br> | ||
|
||
<div> | ||
<%= link_to "Show this game", @game %> | | ||
<%= link_to "Back to games", games_path %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<div class="container"> | ||
<!-- Greeting and Login Section --> | ||
<div class="header"> | ||
<h2>Hello, <%="Guest" %>!</h2> | ||
|
||
<div> | ||
<%# <% if true %> | ||
<%# TODO, using if-else to display login button or account info button %> | ||
<!-- My Account Dropdown --> | ||
<div class="dropdown"> | ||
<button class="dropbtn">My Account</button> | ||
<div class="dropdown-content"> | ||
<%= link_to 'Game Statistics', '#' %> | ||
<%= link_to 'Update', '#' %> | ||
<%= link_to 'Log Out', '#', method: :delete %> | ||
</div> | ||
</div> | ||
<%# <% else %> | ||
<!-- Login Button --> | ||
<%= link_to 'Log In', '#', class: 'btn btn-login' %> | ||
<%# <% end %> | ||
|
||
<% if true %> | ||
<%# TODO, only appear if the user is admin %> | ||
<%= link_to 'All Users for Admin', '#', class: 'btn btn-login btn-admin' %> | ||
<% end%> | ||
</div> | ||
</div> | ||
|
||
<!-- Games Section --> | ||
|
||
<%= render "games" %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.array! @games, partial: "games/game", as: :game |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<% content_for :title, "New game" %> | ||
|
||
<h1>New game</h1> | ||
|
||
<%= render "form", game: @game %> | ||
|
||
<br> | ||
|
||
<div> | ||
<%= link_to "Back to games", games_path %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<p style="color: green"><%= notice %></p> | ||
|
||
<div> | ||
<%= link_to "Edit this game", edit_game_path(@game) %> | | ||
<%= link_to "Back to games", games_path %> | ||
|
||
<%= button_to "Destroy this game", @game, method: :delete %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.partial! "games/game", game: @game |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
Rails.application.routes.draw do | ||
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html | ||
resources :games | ||
root :to => redirect('/games') | ||
|
||
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. | ||
# Can be used by load balancers and uptime monitors to verify that the app is live. | ||
get "up" => "rails/health#show", as: :rails_health_check | ||
|
||
## stub paths to demo game landing page | ||
get '/spellingbee/:id', to: 'games#demo_game', as: 'spellingbee' | ||
get '/wordle/:id', to: 'games#demo_game', as: 'wordle' | ||
get '/letterboxed/:id', to: 'games#demo_game', as: 'letterboxed' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class CreateGames < ActiveRecord::Migration[7.2] | ||
def change | ||
create_table :games do |t| | ||
t.string 'name' | ||
t.string 'game_path' | ||
t.timestamps | ||
end | ||
end | ||
end |
Oops, something went wrong.