diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/db.json | 255 | ||||
| -rw-r--r-- | examples/index.js | 69 | ||||
| -rw-r--r-- | examples/lib/okdumpfm/index.js | 39 | ||||
| -rw-r--r-- | examples/lib/okdumpfm/package.json | 14 | ||||
| -rw-r--r-- | examples/lib/okexample/index.js | 49 | ||||
| -rw-r--r-- | examples/lib/okexample/package.json | 11 |
6 files changed, 422 insertions, 15 deletions
diff --git a/examples/db.json b/examples/db.json index 148391a..b6ab96b 100644 --- a/examples/db.json +++ b/examples/db.json @@ -3,8 +3,8 @@ "bread": [ { "type": "pretzel", - "description": "really a very tasty bread! yup yes", - "color": "green", + "description": "really a very tasty bread!", + "color": "red", "id": "pretzel", "title": "Pretzel Chips", "images": [ @@ -13,6 +13,10 @@ "caption": "cool" }, { + "uri": "https://ltho.s3.amazonaws.com/013781df-a926-409b-ab2a-b7b2becf99fa.png", + "caption": "" + }, + { "uri": "https://ltho.s3.amazonaws.com/5f4c3351-9434-446a-883b-aa4bffce8da3.png", "caption": "errrr" } @@ -21,9 +25,13 @@ "url": "", "type": "", "token": "", + "width": "", + "height": "", "title": "", "thumb": "" - } + }, + "__index": "0", + "dateCreated": "" }, { "type": "bagel", @@ -31,38 +39,263 @@ "id": "bagel", "title": "nice", "color": "blue", - "images": [], + "images": [ + { + "uri": "https://ltho.s3.amazonaws.com/229bcbc6-fb3c-428f-8c34-0c6bb69e70fd.gif", + "caption": "" + }, + { + "uri": "https://ltho.s3.amazonaws.com/a7663bfc-501c-4354-b6ed-6ea305a8fb39.gif", + "caption": "" + }, + { + "uri": "https://ltho.s3.amazonaws.com/7d380c24-7803-491a-94df-e812cbe667bb.gif", + "caption": "" + } + ], "video": { "url": "https://vimeo.com/112498725", "type": "vimeo", "token": "112498725", + "width": "", + "height": "", "title": "FW14-2H-VIDEO-V4 2", "thumb": "http://i.vimeocdn.com/video/497493142_640.jpg" - } + }, + "__index": "1", + "dateCreated": "" }, { "type": "pumpernickel", - "description": "grandma's recipe", + "description": "yup", "id": "pumpernickel", - "title": "Pumpernickel", + "title": "ok", "images": [ { "uri": "cool", "caption": "cool" } - ] + ], + "color": "red", + "video": { + "url": "", + "type": "", + "token": "", + "title": "", + "thumb": "" + }, + "__index": 2 + }, + { + "type": "cracker", + "title": "", + "description": "once upon a time this noble creature etc", + "color": "red", + "video": { + "url": "", + "type": "", + "token": "", + "title": "", + "thumb": "" + }, + "__index": 4, + "id": "cracker" + }, + { + "type": "croissant", + "title": "", + "description": "wow just wow", + "color": "red", + "video": { + "url": "", + "type": "", + "token": "", + "title": "", + "thumb": "" + }, + "__index": 3, + "id": "croissant" } ], "page": [ { "title": "About Us", "body": "Just a small bakery", - "id": "about" + "id": "about", + "__index": "1", + "links": [], + "dateCreated": "" }, { - "title": "contact", + "title": "ok...", "body": "2406 Old Rd, San Juan Bautista", - "id": "contact" + "id": "contact", + "__index": "0", + "links": [ + { + "text": "US Bread Board", + "uri": "http://bread.com/" + }, + { + "text": "National Council on Grain", + "uri": "http://grain.org/" + }, + { + "text": "USDA", + "uri": "http://usda.gov/" + } + ], + "dateCreated": "" + } + ], + "test": [ + { + "id": "red", + "title": "Red", + "media": [ + { + "uri": "https://ltho.s3.amazonaws.com/okcms-example/a91c4210-080c-11e6-8a7d-f30231d4ec26.png", + "width": "800", + "height": "800", + "caption": "", + "type": "image" + }, + { + "uri": "http://asdf.us/", + "caption": "ASDF", + "type": "link" + } + ], + "__index": 0, + "dateCreated": "Mon, 28 Mar 2016 23:02:45 GMT", + "flagged": false + }, + { + "id": "blue", + "title": "Blue", + "__index": 2, + "dateCreated": "Tue, 05 Apr 2016 15:17:54 GMT", + "media": [ + { + "uri": "https://ltho.s3.amazonaws.com/okcms-example/f2775199-d700-4b1f-951f-88fda599014e.png", + "caption": "", + "type": "image" + } + ] + }, + { + "id": "green", + "title": "Green", + "__index": 1, + "dateCreated": "Tue, 05 Apr 2016 15:17:57 GMT", + "media": [ + { + "uri": "http://asdf.us/z/", + "caption": "", + "type": "link" + }, + { + "uri": "http://asdf.us/", + "caption": "", + "type": "link" + }, + { + "type": "video", + "token": "https://ltho.s3.amazonaws.com/ee12b137-1c8a-400a-87e3-89cbee7b4da6.mp4", + "uri": "", + "width": "400", + "height": "400", + "title": "ee12b137-1c8a-400a-87e3-89cbee7b4da6.mp4", + "thumb": "http://okfocus.s3.amazonaws.com/misc/okcms/video.png", + "autoplay": "true", + "loop": "false" + }, + { + "type": "youtube", + "token": "y_35kXCQxN4", + "uri": "", + "width": "640", + "height": "360", + "title": "dëf lëöpär¨d¨¨¨¨<>~!@~#!:I!@", + "thumb": "http://i.ytimg.com/vi/y_35kXCQxN4/hqdefault.jpg", + "autoplay": "false", + "loop": "true" + }, + { + "type": "audio", + "token": "http://asdf.us/clouds35.mp3", + "uri": "", + "duration": "225.645792", + "title": "clouds35.mp3", + "thumb": "http://okfocus.s3.amazonaws.com/misc/okcms/video.png" + } + ], + "flagged": true + } + ], + "flour": [ + { + "id": "test", + "title": "TEST", + "image": { + "uri": "https://ltho.s3.amazonaws.com/okcms-example/7be163d0-080b-11e6-8a7d-f30231d4ec26.png", + "caption": "", + "width": "800", + "height": "800" + }, + "__index": 0, + "dateCreated": "Thu, 21 Apr 2016 21:52:44 GMT" + } + ], + "card": [ + { + "id": "1", + "title": "1", + "stack": "demo", + "__index": 5, + "dateCreated": "Fri, 02 Sep 2016 16:40:43 GMT" + }, + { + "id": "2", + "title": "2", + "stack": "demo", + "__index": 4, + "dateCreated": "Fri, 02 Sep 2016 16:40:57 GMT" + }, + { + "id": "3", + "title": "3", + "stack": "demo", + "__index": 3, + "dateCreated": "Fri, 02 Sep 2016 16:41:00 GMT" + }, + { + "id": "4", + "title": "4", + "stack": "demo-2", + "__index": 1, + "dateCreated": "Fri, 02 Sep 2016 16:41:17 GMT" + }, + { + "id": "5", + "title": "5", + "stack": "demo-2", + "__index": 2, + "dateCreated": "Fri, 02 Sep 2016 16:41:21 GMT" + } + ], + "stack": [ + { + "id": "demo", + "title": "Demo", + "__index": 0, + "dateCreated": "Fri, 02 Sep 2016 16:20:27 GMT" + }, + { + "id": "demo-2", + "title": "Demo #2", + "__index": 1, + "dateCreated": "Fri, 02 Sep 2016 16:41:10 GMT" } ] }
\ No newline at end of file diff --git a/examples/index.js b/examples/index.js index 0b9bf02..f1fabfa 100644 --- a/examples/index.js +++ b/examples/index.js @@ -1,14 +1,32 @@ var okcms = require('..'); +var isProduction = process.env.OK_PRODUCTION === 'true' +var port = process.env.PORT || 1337; + var app = okcms.createApp({ root: 'public', + debug: !isProduction, + production: isProduction, + + admin: { + dashboard: { + resources: { + card: { + groupBy: 'stack', + descending: true + } + } + }, + }, + schemas: { page: { id: {type: 'string'}, title: {type: 'string'}, - body: {type: 'text'} + body: {type: 'text'}, + links: {type: 'link-list'}, }, bread: { type: {type: 'string', id: true}, @@ -16,7 +34,27 @@ var app = okcms.createApp({ description: {type: 'text'}, color: {type: 'enum', options: ["red","blue","green"]}, video: {type: 'video'}, - images: {type: 'captioned-image-list'} + images: {type: 'gallery'} + }, + test: { + id: {type: 'string', hidden: true}, + title: {type: 'string'}, + flagged: {type: 'flag'}, + media: {type: 'media'}, + }, + flour: { + id: {type: 'string', hidden: true}, + title: {type: 'string'}, + image: {type: 'image'}, + }, + card: { + id: {type: 'string', hidden: true}, + title: {type: 'string'}, + stack: {type: 'foreign-key', key: 'stack'}, + }, + stack: { + id: {type: 'string', hidden: true}, + title: {type: 'string'}, } }, @@ -24,6 +62,10 @@ var app = okcms.createApp({ { type: 'page', static: {id: 'about'}}, { type: 'page', static: {id: 'contact'}}, { type: 'bread' }, + { type: 'test' }, + { type: 'flour' }, + { type: 'card' }, + { type: 'stack' }, ], services: { @@ -31,6 +73,25 @@ var app = okcms.createApp({ key: process.env.S3_KEY, secret: process.env.S3_SECRET, bucket: process.env.S3_BUCKET, + dirname: "okcms-example", + image: { allowed: true, preserveFilename: false, maxbytes: 2*1024*1024 }, + video: { allowed: true, preserveFilename: true, maxbytes: 200*1024*1024 }, + audio: { allowed: true, preserveFilename: true, maxbytes: 100*1024*1024 }, + }, + + webhook: { + active: false, + secret: 'test', + command: '/path/to/build.sh', + }, + + example: { + lib: require("./lib/okexample"), + stuff: "things", + }, + + dumpfm: { + lib: require("./lib/okdumpfm"), } }, @@ -52,6 +113,6 @@ var app = okcms.createApp({ } } -}).listen(process.env.PORT || 1337); +}).listen(port) -console.log('Server listening at port ' + (process.env.PORT || 1337) + '...'); +console.log('Server listening at port %d...', port); diff --git a/examples/lib/okdumpfm/index.js b/examples/lib/okdumpfm/index.js new file mode 100644 index 0000000..4dc5461 --- /dev/null +++ b/examples/lib/okdumpfm/index.js @@ -0,0 +1,39 @@ +var request = require('request') + +/** + * Example service which queries the Dump search. + */ +function OKDumpfm (options) { + if (!(this instanceof OKDumpfm)) return new OKDumpfm(options) + options = options || {} + if (!options.express) + throw new Error('Express not provided to OKDumpfm'); + + var express = options.express + var router = express.Router() + + router.get('*', function (req, res) { + var query = req.query.q + request('http://dump.fm/cmd/search/' + query, function (err, response, body) { + if (err || response.statusCode !== 200) { + res.status(response.statusCode) + res.send(err) + } else { + res.set('Content-Type', 'application/json; charset=utf-8') + res.send(body) + } + }) + }) + + router.post('*', function (req, res) { + throw new Error('OKDumpfm POST requests not implemented') + }) + + this._router = router +} + +OKDumpfm.prototype.middleware = function () { + return this._router +} + +module.exports = OKDumpfm diff --git a/examples/lib/okdumpfm/package.json b/examples/lib/okdumpfm/package.json new file mode 100644 index 0000000..17bcba2 --- /dev/null +++ b/examples/lib/okdumpfm/package.json @@ -0,0 +1,14 @@ +{ + "name": "okdumpfm", + "version": "1.0.0", + "description": "service to query the dump search API", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "okfocus <frontdesk@okfoc.us>", + "license": "LNT", + "dependencies": { + "request": "^2.71.0" + } +} diff --git a/examples/lib/okexample/index.js b/examples/lib/okexample/index.js new file mode 100644 index 0000000..04c5984 --- /dev/null +++ b/examples/lib/okexample/index.js @@ -0,0 +1,49 @@ + +/** + * Example service to show how these things should be set up. + * + * Services should be added to index.js in the proper area, + * with any configuration parameters that you want passed in: + * + * services: { + * example: { + * lib: require("./lib/okexample"), + * stuff: "things", + * } + * }, + * + * The service will be mounted on /_services/example + * + * This binds to route '*' but you can specify e.g. "/thing", + * and it will be mounted on /_services/example/thing + */ + +function OKExample (options) { + if (!(this instanceof OKExample)) return new OKExample(options) + options = options || {} + if (!options.express) + throw new Error('Express not provided to OKExample'); + if (!options.config) + throw new Error('Configuration not provided to OKExample'); + + var express = options.express + var router = express.Router() + var config = options.config + var db = options.db + + router.get('*', function (req, res) { + res.send(config.stuff) + }) + + router.post('*', function (req, res) { + throw new Error('OKExample POST requests not implemented') + }) + + this._router = router +} + +OKExample.prototype.middleware = function () { + return this._router +} + +module.exports = OKExample diff --git a/examples/lib/okexample/package.json b/examples/lib/okexample/package.json new file mode 100644 index 0000000..2b2a47c --- /dev/null +++ b/examples/lib/okexample/package.json @@ -0,0 +1,11 @@ +{ + "name": "okexample", + "version": "1.0.0", + "description": "example service", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "okfocus <frontdesk@okfoc.us>", + "license": "LNT" +} |
