From b8ae0749a6e7f85edda8a0926e003cd561e4d172 Mon Sep 17 00:00:00 2001 From: Sean Fridman Date: Fri, 3 Apr 2015 02:28:12 -0400 Subject: Separate schema and resource concepts Also refactor a bit --- examples/index.js | 49 +++++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 26 deletions(-) (limited to 'examples/index.js') 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'} } } -- cgit v1.2.3-70-g09d2