Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importmap #1690

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ group :deployment do
end

gem 'blacklight', '~> 7.14'
gem 'blacklight-spotlight', '~> 3.1'
gem 'blacklight-spotlight', '~> 3.1', github: 'projectblacklight/spotlight', branch: 'nestable'
gem 'twitter-typeahead-rails', '0.11.1.pre.corejavascript'

gem 'friendly_id'
Expand Down Expand Up @@ -111,3 +111,5 @@ gem 'cache_with_locale'

gem 'i18n-js', '< 4' # v4 was a complete rewrite; will take some work to update
gem 'i18n-tasks'

gem 'importmap-rails', '~> 1.1'
133 changes: 56 additions & 77 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,48 @@
GIT
remote: https://github.com/projectblacklight/spotlight.git
revision: 3175f09046db7da5217c316e1e9644bf5e3353fc
branch: nestable
specs:
blacklight-spotlight (3.5.0.2)
activejob-status
acts-as-taggable-on (>= 5.0, < 10)
autoprefixer-rails
blacklight (>= 7.18, < 9)
blacklight-gallery (>= 3.0, < 5)
bootstrap_form (~> 4.1)
breadcrumbs_on_rails (>= 3.0, < 5)
cancancan
carrierwave (~> 2.2)
clipboard-rails (~> 1.5)
devise (~> 4.1)
devise_invitable
faraday
faraday-follow_redirects
friendly_id (~> 5.5)
github-markup
handlebars_assets
i18n
i18n-active_record
iiif-presentation
iiif_manifest
leaflet-rails
legato
mini_magick
nokogiri
oauth2
openseadragon
ostruct (!= 0.3.2, != 0.3.1, != 0.3.0)
paper_trail (>= 11.0, < 13)
rails (>= 6.1, < 8)
redcarpet (>= 2.0.1, < 4)
riiif (~> 2.0)
roar (~> 1.1)
roar-rails
signet
sprockets (>= 4)
tophat
view_component (~> 2.0)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -94,10 +139,6 @@ GEM
aws-sigv4 (~> 1.4)
aws-sigv4 (1.5.2)
aws-eventstream (~> 1, >= 1.0.2)
babel-source (5.8.35)
babel-transpiler (0.7.0)
babel-source (>= 4.0, < 6)
execjs (~> 2.0)
bcrypt (3.1.18)
better_html (2.0.1)
actionview (>= 6.0)
Expand Down Expand Up @@ -128,47 +169,6 @@ GEM
blacklight (>= 7.0, < 9)
rails
ruby-oembed
blacklight-spotlight (3.5.0.2)
activejob-status
acts-as-taggable-on (>= 5.0, < 10)
autoprefixer-rails
blacklight (~> 7.18)
blacklight-gallery (>= 3.0, < 5)
bootstrap_form (~> 4.1)
breadcrumbs_on_rails (>= 3.0, < 5)
cancancan
carrierwave (~> 2.2)
clipboard-rails (~> 1.5)
devise (~> 4.1)
devise_invitable
faraday
faraday_middleware
friendly_id (~> 5.2, != 5.4.1, != 5.4.0)
github-markup
handlebars_assets
i18n
i18n-active_record
iiif-presentation
iiif_manifest
leaflet-rails
legato
mini_magick
nokogiri
oauth2
openseadragon
ostruct (!= 0.3.2, != 0.3.1, != 0.3.0)
paper_trail (>= 11.0, < 13)
rails (>= 6.1, < 8)
redcarpet (>= 2.0.1, < 4)
riiif (~> 2.0)
roar (~> 1.1)
roar-rails
signet
sprockets (>= 3)
sprockets-es6
thor
tophat
underscore-rails (~> 1.6)
blacklight_range_limit (8.2.3)
blacklight (>= 7.25.2, < 9)
bootsnap (1.16.0)
Expand Down Expand Up @@ -305,31 +305,12 @@ GEM
factory_bot_rails (6.2.0)
factory_bot (~> 6.2.0)
railties (>= 5.0.0)
faraday (1.10.3)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0)
faraday-multipart (~> 1.0)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.0)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
faraday-retry (~> 1.0)
faraday (2.7.4)
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
faraday_middleware (1.2.0)
faraday (~> 1.0)
faraday-follow_redirects (0.3.0)
faraday (>= 1, < 3)
faraday-net_http (3.0.2)
ffi (1.15.5)
ffi-compiler (1.0.1)
ffi (>= 1.0.0)
Expand Down Expand Up @@ -380,11 +361,14 @@ GEM
activesupport (>= 3.2.18)
faraday (>= 0.9)
json
iiif_manifest (1.3.0)
iiif_manifest (1.3.1)
activesupport (>= 4)
image_processing (1.12.2)
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3)
importmap-rails (1.1.5)
actionpack (>= 6.0.0)
railties (>= 6.0.0)
io-console (0.6.0)
irb (1.6.2)
reline (>= 0.3.0)
Expand Down Expand Up @@ -440,7 +424,6 @@ GEM
msgpack (1.6.0)
multi_json (1.15.0)
multi_xml (0.6.0)
multipart-post (2.3.0)
net-imap (0.3.4)
date
net-protocol
Expand Down Expand Up @@ -667,10 +650,6 @@ GEM
sprockets (4.2.0)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
sprockets-es6 (0.9.2)
babel-source (>= 5.8.11)
babel-transpiler
sprockets (>= 3.0.0)
sprockets-rails (3.4.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
Expand Down Expand Up @@ -704,7 +683,6 @@ GEM
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
uber (0.1.0)
underscore-rails (1.8.3)
unf (0.1.4)
unf_ext
unf_ext (0.0.8.2)
Expand Down Expand Up @@ -744,7 +722,7 @@ DEPENDENCIES
blacklight-gallery (~> 4.0)
blacklight-hierarchy
blacklight-oembed (>= 0.1.0)
blacklight-spotlight (~> 3.1)
blacklight-spotlight (~> 3.1)!
blacklight_range_limit (~> 8.0)
bootsnap (>= 1.4.4)
bootstrap (~> 4.0)
Expand All @@ -767,6 +745,7 @@ DEPENDENCIES
i18n-js (< 4)
i18n-tasks
iiif-presentation (~> 1.0)
importmap-rails (~> 1.1)
jbuilder (~> 2.7)
jquery-rails
lograge
Expand Down
9 changes: 8 additions & 1 deletion app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
//= link_tree ../images
//= link_directory ../javascripts .js
//= link application.css
//= link spotlight/manifest.js
//= link_tree ../../javascript .js
//= link_tree ../../../vendor/javascript .js

// needed for import map pin_all_under
//= link spotlight/application.js
//= link spotlight/spotlight.esm.js
//= link spotlight/spotlight.js
32 changes: 0 additions & 32 deletions app/assets/javascripts/application.js

This file was deleted.

45 changes: 45 additions & 0 deletions app/javascript/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
import jQuery from 'jquery'
window.jQuery = jQuery
window.$ = jQuery

console.log("JQURY imported")
import 'bootstrap'
import "@hotwired/turbo-rails"
import L from 'leaflet'
window.L = L
import SirTrevor from 'sir-trevor'
window.SirTrevor = SirTrevor
import Clipboard from 'clipboard'
window.Clipboard = Clipboard

// We can probably ditch this dynamic import once we use Blacklight 8
import('blacklight/blacklight')
import('spotlight/spotlight.esm').then((Spotlight)=> {
console.log('spotlight defined')
window.Spotlight = Spotlight
})

import {I18n} from 'i18n-js'
window.I18n = I18n

//= require rails-ujs
//= require turbolinks
//
//
// Required by Blacklight
//= require jquery3
//= require popper
//= require twitter/typeahead
//= require bootstrap
//= require bootstrap/util
//= require blacklight/blacklight

//= require transform_result
//= require i18n/translations
// require_tree .


// For blacklight_range_limit built-in JS, if you don't want it you don't need
// this:
//= require 'blacklight_range_limit'
54 changes: 54 additions & 0 deletions app/views/layouts/spotlight/base.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!DOCTYPE html>
<%= content_tag :html, class: 'no-js', **(try(:html_tag_attributes) || {}) do %>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<%= render partial: 'shared/analytics' %>
<title><%= h(@page_title || application_name.to_s) %></title>
<link href="<%= current_exhibit ? spotlight.opensearch_exhibit_catalog_url(current_exhibit, format: 'xml') : main_app.opensearch_catalog_url(format: 'xml') %>" title="<%= h(@page_title || application_name.to_str) %>" type="application/opensearchdescription+xml" rel="search"/>
<%= favicon_link_tag 'favicon.ico' %>
<% if current_exhibit %>
<%= exhibit_stylesheet_link_tag "application" %>
<% else %>
<%= stylesheet_link_tag "application" %>
<% end %>

<%#= javascript_include_tag "application" %>
<%= javascript_importmap_tags %>
<%= csrf_meta_tags %>
<%= content_for(:head) %>
<%= description %>
<%= twitter_card %>
<%= opengraph %>
<%= javascript_tag "window.addEventListener('load', () => Spotlight.sirTrevorIcon = '#{asset_path('spotlight/blocks/sir-trevor-icons.svg')}')" %>
<%= javascript_tag '$.fx.off = true;' if Rails.env.test? %>
</head>
<body class="<%= render_body_class %>">
<%= render partial: 'shared/body_preamble' %>
<div id="skip-link">
<% if should_render_spotlight_search_bar? %>
<%= link_to t('blacklight.skip_links.search_field'), '#search_field', class: 'element-invisible element-focusable rounded-bottom py-2 px-3', data: { turbolinks: 'false' } %>
<% end %>
<%= link_to t('blacklight.skip_links.main_content'), '#main-container', class: 'element-invisible element-focusable rounded-bottom py-2 px-3', data: { turbolinks: 'false' } %>
<%= content_for(:skip_links) %>
</div>

<%= render partial: 'shared/header_navbar' %>
<%= render partial: 'shared/masthead' %>
<%= content_for?(:header_content) ? yield(:header_content) : "" %>

<main id="main-container" class="<%= container_classes %>" role="main" aria-label="<%= t('blacklight.main.aria.main_container') %>">
<%= content_for(:container_header) %>

<%= render partial: 'shared/flash_msg', layout: 'shared/flash_messages' %>

<div class="row">
<%= content_for?(:content) ? yield(:content) : yield %>
</div>
</main>

<%= render partial: 'shared/footer' %>
<%= render partial: 'shared/modal' %>
</body>
<% end %>
7 changes: 5 additions & 2 deletions app/views/shared/_i18n_js.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<%= javascript_tag do %>
I18n.defaultLocale = "<%= I18n.default_locale %>";
I18n.locale = "<%= I18n.locale %>";
window.addEventListener('load', () => {
console.log("SPOT", window.Spotlight)
I18n.defaultLocale = "<%= I18n.default_locale %>";
I18n.locale = "<%= I18n.locale %>";
})
<% end %>
4 changes: 4 additions & 0 deletions bin/importmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby

require_relative "../config/application"
require "importmap/commands"
Loading