npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tabula-rasa

v1.0.9

Published

Node.js SDK for IIIF Presentation API

Downloads

14

Readme

Tabula Rasa

Build Status

Tabula Rasa is a Node.js SDK (aka, "starter kit") for working with IIIF Presentation API resources (i.e., collections, manifests, canvases, etc.).

It was originally developed as a base library for Tabula, which can be used to create all sorts of useful native web apps that work with IIIF APIs. However, it can just as easily be used on the server to create and edit IIIF Presentation API resources.

About Tabula Rasa

Tabula Rasa is written in ES2015 and transpiled down to good old JavaScript (ES5) so that it can be distributed as an npm module and run in web browsers. Similar Presentation API SDKs exist for other languages:

Tabula Rasa has a few additional features that distinguish it from the libraries listed above. You may find these helpful, depending on your needs.

Persistance via RESTful APIs

Because Tabula Rasa collections and models are based on Ampersand/Backbone, we get fetch() and save() methods on all our objects. The ability to create IIIF resources from external endpoints comes in handy in a variety of scenarios. For example, you can easily test your application against the current collection of official fixtures from the IIIF website. You can also easily edit IIIF resources from any endpoint (and save them back if the endpoint supports it), or even stitch resources together from multiple endpoints. If you like Manifesto convenience methods you can use Tabula Rasa for only setters if you want. See this sample app for an example of how to do that.

Object Observability

The IIIF Presentation API is intended for front-end use. Native Web applications need to manage the state of both objects, and the interfaces used to manipulate these objects. Observability is the best way to separate concerns when managing state and, again, as an extension of Ampersand models and collections (which are extensions of ampersand-state), Tabula Rasa objects and models emit a JavaScript event when they are changed. This makes it easy to know when to update any views in your application.

Node.js: Frontend and Backend

npm (along with its command line tool, the npm-client) is the official package manager for node.js, but it works great for client-side JavaScript too. It helps you publish, consume, and manage modules of JavaScript code in your applications.

commonjs modules are a specification and implementation of a module system in JavaScript. They allow you to separate functionality into separate files or npm modules, that can then require each other. This makes it much easier to break the functionality of your application up into smaller chunks, that can depend on each other, rather than writing your code in one giant file.

You can use tools like Browserify or Webpack that take an application written with commonjs and npm modules, and bundle it up into a single file, that you can then use in a browser.

Getting Started

If you want to use the good old Javascript version, simply include it in your project by installing the npm module:

npm install --save tabula-rasa

Usage

Once it's installed, you can include it and start building IIIF Presentations. See below for details, or play with it on the web a the Tabula Rasa Tonic demo.

var Presentation = require("tabula-rasa")

// create a collection
var c = new Presentation.Collections.Collection()

// create sub-collections
var c1 = new Presentation.Collections.Collection( { _id: 'c1', '@id': 'https://somedomain.com/c1', label: "Collection 1" } )
var c2 = new Presentation.Collections.Collection( { _id: 'c2', '@id': 'https://somedomain.com/c2', label: "Collection 2" } )
var c3 = new Presentation.Collections.Collection( { _id: 'c3', '@id': 'https://somedomain.com/c3', label: "Collection 3" } )

// add sub collections to the first collection
c.collections.add([c1,c2])

// add a sub-collection to a sub-collection
c.collections.get('c1').collections.add([c3])

// add some manifests to the root collection
c.manifests = new TabulaRasa.ManifestList()

c.manifests.add([
  { _id: 'foo', '@id': 'bar', label: 'Manifest 1'},
  { _id: 'fez', '@id': 'baz', label: 'Manifest 2'}
])

// get manifest by internal id and by json-ld @id
console.log(c.manifests.get('foo').label) //=> 'Manifest 1'
c.manifests.get('baz', '@id').label //=> 'Manifest 2'

// fetch from an endpoint (works in browser console, but requires promises to implement)
c.url = 'http://iiif.io/api/presentation/2.0/example/fixtures/collection.json'
c.fetch()
console.log(c.manifests.get('http://iiif.io/api/presentation/2.0/example/fixtures/1/manifest.json', '@id').label[0]['@value']) //=> 'Test 1 Manifest: Minimum Required Fields'

Tests

Tabula Rasa uses Standard to enforce a simple code style. Unit tests are run with Tape.

npm test

Contribute

This library is fairly new. Please report bugs and/or contribute fixes. If you would like to contribute a pull request, you will need to make sure you create the appropriate tests and adhere to the standard style guide.