Service for showing the Crossmark dialog and serving up assets.
The server (i.e. the 'Crossmark service') is versioned, and the version number can be found in the project.clj file. Major, minor and point release numbers are used. This is the version of the service, which serves up both the widget code and the contents of the dialog. There is only one current version of Crossmark service.
The widget itself is versioned. Major and minor versions are used, and correspond to the current server version, but point releases are not used. This is because the script must be referenced explicitly in the publisher's site when they embed the version. A major or minor release requires a publisher to change their HTML, which should happen very infrequently. As such, point releases are not reflected in the version as indicated in the path of the script. However, the full version is included in the content of the script.
A CDN should be provided for assets, mirroring the URLs on this service. The CDN ensures that hotlinked assets, such as the logo image and the widget script, load fast. The CDN should cache assets for no longer than 24 hours (and optionally be invalidated on a deploy).
The widget script should be hotlinked directly to the CDNed version, not rehosted. The technical documentation for Crossmark includes instructions for how to implement Crossmark on a page. It's important to know when an out-of-date script is being used because out-of-date versions may not include bugfixes.
When the script is served, a signed JWT is included that indicates when the script was generated. When served through a CDN this will be cached, so the script will always contain a cryptographically verifiable tag of when it was originally served up. This is passed back to the service when the dialog is called. The script verification functionality will raise an error when a script older than 5 days is used, leaving a few days' grace.
Configuration is done via environment variables.
PORT - port to run server onCDN_URL - public URL of CDN, e.g. https://crossmark-cdn.crossref.org. For development, should be set to e.g. http://localhost:8000.CROSSMARK_SERVER - public url of where this service is running, e.g. https://crossmark.crossref.org. For development, should be set to e.g. http://localhost:8000.JWT_SECRET - a secret for encoding JWTsAPI_BASE - custom base of REST API. Defaults to https://api.crossref.orgPUSH_URL - URL for reporting statsPUSH_TOKEN - token for reporting statusThe server can be deployed either running directly or via Docker.
run.sh.exampleRun via Docker Swarm, or create a docker-compose.yml file with above environment variables.
Run the server:
time docker-compose run --service-ports -w /usr/src/app test lein run
Then visit, e.g.:
http://localhost:8000/dialog?doi=10.1016/j.earscirev.2013.04.010
Tests are split into two categories:
To run server tests:
time docker-compose run -w /usr/src/app test lein test
For browser tests PhantomJS must be installed. This runs on the host machine (for now).
Run the server in the background:
time docker-compose run --service-ports -w /usr/src/app test lein run
Then run tests:
phantomjs js-tests/tests.js
Errors are reported on console, plus a nonzero exit code for any failure.
Tests are written in js-tests/tests.js with accompanying HTML files in the resources/test directory. Each HTML file makes a callback to say that it's ready. See examples.
Run code quality check:
time docker-compose run -w /usr/src/app test lein eastwood
Code coverage from running all tests. Results are found in target/coverage.
lein cloverage
Test stubs are marked with the :todo tag.
Pre-release check everything. Don't release unless this passes!
./check.sh
Copyright © Crossref
Distributed under the The MIT License (MIT).
Content type
Image
Digest
Size
93.7 MB
Last updated
almost 8 years ago
docker pull crossref/crossmark