diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-04-13 17:57:17 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-04-13 17:57:17 -0400 |
| commit | 34f1ca02bea38e0b7ef185ebf07d3ec6df30f370 (patch) | |
| tree | 234b767a8fef77a7a29ff8d0f519ba462129cb92 | |
| parent | 3e255208a9776ad377f3b62d79d982138e89539a (diff) | |
split up the projects by category, add a schema flag so we can use the same singular template
| -rw-r--r-- | app/index.js | 6 | ||||
| -rw-r--r-- | app/node_modules/okquery/index.js | 6 | ||||
| -rw-r--r-- | app/node_modules/okview/index.js | 2 | ||||
| -rw-r--r-- | site/db.json | 8 | ||||
| -rw-r--r-- | site/index.js | 67 | ||||
| -rw-r--r-- | site/templates/index.liquid | 31 |
6 files changed, 65 insertions, 55 deletions
diff --git a/app/index.js b/app/index.js index 419adfc..7860f76 100644 --- a/app/index.js +++ b/app/index.js @@ -87,7 +87,6 @@ function OKCMS(options) { this._createResources(resourceConfig, db, schemas); var errorHandler = createErrorHandlerProducer( templateProvider, adminTemplateProvider, debug); - // Create view instances from config var views = this._views = this._createViews(viewConfig, db, meta, resourceCache, templateProvider, @@ -141,7 +140,7 @@ OKCMS.prototype._createResources = function(resourceConfig, db, schemaCache) { var type = config.type; var schema = schemaCache[type]; if (!schema) - throw new Error('Resource config references nonexistent schema'); + throw new Error('Resource config references nonexistent schema ' + type); var resource = OKResource({ type: type, db: db, @@ -244,7 +243,8 @@ OKCMS.prototype._createQueries = function(queryConfig, resourceCache) { var query = config.query || '*'; return new OKQuery({ resource: resource, - query: query + query: query, + as: config.as, }); }); }; diff --git a/app/node_modules/okquery/index.js b/app/node_modules/okquery/index.js index 9cc8b78..519bc08 100644 --- a/app/node_modules/okquery/index.js +++ b/app/node_modules/okquery/index.js @@ -33,6 +33,12 @@ function OKQuery(options) { enumerable: true }); + Object.defineProperty(this, 'as', { + value: options.as, + writable: false, + enumerable: true + }); + this.get = createQuery(resource, query, { default: options.default }); diff --git a/app/node_modules/okview/index.js b/app/node_modules/okview/index.js index 63f22b5..951261c 100644 --- a/app/node_modules/okview/index.js +++ b/app/node_modules/okview/index.js @@ -139,7 +139,7 @@ function fetchTemplateData(meta, queries, id) { return cache; } var resource = queries[i].resource; - var type = queries[i].type; + var type = queries[i].as || queries[i].type; var manyResult = isarray(result); // Inform template of ID in generic field if (manyResult) { diff --git a/site/db.json b/site/db.json index b6fbf24..22833f1 100644 --- a/site/db.json +++ b/site/db.json @@ -1,9 +1,8 @@ { "meta": [], - "project": [ + "retail": [ { "id": "diesel-ss15", - "category": "advertising", "title": "DIESEL JOGG JEANS SS15 DENIM CAMPAIGN", "shortname": "DIESEL SS15", "description": "Sed posuere consectetur est at lobortis. Donec id elit non mi porta gravida at eget metus. Cras mattis consectetur purus sit amet fermentum. Vestibulum id ligula porta felis euismod semper. Donec sed odio dui. \r\n\r\nVestibulum id ligula porta felis euismod semper. Vestibulum id ligula porta felis euismod semper. Vestibulum id ligula porta felis euismod semper. Aenean lacinia bibendum nulla sed consectetur. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. \r\n\r\nCurabitur blandit tempus porttitor. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec ullamcorper nulla non metus auctor fringilla. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur blandit tempus porttitor. Maecenas sed diam eget risus varius blandit sit amet non magna.", @@ -50,5 +49,8 @@ "image": "http://checkingintocollege.com/wp/wp-content/uploads/2014/08/angryphone.jpg", "__index": 0 } - ] + ], + "advertising": [], + "experiential": [], + "content": [] }
\ No newline at end of file diff --git a/site/index.js b/site/index.js index dace900..8eec697 100644 --- a/site/index.js +++ b/site/index.js @@ -1,5 +1,14 @@ var okcms = require('..'); +var projectSchema = { + id: {type: 'string', id: true}, + title: {type: 'string'}, + shortname: {type: 'string'}, + description: {type: 'text'}, + video: {type: 'video'}, + images: {type: 'captioned-image-list'}, +} + var app = okcms.createApp({ root: 'public', @@ -11,26 +20,19 @@ var app = okcms.createApp({ body: {type: 'text'}, image: {type: 'string'} }, - project: { - id: {type: 'string', id: true}, - title: {type: 'string'}, - shortname: {type: 'string'}, - category: {type: 'enum', options: [ - 'retail', - 'advertising', - 'experiential', - 'content'] - }, - description: {type: 'text'}, - video: {type: 'video'}, - images: {type: 'captioned-image-list'}, - } + retail: projectSchema, + advertising: projectSchema, + experiential: projectSchema, + content: projectSchema, }, resources: [ { type: 'page', static: {id: 'about'}}, { type: 'page', static: {id: 'contact'}}, - { type: 'project' } + { type: 'retail' }, + { type: 'advertising' }, + { type: 'experiential' }, + { type: 'content' } ], services: { @@ -44,8 +46,11 @@ var app = okcms.createApp({ views: { '/': { data: [ - {type: 'project', query: '*'}, - {type: 'page', query: '*'} + {type: 'page', query: '*'}, + {type: 'retail', query: '*'}, + {type: 'advertising', query: '*'}, + {type: 'experiential', query: '*'}, + {type: 'content', query: '*'}, ] }, '/about': { @@ -55,17 +60,19 @@ var app = okcms.createApp({ data: {type: 'page', query: 'contact'} }, '/all': { - data: { - type: 'project', - query: '*' - }, + data: [ + {type: 'retail', query: '*'}, + {type: 'advertising', query: '*'}, + {type: 'experiential', query: '*'}, + {type: 'content', query: '*'}, + ], template: 'all' }, '/retail/:id': { data: { - type: 'project', + type: 'retail', + as: 'project', query: { - category: 'retail', id: ':id' } }, @@ -73,9 +80,8 @@ var app = okcms.createApp({ }, '/advertising/:id': { data: { - type: 'project', + type: 'advertising', query: { - category: 'advertising', id: ':id' } }, @@ -83,9 +89,9 @@ var app = okcms.createApp({ }, '/experiential/:id': { data: { - type: 'project', + type: 'experiential', + as: 'project', query: { - category: 'experiential', id: ':id' } }, @@ -93,12 +99,13 @@ var app = okcms.createApp({ }, '/content/:id': { data: { - type: 'project', + type: 'content', + as: 'project', query: { - category: 'content', id: ':id' } - } + }, + template: 'project' } } diff --git a/site/templates/index.liquid b/site/templates/index.liquid index 954670a..0bd6b7d 100644 --- a/site/templates/index.liquid +++ b/site/templates/index.liquid @@ -85,36 +85,28 @@ WEBSITE BY OKFOCUS, http://okfoc.us, Internet Legends. <nav> <div class="top"> <img src="assets/images/2H_WORDMARK.png" class="toplogo"> - <div class="cat">RETAIL</div> + <div class="cat">retail</div> <div class="sub"> - {% for project in projects %} - {% if project.category == 'retail' %} - <a href="/retail/{{ project.id }}">{{ project.shortname }}</a> - {% endif %} + {% for project in retails %} + <a href="/retail/{{ project.id }}">{{ project.shortname }}</a> {% endfor %} </div> <div class="cat">advertising</div> <div class="sub"> - {% for project in projects %} - {% if project.category == 'advertising' %} - <a href="/advertising/{{ project.id }}">{{ project.shortname }}</a> - {% endif %} + {% for project in advertisings %} + <a href="/advertising/{{ project.id }}">{{ project.shortname }}</a> {% endfor %} </div> <div class="cat">experiential</div> <div class="sub"> - {% for project in projects %} - {% if project.category == 'experiential' %} - <a href="/experiential/{{ project.id }}">{{ project.shortname }}</a> - {% endif %} + {% for project in experientials %} + <a href="/experiential/{{ project.id }}">{{ project.shortname }}</a> {% endfor %} </div> <div class="cat">content</div> <div class="sub"> - {% for project in projects %} - {% if project.category == 'content' %} - <a href="/content/{{ project.id }}">{{ project.shortname }}</a> - {% endif %} + {% for project in contents %} + <a href="/content/{{ project.id }}">{{ project.shortname }}</a> {% endfor %} </div> </div> @@ -133,7 +125,10 @@ WEBSITE BY OKFOCUS, http://okfoc.us, Internet Legends. </div> <script type="text/plain" id="preload-image-list"> -{% for project in projects %}{{ project.images[0].uri }} +{% for project in retails %}{{ project.images[0].uri }} +{% endfor %}{% for project in advertisings %}{{ project.images[0].uri }} +{% endfor %}{% for project in experientials %}{{ project.images[0].uri }} +{% endfor %}{% for project in contents %}{{ project.images[0].uri }} {% endfor %}{% for page in pages %}{{ page.image }} {% endfor %}</script> |
