Commit 25069b0

mo <mo@mokhan.ca>
2018-09-24 20:18:56
do not use sprockets
1 parent d6ed81f
app/assets/config/manifest.js
@@ -1,3 +0,0 @@
-//= link_tree ../images
-//= link_directory ../javascripts .js
-//= link_directory ../stylesheets .css
app/assets/javascripts/channels/.keep
app/assets/javascripts/application.js
@@ -1,16 +0,0 @@
-// 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, or any plugin's
-// vendor/assets/javascripts directory 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. JavaScript code in this file should be added after the last require_* statement.
-//
-// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
-// about supported directives.
-//
-//= require rails-ujs
-//= require activestorage
-//= require turbolinks
-//= require_tree .
app/assets/javascripts/cable.js
@@ -1,13 +0,0 @@
-// Action Cable provides the framework to deal with WebSockets in Rails.
-// You can generate new channels where WebSocket features live using the `rails generate channel` command.
-//
-//= require action_cable
-//= require_self
-//= require_tree ./channels
-
-(function() {
-  this.App || (this.App = {});
-
-  App.cable = ActionCable.createConsumer();
-
-}).call(this);
app/assets/stylesheets/application.css
@@ -1,32 +0,0 @@
-/*
- * 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, or any plugin's
- * vendor/assets/stylesheets directory 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 other CSS/SCSS
- * files in this directory. Styles in this file should be added after the last require_* statement.
- * It is generally better to create a new file per style scope.
- *
- *= require_tree .
- *= require_self
- */
-
-@keyframes spinner {
-  0% { transform: rotate(0deg) }
-  100% { transform: rotate(360deg) }
-}
-
-.spinner {
-  margin: auto;
-  width: 48px;
-  height: 48px;
-  animation: spinner 0.65s infinite steps(12);
-}
-
-.spinner svg {
-  width: 48px;
-  height: 48px;
-}
app/channels/application_cable/channel.rb
@@ -1,6 +0,0 @@
-# frozen_string_literal: true
-
-module ApplicationCable
-  class Channel < ActionCable::Channel::Base
-  end
-end
app/channels/application_cable/connection.rb
@@ -1,6 +0,0 @@
-# frozen_string_literal: true
-
-module ApplicationCable
-  class Connection < ActionCable::Connection::Base
-  end
-end
app/assets/images/.keep → app/javascript/images/icon.png
File renamed without changes
app/javascript/images/index.js
@@ -0,0 +1,2 @@
+import './icon.png'
+import './logo.png'
app/javascript/images/logo.png
Binary file
app/javascript/packs/application.js
@@ -12,6 +12,7 @@ import { Application } from 'stimulus';
 import { definitionsFromContext } from 'stimulus/webpack-helpers';
 import LocalTime from 'local-time';
 import Rails from 'rails-ujs';
+import Turbolinks from 'turbolinks';
 import '../application.scss';
 
 const application = Application.start();
@@ -19,3 +20,4 @@ const context = require.context('controllers', true, /.js$/);
 application.load(definitionsFromContext(context));
 LocalTime.start();
 Rails.start();
+Turbolinks.start();
app/javascript/packs/images.js
@@ -0,0 +1,1 @@
+import '../images'
app/javascript/application.scss
@@ -1,1 +1,18 @@
 @import '~bootstrap/scss/bootstrap';
+
+@keyframes spinner {
+  0% { transform: rotate(0deg) }
+  100% { transform: rotate(360deg) }
+}
+
+.spinner {
+  margin: auto;
+  width: 48px;
+  height: 48px;
+  animation: spinner 0.65s infinite steps(12);
+}
+
+.spinner svg {
+  width: 48px;
+  height: 48px;
+}
app/views/application/_navbar.html.erb
@@ -1,6 +1,8 @@
 <div class="container">
   <nav class="navbar navbar-expand-lg navbar-light bg-light">
-    <%= link_to t(".proof"), my_dashboard_path, class: 'navbar-brand' %>
+    <%= link_to my_dashboard_path, class: 'navbar-brand' do %>
+      <img src="<%= asset_pack_path("images/logo.png") %>" width="50" />
+    <% end %>
     <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
       <span class="navbar-toggler-icon"></span>
     </button>
app/views/layouts/application.html.erb
@@ -5,8 +5,7 @@
     <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
     <%= csrf_meta_tags %>
 
-    <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
-    <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
+    <%= javascript_pack_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
     <%= stylesheet_pack_tag 'application' %>
   </head>
   <body>
config/environments/development.rb
@@ -33,7 +33,7 @@ Rails.application.configure do
 
   # Store uploaded files on the local file system
   # (see config/storage.yml for options)
-  config.active_storage.service = :local
+  # config.active_storage.service = :local
 
   # Don't care if the mailer can't send.
   config.action_mailer.raise_delivery_errors = false
@@ -52,10 +52,10 @@ Rails.application.configure do
   # Debug mode disables concatenation and preprocessing of assets.
   # This option may cause significant delays in view rendering with a large
   # number of complex assets.
-  config.assets.debug = true
+  # config.assets.debug = true
 
   # Suppress logger output for asset requests.
-  config.assets.quiet = true
+  # config.assets.quiet = true
 
   # Raises error for missing translations
   # config.action_view.raise_on_missing_translations = true
config/environments/production.rb
@@ -29,11 +29,11 @@ Rails.application.configure do
   config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
 
   # Compress JavaScripts and CSS.
-  config.assets.js_compressor = Uglifier.new(harmony: true)
+  # config.assets.js_compressor = Uglifier.new(harmony: true)
   # config.assets.css_compressor = :sass
 
   # Do not fallback to assets pipeline if a precompiled asset is missed.
-  config.assets.compile = false
+  # config.assets.compile = false
 
   # `config.assets.precompile` and `config.assets.version` have moved to
   # config/initializers/assets.rb
@@ -47,7 +47,7 @@ Rails.application.configure do
 
   # Store uploaded files on the local file system
   # (see config/storage.yml for options)
-  config.active_storage.service = :local
+  # config.active_storage.service = :local
 
   # Mount Action Cable outside main process or domain
   # config.action_cable.mount_path = nil
config/environments/test.rb
@@ -32,7 +32,7 @@ Rails.application.configure do
   config.action_controller.allow_forgery_protection = false
 
   # Store uploaded files on the local file system in a temporary directory
-  config.active_storage.service = :test
+  # config.active_storage.service = :test
 
   config.action_mailer.perform_caching = false
 
config/initializers/assets.rb
@@ -3,12 +3,12 @@
 # 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.
-Rails.application.config.assets.version = '1.0'
+# Rails.application.config.assets.version = '1.0'
 
 # Add additional assets to the asset load path.
 # Rails.application.config.assets.paths << Emoji.images_path
 # Add Yarn node_modules folder to the asset load path.
-Rails.application.config.assets.paths << Rails.root.join('node_modules')
+# Rails.application.config.assets.paths << Rails.root.join('node_modules')
 
 # Precompile additional assets.
 # application.js, application.css, and all non-JS/CSS in the app/assets
config/webpack/environment.js
@@ -8,13 +8,10 @@ environment.plugins.prepend('RailsTranslationsPlugin', new RailsTranslationsPlug
   localesPath: path.resolve(__dirname, "../locales/"),
   root: './app/javascript'
 }))
-environment.plugins.append(
-  'Provide',
-  new webpack.ProvidePlugin({
-    $: 'jquery',
-    jQuery: 'jquery',
-    'window.jQuery': 'jquery',
-  })
-)
+environment.plugins.append('Provide', new webpack.ProvidePlugin({
+  $: 'jquery',
+  jQuery: 'jquery',
+  'window.jQuery': 'jquery',
+}));
 
 module.exports = environment
config/application.rb
@@ -2,13 +2,20 @@
 
 require_relative 'boot'
 
-require 'rails/all'
+require "rails"
+require "active_model/railtie"
+require "active_job/railtie"
+require "active_record/railtie"
+require "action_controller/railtie"
+require "action_mailer/railtie"
+require "action_view/railtie"
+require "dotenv"
+Dotenv.load(".env.local", ".env.#{Rails.env}", ".env")
 
 # Require the gems listed in Gemfile, including any gems
 # you've limited to :test, :development, or :production.
 Bundler.require(*Rails.groups)
 
-Dotenv.load(".env.local", ".env.#{Rails.env}", ".env")
 module Proof
   class Application < Rails::Application
     # Initialize configuration defaults for originally generated Rails version.
lib/package.rb
@@ -15,7 +15,6 @@ class Package
     "db/**/*",
     "lib/**/*",
     "public/**/*",
-    "public/assets/.sprockets*",
     "vendor/cache/**/*"
   ].freeze
 
Gemfile
@@ -8,7 +8,6 @@ gem 'activerecord-session_store', '~> 1.1'
 gem 'audited', '~> 4.8'
 gem 'bcrypt', '~> 3.1'
 gem 'bootsnap', '>= 1.1.0', require: false
-gem 'coffee-rails', '~> 4.2'
 gem 'dotenv', '~> 2.5'
 gem 'email_validator', '~> 1.6'
 gem 'flipper', '~> 0.16'
@@ -21,7 +20,6 @@ gem 'puma', '~> 3.11'
 gem 'rails', '~> 5.2.0'
 gem 'rotp', '~> 3.3'
 gem 'saml-kit', '~> 1.0'
-gem 'sass-rails', '~> 5.0'
 gem 'scim-shady', '~> 0.2'
 gem 'spank', '~> 1.0'
 gem 'turbolinks', '~> 5'
Gemfile.lock
@@ -76,13 +76,6 @@ GEM
       launchy
     childprocess (0.9.0)
       ffi (~> 1.0, >= 1.0.11)
-    coffee-rails (4.2.2)
-      coffee-script (>= 2.2.0)
-      railties (>= 4.0.0)
-    coffee-script (2.4.1)
-      coffee-script-source
-      execjs
-    coffee-script-source (1.12.2)
     concurrent-ruby (1.0.5)
     crack (0.4.3)
       safe_yaml (~> 1.0.0)
@@ -231,17 +224,6 @@ GEM
       activemodel (>= 4.2.0)
       net-hippie (~> 0.1.8)
       xml-kit (>= 0.1.13, <= 1.0.0)
-    sass (3.5.7)
-      sass-listen (~> 4.0.0)
-    sass-listen (4.0.0)
-      rb-fsevent (~> 0.9, >= 0.9.4)
-      rb-inotify (~> 0.9, >= 0.9.7)
-    sass-rails (5.0.7)
-      railties (>= 4.0.0, < 6)
-      sass (~> 3.1)
-      sprockets (>= 2.8, < 4.0)
-      sprockets-rails (>= 2.0, < 4.0)
-      tilt (>= 1.1, < 3)
     scim-shady (0.2.1)
       activesupport (>= 4.2.0)
     selenium-webdriver (3.14.0)
@@ -309,7 +291,6 @@ DEPENDENCIES
   byebug
   capybara (~> 3.6)
   capybara-screenshot (~> 1.0)
-  coffee-rails (~> 4.2)
   dotenv (~> 2.5)
   email_validator (~> 1.6)
   factory_bot_rails (~> 4.11)
@@ -330,7 +311,6 @@ DEPENDENCIES
   rspec-rails (~> 3.7)
   rubocop (~> 0.58)
   saml-kit (~> 1.0)
-  sass-rails (~> 5.0)
   scim-shady (~> 0.2)
   selenium-webdriver (~> 3.14)
   spank (~> 1.0)
package.json
@@ -16,7 +16,8 @@
     "qrcode": "^1.2.0",
     "rails-translations-webpack-plugin": "^1.1.0",
     "rails-ujs": "^5.2.1",
-    "stimulus": "^1.0.1"
+    "stimulus": "^1.0.1",
+    "turbolinks": "^5.2.0"
   },
   "devDependencies": {
     "babel-eslint": "^9.0.0",
yarn.lock
@@ -7194,6 +7194,10 @@ tunnel-agent@~0.4.1:
   version "0.4.3"
   resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.4.3.tgz#6373db76909fe570e08d73583365ed828a74eeeb"
 
+turbolinks@^5.2.0:
+  version "5.2.0"
+  resolved "https://registry.yarnpkg.com/turbolinks/-/turbolinks-5.2.0.tgz#e6877a55ea5c1cb3bb225f0a4ae303d6d32ff77c"
+
 tweetnacl@^0.14.3, tweetnacl@~0.14.0:
   version "0.14.5"
   resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"