Skip to content

Commit

Permalink
some things ;)
Browse files Browse the repository at this point in the history
  • Loading branch information
baldarn committed Jul 19, 2024
1 parent 4a648e3 commit cb71a3f
Show file tree
Hide file tree
Showing 53 changed files with 476 additions and 181 deletions.
32 changes: 24 additions & 8 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
# Omakase Ruby styling for Rails
inherit_gem: { rubocop-rails-omakase: rubocop.yml }

# Overwrite or add rules to create your own house style
#
# # Use `[a, [b, c]]` not `[ a, [ b, c ] ]`
# Layout/SpaceInsideArrayLiteralBrackets:
# Enabled: false
inherit_from: .rubocop_todo.yml

require:
- rubocop-capybara
- rubocop-rails

AllCops:
TargetRubyVersion: 3.3
NewCops: enable
Exclude:
- bin/*
- db/schema.rb

Style/Documentation:
Enabled: false

Metrics/BlockLength:
Exclude:
- config/environments/*

Metrics/MethodLength:
Max: 35
Exclude:
- db/migrate/*
7 changes: 7 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-07-19 12:31:30 UTC using RuboCop version 1.64.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
70 changes: 36 additions & 34 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,55 +1,57 @@
source "https://rubygems.org"
# frozen_string_literal: true

ruby file: ".ruby-version"
source 'https://rubygems.org'

gem "rails", "~> 7.1"
ruby file: '.ruby-version'

gem 'rails', '~> 7.1'

# Drivers
gem "sqlite3", "~> 1.4"
gem "redis", ">= 4.0.1"
gem 'redis', '>= 4.0.1'
gem 'sqlite3', '~> 1.4'

# Deployment
gem "puma", ">= 5.0"
gem 'puma', '>= 5.0'

# Jobs
gem "resque", "~> 2.6.0"
gem "resque-pool", "~> 0.7.1"
gem 'resque', '~> 2.6.0'
gem 'resque-pool', '~> 0.7.1'

# Front-end
gem "propshaft"
gem "importmap-rails"
gem "turbo-rails"
gem "stimulus-rails"
gem "bootstrap", "~> 5.1"
gem "sassc-rails"
gem "simple_form", "~> 5.3"
gem 'bootstrap', '~> 5.1'
gem 'importmap-rails'
gem 'simple_form', '~> 5.3'
gem 'stimulus-rails'
gem 'turbo-rails'

# Other
gem "sprockets-rails"
gem "useragent", github: "basecamp/useragent"
gem "jbuilder"
gem "redcarpet", "~> 3.6"
gem "rouge", "~> 4.2"
gem "bcrypt", "~> 3.1.7"
gem "image_processing", "~> 1.2"
gem "rqrcode"
gem "thruster"
gem "front_matter_parser"
gem "rails-i18n", "~> 7.0.0"
gem 'bcrypt', '~> 3.1.7'
gem 'front_matter_parser'
gem 'image_processing', '~> 1.2'
gem 'jbuilder'
gem 'rails-i18n', '~> 7.0.0'
gem 'redcarpet', '~> 3.6'
gem 'rouge', '~> 4.2'
gem 'rqrcode'
gem 'sassc-rails'
gem 'sprockets-rails'
gem 'thruster'
gem 'useragent', github: 'basecamp/useragent'

group :development, :test do
gem "debug"
gem "faker", require: false
gem "brakeman", require: false
gem "rubocop-rails-omakase", require: false
gem 'brakeman', require: false
gem 'debug'
gem 'faker', require: false
gem 'rubocop-capybara', require: false
gem 'rubocop-rails', require: false
end

group :development do
gem "web-console"
gem "htmlbeautifier"
gem 'htmlbeautifier'
gem 'web-console'
end

group :test do
gem "capybara"
gem "selenium-webdriver"
gem 'capybara'
gem 'selenium-webdriver'
end
22 changes: 4 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,6 @@ GEM
ast (~> 2.4.1)
racc
popper_js (2.11.8)
propshaft (0.8.0)
actionpack (>= 7.0.0)
activesupport (>= 7.0.0)
rack
railties (>= 7.0.0)
psych (5.1.2)
stringio
public_suffix (5.0.5)
Expand Down Expand Up @@ -282,22 +277,13 @@ GEM
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.3)
parser (>= 3.3.1.0)
rubocop-minitest (0.35.0)
rubocop (>= 1.61, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-performance (1.21.0)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-capybara (2.21.0)
rubocop (~> 1.41)
rubocop-rails (2.25.0)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rails-omakase (1.0.0)
rubocop
rubocop-minitest
rubocop-performance
rubocop-rails
ruby-progressbar (1.13.0)
ruby-vips (2.2.1)
ffi (~> 1.12)
Expand Down Expand Up @@ -391,7 +377,6 @@ DEPENDENCIES
image_processing (~> 1.2)
importmap-rails
jbuilder
propshaft
puma (>= 5.0)
rails (~> 7.1)
rails-i18n (~> 7.0.0)
Expand All @@ -401,7 +386,8 @@ DEPENDENCIES
resque-pool (~> 0.7.1)
rouge (~> 4.2)
rqrcode
rubocop-rails-omakase
rubocop-capybara
rubocop-rails
sassc-rails
selenium-webdriver
simple_form (~> 5.3)
Expand Down
4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

# 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.

require_relative "config/application"
require_relative 'config/application'

Rails.application.load_tasks
26 changes: 25 additions & 1 deletion app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,28 @@ $theme-colors: map-merge($theme-colors, $custom-colors);
@import "bootstrap";

// simple_form helpers
@import "simple_form-bootstrap/simple_form-bootstrap";
@import "simple_form-bootstrap/simple_form-bootstrap";

.dot-ok {
height: 10px;
width: 10px;
background-color: green;
border-radius: 50%;
display: inline-block;
}

.dot-warning {
height: 10px;
width: 10px;
background-color: orange;
border-radius: 50%;
display: inline-block;
}

.dot-error {
height: 10px;
width: 10px;
background-color: red;
border-radius: 50%;
display: inline-block;
}
2 changes: 2 additions & 0 deletions app/channels/application_cable/channel.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationCable
class Channel < ActionCable::Channel::Base
end
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ApplicationController < ActionController::Base
# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
allow_browser versions: :modern
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# frozen_string_literal: true

class HomeController < ApplicationController
def index
@members = Member.all
end
end
2 changes: 2 additions & 0 deletions app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ApplicationJob < ActiveJob::Base
# Automatically retry jobs that encountered a deadlock
# retry_on ActiveRecord::Deadlocked
Expand Down
6 changes: 4 additions & 2 deletions app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# frozen_string_literal: true

class ApplicationMailer < ActionMailer::Base
default from: "[email protected]"
layout "mailer"
default from: '[email protected]'
layout 'mailer'
end
5 changes: 5 additions & 0 deletions app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
9 changes: 9 additions & 0 deletions app/models/medical_certificate.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

class MedicalCertificate < ApplicationRecord
has_one_attached :certificate

enum :kind, %i[regular competitive]

validates :kind, :certificate, :expires_at, presence: true
end
12 changes: 12 additions & 0 deletions app/models/member.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

class Member < ApplicationRecord
has_many :payments, dependent: :destroy
has_many :memberships, dependent: :destroy

validates :name, :surname, :born_at, :born_in, :citizenship, :address, :postal_code, presence: true

def status
%w[ok warning error].sample
end
end
5 changes: 5 additions & 0 deletions app/models/membership.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

class Membership < ApplicationRecord
belongs_to :member
end
7 changes: 7 additions & 0 deletions app/models/payment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class Payment < ApplicationRecord
belongs_to :member

validates :amount, presence: true
end
18 changes: 17 additions & 1 deletion app/views/home/index.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
asdasd
<ul class="nav nav-tabs" id="myTab" role="tablist">
<% @members.each do |member| %>
<li class="nav-item" role="presentation">
<button class="nav-link" id="<%= member.name.parameterize %>-tab" data-bs-toggle="tab" data-bs-target="#<%= member.name.parameterize %>" type="button" role="tab" aria-controls="<%= member.name %>" aria-selected="true">
<span class="dot-<%= member.status %>"></span>
<%= member.name %>
</button>
</li>
<% end %>
</ul>
<div class="tab-content" id="myTabContent">
<% @members.each do |member| %>
<div class="tab-pane fade show" id="<%= member.name.parameterize %>" role="tabpanel" aria-labelledby="<%= member.name.parameterize %>-tab">
<%= member.name %>
</div>
<% end %>
</div>
4 changes: 3 additions & 1 deletion config.ru
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

# This file is used by Rack-based servers to start the application.

require_relative "config/environment"
require_relative 'config/environment'

run Rails.application
Rails.application.load_server
6 changes: 4 additions & 2 deletions config/application.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require_relative "boot"
# frozen_string_literal: true

require "rails/all"
require_relative 'boot'

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Expand Down
6 changes: 4 additions & 2 deletions config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
# frozen_string_literal: true

require "bundler/setup" # Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)

require 'bundler/setup' # Set up gems listed in the Gemfile.
4 changes: 3 additions & 1 deletion config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

# Load the Rails application.
require_relative "application"
require_relative 'application'

# Initialize the Rails application.
Rails.application.initialize!
8 changes: 5 additions & 3 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require "active_support/core_ext/integer/time"
# frozen_string_literal: true

require 'active_support/core_ext/integer/time'

Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
Expand All @@ -19,12 +21,12 @@

# Enable/disable caching. By default caching is disabled.
# 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.enable_fragment_cache_logging = true

config.cache_store = :memory_store
config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" }
config.public_file_server.headers = { 'Cache-Control' => "public, max-age=#{2.days.to_i}" }
else
config.action_controller.perform_caching = false

Expand Down
Loading

0 comments on commit cb71a3f

Please sign in to comment.