Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Is this on?

  • Loading branch information
killercup committed Mar 23, 2015
1 parent b6e43e5 commit ecd99b90125420811fbf3a2da55bd1590d6f2d3e
@@ -0,0 +1,63 @@
{
"env": {
"browser": false,
"node": true,
"mocha": true
},
"settings": {
"ecmascript": 5
},
"plugins": [
"mocha",
"nodeca"
],
"globals": {
"Promise": true
},
"rules": {
"eqeqeq": 1,
"curly": 2,
"quotes": 0,
"strict": 0,
"camelcase": 0,
"radix": 1,
"no-sync": 1,
"guard-for-in": 2,
"no-eq-null": 1,

"complexity": [1, 10],
"no-unused-vars": [2, {"vars": "all", "args": "none"}],
"block-scoped-var": 2,
"max-nested-callbacks": [1, 4],

"valid-jsdoc": 1,
"no-warning-comments": [1, { "terms": ["todo", "fixme"], "location": "start" }],
"spaced-line-comment": [1, "always"],
"max-len": [1, 80, 4],

"new-parens": 1,
"new-cap": 0,
"no-trailing-spaces": 1,
"no-mixed-spaces-and-tabs": 2,
# "indent": [2, 2, {"indentSwitchCase": true}],
"nodeca/indent": [ 2, "spaces", 2 ],
"nodeca/no-lodash-aliases": 1,
"space-before-blocks": [1, "always"],
"space-after-keywords": [1, "always"],
"space-before-function-parentheses": [2, {"anonymous": "always", "named": "never"}],
"space-in-parens": [1, "never"],
"padded-blocks": [1, "never"],
"comma-style": [1, "last"],
"wrap-iife": [2, "outside"],
"no-lonely-if": 1,
"no-nested-ternary": 1,
"no-multiple-empty-lines": 1,
"wrap-regex": 1,
"default-case": 2,
"no-else-return": 1,
"no-floating-decimal": 1,
"no-multi-str": 0,

"mocha/no-exclusive-tests": 2
}
}
@@ -0,0 +1,46 @@
# Project specific stuff
docs/

# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# Commenting this out is preferred by some people, see
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
node_modules

# Users Environment Variables
.lock-wscript

# Editor Stuff
*.sublime-project
*.bak
*~

# System stuff
.DS_Store
.Spotlight-V100
.Trashes
Thumbs.db
ehthumbs.db
Desktop.ini
$RECYCLE.BIN/
.directory
@@ -0,0 +1,7 @@

<article class="article is-teaser">
<h1>Welcome to ZOMBO.COM</h1>
<p class="teaser">
The infinite is possible on ZOMBO.COM!
</p>
</article>
@@ -0,0 +1,6 @@
<article class="article is-teaser">
<h1>Welcome to ZOMBO.COM</h1>
<p class="teaser">
The infinite is possible on ZOMBO.COM!
</p>
</article>
@@ -0,0 +1,5 @@
<article>
<h1>
Start page!
</h1>
</article>
@@ -0,0 +1,98 @@
var fs = require('vinyl-fs');
var path = require('path');
var Promise = require('bluebird');
var collect = Promise.promisify(require('collect-stream'));
var writeFile = Promise.promisify(require('fs-extra').outputFile);
var del = Promise.promisify(require('del'));
var slug = require('slug');
var l = require('lodash');

var SiliconZucchini = require('../../');
var S = SiliconZucchini;

function getData() {
return fs.src('./data/**/*.{json,cson,md}')
.pipe(S.loadCson())
.pipe(S.loadJson())
.pipe(S.loadCsonFrontmatter())
.pipe(S.dataDefaults('^articles/', {
schema: 'article',
slug: function (a) {
return a.data.slug || slug(a.data.title).toLowerCase();
}
}))
.pipe(S.dataDefaults('^pages/', {
schema: 'page',
permalink: function (p) {
return p.data.permalink || S.stripFileExt(p.relative);
}
}))
;
}

function getSchemas() {
return fs.src('./src/schemas/**/*.{json,cson}')
.pipe(S.loadCson())
.pipe(S.loadJson())
;
}

function getTemplates() {
return fs.src('./src/**/*.html')
.pipe(S.loadCsonFrontmatter())
;
}

Promise.all([
collect(getData()),
collect(getSchemas()),
collect(getTemplates()),
del('build')
])
.spread(function (data, schemas, templates) {
data.map(function (item) {
return S.dataValidate(item, {schemas: schemas});
});

function getTemplate(name) {
return l.find(templates, function (t) {
return t.relative === name;
});
}

var routes = l.flatten([
{
data: {articles: l.pluck(S.filterByPath('^articles/', data), 'data')},
route: 'artikel',
layout: getTemplate('templates/articles.html')
},
S.filterByPath('^articles/', data).map(function (article) {
return {
data: article.data,
route: path.join('artikel', article.data.slug),
layout: getTemplate('templates/article.html')
};
}),
S.filterByPath('^pages/', data).map(function (page) {
return {
data: page.data,
route: page.data.permalink,
layout: getTemplate('templates/page.html')
};
})
]);

return Promise.map(routes, function (route) {
var html = S.renderTemplate(route.layout, route.data, {
schemas: schemas, getTemplate: getTemplate
});
var filePath = path.join('build', route.route, 'index.html');
return writeFile(filePath, html)
.then(function () {
console.log('✓', filePath);
});
});
})
.catch(function (err) {
console.error('oh noes!', err);
});
@@ -0,0 +1,34 @@
var slug = require('slug');
var SiliconZucchini = require('../../');
var h = SiliconZucchini.helpers;

new SiliconZucchini()
.getData('./data')
.getSchemas('./src/schemas/**/*.{json,cson}')
.getTemplates('./src/templates/**/*.html')
.then(h.setDefaults(/^articles\//, {
schema: 'article',
slug: function (article) { return article.slug || slug(article.title); }
}))
.then(h.setDefaults(/^pages\//, {
schema: 'page'
}))
.then(h.validate({field: 'schema'}))
.then(h.render(function (data, templates) {
return [
h.filterByFilename(data, /^articles\//).map(function (article) {
return {
data: article,
route: '/artikel/' + article.slug,
layout: templates.get('templates/article')
};
}),
h.filterByFilename(data, /^pages\//).map(function (page) {
return {
data: page,
route: page.permalink || '/' + page.relative
};
})
];
}))
.build();
@@ -0,0 +1,4 @@
---
title: "Welcome to ZOMBO.COM"
---
The infinite is possible on ZOMBO.COM!
@@ -0,0 +1,3 @@
title: "Start page!"
content: ""
subtitle: "Sup ya fools?"
@@ -0,0 +1,11 @@
---
name: "Article Teaser"
input:
$ref: "#article"
---
<article class="article is-teaser">
<h1>{{ data.title }}</h1>
<p class="teaser">
{{ data.teaser || data.content.slice(0, 80) }}
</p>
</article>
@@ -0,0 +1,7 @@
title: "article"
type: "object"
required: ["title", "content"]
properties:
title: {type: "string"}
teaser: {type: "string"}
content: {type: "string"}
@@ -0,0 +1,9 @@
title: "page"
type: "object"
required: ["title", "content"]
properties:
title:
type: "string"
maxLength: 255
content:
type: "string"
@@ -0,0 +1,6 @@
---
name: "Article"
input:
$ref: "#article"
---
{{ include("organisms/article-teaser.html", data) }}
@@ -0,0 +1,11 @@
---
name: "Article"
input:
type: "object"
articles:
type: "array"
items: { $ref: "#article" }
---
{% data.articles.forEach(function(article) { %}
{{ include("organisms/article-teaser.html", article) }}
{% }); %}
@@ -0,0 +1,10 @@
---
name: "Page"
input:
$ref: "#page"
---
<article>
<h1>
{{ data.title }}
</h1>
</article>
@@ -0,0 +1,10 @@
module.exports = {
dataDefaults: require('./lib/data-defaults'),
dataValidate: require('./lib/data-validate'),
filterByPath: require('./lib/helpers/filter-by-path'),
loadCson: require('./lib/load-cson'),
loadCsonFrontmatter: require('./lib/load-cson-frontmatter'),
loadJson: require('./lib/load-json'),
renderTemplate: require('./lib/render-template'),
stripFileExt: require('./lib/helpers/strip-file-ext')
};
@@ -0,0 +1,30 @@
var l = require('lodash');
var map = require('map-stream');
var Promise = require('bluebird');

function callProps(context, obj) {
return l.mapValues(obj, function (value) {
if (l.isFunction(value)) {
return value(context);
}
return value;
});
}

module.exports = function setDefaults(pattern, values) {
pattern = new RegExp(pattern, 'i');

return map(function (file, cb) {
if (!pattern.test(file.relative)) {
return cb(null, file);
}

Promise.props(values)
.then(callProps.bind(null, file))
.then(function (actualDefaults) {
file.data = l.defaults({}, file.data, actualDefaults);
cb(null, file);
})
.catch(cb);
});
};
@@ -0,0 +1,3 @@
module.exports = function dataValidate(item, opts) {
return true;
};

0 comments on commit ecd99b9

Please sign in to comment.
You can’t perform that action at this time.