Skip to content

Embed a JS search form to your Primo (new) UI in any webpage.

Notifications You must be signed in to change notification settings

NYULibraries/bess-vue

Repository files navigation

Bess Vue

CircleCI

Embed a JS search form to your Primo (new) UI in any webpage.

Example image of bess-vue


Usage

<!-- container where embeddable search will be injected -->
<div id="bess_vue_container_nyuad"></div>
<!-- ensure that the injectable element's id matches the element_id value in query string -->
<script type="text/javascript" id="bess_vue" src="https://cdn.library.nyu.edu/bess-vue/app.min.js?institution=NYUAD&element_id=bess_vue_container_nyuad">
</script>
<!-- Component comes unstyled. Optionally embed CSS. -->
<!-- NOTE: See "Project rename: primo-explore-search-embed to bess-vue" in this
           README for the reason why the previous widget name primo-explore-search-embed
           is being used for the CSS file name. -->
<link type="text/css" rel="stylesheet" href="https://cdn.library.nyu.edu/bess-vue/primo_explore_search_embed.min.css" />

Prerequisites

  • Node 18 or higher (nvm recommended)

Getting started


Install

git clone git@github.com:NYULibraries/bess-vue.git
cd bess-vue/
npm install

Build

Build for distribution. The components self-configure based on Vite mode (see Vite Modes). Currently two modes are supported: dev and prod. Builds can be run in watch mode: Rebuild on files changes

npm run build:dev
npm run build:prod
# Trigger rebuild on file changes
npm run build:dev:watch
npm run build:prod:watch

Using Docker Compose:

docker compose up build-dev
docker compose up build-prod
# Trigger rebuild on file changes
docker compose up build-dev-watch
docker compose up build-prod-watch

Run in dev server with HMR

npm run dev:nyu
npm run dev:nyuad
npm run dev:nyush
npm run dev:nyu-home

Using Docker Compose:

docker compose up dev-nyu
docker compose up dev-nyuad
docker compose up dev-nyush
docker compose up dev-nyu-home

Preview configurations for all institutions on one page

Open file index-all-institutions.html directly in a browser. This HTML page contains instances for all institution configurations on a single page, loaded from the local repo clone and un-styled.


View dev CDN build in sample institution HTML pages

There aren't always live dev instances of the websites that use bess-vue, and in cases where there are dev instances, we don't always have the ability configure them to load bess-vue from the dev CDN in order to preview changes. We can work around this limitation somewhat but making use of local overrides.

For Chromium-based browsers:


ESLint

Fix ESLint errors

To fix all ESLint errors in files for which we enforce ESLint rules:

npm run eslint:fix

Using Docker Compose:

docker compose up eslint-fix

Tests

npm run test

Using Docker Compose:

docker compose up test

References


Caveats

Do not put <style> tags in SFCs

  • vite injects a <style> tag into the HTML containing the compiled CSS from the Vue SFCs, which causes no problems when developing locally w/ HMR or viewing the viewing the embedded widgets in index-all-institutions.html, but when embedding the widget in a web page that does not opt to use the styles from the project, this injected <style> tag can override the intended styles from that web page's stylesheets and <style> tags.
  • This injection happens in both development and production mode. rollupOptions.output.assetFileNames in vite.config.js ensures the creation of the CSS file in dist/, but does not suppress the injection of the <style> tag. There does not appear to be any build option for turning off injection. The solution is to put all CSS into public/primo_explore_search_embed.min.css, which is effectively copied directly into dist/.
  • TODO: See if this feature can be used to achieve what we want: Disabling CSS injection into the page

HMR and --watch of vite build might not work on some machines and in some Docker containers

Must use Node 18 in Dockerfile due to npm install error in Docker: "npm ERR! network request to https://registry.npmjs.org/[WHATEVER] failed"

browser-overrides/ are not automatically kept up to date

  • The browser-overrides/ files should not be considered authoritative. We do not currently have an automated process for updating them. They may break or become stale at any time.
  • The globalhome.nyu.edu override in particular can break completely at any moment because the web page currently loads chunked assets whose hashes change. Note that globalhome injects the <script> tag for bess-vue into the HTML via JavaScript in the js/chunk-[HASH].js file. When updating the override, search for "cdn.library.nyu.edu" in the new chunk file and change it to "cdn-dev.library.nyu.edu". Delete the <script> tag in the downloaded HTML and also delete the old chunk file. As with any of the overrides, this procedure could become obsolete at any time.

Project rename: primo-explore-search-embed to bess-vue

This project was renamed bess-vue in 10/2022. The original name for this project was primo-explore-search-embed, which could at times cause a little confusion given it shared a prefix with the Primo customization packages. Internally the project/widget was referred to as BESS, so a decision was made to make this the official name. Note that there is one reference which was not changed - the name of the compiled CSS file. The HTML of the websites that have already embedded this widget and are linking to the CSS file cannot easily be changed by us.

About

Embed a JS search form to your Primo (new) UI in any webpage.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published