Basic setup, launch config and layout

This commit is contained in:
David Schärer 2024-07-15 14:31:54 +02:00
parent 535a051755
commit 1a3d172fe5
41 changed files with 382 additions and 105 deletions

View file

@ -0,0 +1,51 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
{
"name": "a11yist",
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
"dockerComposeFile": [
"../docker-compose.yml",
"docker-compose.yml"
],
// The 'service' property is the name of the service for the container that VS Code should
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
"service": "app",
// The optional 'workspaceFolder' property is the path VS Code should open by default when
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
"workspaceFolder": "/app",
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Uncomment the next line if you want start specific services in your Docker Compose config.
// "runServices": [],
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
// "shutdownAction": "none",
// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "cat /etc/os-release",
"postCreateCommand": "bundle",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
"remoteUser": "app",
"customizations": {
"vscode": {
"extensions": [
"Shopify.ruby-lsp",
"TabbyML.vscode-tabby"
]
}
}
}

View file

@ -0,0 +1,6 @@
version: '3.8'
services:
# Update this to the name of the service you want to work with in your docker-compose.yml file
app:
command: /bin/sh -c "while sleep 1000; do :; done"

12
.github/dependabot.yml vendored Normal file
View file

@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot
version: 2
updates:
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly

12
.rubocop.yml Normal file
View file

@ -0,0 +1,12 @@
AllCops:
Exclude:
- 'config/**/*.rb'
- 'db/**/*.rb'
- 'vendor/**/*.rb'
- 'bin/bundle'
- 'bin/rake'
- 'bin/rails'
- 'bin/setup'
Style/Documentation:
enabled: false

26
.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,26 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "ruby_lsp",
"name": "Attach debugger",
"request": "attach"
},
{
"type": "ruby_lsp",
"name": "Debug script",
"request": "launch",
"program": "ruby ${file}"
},
{
"type": "ruby_lsp",
"name": "Debug test",
"request": "launch",
"program": "ruby -Itest ${relativeFile}"
},
]
}

39
Gemfile
View file

@ -1,33 +1,35 @@
source "https://rubygems.org" # frozen_string_literal: true
ruby "3.3.0" source 'https://rubygems.org'
ruby '3.3.0'
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.1.3", ">= 7.1.3.4" gem 'rails', '~> 7.1.3', '>= 7.1.3.4'
# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem "sprockets-rails" gem 'sprockets-rails'
# Use sqlite3 as the database for Active Record # Use sqlite3 as the database for Active Record
gem "sqlite3", "~> 1.4" gem 'sqlite3', '~> 1.4'
# Use the Puma web server [https://github.com/puma/puma] # Use the Puma web server [https://github.com/puma/puma]
gem "puma", ">= 5.0" gem 'puma', '>= 5.0'
# Bundle and transpile JavaScript [https://github.com/rails/jsbundling-rails] # Bundle and transpile JavaScript [https://github.com/rails/jsbundling-rails]
gem "jsbundling-rails" gem 'jsbundling-rails'
# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev] # Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
gem "turbo-rails" gem 'turbo-rails'
# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev] # Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
gem "stimulus-rails" gem 'stimulus-rails'
# Bundle and process CSS [https://github.com/rails/cssbundling-rails] # Bundle and process CSS [https://github.com/rails/cssbundling-rails]
gem "cssbundling-rails" gem 'cssbundling-rails'
# Build JSON APIs with ease [https://github.com/rails/jbuilder] # Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem "jbuilder" gem 'jbuilder'
# Use Redis adapter to run Action Cable in production # Use Redis adapter to run Action Cable in production
# gem "redis", ">= 4.0.1" # gem "redis", ">= 4.0.1"
@ -39,32 +41,35 @@ gem "jbuilder"
# gem "bcrypt", "~> 3.1.7" # gem "bcrypt", "~> 3.1.7"
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ windows jruby ] gem 'tzinfo-data', platforms: %i[windows jruby]
# Reduces boot times through caching; required in config/boot.rb # Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false gem 'bootsnap', require: false
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2" # gem "image_processing", "~> 1.2"
group :development, :test do group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri windows ] gem 'debug', platforms: %i[mri windows]
end end
group :development do group :development do
# Use console on exceptions pages [https://github.com/rails/web-console] # Use console on exceptions pages [https://github.com/rails/web-console]
gem "web-console" gem 'web-console'
# Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler] # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
# gem "rack-mini-profiler" # gem "rack-mini-profiler"
# Speed up commands on slow machines / big apps [https://github.com/rails/spring] # Speed up commands on slow machines / big apps [https://github.com/rails/spring]
# gem "spring" # gem "spring"
gem 'rubocop'
gem 'ruby-lsp'
gem 'ruby-lsp-rails'
end end
group :test do group :test do
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
gem "capybara" gem 'capybara'
gem "selenium-webdriver" gem 'selenium-webdriver'
end end

View file

@ -77,6 +77,7 @@ GEM
tzinfo (~> 2.0) tzinfo (~> 2.0)
addressable (2.8.7) addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0) public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2)
base64 (0.2.0) base64 (0.2.0)
bigdecimal (3.1.8) bigdecimal (3.1.8)
bindex (0.8.1) bindex (0.8.1)
@ -116,6 +117,8 @@ GEM
activesupport (>= 5.0.0) activesupport (>= 5.0.0)
jsbundling-rails (1.3.0) jsbundling-rails (1.3.0)
railties (>= 6.0.0) railties (>= 6.0.0)
json (2.7.2)
language_server-protocol (3.17.0.3)
logger (1.6.0) logger (1.6.0)
loofah (2.22.0) loofah (2.22.0)
crass (~> 1.0.2) crass (~> 1.0.2)
@ -153,6 +156,11 @@ GEM
racc (~> 1.4) racc (~> 1.4)
nokogiri (1.16.6-x86_64-linux) nokogiri (1.16.6-x86_64-linux)
racc (~> 1.4) racc (~> 1.4)
parallel (1.25.1)
parser (3.3.4.0)
ast (~> 2.4.1)
racc
prism (0.30.0)
psych (5.1.2) psych (5.1.2)
stringio stringio
public_suffix (6.0.0) public_suffix (6.0.0)
@ -196,7 +204,10 @@ GEM
rake (>= 12.2) rake (>= 12.2)
thor (~> 1.0, >= 1.2.2) thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6) zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.2.1) rake (13.2.1)
rbs (3.5.2)
logger
rdoc (6.7.0) rdoc (6.7.0)
psych (>= 4.0.0) psych (>= 4.0.0)
regexp_parser (2.9.2) regexp_parser (2.9.2)
@ -204,6 +215,27 @@ GEM
io-console (~> 0.5) io-console (~> 0.5)
rexml (3.3.1) rexml (3.3.1)
strscan strscan
rubocop (1.65.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.4, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.3)
parser (>= 3.3.1.0)
ruby-lsp (0.17.7)
language_server-protocol (~> 3.17.0)
prism (>= 0.29.0, < 0.31)
rbs (>= 3, < 4)
sorbet-runtime (>= 0.5.10782)
ruby-lsp-rails (0.3.10)
ruby-lsp (>= 0.17.2, < 0.18.0)
ruby-progressbar (1.13.0)
rubyzip (2.3.2) rubyzip (2.3.2)
selenium-webdriver (4.22.0) selenium-webdriver (4.22.0)
base64 (~> 0.2) base64 (~> 0.2)
@ -211,6 +243,7 @@ GEM
rexml (~> 3.2, >= 3.2.5) rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0) rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0) websocket (~> 1.0)
sorbet-runtime (0.5.11481)
sprockets (4.2.1) sprockets (4.2.1)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4) rack (>= 2.2.4, < 4)
@ -236,6 +269,7 @@ GEM
railties (>= 6.0.0) railties (>= 6.0.0)
tzinfo (2.0.6) tzinfo (2.0.6)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
web-console (4.2.1) web-console (4.2.1)
actionview (>= 6.0.0) actionview (>= 6.0.0)
activemodel (>= 6.0.0) activemodel (>= 6.0.0)
@ -267,6 +301,9 @@ DEPENDENCIES
jsbundling-rails jsbundling-rails
puma (>= 5.0) puma (>= 5.0)
rails (~> 7.1.3, >= 7.1.3.4) rails (~> 7.1.3, >= 7.1.3.4)
rubocop
ruby-lsp
ruby-lsp-rails
selenium-webdriver selenium-webdriver
sprockets-rails sprockets-rails
sqlite3 (~> 1.4) sqlite3 (~> 1.4)

View file

@ -1,6 +1,8 @@
# frozen_string_literal: true
# Add your own tasks in files placed in lib/tasks ending in .rake, # Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require_relative "config/application" require_relative 'config/application'
Rails.application.load_tasks Rails.application.load_tasks

View file

@ -1,2 +1,31 @@
@font-face {
font-family: 'Lexend';
src: url('Lexend-VariableFont_wght.ttf');
font-display: swap;
}
$font-family-sans-serif:
Lexend,
// Cross-platform generic font family (default user interface font)
system-ui,
// Safari for macOS and iOS (San Francisco)
-apple-system,
// Windows
"Segoe UI",
// Android
Roboto,
// Basic web fallback
"Helvetica Neue", Arial,
// Linux
"Noto Sans",
"Liberation Sans",
// Sans serif fallback
sans-serif,
// Emoji fonts
"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" !default;
$primary: #0074d9;
$danger: #ff4136;
@import 'bootstrap/scss/bootstrap'; @import 'bootstrap/scss/bootstrap';
@import 'bootstrap-icons/font/bootstrap-icons'; @import 'bootstrap-icons/font/bootstrap-icons';

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ApplicationCable module ApplicationCable
class Channel < ActionCable::Channel::Base class Channel < ActionCable::Channel::Base
end end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ApplicationCable module ApplicationCable
class Connection < ActionCable::Connection::Base class Connection < ActionCable::Connection::Base
end end

View file

@ -1,2 +1,15 @@
# frozen_string_literal: true
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
before_action :initialize_navbar
private
def initialize_navbar
@navbar_items = [
{ label: 'Dashboard', path: :root },
{ label: 'Home', path: :home }
]
@search_url = nil # root_url
end
end end

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
class HomeController < ApplicationController class HomeController < ApplicationController
def show def show; end
end
end end

View file

@ -1,2 +1,4 @@
# frozen_string_literal: true
module ApplicationHelper module ApplicationHelper
end end

View file

@ -1,2 +1,4 @@
# frozen_string_literal: true
module HomeHelper module HomeHelper
end end

View file

@ -6,3 +6,6 @@ import { application } from "./application"
import HelloController from "./hello_controller" import HelloController from "./hello_controller"
application.register("hello", HelloController) application.register("hello", HelloController)
import SetThemeController from "./set_theme_controller"
application.register("set-theme", SetThemeController)

View file

@ -0,0 +1,18 @@
import { Controller } from "@hotwired/stimulus"
import Cookie from "../lib/cookies"
// Connects to data-controller="set-theme"
export default class extends Controller {
COOKIE_NAME = "modeTheme";
connect() {
const cookieValue = Cookie.get(this.COOKIE_NAME);
console.log("cookieValue", cookieValue);
if(cookieValue) {
return true;
}
const darkMode = window.matchMedia("(prefers-color-scheme:dark)").matches ? "dark" : "light";
Cookie.set(this.COOKIE_NAME, darkMode);
window.document.getElementsByTagName("html")[0].setAttribute("data-bs-theme", darkMode)
}
}

View file

@ -0,0 +1,23 @@
export default class Cookies {
static set(cname, cvalue, exdays = 365) {
const d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
let expires = "expires="+d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
static get(cname) {
let name = cname + "=";
let ca = document.cookie.split(';');
for(let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
}

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ApplicationJob < ActiveJob::Base class ApplicationJob < ActiveJob::Base
# Automatically retry jobs that encountered a deadlock # Automatically retry jobs that encountered a deadlock
# retry_on ActiveRecord::Deadlocked # retry_on ActiveRecord::Deadlocked

View file

@ -1,4 +1,6 @@
# frozen_string_literal: true
class ApplicationMailer < ActionMailer::Base class ApplicationMailer < ActionMailer::Base
default from: "from@example.com" default from: 'from@example.com'
layout "mailer" layout 'mailer'
end end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ApplicationRecord < ActiveRecord::Base class ApplicationRecord < ActiveRecord::Base
primary_abstract_class primary_abstract_class
end end

View file

@ -1,2 +1,3 @@
<h1>Welcome</h1> <h1>Welcome</h1>
<p>Find me in app/views/home/show.html.erb</p> <p>Find me in app/views/home/show.html.erb</p>
<button class="btn btn-primary">Test</button>

View file

@ -1,15 +1,18 @@
<nav class="navbar navbar-expand-lg bg-body-tertiary"> <nav class="navbar navbar-expand-lg bg-body-tertiary">
<div class="container-fluid"> <div class="container-fluid">
<a class="navbar-brand" href="#">Navbar</a> <a class="navbar-brand" href="<%= root_path %>">A11Yist</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
<div class="collapse navbar-collapse" id="navbarSupportedContent"> <div class="collapse navbar-collapse" id="navbarSupportedContent">
<% if @navbar_items %>
<ul class="navbar-nav me-auto mb-2 mb-lg-0"> <ul class="navbar-nav me-auto mb-2 mb-lg-0">
<% @navbar_items.each do |navbar_item| %>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a> <a class="nav-link <%= current_page?(navbar_item[:path]) && "active" %>" <%= current_page?(navbar_item[:path]) && "aria-current=\"page\"" %> href="<%= url_for(navbar_item[:path]) %>"><%= navbar_item[:label] %></a>
</li> </li>
<li class="nav-item"> <% end %>
<%# <li class="nav-item">
<a class="nav-link" href="#">Link</a> <a class="nav-link" href="#">Link</a>
</li> </li>
<li class="nav-item dropdown"> <li class="nav-item dropdown">
@ -25,12 +28,17 @@
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a> <a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li> </li> %>
</ul> </ul>
<form class="d-flex" role="search"> <% else %>
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search"> <div class="me-auto"></div>
<button class="btn btn-outline-success" type="submit">Search</button> <% end %>
<% if @search_url %>
<form class="d-flex" role="search" action="<%= @search_url %>">
<input class="form-control me-2" type="search" placeholder="<%= @search_placeholder || "..." %>" aria-label="Search">
<button class="btn btn-outline-success" type="submit" name="<%= @search_name || "q" %>"><%= @search_placeholder || "Suchen" %></button>
</form> </form>
<% end %>
</div> </div>
</div> </div>
</nav> </nav>

View file

View file

@ -1,8 +1,9 @@
<!DOCTYPE html> <!doctype html>
<html> <html <%== cookies[:"modeTheme"] && "data-bs-theme=\"#{cookies[:"modeTheme"]}\"" %> data-controller="set-theme">
<head> <head>
<title>A11yist</title> <title>A11yist</title>
<meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="viewport" content="width=device-width,initial-scale=1">
<%= csrf_meta_tags %> <%= csrf_meta_tags %>
<%= csp_meta_tag %> <%= csp_meta_tag %>
@ -10,9 +11,14 @@
<%= javascript_include_tag "application", "data-turbo-track": "reload", type: "module" %> <%= javascript_include_tag "application", "data-turbo-track": "reload", type: "module" %>
</head> </head>
<body> <body class="">
<%= render partial: "layouts/navigation" %> <%= render partial: "layouts/navigation" %>
<main class="">
<%= render partial: "layouts/sidebar" %>
<div class="p-3">
<%= yield %> <%= yield %>
</div>
</main>
</body> </body>
</html> </html>

View file

@ -1,6 +1,8 @@
# frozen_string_literal: true
# This file is used by Rack-based servers to start the application. # This file is used by Rack-based servers to start the application.
require_relative "config/environment" require_relative 'config/environment'
run Rails.application run Rails.application
Rails.application.load_server Rails.application.load_server

View file

@ -1,18 +1,18 @@
require_relative "boot" require_relative 'boot'
require "rails" require 'rails'
# Pick the frameworks you want: # Pick the frameworks you want:
require "active_model/railtie" require 'active_model/railtie'
require "active_job/railtie" require 'active_job/railtie'
require "active_record/railtie" require 'active_record/railtie'
require "active_storage/engine" require 'active_storage/engine'
require "action_controller/railtie" require 'action_controller/railtie'
require "action_mailer/railtie" require 'action_mailer/railtie'
# require "action_mailbox/engine" # require "action_mailbox/engine"
require "action_text/engine" require 'action_text/engine'
require "action_view/railtie" require 'action_view/railtie'
require "action_cable/engine" require 'action_cable/engine'
require "rails/test_unit/railtie" require 'rails/test_unit/railtie'
# Require the gems listed in Gemfile, including any gems # Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production. # you've limited to :test, :development, or :production.
@ -26,7 +26,7 @@ module A11yist
# Please, add to the `ignore` list any other `lib` subdirectories that do # Please, add to the `ignore` list any other `lib` subdirectories that do
# not contain `.rb` files, or that should not be reloaded or eager loaded. # not contain `.rb` files, or that should not be reloaded or eager loaded.
# Common ones are `templates`, `generators`, or `middleware`, for example. # Common ones are `templates`, `generators`, or `middleware`, for example.
config.autoload_lib(ignore: %w(assets tasks)) config.autoload_lib(ignore: %w[assets tasks])
# Configuration for the application, engines, and railties goes here. # Configuration for the application, engines, and railties goes here.
# #

View file

@ -1,4 +1,4 @@
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require "bundler/setup" # Set up gems listed in the Gemfile. require 'bundler/setup' # Set up gems listed in the Gemfile.
require "bootsnap/setup" # Speed up boot time by caching expensive operations. require 'bootsnap/setup' # Speed up boot time by caching expensive operations.

View file

@ -1,5 +1,5 @@
# Load the Rails application. # Load the Rails application.
require_relative "application" require_relative 'application'
# Initialize the Rails application. # Initialize the Rails application.
Rails.application.initialize! Rails.application.initialize!

View file

@ -1,4 +1,4 @@
require "active_support/core_ext/integer/time" require 'active_support/core_ext/integer/time'
Rails.application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb. # Settings specified here will take precedence over those in config/application.rb.
@ -19,13 +19,13 @@ Rails.application.configure do
# Enable/disable caching. By default caching is disabled. # Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching. # Run rails dev:cache to toggle caching.
if Rails.root.join("tmp/caching-dev.txt").exist? if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true config.action_controller.enable_fragment_cache_logging = true
config.cache_store = :memory_store config.cache_store = :memory_store
config.public_file_server.headers = { config.public_file_server.headers = {
"Cache-Control" => "public, max-age=#{2.days.to_i}" 'Cache-Control' => "public, max-age=#{2.days.to_i}"
} }
else else
config.action_controller.perform_caching = false config.action_controller.perform_caching = false

View file

@ -1,4 +1,4 @@
require "active_support/core_ext/integer/time" require 'active_support/core_ext/integer/time'
Rails.application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb. # Settings specified here will take precedence over those in config/application.rb.
@ -62,7 +62,7 @@ Rails.application.configure do
# "info" includes generic and useful information about system operation, but avoids logging too much # "info" includes generic and useful information about system operation, but avoids logging too much
# information to avoid inadvertent exposure of personally identifiable information (PII). If you # information to avoid inadvertent exposure of personally identifiable information (PII). If you
# want to log everything, set the level to "debug". # want to log everything, set the level to "debug".
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info')
# Use a different cache store in production. # Use a different cache store in production.
# config.cache_store = :mem_cache_store # config.cache_store = :mem_cache_store

View file

@ -1,4 +1,4 @@
require "active_support/core_ext/integer/time" require 'active_support/core_ext/integer/time'
# The test environment is used exclusively to run your application's # The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that # test suite. You never need to work with it otherwise. Remember that
@ -15,12 +15,12 @@ Rails.application.configure do
# this is usually not necessary, and can slow down your test suite. However, it's # this is usually not necessary, and can slow down your test suite. However, it's
# recommended that you enable it in continuous integration systems to ensure eager # recommended that you enable it in continuous integration systems to ensure eager
# loading is working properly before deploying your code. # loading is working properly before deploying your code.
config.eager_load = ENV["CI"].present? config.eager_load = ENV['CI'].present?
# Configure public file server for tests with Cache-Control for performance. # Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true config.public_file_server.enabled = true
config.public_file_server.headers = { config.public_file_server.headers = {
"Cache-Control" => "public, max-age=#{1.hour.to_i}" 'Cache-Control' => "public, max-age=#{1.hour.to_i}"
} }
# Show full error reports and disable caching. # Show full error reports and disable caching.

View file

@ -1,11 +1,11 @@
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets. # Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = "1.0" Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path. # Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path # Rails.application.config.assets.paths << Emoji.images_path
Rails.application.config.assets.paths << Rails.root.join("node_modules/bootstrap-icons/font") Rails.application.config.assets.paths << Rails.root.join('node_modules/bootstrap-icons/font')
# Precompile additional assets. # Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets # application.js, application.css, and all non-JS/CSS in the app/assets

View file

@ -3,6 +3,6 @@
# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file. # Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
# Use this to limit dissemination of sensitive information. # Use this to limit dissemination of sensitive information.
# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors. # See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
Rails.application.config.filter_parameters += [ Rails.application.config.filter_parameters += %i[
:passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn passw secret token _key crypt salt certificate otp ssn
] ]

View file

@ -7,29 +7,29 @@
# Any libraries that use thread pools should be configured to match # Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum # the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record. # and maximum; this matches the default thread size of Active Record.
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } max_threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count }
threads min_threads_count, max_threads_count threads min_threads_count, max_threads_count
# Specifies that the worker count should equal the number of processors in production. # Specifies that the worker count should equal the number of processors in production.
if ENV["RAILS_ENV"] == "production" if ENV['RAILS_ENV'] == 'production'
require "concurrent-ruby" require 'concurrent-ruby'
worker_count = Integer(ENV.fetch("WEB_CONCURRENCY") { Concurrent.physical_processor_count }) worker_count = Integer(ENV.fetch('WEB_CONCURRENCY') { Concurrent.physical_processor_count })
workers worker_count if worker_count > 1 workers worker_count if worker_count > 1
end end
# Specifies the `worker_timeout` threshold that Puma will use to wait before # Specifies the `worker_timeout` threshold that Puma will use to wait before
# terminating a worker in development environments. # terminating a worker in development environments.
worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" worker_timeout 3600 if ENV.fetch('RAILS_ENV', 'development') == 'development'
# Specifies the `port` that Puma will listen on to receive requests; default is 3000. # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
port ENV.fetch("PORT") { 3000 } port ENV.fetch('PORT') { 3000 }
# Specifies the `environment` that Puma will run in. # Specifies the `environment` that Puma will run in.
environment ENV.fetch("RAILS_ENV") { "development" } environment ENV.fetch('RAILS_ENV') { 'development' }
# Specifies the `pidfile` that Puma will use. # Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } pidfile ENV.fetch('PIDFILE') { 'tmp/pids/server.pid' }
# Allow puma to be restarted by `bin/rails restart` command. # Allow puma to be restarted by `bin/rails restart` command.
plugin :tmp_restart plugin :tmp_restart

View file

@ -1,11 +1,11 @@
Rails.application.routes.draw do Rails.application.routes.draw do
get 'home/show' get 'home/show', as: :home
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. # 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. # 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 get 'up' => 'rails/health#show', as: :rails_health_check
# Defines the root path route ("/") # Defines the root path route ("/")
root "home#show" root 'home#show'
end end

View file

@ -1,4 +1,6 @@
require "test_helper" # frozen_string_literal: true
require 'test_helper'
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
driven_by :selenium, using: :chrome, screen_size: [1400, 1400] driven_by :selenium, using: :chrome, screen_size: [1400, 1400]

View file

@ -1,4 +1,6 @@
require "test_helper" # frozen_string_literal: true
require 'test_helper'
module ApplicationCable module ApplicationCable
class ConnectionTest < ActionCable::Connection::TestCase class ConnectionTest < ActionCable::Connection::TestCase

View file

@ -1,7 +1,9 @@
require "test_helper" # frozen_string_literal: true
require 'test_helper'
class HomeControllerTest < ActionDispatch::IntegrationTest class HomeControllerTest < ActionDispatch::IntegrationTest
test "should get show" do test 'should get show' do
get home_show_url get home_show_url
assert_response :success assert_response :success
end end

View file

@ -1,6 +1,8 @@
ENV["RAILS_ENV"] ||= "test" # frozen_string_literal: true
require_relative "../config/environment"
require "rails/test_help" ENV['RAILS_ENV'] ||= 'test'
require_relative '../config/environment'
require 'rails/test_help'
module ActiveSupport module ActiveSupport
class TestCase class TestCase

Binary file not shown.