From 5bf2ef42a0b2f42674edb276ce83c271600c838c Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Fri, 13 Sep 2024 21:16:46 -0700 Subject: [PATCH] Move JS libraries to vendor/javascript MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The silly motivation is that I wanted to remove `.prettierignore`, which just exists to omit that one folder from `npm run format`. But it also seems like this is the standard place to put them—a standard created long after we first set this up lol --- .prettierignore | 1 - app/assets/config/manifest.js | 1 + app/controllers/swf_assets_controller.rb | 4 ++-- app/views/closet_hangers/index.html.haml | 4 ++-- app/views/items/show.html.haml | 2 +- app/views/outfits/new.html.haml | 2 +- app/views/swf_assets/show.html.haml | 6 +++--- config/application.rb | 1 - config/initializers/assets.rb | 5 ++++- .../javascripts/lib => vendor/javascript}/easeljs.min.js | 0 .../javascripts/lib => vendor/javascript}/idiomorph.js | 0 .../javascripts/lib => vendor/javascript}/jquery.jgrowl.js | 0 .../javascripts/lib => vendor/javascript}/jquery.timeago.js | 0 .../javascripts/lib => vendor/javascript}/jquery.ui.js | 0 {app/assets/javascripts/lib => vendor/javascript}/react.js | 0 .../javascripts/lib => vendor/javascript}/tweenjs.min.js | 0 16 files changed, 14 insertions(+), 12 deletions(-) delete mode 100644 .prettierignore rename {app/assets/javascripts/lib => vendor/javascript}/easeljs.min.js (100%) rename {app/assets/javascripts/lib => vendor/javascript}/idiomorph.js (100%) rename {app/assets/javascripts/lib => vendor/javascript}/jquery.jgrowl.js (100%) rename {app/assets/javascripts/lib => vendor/javascript}/jquery.timeago.js (100%) rename {app/assets/javascripts/lib => vendor/javascript}/jquery.ui.js (100%) rename {app/assets/javascripts/lib => vendor/javascript}/react.js (100%) rename {app/assets/javascripts/lib => vendor/javascript}/tweenjs.min.js (100%) diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index 36c817ea..00000000 --- a/.prettierignore +++ /dev/null @@ -1 +0,0 @@ -/app/assets/javascripts/lib diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js index 7b44d49c..2d41fe9d 100644 --- a/app/assets/config/manifest.js +++ b/app/assets/config/manifest.js @@ -1,5 +1,6 @@ //= link_tree ../images //= link_tree ../javascripts .js +//= link_tree ../../../vendor/javascript .js //= link_tree ../stylesheets .css //= link_directory ../fonts .otf //= link_tree ../builds diff --git a/app/controllers/swf_assets_controller.rb b/app/controllers/swf_assets_controller.rb index 43c0c898..4803d3ef 100644 --- a/app/controllers/swf_assets_controller.rb +++ b/app/controllers/swf_assets_controller.rb @@ -24,8 +24,8 @@ class SwfAssetsController < ApplicationController policy.script_src -> { src_list( - helpers.javascript_url("lib/easeljs.min"), - helpers.javascript_url("lib/tweenjs.min"), + helpers.javascript_url("easeljs.min"), + helpers.javascript_url("tweenjs.min"), helpers.javascript_url("swf_assets/show"), @swf_asset.canvas_movie_library_url, ) diff --git a/app/views/closet_hangers/index.html.haml b/app/views/closet_hangers/index.html.haml index ddcd87ed..ff1e8926 100644 --- a/app/views/closet_hangers/index.html.haml +++ b/app/views/closet_hangers/index.html.haml @@ -152,7 +152,7 @@ - content_for :javascripts do = include_javascript_libraries :jquery, :jquery_tmpl - = javascript_include_tag 'ajax_auth', 'lib/jquery.ui', 'lib/jquery.jgrowl', + = javascript_include_tag 'ajax_auth', 'jquery.ui', 'jquery.jgrowl', defer: true - content_for :javascripts_body do @@ -167,4 +167,4 @@ %meta{ name: "trade-matches-wants", value: @items.select(&:wanted?).map(&:id).join(",") - } \ No newline at end of file + } diff --git a/app/views/items/show.html.haml b/app/views/items/show.html.haml index a63d40bd..6af3cecb 100644 --- a/app/views/items/show.html.haml +++ b/app/views/items/show.html.haml @@ -126,6 +126,6 @@ = page_stylesheet_link_tag "items/show" - content_for :javascripts do - = javascript_include_tag "lib/idiomorph", async: true + = javascript_include_tag "idiomorph", async: true = javascript_include_tag "outfit-viewer", async: true = javascript_include_tag "items/show", async: true diff --git a/app/views/outfits/new.html.haml b/app/views/outfits/new.html.haml index c83c1f6c..98ed523e 100644 --- a/app/views/outfits/new.html.haml +++ b/app/views/outfits/new.html.haml @@ -130,7 +130,7 @@ - content_for :javascripts do = include_javascript_libraries :jquery, :jquery_tmpl - = javascript_include_tag 'ajax_auth', 'lib/jquery.timeago', defer: true + = javascript_include_tag 'ajax_auth', 'jquery.timeago', defer: true - content_for :javascripts_body do = javascript_include_tag 'outfits/new', defer: true diff --git a/app/views/swf_assets/show.html.haml b/app/views/swf_assets/show.html.haml index 7fae5113..fe1b4cd9 100644 --- a/app/views/swf_assets/show.html.haml +++ b/app/views/swf_assets/show.html.haml @@ -21,8 +21,8 @@ -# Load the scripts: EaselJS libs first, then the asset's "library" file, -# then our page script that starts the movie. - = javascript_include_tag "lib/easeljs.min", defer: true, debug: false - = javascript_include_tag "lib/tweenjs.min", defer: true, debug: false + = javascript_include_tag "easeljs.min", defer: true, debug: false + = javascript_include_tag "tweenjs.min", defer: true, debug: false = javascript_include_tag @swf_asset.canvas_movie_library_url, defer: true, id: "canvas-movie-library" = javascript_include_tag "swf_assets/show", defer: true, debug: false @@ -33,4 +33,4 @@ -# the browser won't bother to load it if it's not used. = image_tag @swf_asset.image_url, id: "fallback", alt: "", loading: "lazy" - else - = image_tag @swf_asset.image_url, alt: "", id: "asset-image" \ No newline at end of file + = image_tag @swf_asset.image_url, alt: "", id: "asset-image" diff --git a/config/application.rb b/config/application.rb index 2ca3bd5d..d0861c0b 100644 --- a/config/application.rb +++ b/config/application.rb @@ -57,7 +57,6 @@ module OpenneoImpressItems config.assets.enabled = true config.assets.version = '1.0' - config.assets.paths << Rails.root.join('app', 'assets', 'fonts') config.assets.precompile << '*.js' config.assets.initialize_on_precompile = false config.assets.css_compressor = nil # Sass's compressor can't handle all modern CSS… diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index ec985f86..3a9602b3 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -4,7 +4,10 @@ Rails.application.config.assets.version = "1.0" # Add additional assets to the asset load path. -# Rails.application.config.assets.paths << Emoji.images_path +Rails.application.config.assets.paths += [ + Rails.root.join('app', 'assets', 'fonts'), + Rails.root.join('vendor', 'javascript'), +] # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in the app/assets diff --git a/app/assets/javascripts/lib/easeljs.min.js b/vendor/javascript/easeljs.min.js similarity index 100% rename from app/assets/javascripts/lib/easeljs.min.js rename to vendor/javascript/easeljs.min.js diff --git a/app/assets/javascripts/lib/idiomorph.js b/vendor/javascript/idiomorph.js similarity index 100% rename from app/assets/javascripts/lib/idiomorph.js rename to vendor/javascript/idiomorph.js diff --git a/app/assets/javascripts/lib/jquery.jgrowl.js b/vendor/javascript/jquery.jgrowl.js similarity index 100% rename from app/assets/javascripts/lib/jquery.jgrowl.js rename to vendor/javascript/jquery.jgrowl.js diff --git a/app/assets/javascripts/lib/jquery.timeago.js b/vendor/javascript/jquery.timeago.js similarity index 100% rename from app/assets/javascripts/lib/jquery.timeago.js rename to vendor/javascript/jquery.timeago.js diff --git a/app/assets/javascripts/lib/jquery.ui.js b/vendor/javascript/jquery.ui.js similarity index 100% rename from app/assets/javascripts/lib/jquery.ui.js rename to vendor/javascript/jquery.ui.js diff --git a/app/assets/javascripts/lib/react.js b/vendor/javascript/react.js similarity index 100% rename from app/assets/javascripts/lib/react.js rename to vendor/javascript/react.js diff --git a/app/assets/javascripts/lib/tweenjs.min.js b/vendor/javascript/tweenjs.min.js similarity index 100% rename from app/assets/javascripts/lib/tweenjs.min.js rename to vendor/javascript/tweenjs.min.js