Organise with layouts
Some checks are pending
CI / scan_ruby (push) Waiting to run
CI / scan_js (push) Waiting to run
CI / lint (push) Waiting to run
CI / test (push) Waiting to run

This commit is contained in:
sto 2025-03-15 08:44:08 +01:00
parent 54b25a061e
commit caa45332b0
13 changed files with 61 additions and 47 deletions

View File

@ -2,4 +2,16 @@ class ApplicationController < ActionController::Base
include Authentication
# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
allow_browser versions: :modern
before_action :set_title, :set_current_user
layout "authenticated"
private
def set_title
@title = "Public scoreboard"
end
def set_current_user
@current_user = current_user
end
end

View File

@ -3,14 +3,16 @@ class ContestsController < ApplicationController
def index
@contests = current_user.contests
@user = current_user
@title = "Welcome #{current_user.username}!"
end
def show
@title = "Contest: #{@contest.name}"
end
def new
@contest = Contest.new
@title = "Create a new jigsaw puzzle competition"
end
def create

View File

@ -2,9 +2,11 @@ class UsersController < ApplicationController
before_action :set_user, only: %i[ destroy edit update show ]
def index
@title = "All users"
end
def edit
@title = "My settings"
end
def update
@ -16,6 +18,7 @@ class UsersController < ApplicationController
end
def show
redirect_to edit_user_path(@user)
end
def new

View File

@ -0,0 +1,8 @@
= form_with model: contest do |form|
.row
.col.g-3
.form-floating.mt-5
= form.text_field :name, autocomplete: "off", class: "form-control"
= form.label :name, class: "required"
div.mt-3
= form.submit

View File

@ -1,14 +1,3 @@
- if authenticated?
.float-end.ms-3
= button_to "Log out", session_path, method: :delete
.float-end.mt-1
= link_to "Settings", user_path(@user)
h1 Welcome!
.alert.alert-primary role="alert"
| This is a brand new website!
h4.mt-4 Manage your contests
- @contests.each do |contest|

View File

@ -1,8 +1 @@
h1 Create a new contest
= form_with model: @contest do |form|
div
= form.label :name
= form.text_field :name
div
= form.submit
= render "form", contest: @contest

View File

@ -1,4 +0,0 @@
h1 Contest: "#{@contest.name}"
a.btn.btn-primary href=root_path
| Back to all contests

View File

@ -0,0 +1,16 @@
head
title Puzzle Scoreboard
meta name="viewport" content="width=device-width,initial-scale=1"
meta name="apple-mobile-web-app-capable" content="yes"
meta name="mobile-web-app-capable" content="yes"
= csrf_meta_tags
= csp_meta_tag
= yield :head
link rel="icon" href="/icon.png" type="image/png"
link rel="icon" href="/icon.svg" type="image/svg+xml"
link rel="apple-touch-icon" href="/icon.png"
= stylesheet_link_tag :app, "data-turbo-track": "reload"
= javascript_importmap_tags

View File

@ -1,21 +1,6 @@
doctype html
html
head
title Puzzle Scoreboard
meta name="viewport" content="width=device-width,initial-scale=1"
meta name="apple-mobile-web-app-capable" content="yes"
meta name="mobile-web-app-capable" content="yes"
= csrf_meta_tags
= csp_meta_tag
= yield :head
link rel="icon" href="/icon.png" type="image/png"
link rel="icon" href="/icon.svg" type="image/svg+xml"
link rel="apple-touch-icon" href="/icon.png"
= stylesheet_link_tag :app, "data-turbo-track": "reload"
= javascript_importmap_tags
= render "layouts/header"
body
.container.mt-5

View File

@ -0,0 +1,16 @@
doctype html
html
= render "layouts/header"
body
.container.mt-5
.float-end.ms-3
= button_to "Log out", session_path, method: :delete
.float-end.mt-1.ms-3
= link_to "Settings", user_path(@current_user)
.float-end.mt-1
= link_to "Home", contests_path
h1 = @title
= yield

View File

@ -1,3 +1 @@
h1 Edit settings
= render "form", user: @user

View File

@ -1,3 +1 @@
h1 Create a new user
= render "form", user: @user

View File

@ -1,5 +1,3 @@
h1 = @user.username
p
|> Email:
= @user.email_address