|
1 | | -import Model from 'ampersand-model' |
| 1 | +import {Manifest} from 'tabula-rasa' |
2 | 2 | import manifesto from '../../../node_modules/manifesto.js/dist/server/manifesto.js' |
3 | | -import SequenceCollection from './sequence-collection' |
4 | 3 | import config from '../../config' |
5 | 4 |
|
6 | | -export default Model.extend({ |
| 5 | +export default Manifest.extend({ |
7 | 6 |
|
8 | 7 | initialize () { |
9 | 8 | this.getManifest // load the manifesto object into this.manifest |
10 | 9 | }, |
11 | 10 |
|
12 | | - idAttribute: '_id', |
13 | | - |
14 | 11 | 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' |
41 | 13 | }, |
42 | 14 |
|
43 | 15 | derived: { |
44 | | - app_url: { |
| 16 | + foo: { |
45 | 17 | deps: ['_id'], |
46 | 18 | fn () { |
47 | | - return 'presentations/' + this._id |
| 19 | + return 'foo/' + this._id |
48 | 20 | } |
49 | 21 | }, |
50 | | - subjects: { |
51 | | - deps: ['metadata'], |
| 22 | + app_url: { |
| 23 | + deps: ['_id'], |
52 | 24 | 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 |
64 | 26 | } |
65 | 27 | }, |
66 | 28 | /* *** |
67 | 29 | // The getManifest() method is for demo purposes, showing how one can use |
68 | 30 | // the Manifesto library within this app by attaching a Manifesto object, |
69 | 31 | // with all its methods to this model. |
70 | | - // i.e. this.manifest.getLabel() |
| 32 | + // i.e. this.manifestation.getLabel() |
71 | 33 | *** */ |
72 | 34 | getManifest: { |
73 | | - deps: ['_id'], |
| 35 | + deps: ['@id'], |
74 | 36 | fn () { |
75 | 37 | 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 |
79 | 42 | }, |
80 | 43 | function (error) { |
81 | 44 | console.error('Failed!', error) |
82 | 45 | }) |
83 | | - this.manifest = _this.manifest |
| 46 | + |
| 47 | + this.manifestation = _this.manifestation |
84 | 48 | } |
85 | 49 | } |
86 | 50 | } |
|
0 commit comments