Blacklight collections creation and installation notes¶
After the Muscat team decided to remove Blacklight from Muscat (https://github.com/rism-digital/muscat/discussions/1113), we need a Blacklight for our own. Blacklight is not a self-contained Rails application (https://github.com/projectblacklight/blacklight#installation), but an Engine (https://guides.rubyonrails.org/engines.html) that needs a "host" application that runs it.
Great. This allows us to create a collection naviation Rails application and insert Blacklight in it.
Create the new application¶
Let's use a current Ruby and Rails version Ruby_for_Invenio_admins:
traces_muscat@taltabull:~/blacklight$ chruby ruby-3.1.2
traces_muscat@taltabull:~/blacklight$ which ruby
/opt/rubies/ruby-3.1.2/bin/ruby
traces_muscat@taltabull:~/blacklight$ which rails
/opt/rubies/ruby-3.1.2/bin/rails
traces_muscat@taltabull:~/blacklight$ rails new collections
create
create README.md
create Rakefile
create .ruby-version
create config.ru
create .gitignore
create .gitattributes
create Gemfile
run git init from "."
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
Initialized empty Git repository in /home/traces_muscat/blacklight/collections/.git/
create app
create app/assets/config/manifest.js
create app/assets/style
sheets/application.css
[...]
I'm reproducing the steps here. So if it is easier to recreate the application rather than upgrade Rails, it can be done following the steps and importing the patches:
traces_muscat@taltabull:~/blacklight/collections (main)$ echo /vendor >>.gitignore
traces_muscat@taltabull:~/blacklight/collections (main)$ cat .ruby-version
ruby-3.1.2
traces_muscat@taltabull:~/blacklight/collections (main)$ which ruby
/opt/rubies/ruby-3.1.2/bin/ruby
traces_muscat@taltabull:~/blacklight/collections (main)$ bin/rails --version
Rails 7.0.4
traces_muscat@taltabull:~/blacklight/collections (main)$ git add --all
traces_muscat@taltabull:~/blacklight/collections (main)$ git commit -m "Initial commit"
traces_muscat@taltabull:~/blacklight/collections (main)$ bin/rails generate scaffold Collection name:string:index:uniq titles:text webset:boolean oaiset:boolean query:string regular_subcollections:string virtual_subcollections:string descriptions:text recids:text
invoke active_record
create db/migrate/20221128085812_create_collections.rb
create app/models/collection.rb
invoke test_unit
create test/models/collection_test.rb
create test/fixtures/collections.yml
[...]
traces_muscat@taltabull:~/blacklight/collections (main)$ bin/rails db:migrate
== 20221128085812 CreateCollections: migrating ================================
-- create_table(:collections)
-> 0.0017s
-- add_index(:collections, :name)
-> 0.0007s
== 20221128085812 CreateCollections: migrated (0.0024s) =======================
traces_muscat@taltabull:~/blacklight/collections (main)$ git commit -a
Replicate the application for the other sites¶
<code class="shell"> ddd_muscat@taltabull:~/blacklight ddd_muscat@taltabull:~/blacklight$ git clone ~ifmuc_muscat/blacklight/collections/.git Cloning into 'collections'... done. ddd_muscat@taltabull:~/blacklight$ ls -l total 16 drwxr-xr-x 14 ddd_muscat muscat 4096 Dec 1 08:31 collections/ ddd_muscat@taltabull:~/blacklight$ cd collections chruby: unknown Ruby: ruby-3.1.2 # Exit the shell and re-login to solve this ddd_muscat@taltabull:~/blacklight/collections (main)$ ls -l total 72 -rw-r--r-- 1 ddd_muscat muscat 2789 Dec 1 08:31 Gemfile -rw-r--r-- 1 ddd_muscat muscat 9210 Dec 1 08:31 Gemfile.lock -rw-r--r-- 1 ddd_muscat muscat 374 Dec 1 08:31 README.md -rw-r--r-- 1 ddd_muscat muscat 290 Dec 1 08:31 Rakefile drwxr-xr-x 11 ddd_muscat muscat 4096 Dec 1 08:31 app/ drwxr-xr-x 2 ddd_muscat muscat 4096 Dec 1 08:31 bin/ drwxr-xr-x 6 ddd_muscat muscat 4096 Dec 1 08:31 config/ -rw-r--r-- 1 ddd_muscat muscat 160 Dec 1 08:31 config.ru drwxr-xr-x 3 ddd_muscat muscat 4096 Dec 1 08:31 db/ drwxr-xr-x 4 ddd_muscat muscat 4096 Dec 1 08:31 lib/ drwxr-xr-x 2 ddd_muscat muscat 4096 Dec 1 08:31 log/ drwxr-xr-x 2 ddd_muscat muscat 4096 Dec 1 08:31 public/ drwxr-xr-x 3 ddd_muscat muscat 4096 Dec 1 08:31 solr/ drwxr-xr-x 2 ddd_muscat muscat 4096 Dec 1 08:31 storage/ drwxr-xr-x 10 ddd_muscat muscat 4096 Dec 1 08:31 test/ drwxr-xr-x 4 ddd_muscat muscat 4096 Dec 1 08:31 tmp/ ddd_muscat@taltabull:~/blacklight/collections (main)$ bundle install Fetching gem metadata from https://rubygems.org/.......... Fetching rake 13.0.6 Installing rake 13.0.6 Using racc 1.6.0 [...] ddd_muscat@taltabull:~/blacklight/collections (main)$ bin/rails db:migrate == 20221130094714 CreateCollections: migrating ================================ -- create_table(:collections) -> 0.0016s -- add_index(:collections, :name) -> 0.0007s [...] </code>
Import Muscat (or Invenio) collections:
ddd_muscat@taltabull:~/blacklight/collections (main)$ bin/rails runner ~/bin/collectionsdb2blacklight.rb
Adjust Ruby version in the Apache configuration file:
RailsEnv development
PassengerRuby /opt/rubies/ruby-3.1.2/bin/ruby
DocumentRoot /home/ifmuc_muscat/blacklight/collections-current/public
<Directory /home/ifmuc_muscat/blacklight/collections-current/public>
Options All +Indexes -ExecCGI -Includes +MultiViews
Require all granted
</Directory>
If you see this error:
link_tree argument must be a directory Extracted source (around line #4): //= link_directory ../stylesheets .css //= link_tree ../../javascript .js //= link_tree ../../../vendor/javascript .js Trace of template inclusion: #<ActionView::Template vendor/bundle/ruby/3.1.0/gems/blacklight-7.32.0/app/views/layouts/blacklight.html.erb locals=[]>
It means that there is a missing (empty) directory in the vendor (imported) directory. Just create it:
ddd_muscat@taltabull:~/blacklight/collections (main)$ mkdir ./vendor/javascript <pre>
Actualitzat per Ferran Jorba fa més de 3 anys · 10 revisions