Collections Online
JavaScript HTML CSS
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
auth
bin adds tests for document tree #311 Sep 15, 2016
client
description-boxes update railway museum logo and urls Apr 18, 2018
fixtures use unicode for emdash Jul 30, 2018
handlers
lib use _lower in ES query for categories Jul 26, 2018
public Adds a promo block for railway-photographic-collection to homepage Jul 28, 2018
routes Update routes/index.js (post merge) Jul 17, 2018
schemas reduce paginatin to 10 pages Nov 20, 2017
scripts
templates
test Update test Jul 26, 2018
.corc.template refs #299 Proxy to sitemap on s3 bucket Aug 19, 2016
.editorconfig
.gitignore Merge branch 'master' of github.com:TheScienceMuseum/collectionsonline Jul 13, 2018
.travis.yml
LICENSE Updated the licencee Jun 14, 2016
README.md Update README.md Oct 12, 2017
config.js add GA only in production, #680 Dec 5, 2016
nightwatch.conf.js downloads selenium server on postinstall #116 Jun 29, 2016
package.json Abstract passing of 360 path to embed code Jul 12, 2018
server.js adds images for 404 page #893 Jul 3, 2017

README.md

Build Status Dependency Status Coverage Status

Science Museum Group: Collections Online

Getting started

  1. Install Node.js version 7 or 8
  2. Install dependencies: npm install
  3. Copy .corc.template to .corc in the project route
  4. Add required config values to .corc
  5. Start the server: npm start

Or use npm run watch to rebuild and restart the server as you edit things.

Testing

Use npm test to run all the tests (including linting).

There are two types of tests that can be run: unit and end-to-end. These can be run individually by running npm run test:unit and/or npm run test:endtoend.

Unit tests

By default, npm run test:unit syncs fixtures from the live index so you need to have a correctly configured .corc file pointing at the latest elasticsearch server.

Offline

Use npm run test:unit:tape to run the unit tests using the existing fixtures provided in the repo.

End-to-end tests

The end-to-end tests require an instance of the application to be running on http://localhost:8000.

Directory structure

.
├── bin         # Executable(s) for starting the server etc.
├── lib         # Shared modules
├── public      # Public resources exposed by the server
├── routes      # API routes
├── schemas     # Joi schemas for input validation
├── templates   # Handlebars templates - layouts, pages, partials and helpers
└── test        # Unit and integration tests

Collections

Index types

The following main 3 document types are available in the index:

  • Agent
  • Object
  • Archive

Other document types:

  • Location (museum location / gallery)
  • Event (historical)
  • Place (geographical)
  • Term (thesaurus term)

Display names

The name of the index types isn't always obvious to the public so on the site they are mapped as follows:

  • People => Agent
  • Objects => Object
  • Documents => Archive
  • Location => Facility

Routes

To access the pages we currently have templates for, use:

  • /
  • /search?q={query}
  • /objects/{id}/{slug?}
  • /people/{id}/{slug?}
  • /documents/{id}/{slug?}

The routes will not work without params, however any random string will lead you to the example pages.

Deployment

We use Travis for CI and production deployment. The .travis.yml file in the root directory contains configuration for deployments.

Setup CI

Follow these steps to setup a new CI environment:

  • Create an elasticbeanstalk Node.js app in the eu-west-1 region

    • Make a note of the application name and environment name (you'll need this later)
  • Get the name of the S3 bucket it creates

    • It will look like elasticbeanstalk-eu-west-1-431258931377
  • Create an IAM user smg-collectionsonline-deploy-travis

    • Save the access key and secret (you'll need this later)
  • Create an IAM group smg-collections-online-deploy

  • Add the following inline policy (named: DeployPolicy) to the group, substituting the resource values appropriately:

    {
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "elasticbeanstalk:Check*",
                    "elasticbeanstalk:Describe*",
                    "elasticbeanstalk:List*",
                    "elasticbeanstalk:RequestEnvironmentInfo",
                    "elasticbeanstalk:RetrieveEnvironmentInfo",
                    "ec2:Describe*",
                    "elasticloadbalancing:Describe*",
                    "autoscaling:Describe*",
                    "cloudwatch:Describe*",
                    "cloudwatch:List*",
                    "cloudwatch:Get*",
                    "s3:Get*",
                    "s3:List*",
                    "sns:Get*",
                    "sns:List*",
                    "cloudformation:Describe*",
                    "cloudformation:Get*",
                    "cloudformation:List*",
                    "cloudformation:Validate*",
                    "cloudformation:Estimate*",
                    "rds:Describe*",
                    "sqs:Get*",
                    "sqs:List*"
                ],
                "Resource": "*"
            },
            {
                "Effect": "Allow",
                "Action": "s3:*",
                "Resource": [
                    "arn:aws:s3:::elasticbeanstalk-eu-west-1-431258931377",
                    "arn:aws:s3:::elasticbeanstalk-eu-west-1-431258931377/*"
                ]
            },
            {
                "Effect": "Allow",
                "Action": "elasticbeanstalk:*",
                "Resource": "arn:aws:elasticbeanstalk:eu-west-1:431258931377:*"
            },
            {
                "Effect": "Allow",
                "Action": "elasticbeanstalk:UpdateEnvironment",
                "Resource": "arn:aws:elasticbeanstalk:eu-west-1:431258931377:environment/Default-Environment/My First Elastic Beanstalk Application"
            },
            {
                "Effect": "Allow",
                "Action": "cloudformation:*",
                "Resource": "arn:aws:cloudformation:eu-west-1:431258931377:*"
            },
            {
                "Effect": "Allow",
                "Action": [  
                    "autoscaling:SuspendProcesses",
                    "autoscaling:ResumeProcesses"
                ],
                "Resource": "*"
            },
            {
                "Effect": "Allow",
                "Action": "elasticloadbalancing:*",
                "Resource": "arn:aws:elasticloadbalancing:eu-west-1:431258931377:*"
            }
        ]
    }
  • Create a .travis.yml in the project root and add the following:

    language: node_js
    
    node_js:
      - '4'
    
  • Install the Travis CLI tool

  • Run travis setup elasticbeanstalk

    $ travis setup elasticbeanstalk
    Access key ID: AKIAIYE5GN7RNPZSZELA
    Secret access key: ****************************************
    Elastic Beanstalk region: |us-east-1| eu-west-1
    Elastic Beanstalk application name: My First Elastic Beanstalk Application
    Elastic Beanstalk environment to update: Default-Environment
    Encrypt secret access key? |yes|
    Deploy only from TheScienceMuseum/collectionsonline? |yes|
  • Add the following to the travis config:

    • Zip up the built site before deploy
    before_deploy:
      - zip -q -x .git\* node_modules/\* -r collectionsonline *
    • Add the bucket name, zip file path and skip cleanup to the deploy section:
    deploy:
      bucket_name: elasticbeanstalk-eu-west-1-431258931377
      zip_file: collectionsonline.zip
      skip_cleanup: true
  • In AWS elasticbeanstalk navigate to "Software Configuration" for the app

    • Add npm start as the "Node command"
    • Add config as environment vars to the new apps:
      • co_rootUrl
      • co_elasticsearch__host

Development Notes

Scripts

Some scripts need to be run whenever the index is updated. To do this run the command:

npm run index-update


Browser testing courtesy of BrowserStack

BrowserStack logo