projectblacklight / spotlight

Spotlight enables librarians, curators, and others who are responsible for digital collections to create attractive, feature-rich websites that highlight these collections.
Other
161 stars 65 forks source link

Generated manifest.js is broken #2995

Open mephillips-durham opened 11 months ago

mephillips-durham commented 11 months ago

If you bootstrap a new Rails application, following the instructions in README.md then the generated app/assets/config/manifest.js is broken in two ways.

Firstly, two of the lines are concatenated, and secondly the "link application.js" line causes a DoubleLinkError as noted by @jcoyne in #2896

The full file, as generated is

//= link_tree ../images
//= link_directory ../stylesheets .css

//= link application.js

//= link spotlight/manifest.js
//= link openseadragon-assets

//= link blacklight_gallery/manifest.js//= link_tree ../../javascript .js
//= link_tree ../../../vendor/javascript .js

I don't know whether the fault is in Spotlight itself, or in a related gem like Blacklight gallery (which is mentioned in the penultimate line, where there is a newline missing).

dnoneill commented 7 months ago

I am getting a very similar issue when following instructions in https://github.com/projectblacklight/spotlight?tab=readme-ov-file#installation. See attached screenshot. I am using Rails 7.0.8.1, Ruby 3.3.0 Screenshot 2024-03-18 at 3 03 13 PM

dnoneill commented 7 months ago

@hudajkhan and I looked into this and wasn't able to fix. The problem is two fold.

  1. //= link blackligh_gallery/manifest.js is on the same line as //=link_tree ../../javascript .js. They need to be separate lines to work.
  2. there are two application.js files being imported. One located in app/assets/javascripts/application.js and the other app/javascript/application.js

It looks like the importer deletes one of the application.js files but it ends up popping back up. @jcoyne @cbeer any ideas?

jcoyne commented 7 months ago

No idea. I haven't worked on this in years. It's probably due to the churn in how Rails has packaged assets from 4-7, and how Blacklight is dealing with that and how Spotlight hasn't seen a lot of attention.

corylown commented 2 months ago

The DoubleLinkError does not occur when generating the test app (seems to have been fixed in https://github.com/projectblacklight/spotlight/commit/176837fcb84b372b02968593bbf9ab369dec7883) where remove_file 'app/javascript/application.js' was added to the generator. However, I think that during app generation following the installation instructions (SKIP_TRANSLATION=1 rails new app-name -m https://raw.githubusercontent.com/projectblacklight/spotlight/main/template.rb), the app/javascript/application.js doesn't exist yet when remove_file is executed and gets added later, possible because of the order in which bundle install is run. However, I think this may be fixed when we add support for importmaps to Spotlight, which is work in progress.