diff options
| author | Sean Fridman <fridman@mail.sfsu.edu> | 2015-04-03 02:28:12 -0400 |
|---|---|---|
| committer | Sean Fridman <fridman@mail.sfsu.edu> | 2015-04-03 02:28:12 -0400 |
| commit | b8ae0749a6e7f85edda8a0926e003cd561e4d172 (patch) | |
| tree | cbf7e35a550c8133ea5fad257997ecb7c9370ed8 /examples/index.js | |
| parent | 6fbccc554b2ab51f683718334338eae2b7b06200 (diff) | |
Separate schema and resource concepts
Also refactor a bit
Diffstat (limited to 'examples/index.js')
| -rw-r--r-- | examples/index.js | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/examples/index.js b/examples/index.js index 1a7bbfb..1e74968 100644 --- a/examples/index.js +++ b/examples/index.js @@ -1,48 +1,45 @@ var okcms = require('..'); -var Page = okcms.OKResource('page', { - title: { name: 'string' }, - body: { name: 'string' } -}); - -var Project = okcms.OKResource('project', { - title: {name: 'string'}, - index: {name: 'integer'}, - category: {name: 'string'}, - body: {name: 'string'}, - videos: {name: 'array:uri'}, - images: {name: 'array:image'} -}); - var app = okcms.createApp({ root: 'www', + schemas: { + page: { + title: {type: 'string'}, + body: {type: 'string'} + }, + project: { + title: {type: 'string'}, + index: {type: 'integer'}, + category: {type: 'enum'}, + body: {type: 'string'}, + videos: [{type: 'uri'}], + images: [{index: {type: 'string'}, uri: {type: 'uri'}}] + } + }, + resources: [ - { resource: Page, id: 'about' }, - { resource: Page, id: 'contact' }, - { resource: Project, id: '*' }, + { type: 'page', id: 'about' }, + { type: 'page', id: 'contact' }, + { type: 'project' }, ], views: { '/': { - template: 'index', data: [ - {name: 'project', id: '*'}, - {name: 'page', id: '*'} + {type: 'project', id: '*'}, + {type: 'page', id: '*'} ] }, '/about': { - template: 'page', - data: {name: 'page', id: 'about'} + data: {type: 'page', id: 'about'} }, '/contact': { - template: 'page', - data: {name: 'page', id: 'contact'} + data: {type: 'page', id: 'contact'} }, '/:id': { - template: 'project', - data: {name: 'project', id: ':id'} + data: {type: 'project', id: ':id'} } } |
