Skip to content

neurocracy/drupal-omnipedia-site-theme

Repository files navigation

This contains the source files for the Omnipedia Drupal theme.

⚠️ Why open source? / Spoiler warning


Requirements

Drupal dependencies

Before attempting to install this, you must add the Composer repositories as described in the installation instructions for these dependencies:

Front-end dependencies

To build front-end assets for this project, Node.js and Yarn are required.


Installation

Composer

Set up

Ensure that you have your Drupal installation set up with the correct Composer installer types such as those provided by the drupal/recommended-project template. If you're starting from scratch, simply requiring that template and following the Drupal.org Composer documentation should get you up and running.

Repository

In your root composer.json, add the following to the "repositories" section:

"drupal/omnipedia_site_theme": {
  "type": "vcs",
  "url": "https://github.com/neurocracy/drupal-omnipedia-site-theme.git"
}

Installing

Once you've completed all of the above, run composer require "drupal/omnipedia_site_theme:^7.0@dev" in the root of your project to have Composer install this and its required dependencies for you.

Front-end assets

To build front-end assets for this project, you'll need to install Node.js and Yarn.

This package makes use of Yarn Workspaces and references other local workspace dependencies. In the package.json in the root of your Drupal project, you'll need to add the following:

"workspaces": [
  "<web directory>/themes/custom/*"
],

where <web directory> is your public Drupal directory name, web by default. Once those are defined, add the following to the "dependencies" section of your top-level package.json:

"drupal-omnipedia-site-theme": "workspace:^6"

Then run yarn install and let Yarn do the rest.

Optional: install yarn.BUILD

While not required, yarn.BUILD is recommended to make building all of the front-end assets even easier.

Optional: use nvm

If you want to be sure you're using the same Node.js version we're using, we support using Node Version Manager (nvm) (Windows port). Once nvm is installed, you can simply navigate to the project root and run nvm install to install the appropriate version contained in the .nvmrc file.

Note that if you're using the Windows port, it does not support .nvmrc files, so you'll have to provide the version contained in the .nvmrc as a parameter: nvm install <version> (without the < and >).

This step is not required, and may be dropped in the future as Node.js is fairly mature and stable at this point.


Building front-end assets

This uses Webpack and Symfony Webpack Encore to automate most of the build process. These will have been installed for you if you followed the Yarn installation instructions above.

If you have yarn.BUILD installed, you can run:

yarn build

from the root of your Drupal site. If you want to build just this package, run:

yarn workspace drupal-omnipedia-site-theme run build

Breaking changes

The following major version bumps indicate breaking changes:

  • 3.x - Changed Composer installer type to drupal-custom-theme; moved theme contents into root directory; renamed theme from omnipedia_site to omnipedia_site_theme for clarity.

  • 4.x - Front-end dependencies now installed via Yarn, removing all use of Asset Packagist; front-end build process ported to Webpack.

  • 5.x - Requires Drupal 9.5 or Drupal 10.

  • 6.x:

  • 7.x:

    • Much of the front-end JavaScript has been heavily reworked and modernized as object-oriented and self-contained so that they don't reference elements or other instances outside of behaviours. This makes them more robust and allows repeated detaching and re-attaching.