Skip to content

Commit a06b1dd

Browse files
committed
Merge pull request #3 from sdellis/tabula-rasa
adds tabula-rasa (npm module) base extendable library
2 parents 108fbbc + 9133d18 commit a06b1dd

10 files changed

Lines changed: 66 additions & 128 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
=============================================================================
33
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
44

5+
_"Show, don't tell."_
6+
57
Tabula is a "starter kit" for native web applications (aka, "single-page apps") that make use of the IIIF Presentation API.
68

79
## About tabula

package.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
"build": "NODE_ENV=production webpack",
1010
"deploy": "surge -p public -d tabula.surge.sh",
1111
"yolo": "npm run build && npm run deploy",
12-
"test": "standard"
12+
"test": "babel-node node_modules/argg src/models/presentation/test/index.spec.js",
13+
"quiz": "webpack src/models/presentation/test/index.spec.js public/tabula.tests.js | ./node_modules/tape/bin/tape-run/run.js",
14+
"lint": "standard"
1315
},
1416
"repository": {
1517
"type": "git",
@@ -54,7 +56,6 @@
5456
"style-loader": "^0.12.1",
5557
"stylus-loader": "^1.1.0",
5658
"surge": "^0.11.1",
57-
"tape": "^4.2.2",
5859
"url-loader": "^0.5.5",
5960
"webpack": "^1.8.11",
6061
"webpack-dev-server": "^1.8.2",
@@ -65,5 +66,18 @@
6566
"ignore": [
6667
"public/*"
6768
]
69+
},
70+
"devDependencies": {
71+
"argg": "0.0.2",
72+
"istanbul-instrumenter-loader": "^0.1.3",
73+
"karma": "^0.13.15",
74+
"karma-chrome-launcher": "^0.2.2",
75+
"karma-coverage": "^0.5.3",
76+
"karma-phantomjs-launcher": "^0.2.1",
77+
"karma-tap": "^1.0.3",
78+
"karma-webpack": "^1.7.0",
79+
"phantomjs": "git://github.com/just-boris/phantomjs",
80+
"tape": "^4.2.2",
81+
"tape-run": "^2.1.0"
6882
}
6983
}

src/config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ const config = {
22
'ltopmacellis.local': {
33
clientId: '900ada97278b5f64a533',
44
gatekeeperUrl: 'https://tabula-localhost.herokuapp.com/authenticate',
5-
manifestStore: 'http://localhost:4000/collections/manifests'
5+
manifestStore: 'http://iiif.io/api/presentation/2.0/example/fixtures'
6+
// manifestStore: 'http://localhost:4000/collections/manifests'
67
},
78

89
'tabula.surge.sh': {

src/models/me.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Model from 'ampersand-model'
22
import RepoCollection from './annotation/repo-collection'
3-
import ManifestCollection from './presentation/manifest-collection'
3+
import Collection from './presentation/collection'
44
import githubMixin from '../helpers/github-mixin'
55

66
export default Model.extend(githubMixin, {
@@ -11,6 +11,9 @@ export default Model.extend(githubMixin, {
1111
this.on('change:token', this.onChangeToken)
1212
},
1313

14+
/* to-do: use a Gist to persist user data such as preferred language and
15+
|| possible endpoints to select content from
16+
*****/
1417
props: {
1518
id: 'number',
1619
login: 'string',
@@ -22,8 +25,11 @@ export default Model.extend(githubMixin, {
2225
},
2326

2427
collections: {
25-
repos: RepoCollection,
26-
presentations: ManifestCollection
28+
repos: RepoCollection
29+
},
30+
31+
children: {
32+
presentations: Collection
2733
},
2834

2935
onChangeToken () {

src/models/presentation/collection-collection.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/models/presentation/collection.js

Lines changed: 13 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,24 @@
1-
import Model from 'ampersand-model'
2-
import ManifestCollection from './manifest-collection'
3-
import IIIFCollection from './collection-collection'
4-
import ServiceCollection from './service-collection'
5-
import config from '../config'
1+
import {Collections} from 'tabula-rasa'
2+
import ManifestList from './manifest-collection'
3+
import uuid from 'node-uuid'
4+
import config from '../../config'
65

7-
export default Model.extend({
8-
9-
initialize () {
10-
this.getManifest // load the manifesto object into this.manifest
11-
},
12-
13-
idAttribute: '_id',
14-
15-
url () {
16-
return config.manifestStore + '/' + this._id
17-
},
6+
export default Collections.Collection.extend({
187

198
props: {
20-
_id: 'string',
21-
'@id': 'string',
22-
'@type': {
9+
'_id': {
2310
type: 'string',
2411
required: 'true',
25-
default: 'sc:Collection',
26-
test: function (value) {
27-
if (value !== 'sc:Collection') {
28-
return "Value must equal 'sc:Collection'."
29-
}
30-
return false
31-
}
32-
},
33-
label: 'string',
34-
logo: 'string',
35-
license: 'string',
36-
viewingHint: 'string',
37-
related: 'string',
38-
seeAlso: 'string',
39-
within: 'string',
40-
thumbnail: 'string',
41-
description: 'string',
42-
attribution: 'string',
43-
metadata: 'array'
12+
default: uuid()
13+
}
14+
},
15+
16+
url () {
17+
return config.manifestStore + '/collection.json'
4418
},
4519

4620
collections: {
47-
manifests: ManifestCollection,
48-
collections: IIIFCollection,
49-
services: ServiceCollection
21+
manifests: ManifestList,
5022
},
5123

5224
derived: {

src/models/presentation/manifest-collection.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import Collection from 'ampersand-rest-collection'
21
import Manifest from './manifest'
2+
import {ManifestList} from 'tabula-rasa'
33
import config from '../../config'
44

5-
export default Collection.extend({
6-
url: config.manifestStore,
7-
5+
export default ManifestList.extend({
86
model: Manifest,
97

108
getById (id) {
@@ -18,4 +16,5 @@ export default Collection.extend({
1816

1917
return model
2018
}
19+
2120
})

src/models/presentation/manifest.js

Lines changed: 16 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,50 @@
1-
import Model from 'ampersand-model'
1+
import {Manifest} from 'tabula-rasa'
22
import manifesto from '../../../node_modules/manifesto.js/dist/server/manifesto.js'
3-
import SequenceCollection from './sequence-collection'
43
import config from '../../config'
54

6-
export default Model.extend({
5+
export default Manifest.extend({
76

87
initialize () {
98
this.getManifest // load the manifesto object into this.manifest
109
},
1110

12-
idAttribute: '_id',
13-
1411
url () {
15-
return config.manifestStore + '/' + this._id
16-
},
17-
18-
props: {
19-
_id: 'string',
20-
'@id': 'string',
21-
'@context': 'string',
22-
'@type': {
23-
type: 'string',
24-
required: 'true',
25-
default: 'sc:Manifest',
26-
test: function (value) {
27-
if (value !== 'sc:Manifest') {
28-
return "Value must equal 'sc:Manifest'."
29-
}
30-
return false
31-
}
32-
},
33-
label: 'string',
34-
thumbnail: 'string',
35-
viewingHint: 'string',
36-
metadata: 'array'
37-
},
38-
39-
collections: {
40-
sequences: SequenceCollection
12+
return config.manifestStore + '/' + this._id + '/manifest.json'
4113
},
4214

4315
derived: {
44-
app_url: {
16+
foo: {
4517
deps: ['_id'],
4618
fn () {
47-
return 'presentations/' + this._id
19+
return 'foo/' + this._id
4820
}
4921
},
50-
subjects: {
51-
deps: ['metadata'],
22+
app_url: {
23+
deps: ['_id'],
5224
fn () {
53-
var s = ''
54-
55-
if (this.metadata) {
56-
this.metadata.forEach(function (md) {
57-
if (md.label === 'Subjects') {
58-
s = md.value.join(', ')
59-
}
60-
})
61-
}
62-
63-
return s
25+
return 'presentations/' + this._id
6426
}
6527
},
6628
/* ***
6729
// The getManifest() method is for demo purposes, showing how one can use
6830
// the Manifesto library within this app by attaching a Manifesto object,
6931
// with all its methods to this model.
70-
// i.e. this.manifest.getLabel()
32+
// i.e. this.manifestation.getLabel()
7133
*** */
7234
getManifest: {
73-
deps: ['_id'],
35+
deps: ['@id'],
7436
fn () {
7537
var _this = this
76-
manifesto.loadManifest(config.manifestStore + '/' + this._id).then(function (manifest) {
77-
_this.manifest = manifesto.create(manifest)
78-
return _this.manifest
38+
39+
manifesto.loadManifest(this['@id']).then(function (manifest) {
40+
_this.manifestation = manifesto.create(manifest)
41+
return _this.manifestation
7942
},
8043
function (error) {
8144
console.error('Failed!', error)
8245
})
83-
this.manifest = _this.manifest
46+
47+
this.manifestation = _this.manifestation
8448
}
8549
}
8650
}

src/pages/presentation-detail.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ export default React.createClass({
2424

2525
return (
2626
<div className='container'>
27-
<h1>{presentation.manifest.getLabel()} Slides</h1>
27+
<h1>{presentation.manifestation.getLabel()} Slides</h1>
2828
<p><strong>Subjects:</strong> {presentation.subjects}</p>
2929
<ul>
30-
{presentation.manifest.getSequences().map((sequence) => {
30+
{presentation.manifestation.getSequences().map((sequence) => {
3131
let label = 'Untitled Slide Group'
3232
if (!sequence.getLabel() === 'undefined') { label = sequence.getLabel() }
3333
return (
@@ -39,7 +39,7 @@ export default React.createClass({
3939
<button onClick={this.onAddClick} className='button'>Add a Slide</button>
4040
</p>
4141
<ul className='sequence'>
42-
{presentation.manifest.getSequences()[0].getThumbs(200).map((thumb) => {
42+
{presentation.manifestation.getSequences()[0].getThumbs(200).map((thumb) => {
4343
return (
4444
<li className='slide'><img src={thumb.uri}/></li>
4545
)

src/router.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ export default Router.extend({
4242
},
4343

4444
presentations () {
45-
this.renderPage(<PresentationsPage presentations={app.me.presentations}/>)
45+
this.renderPage(<PresentationsPage presentations={app.me.presentations.manifests}/>)
4646
},
4747

4848
presentationDetail (id) {
49-
const presentation = app.me.presentations.getById(id)
49+
const presentation = app.me.presentations.manifests.getById(id)
5050
this.renderPage(<PresentationDetailPage presentation={presentation}/>)
5151
},
5252

0 commit comments

Comments
 (0)