Skip to content

About

The frontend used for kb's digital collections, based on blacklight and SOLR

Resources

Stars

1 star

Watchers

8 watching

Forks

Repository files navigation

COP Frontend

Frontend for the COP, built with Ruby on Rails and Blacklight plus a Solr backend.

The application provides the web interface for searching and browsing COP editions. Search and record data are retrieved from a Solr backend.

Architecture

The application consists primarily of:

  • Ruby on Rails 5.1.7 — web application and frontend
  • Blacklight 6.20.0 — search interface and Solr integration
  • Solr — backend search/index containing COP edition data
  • Puma 4.3.12 — development web server
  • SQLite — local Rails development database

Run with Docker (recommended for development)

Everything (Ruby 2.6.5, Bundler 1.17.2, all gems and native build deps) is installed in the image; you only need Docker with Compose.

docker compose --file docker/compose.yaml up --build

Open http://localhost:3000. The source is bind-mounted, so edits are picked up without a restart (allow a few seconds). Migrations run automatically on start.

  • Solr: by default the app uses the KB-internal cop-devel-01.kb.dk Solr, so you must be on the KB network/VPN. Point elsewhere with SOLR_URL=http://host:port/solr/core docker compose --file docker/compose.yaml up.
  • Port taken? COP_PORT=3001 docker compose --file docker/compose.yaml up publishes on another host port.
  • After changing Gemfile/Gemfile.lock: docker compose --file docker/compose.yaml build.
  • Rails console: docker compose --file docker/compose.yaml exec web bin/rails console.
  • byebug: run docker compose --file docker/compose.yaml up -d, then docker compose --file docker/compose.yaml attach web (detach with Ctrl-p Ctrl-q).
  • Reset the dev database: docker compose --file docker/compose.yaml run --rm web bin/rails db:reset.
  • Shorter commands: export COMPOSE_FILE=docker/compose.yaml in the repo root lets you drop --file docker/compose.yaml.
  • The image is linux/amd64 only (therubyracer's libv8 has no ARM build); on ARM machines it runs under emulation.

The manual setup below is the alternative to Docker.

Requirements

The repository is an older Rails application and requires specific versions of Ruby and Bundler.

Required versions

Dependency Version
Ruby 2.6.5
Bundler 1.17.2
Rails 5.1.7
Blacklight 6.20.0
Puma 4.3.12

The exact Ruby and Bundler versions are also reflected in Gemfile.lock.

You will need:

  • Git
  • Ruby 2.6.5
  • Bundler 1.17.2
  • Node/npm are not required to run the Rails application

The easiest way to manage Ruby versions is rbenv.


Getting started

1. Clone the repository

git clone https://github.com/kb-dk/COP-frontend.git
cd COP-frontend

2. Install rbenv

On Ubuntu:

sudo apt update
sudo apt install rbenv ruby-build

If the Ubuntu ruby-build package is too old to provide Ruby 2.6.5, install/update ruby-build from the upstream project.

After installing rbenv, make sure it is initialized in your shell.

Check that it works:

rbenv --version

3. Install Ruby 2.6.5

From the repository:

rbenv install 2.6.5

You might run into problems here if you're on a newer version of Ubuntu (26.04 or above). To remove the errors, do this intall instead:

export CFLAGS="-std=gnu11 -Wno-error=incompatible-pointer-types"
export RUBY_CONFIGURE_OPTS="--disable-jit-support"
rbenv install 2.6.5

If it is already installed, this step can be skipped.

Set Ruby 2.6.5 as the Ruby version for this project only:

rbenv local 2.6.5

If you're using a newer Ubuntu version (26.04 or newer), you may need to add rbenv to your PATH manually in ~/.bashrc:

export PATH="$HOME/.rbenv/bin:$PATH"

After adding it, reload your shell configuration:

source ~/.bashrc

This creates a .ruby-version file.

Verify:

ruby --version

You should see something similar to:

ruby 2.6.5p114

Using rbenv local is preferable to changing your global Ruby version, since other projects may require newer Ruby versions.


4. Install the correct Bundler version

The project uses Bundler 1.17.2:

gem install bundler -v 1.17.2

Verify:

bundle _1.17.2_ --version

Expected:

Bundler version 1.17.2

5. Install the Ruby dependencies

From the repository root:

bundle _1.17.2_ install

Again, on newer Ubuntus (26.04 and above), you might run into problems here. If you do, you should run the install command with the following flags:

bundle config build.sqlite3 --with-cflags="-Wno-error=incompatible-pointer-types -Wno-error=int-conversion -std=gnu99"
bundle _1.17.2_ install

This installs the dependencies specified by the Gemfile and Gemfile.lock.

6. Set up the local database

The first time the application is started, Rails may report:

ActiveRecord::PendingMigrationError

If so, run:

bundle _1.17.2_ exec rails db:migrate

You normally only need to do this once, unless new migrations are added.


Start the application

Start the Rails development server:

bundle _1.17.2_ exec rails server

You should see something similar to:

=> Booting Puma
=> Rails 5.1.7 application starting in development
* Version 4.3.12 (ruby 2.6.5-p114)
* Listening on tcp://127.0.0.1:3000

Open:

http://localhost:3000

About

The frontend used for kb's digital collections, based on blacklight and SOLR

Resources

Stars

1 star

Watchers

8 watching

Forks

Releases

Packages

Used by

Contributors

Languages