diff --git a/.DS_Store b/.DS_Store index 6d2c698..3d93dff 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.cursorrules b/.cursorrules index 7780223..01862e5 100644 --- a/.cursorrules +++ b/.cursorrules @@ -3,4 +3,5 @@ - If the Gemfile changes, you need to rebuild the docker image: docker build -t wrestlingdev-dev -f deploy/rails-dev-Dockerfile. - Do not add unnecessary comments to the code where you remove things. - Cypress tests are created for js tests. They can be found in cypress-tests/cypress -- Cypress tests can be run with docker: bash cypress-tests/run-cypress-tests.sh \ No newline at end of file +- Cypress tests can be run with docker: bash cypress-tests/run-cypress-tests.sh +- Write as little code as possible. I do not want crazy non standard rails implementations. \ No newline at end of file diff --git a/Gemfile b/Gemfile index ffebf40..ad93562 100644 --- a/Gemfile +++ b/Gemfile @@ -7,8 +7,9 @@ gem 'rails', '8.0.2' # Added in rails 7.1 gem 'rails-html-sanitizer' -# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] -gem "sprockets-rails" +# Asset Management: Propshaft for serving, Importmap for JavaScript +gem "propshaft" +gem "importmap-rails" # Reduces boot times through caching; required in config/boot.rb gem "bootsnap", require: false @@ -17,17 +18,17 @@ gem "bootsnap", require: false # Use sqlite3 version compatible with Rails 8 gem 'sqlite3', ">= 2.1", :group => :development -# Use Uglifier as compressor for JavaScript assets -gem 'uglifier' -# Use CoffeeScript for .js.coffee assets and views -gem 'coffee-rails' +# JavaScript and CSS related gems +# Uglifier is not used with Propshaft by default +# CoffeeScript (.js.coffee) files need to be converted to .js as Propshaft doesn't compile them + # See https://github.com/sstephenson/execjs#readme for more supported runtimes # gem 'therubyracer', platforms: :ruby # Use jquery as the JavaScript library gem 'jquery-rails' -# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks -gem 'turbolinks' +# Turbo for modern page interactions +gem 'turbo-rails' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder' # bundle exec rake doc:rails generates the API under doc/api. @@ -90,5 +91,3 @@ group :development, :test do gem 'rails-controller-testing' end -gem 'font-awesome-sass' - diff --git a/Gemfile.lock b/Gemfile.lock index dccb5f8..76ba936 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -88,13 +88,6 @@ GEM bundler (>= 1.2.0, < 3) thor (~> 1.0) cancancan (3.6.1) - coffee-rails (5.0.0) - coffee-script (>= 2.2.0) - railties (>= 5.2.0) - coffee-script (2.4.1) - coffee-script-source - execjs - coffee-script-source (1.12.2) concurrent-ruby (1.3.5) connection_pool (2.5.3) crass (1.0.6) @@ -104,17 +97,6 @@ GEM erubi (1.13.1) et-orbi (1.2.11) tzinfo - execjs (2.10.0) - ffi (1.17.2-aarch64-linux-gnu) - ffi (1.17.2-aarch64-linux-musl) - ffi (1.17.2-arm-linux-gnu) - ffi (1.17.2-arm-linux-musl) - ffi (1.17.2-arm64-darwin) - ffi (1.17.2-x86_64-darwin) - ffi (1.17.2-x86_64-linux-gnu) - ffi (1.17.2-x86_64-linux-musl) - font-awesome-sass (6.7.2) - sassc (~> 2.0) fugit (1.11.1) et-orbi (~> 1, >= 1.2.11) raabro (~> 1.4) @@ -122,6 +104,10 @@ GEM activesupport (>= 6.1) i18n (1.14.7) concurrent-ruby (~> 1.0) + importmap-rails (2.1.0) + actionpack (>= 6.0.0) + activesupport (>= 6.0.0) + railties (>= 6.0.0) influxdb (0.8.1) influxdb-rails (1.0.3) influxdb (~> 0.6, >= 0.6.4) @@ -183,6 +169,11 @@ GEM pp (0.6.2) prettyprint prettyprint (0.2.0) + propshaft (1.1.0) + actionpack (>= 7.0.0) + activesupport (>= 7.0.0) + rack + railties (>= 7.0.0) psych (5.2.6) date stringio @@ -244,8 +235,6 @@ GEM io-console (~> 0.5) round_robin_tournament (0.1.2) ruby2_keywords (0.0.5) - sassc (2.4.0) - ffi (~> 1.9) sdoc (2.6.1) rdoc (>= 5.0) securerandom (0.4.1) @@ -266,14 +255,6 @@ GEM railties (>= 7.1) thor (~> 1.3.1) spring (4.3.0) - sprockets (4.2.2) - concurrent-ruby (~> 1.0) - logger - rack (>= 2.2.4, < 4) - sprockets-rails (3.5.2) - actionpack (>= 6.1) - activesupport (>= 6.1) - sprockets (>= 3.0.0) sqlite3 (2.6.0-aarch64-linux-gnu) sqlite3 (2.6.0-aarch64-linux-musl) sqlite3 (2.6.0-arm-linux-gnu) @@ -285,15 +266,13 @@ GEM stringio (3.1.7) thor (1.3.2) timeout (0.4.3) - turbolinks (5.2.1) - turbolinks-source (~> 5.2) - turbolinks-source (5.2.0) + turbo-rails (2.0.13) + actionpack (>= 7.1.0) + railties (>= 7.1.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) tzinfo-data (1.2025.2) tzinfo (>= 1.0.0) - uglifier (4.2.1) - execjs (>= 0.3.0, < 3) uniform_notifier (1.17.0) uri (1.0.3) useragent (0.16.11) @@ -320,14 +299,14 @@ DEPENDENCIES bullet bundler-audit cancancan - coffee-rails daemons - font-awesome-sass + importmap-rails influxdb-rails jbuilder jquery-rails mocha mysql2 + propshaft puma rails (= 8.0.2) rails-controller-testing @@ -340,11 +319,9 @@ DEPENDENCIES solid_cache solid_queue spring - sprockets-rails sqlite3 (>= 2.1) - turbolinks + turbo-rails tzinfo-data - uglifier RUBY VERSION ruby 3.2.0p0 diff --git a/README.md b/README.md index c56d2a7..a94bdab 100644 --- a/README.md +++ b/README.md @@ -174,4 +174,15 @@ SolidQueue plugin enabled in Puma See `SOLID_QUEUE.md` for details about the job system configuration. -This project provides multiple ways to develop and deploy, with Docker being the primary method. \ No newline at end of file +This project provides multiple ways to develop and deploy, with Docker being the primary method. + +# Sprockets to Propshaft Migration + +- Propshaft will automatically include in its search paths the folders vendor/assets, lib/assets and app/assets of your project and of all the gems in your Gemfile. You can see all included files by using the reveal rake task: `rake assets:reveal`. When importing you'll use the relative path from this command. +- All css files are imported via `app/assets/stylesheets/application.css`. This is imported on `app/views/layouts/application.html.erb`. + - Bootstrap and fontawesome have been downloaded locally to `vendor/` +- All js files are imported with a combination of "pinning" with `config/importmaps.rb` and `app/assets/javascript/application.js` and imported to `app/views/layouts/application.html.erb` + - Jquery, bootstrap, datatables have been downloaded locally to `vendor/` + - Turbo and action cable are gems and get pathed properly by propshaft. +- development is "nobuild" with `config.assets.build_assets = false` in `config/environments/development.rb` +- production needs to run rake assets:precompile. This is done in the `deploy/rails-prod-Dockerfile`. \ No newline at end of file diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js index b16e53d..75ce659 100644 --- a/app/assets/config/manifest.js +++ b/app/assets/config/manifest.js @@ -1,3 +1,11 @@ //= link_tree ../images -//= link_directory ../javascripts .js -//= link_directory ../stylesheets .css + +// Link all .js files from app/javascript for importmap, and vendor/javascript if needed directly +//= link_tree ../../javascript .js +//= link_tree ../../../vendor/assets/javascripts .js + +// Explicitly link all .css files from app/assets/stylesheets and vendor/assets/stylesheets +//= link_tree ../stylesheets .css +//= link_tree ../../../vendor/assets/stylesheets .css + +//= link_tree ../../../vendor/assets/webfonts diff --git a/app/assets/javascripts/admin.js.coffee b/app/assets/javascripts/admin.js.coffee deleted file mode 100644 index 24f83d1..0000000 --- a/app/assets/javascripts/admin.js.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/api.js.coffee b/app/assets/javascripts/api.js.coffee deleted file mode 100644 index 24f83d1..0000000 --- a/app/assets/javascripts/api.js.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 38834d7..4baac29 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -1,32 +1,27 @@ -// This is a manifest file that'll be compiled into application.js, which will include all the files -// listed below. -// -// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, -// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. -// -// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the -// compiled file. -// -// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details -// about supported directives. -// -//= require jquery -//= require jquery_ujs -// Bootstrap 3.3.6 in vendor/assets/javascripts -//= require bootstrap.min.js -// Data Tables 1.10.6 in vendor/assets/javascripts -//= require jquery.dataTables.min.js -//= require turbolinks -// -//= require actioncable -//= require_self -//= require_tree . +// Entry point for your JavaScript application -// Create the Action Cable consumer instance +// These are pinned in config/importmap.rb +import "@hotwired/turbo-rails"; +import { createConsumer } from "@rails/actioncable"; // Import createConsumer directly +import "jquery"; +import "bootstrap"; +import "datatables.net"; + +// Your existing Action Cable consumer setup (function() { - this.App || (this.App = {}); - - App.cable = ActionCable.createConsumer(); - + try { + window.App || (window.App = {}); + window.App.cable = createConsumer(); // Use the imported createConsumer + console.log('Action Cable Consumer Created via app/javascript/application.js'); + } catch (e) { + console.error('Error creating ActionCable consumer:', e); + console.error('ActionCable not loaded or createConsumer failed, App.cable not created.'); + } }).call(this); +console.log("Propshaft/Importmap application.js initialized with jQuery, Bootstrap, and DataTables."); + +// If you have custom JavaScript files in app/javascript/ that were previously +// handled by Sprockets `require_tree`, you'll need to import them here explicitly. +// For example: +// import "./my_custom_logic"; \ No newline at end of file diff --git a/app/assets/javascripts/matches.js.coffee b/app/assets/javascripts/matches.js.coffee deleted file mode 100644 index 43d766d..0000000 --- a/app/assets/javascripts/matches.js.coffee +++ /dev/null @@ -1,4 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ - diff --git a/app/assets/javascripts/mats.js.coffee b/app/assets/javascripts/mats.js.coffee deleted file mode 100644 index 24f83d1..0000000 --- a/app/assets/javascripts/mats.js.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/schools.js.coffee b/app/assets/javascripts/schools.js.coffee deleted file mode 100644 index 24f83d1..0000000 --- a/app/assets/javascripts/schools.js.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/static_pages.js.coffee b/app/assets/javascripts/static_pages.js.coffee deleted file mode 100644 index 24f83d1..0000000 --- a/app/assets/javascripts/static_pages.js.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/tournaments.js.coffee b/app/assets/javascripts/tournaments.js.coffee deleted file mode 100644 index 24f83d1..0000000 --- a/app/assets/javascripts/tournaments.js.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/weights.js.coffee b/app/assets/javascripts/weights.js.coffee deleted file mode 100644 index 24f83d1..0000000 --- a/app/assets/javascripts/weights.js.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/wrestlers.js.coffee b/app/assets/javascripts/wrestlers.js.coffee deleted file mode 100644 index 24f83d1..0000000 --- a/app/assets/javascripts/wrestlers.js.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/admin.css b/app/assets/stylesheets/admin.css deleted file mode 100644 index 0f4f3b2..0000000 --- a/app/assets/stylesheets/admin.css +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the Admin controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/api.css b/app/assets/stylesheets/api.css deleted file mode 100644 index afad32d..0000000 --- a/app/assets/stylesheets/api.css +++ /dev/null @@ -1,4 +0,0 @@ -/* - Place all the styles related to the matching controller here. - They will automatically be included in application.css. -*/ diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 7b5ab14..852b4f1 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -1,35 +1,17 @@ -/* - * 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 vendor/assets/stylesheets of plugins, if any, 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 styles - * defined in the other CSS/SCSS files in this directory. It is generally better to create a new - * file per style scope. - * - * For some reason this needs to be above bootstrap for the zindex of the main navbar to work. - * With it lower, bootstraps css overrides it. - *= require custom - * Bootstrap 3.3.6 in vendor/assets/stylesheets - *= require bootstrap.min.css - *= require bootstrap-theme.min.css - * Font Awesome 5.7.1 in vendor/assets/stylesheets/fontawesome - *= require fontawesome/all - *= require_tree . - *= require_self - */ +/* relative pathing from /vender/assets/stylesheets = / */ +@import url("/bootstrap.min.css"); +@import url("/bootstrap-theme.min.css"); +@import url("/fontawesome/all.css"); +@import url("/custom.css"); +@import url("/scaffolds.css"); @font-face { - font-family: 'Font Awesome 5 Brands'; - /* other properties */ - src: url("/webfonts/fa-brands-400.eot"); - src: url("/webfonts/fa-brands-400.eot?#iefix") format("embedded-opentype"), - url("/webfonts/fa-brands-400.woff2") format("woff2"), - url("/webfonts/fa-brands-400.woff") format("woff"), - url("/webfonts/fa-brands-400.ttf") format("truetype"), - url("/webfonts/fa-brands-400.svg#fontawesome") format("svg"); -} - + font-family: 'Font Awesome 5 Brands'; + /* relative pathing from /vender/assets/stylesheets = / */ + src: url("/webfonts/fa-brands-400.eot"); + src: url("/webfonts/fa-brands-400.eot?#iefix") format("embedded-opentype"), + url("/webfonts/fa-brands-400.woff2") format("woff2"), + url("/webfonts/fa-brands-400.woff") format("woff"), + url("/webfonts/fa-brands-400.ttf") format("truetype"), + url("/webfonts/fa-brands-400.svg#fontawesome") format("svg"); + } diff --git a/app/assets/stylesheets/matches.css b/app/assets/stylesheets/matches.css deleted file mode 100644 index 9b13d59..0000000 --- a/app/assets/stylesheets/matches.css +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the Matches controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/mats.css b/app/assets/stylesheets/mats.css deleted file mode 100644 index 92a20d9..0000000 --- a/app/assets/stylesheets/mats.css +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the Mats controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/schools.css b/app/assets/stylesheets/schools.css deleted file mode 100644 index 813d2d0..0000000 --- a/app/assets/stylesheets/schools.css +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the Schools controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/static_pages.css b/app/assets/stylesheets/static_pages.css deleted file mode 100644 index d55836c..0000000 --- a/app/assets/stylesheets/static_pages.css +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the StaticPages controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/tournaments.css b/app/assets/stylesheets/tournaments.css deleted file mode 100644 index e372b90..0000000 --- a/app/assets/stylesheets/tournaments.css +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the tournaments controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/weights.css b/app/assets/stylesheets/weights.css deleted file mode 100644 index 90a4fae..0000000 --- a/app/assets/stylesheets/weights.css +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the Weights controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/wrestlers.css b/app/assets/stylesheets/wrestlers.css deleted file mode 100644 index 6a79218..0000000 --- a/app/assets/stylesheets/wrestlers.css +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the Wrestlers controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index d3cf640..5f2f651 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -5,9 +5,8 @@ <%= csrf_meta_tags %> <%= action_cable_meta_tag %>