A javascript component that will display an ODRL offer in human-readable form.
Acronym | Description |
---|---|
ODRL | Open Digital Rights Language |
Start by installing the offer-viewer via npm:
npm install offer-viewer --save
The Offer viewer uses bootstrap components and class names. For details on how to customise the css of the Offer Viewer please refer to the Bootstrap documentation.
index.js
var OfferViewer = require('offer-viewer');
var offer = <json-ld offer>
new OfferViewer(offer);
index.html
<html>
<body>
<offer></offer>
</body>
</html>
index.js
var OfferViewer = require('offer-viewer');
var offer = <json-ld offer>
new OfferViewer(offer, tag='my-tag');
index.html
<html>
<body>
<my-tag></my-tag>
</body>
</html>
See index.html for sample usage.
The UI is implemented completely in JavaScript using Riot.js as an html templating framework
Download & install node & npm or use your package manager of choice e.g.
brew install node
npm install
A standalone version of the Offer Viewer can be generated. The standalone script will be built in the "dist" directory, and creates a OfferViewer
global when the script is included in a web page. To build the standalone script run
npm run build-standalone
or if you require automatic rebuild of the bundle whenever there are file changes, run
npm run build-standalone:watch
or if you require a minified version of the standalone build, run
npm run build-standalone:min
You need a web server to serve index.html. We recommend you use python's HTTP Server e.g:
python -m SimpleHTTPServer
You should be able to view the application at http://localhost:8000.
The offer-viewer has been published to npm under the OpenPermissions account. To publish a new version, increase the version number in package.json and run
npm publish ./
The UI is deployed to a S3 bucket, so you need the AWS_ACCESS_KEY_ID
and
AWS_SECRET_ACCESS_KEY
to be in the environment or defined in the
deploy/config.json file using the accessKeyId
and
secretAccessKey
object keys (see the
docs).
To deploy run:
npm run deploy <S3_BUCKET>
Run the following commands to deploy to offer.digicat.io
npm install
npm run deploy offer.digicat.io