summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorSean Fridman <fridman@mail.sfsu.edu>2015-04-01 18:27:51 -0400
committerSean Fridman <fridman@mail.sfsu.edu>2015-04-01 18:27:51 -0400
commit2e041ff6cd1b40c26bf16d37777c2c1c5153a669 (patch)
tree1e427659faf343bf42795beae8980000436617b8 /examples
parentae24790e8122296b06f88fa883b8e272c6454d46 (diff)
Bootstrappin young lad
Diffstat (limited to 'examples')
-rw-r--r--examples/index.js51
-rw-r--r--examples/www/index.mustache13
-rw-r--r--examples/www/page.mustache5
-rw-r--r--examples/www/project.mustache2
4 files changed, 71 insertions, 0 deletions
diff --git a/examples/index.js b/examples/index.js
new file mode 100644
index 0000000..1a7bbfb
--- /dev/null
+++ b/examples/index.js
@@ -0,0 +1,51 @@
+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',
+
+ resources: [
+ { resource: Page, id: 'about' },
+ { resource: Page, id: 'contact' },
+ { resource: Project, id: '*' },
+ ],
+
+ views: {
+ '/': {
+ template: 'index',
+ data: [
+ {name: 'project', id: '*'},
+ {name: 'page', id: '*'}
+ ]
+ },
+ '/about': {
+ template: 'page',
+ data: {name: 'page', id: 'about'}
+ },
+ '/contact': {
+ template: 'page',
+ data: {name: 'page', id: 'contact'}
+ },
+ '/:id': {
+ template: 'project',
+ data: {name: 'project', id: ':id'}
+ }
+ }
+
+}).listen(1337);
+
+console.log('Server listening at port 1337...');
diff --git a/examples/www/index.mustache b/examples/www/index.mustache
new file mode 100644
index 0000000..04d0632
--- /dev/null
+++ b/examples/www/index.mustache
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ </head>
+ <body>
+ {{meta.project}}
+ <ul>
+ {{#projects}}
+ <li>{{id}}</li>
+ {{/projects}}
+ </ul>
+ </body>
+</html>
diff --git a/examples/www/page.mustache b/examples/www/page.mustache
new file mode 100644
index 0000000..f7d899f
--- /dev/null
+++ b/examples/www/page.mustache
@@ -0,0 +1,5 @@
+woop
+<h1>{{page.title}}</h1>
+<p>
+ {{page.body}}
+</p>
diff --git a/examples/www/project.mustache b/examples/www/project.mustache
new file mode 100644
index 0000000..dac1d8d
--- /dev/null
+++ b/examples/www/project.mustache
@@ -0,0 +1,2 @@
+babaganuj
+{{project.id}}