Skip to content
This repository was archived by the owner on May 5, 2020. It is now read-only.

Commit ecd99b9

Browse files
committed
Is this on?
1 parent b6e43e5 commit ecd99b9

28 files changed

Lines changed: 551 additions & 0 deletions

.eslintrc

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"env": {
3+
"browser": false,
4+
"node": true,
5+
"mocha": true
6+
},
7+
"settings": {
8+
"ecmascript": 5
9+
},
10+
"plugins": [
11+
"mocha",
12+
"nodeca"
13+
],
14+
"globals": {
15+
"Promise": true
16+
},
17+
"rules": {
18+
"eqeqeq": 1,
19+
"curly": 2,
20+
"quotes": 0,
21+
"strict": 0,
22+
"camelcase": 0,
23+
"radix": 1,
24+
"no-sync": 1,
25+
"guard-for-in": 2,
26+
"no-eq-null": 1,
27+
28+
"complexity": [1, 10],
29+
"no-unused-vars": [2, {"vars": "all", "args": "none"}],
30+
"block-scoped-var": 2,
31+
"max-nested-callbacks": [1, 4],
32+
33+
"valid-jsdoc": 1,
34+
"no-warning-comments": [1, { "terms": ["todo", "fixme"], "location": "start" }],
35+
"spaced-line-comment": [1, "always"],
36+
"max-len": [1, 80, 4],
37+
38+
"new-parens": 1,
39+
"new-cap": 0,
40+
"no-trailing-spaces": 1,
41+
"no-mixed-spaces-and-tabs": 2,
42+
# "indent": [2, 2, {"indentSwitchCase": true}],
43+
"nodeca/indent": [ 2, "spaces", 2 ],
44+
"nodeca/no-lodash-aliases": 1,
45+
"space-before-blocks": [1, "always"],
46+
"space-after-keywords": [1, "always"],
47+
"space-before-function-parentheses": [2, {"anonymous": "always", "named": "never"}],
48+
"space-in-parens": [1, "never"],
49+
"padded-blocks": [1, "never"],
50+
"comma-style": [1, "last"],
51+
"wrap-iife": [2, "outside"],
52+
"no-lonely-if": 1,
53+
"no-nested-ternary": 1,
54+
"no-multiple-empty-lines": 1,
55+
"wrap-regex": 1,
56+
"default-case": 2,
57+
"no-else-return": 1,
58+
"no-floating-decimal": 1,
59+
"no-multi-str": 0,
60+
61+
"mocha/no-exclusive-tests": 2
62+
}
63+
}

.gitignore

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Project specific stuff
2+
docs/
3+
4+
# Logs
5+
logs
6+
*.log
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
13+
# Directory for instrumented libs generated by jscoverage/JSCover
14+
lib-cov
15+
16+
# Coverage directory used by tools like istanbul
17+
coverage
18+
19+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
20+
.grunt
21+
22+
# Compiled binary addons (http://nodejs.org/api/addons.html)
23+
build/Release
24+
25+
# Dependency directory
26+
# Commenting this out is preferred by some people, see
27+
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
28+
node_modules
29+
30+
# Users Environment Variables
31+
.lock-wscript
32+
33+
# Editor Stuff
34+
*.sublime-project
35+
*.bak
36+
*~
37+
38+
# System stuff
39+
.DS_Store
40+
.Spotlight-V100
41+
.Trashes
42+
Thumbs.db
43+
ehthumbs.db
44+
Desktop.ini
45+
$RECYCLE.BIN/
46+
.directory
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
<article class="article is-teaser">
3+
<h1>Welcome to ZOMBO.COM</h1>
4+
<p class="teaser">
5+
The infinite is possible on ZOMBO.COM!
6+
</p>
7+
</article>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<article class="article is-teaser">
2+
<h1>Welcome to ZOMBO.COM</h1>
3+
<p class="teaser">
4+
The infinite is possible on ZOMBO.COM!
5+
</p>
6+
</article>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<article>
2+
<h1>
3+
Start page!
4+
</h1>
5+
</article>

examples/01/compile.js

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
var fs = require('vinyl-fs');
2+
var path = require('path');
3+
var Promise = require('bluebird');
4+
var collect = Promise.promisify(require('collect-stream'));
5+
var writeFile = Promise.promisify(require('fs-extra').outputFile);
6+
var del = Promise.promisify(require('del'));
7+
var slug = require('slug');
8+
var l = require('lodash');
9+
10+
var SiliconZucchini = require('../../');
11+
var S = SiliconZucchini;
12+
13+
function getData() {
14+
return fs.src('./data/**/*.{json,cson,md}')
15+
.pipe(S.loadCson())
16+
.pipe(S.loadJson())
17+
.pipe(S.loadCsonFrontmatter())
18+
.pipe(S.dataDefaults('^articles/', {
19+
schema: 'article',
20+
slug: function (a) {
21+
return a.data.slug || slug(a.data.title).toLowerCase();
22+
}
23+
}))
24+
.pipe(S.dataDefaults('^pages/', {
25+
schema: 'page',
26+
permalink: function (p) {
27+
return p.data.permalink || S.stripFileExt(p.relative);
28+
}
29+
}))
30+
;
31+
}
32+
33+
function getSchemas() {
34+
return fs.src('./src/schemas/**/*.{json,cson}')
35+
.pipe(S.loadCson())
36+
.pipe(S.loadJson())
37+
;
38+
}
39+
40+
function getTemplates() {
41+
return fs.src('./src/**/*.html')
42+
.pipe(S.loadCsonFrontmatter())
43+
;
44+
}
45+
46+
Promise.all([
47+
collect(getData()),
48+
collect(getSchemas()),
49+
collect(getTemplates()),
50+
del('build')
51+
])
52+
.spread(function (data, schemas, templates) {
53+
data.map(function (item) {
54+
return S.dataValidate(item, {schemas: schemas});
55+
});
56+
57+
function getTemplate(name) {
58+
return l.find(templates, function (t) {
59+
return t.relative === name;
60+
});
61+
}
62+
63+
var routes = l.flatten([
64+
{
65+
data: {articles: l.pluck(S.filterByPath('^articles/', data), 'data')},
66+
route: 'artikel',
67+
layout: getTemplate('templates/articles.html')
68+
},
69+
S.filterByPath('^articles/', data).map(function (article) {
70+
return {
71+
data: article.data,
72+
route: path.join('artikel', article.data.slug),
73+
layout: getTemplate('templates/article.html')
74+
};
75+
}),
76+
S.filterByPath('^pages/', data).map(function (page) {
77+
return {
78+
data: page.data,
79+
route: page.data.permalink,
80+
layout: getTemplate('templates/page.html')
81+
};
82+
})
83+
]);
84+
85+
return Promise.map(routes, function (route) {
86+
var html = S.renderTemplate(route.layout, route.data, {
87+
schemas: schemas, getTemplate: getTemplate
88+
});
89+
var filePath = path.join('build', route.route, 'index.html');
90+
return writeFile(filePath, html)
91+
.then(function () {
92+
console.log('✓', filePath);
93+
});
94+
});
95+
})
96+
.catch(function (err) {
97+
console.error('oh noes!', err);
98+
});

examples/01/compile_1.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
var slug = require('slug');
2+
var SiliconZucchini = require('../../');
3+
var h = SiliconZucchini.helpers;
4+
5+
new SiliconZucchini()
6+
.getData('./data')
7+
.getSchemas('./src/schemas/**/*.{json,cson}')
8+
.getTemplates('./src/templates/**/*.html')
9+
.then(h.setDefaults(/^articles\//, {
10+
schema: 'article',
11+
slug: function (article) { return article.slug || slug(article.title); }
12+
}))
13+
.then(h.setDefaults(/^pages\//, {
14+
schema: 'page'
15+
}))
16+
.then(h.validate({field: 'schema'}))
17+
.then(h.render(function (data, templates) {
18+
return [
19+
h.filterByFilename(data, /^articles\//).map(function (article) {
20+
return {
21+
data: article,
22+
route: '/artikel/' + article.slug,
23+
layout: templates.get('templates/article')
24+
};
25+
}),
26+
h.filterByFilename(data, /^pages\//).map(function (page) {
27+
return {
28+
data: page,
29+
route: page.permalink || '/' + page.relative
30+
};
31+
})
32+
];
33+
}))
34+
.build();
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: "Welcome to ZOMBO.COM"
3+
---
4+
The infinite is possible on ZOMBO.COM!

examples/01/data/pages/start.cson

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
title: "Start page!"
2+
content: ""
3+
subtitle: "Sup ya fools?"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
name: "Article Teaser"
3+
input:
4+
$ref: "#article"
5+
---
6+
<article class="article is-teaser">
7+
<h1>{{ data.title }}</h1>
8+
<p class="teaser">
9+
{{ data.teaser || data.content.slice(0, 80) }}
10+
</p>
11+
</article>

0 commit comments

Comments
 (0)