Skip to content

Commit

Permalink
Intial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
vohedge committed Jun 3, 2013
0 parents commit 96888c7
Show file tree
Hide file tree
Showing 53 changed files with 7,870 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
npm-debug.log
tmp
14 changes: 14 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"sub": true,
"undef": true,
"boss": true,
"eqnull": true,
"node": true,
"es5": true
}
72 changes: 72 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* grunt-wintersmith-compile
* https://github.com/vohedge/grunt-wintersmith-compile
*
* Copyright (c) 2013 vohedge
* Licensed under the MIT license.
*/

'use strict';

module.exports = function(grunt) {

// Project configuration.
grunt.initConfig({
jshint: {
all: [
'Gruntfile.js',
'tasks/*.js',
'<%= nodeunit.tests %>',
],
options: {
jshintrc: '.jshintrc',
},
},

// Before generating any new files, remove any previously-created files.
clean: {
tests: ['tmp'],
},

// Configuration to be run (and then tested).
wintersmith_compile: {
// In default option, this task tries to find config.json from
// same directory to Gruntfile.
// default_options: {
// options: {
// config: 'config.json',
// output: 'build'
// }
// },
custom_options: {
options: {
config: 'test/fixtures/config.json',
output: 'tmp/public'
}
}
},

// Unit tests.
nodeunit: {
tests: ['test/*_test.js'],
},

});

// Actually load this plugin's task(s).
grunt.loadTasks('tasks');

// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-nodeunit');

// Whenever the "test" task is run, first clean the "tmp" dir, then run this
// plugin's task(s), then test the result.
grunt.registerTask('test', ['clean', 'wintersmith_compile', 'nodeunit']);

// By default, lint and run all tests.
grunt.registerTask('default', ['jshint', 'test']);

grunt.registerTask('dev', ['jshint']);
};
22 changes: 22 additions & 0 deletions LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Copyright (c) 2013 vohedge

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
79 changes: 79 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# grunt-wintersmith-compile

> A grunt task for "wintersmith build" command.
<!--
## Getting Started
This plugin requires Grunt `~0.4.1`
If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
```shell
npm install grunt-wintersmith-compile - -save-dev
```
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
```js
grunt.loadNpmTasks('grunt-wintersmith-compile');
```
-->

## The "wintersmith_compile" task

### Overview
In your project's Gruntfile, add a section named `wintersmith_compile` to the data object passed into `grunt.initConfig()`.

```js
grunt.initConfig({
wintersmith_compile: {
your_target: {
config: 'path/to/config.json',
output: 'path/to/build'
},
},
})
```

### Options

#### options.config
Type: `String`
Default value: `'config.json'`

A string value that is a path to config.json.

#### options.output
Type: `String`
Default value: `'build'`

A string value that is used to output the html, css, js, images etc.

### Usage Examples

#### Default Options
```js
grunt.initConfig({
wintersmith_compile: {
your_target: {}
},
})
```

#### Custom Options

```js
grunt.initConfig({
wintersmith_compile: {
your_target: {
config: 'path/to/config.json',
output: 'path/to/build'
}
},
})
```

## Release History
_(Nothing yet)_
48 changes: 48 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "grunt-wintersmith-compile",
"description": "A grunt task for wintersmith build process.",
"version": "0.1.0",
"homepage": "https://github.com/vohedge/grunt-wintersmith-compile",
"author": {
"name": "vohedge",
"email": "vohedge@gmail.com"
},
"repository": {
"type": "git",
"url": "git://github.com/vohedge/grunt-wintersmith-compile.git"
},
"bugs": {
"url": "https://github.com/vohedge/grunt-wintersmith-compile/issues"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/vohedge/grunt-wintersmith-compile/blob/master/LICENSE-MIT"
}
],
"main": "Gruntfile.js",
"engines": {
"node": ">= 0.8.0"
},
"scripts": {
"test": "grunt test"
},
"dependencies": {
"wintersmith": "~2.0.5"
},
"devDependencies": {
"grunt-contrib-jshint": "~0.1.1",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-nodeunit": "~0.1.2",
"grunt": "~0.4.1",
"moment": "~2.0.0",
"underscore": "~1.4.4",
"typogr": "~0.5.2"
},
"peerDependencies": {
"grunt": "~0.4.1"
},
"keywords": [
"gruntplugin"
]
}
55 changes: 55 additions & 0 deletions tasks/wintersmith_compile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* grunt-wintersmith-compile
* https://github.com/vohedge/grunt-wintersmith-compile
*
* Copyright (c) 2013 vohedge
* Licensed under the MIT license.
*/

'use strict';

module.exports = function(grunt) {

var wintersmith = require('wintersmith');
var fs = require("fs");
var path = require("path");

grunt.registerMultiTask('wintersmith_compile', 'Just run "wintersmith build"', function() {
var options, cwd, config, configDir, output, rawOutput, done, env;

// Default option value
options = this.options({
config: 'config.json',
output: 'build'
});

// Set config.json path
config = path.resolve(options.config);
if (!fs.existsSync(config)) {
grunt.fail.warn('"config.json" is not found: ' + config);
}
grunt.log.writeln('config: ' + config);

// Set output path
// Default path is the same directory to config.json
rawOutput = grunt.config.get([this.name, this.target, 'options', 'output']);
if (!rawOutput) {
configDir = path.dirname(config);
output = configDir + '/' + options.output;
} else {
output = path.resolve(options.output);
}
grunt.log.writeln('output: ' + output);

// Wintersimith Build
env = wintersmith(config);
done = this.async();
env.build(output, function(error) {
if (error) {
grunt.warn(error);
}
grunt.log.writeln('Done!');
done();
});
});
};
66 changes: 66 additions & 0 deletions test/expected/custom_options/archive.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width">
<title>The Wintersmith's blog
</title>
<link rel="alternate" href="http://localhost:8080/feed.xml" type="application/rss+xml" title="Ramblings of an immor(t)al demigod">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic|Anonymous+Pro:400,700,400italic,700italic|Merriweather:400,700,300">
<link rel="stylesheet" href="/css/main.css">
</head>
<body>
<header class="header">
<div class="content-wrap">
<div class="logo">
<h1><a href="http://localhost:8080">The Wintersmith's blog</a></h1>
<p class="description">Ramblings of an immor(t)al demigod</p>
</div>
</div>
</header>
<div id="content">
<div class="content-wrap">
<section class="archive">
<h2>Archive</h2>
<ul>
<li style="height: 4.4em" class="year"><span style="line-height: 4.4em" class="year-label">2013</span>
<ul>
<li style="height: 4.4em" class="month"><span style="line-height: 4.4em" class="month-label">April</span><a href="/articles/hello-world/" style="line-height: 2.2em">README</a><a href="/articles/red-herring/" style="line-height: 2.2em">A red herring</a>
</li>
</ul>
</li>
<li style="height: 6.6000000000000005em" class="year"><span style="line-height: 6.6000000000000005em" class="year-label last">2012</span>
<ul>
<li style="height: 2.2em" class="month"><span style="line-height: 2.2em" class="month-label">October</span><a href="/articles/another-test/" style="line-height: 2.2em">Code and stuff!</a>
</li>
<li style="height: 4.4em" class="month"><span style="line-height: 4.4em" class="month-label last">February</span><a href="/articles/markdown-syntax/" style="line-height: 2.2em">Markdown syntax</a><a href="/articles/bamboo-cutter/" style="line-height: 2.2em" class="last">Taketori Monogatari</a>
</li>
</ul>
</li>
</ul>
</section>
</div>
</div>
<footer>
<div class="content-wrap">
<section class="about"><p>Wintersmith is made by <a href="http://johan-nordberg.com/">Johan Nordberg</a> and licensed under the <a href="http://opensource.org/licenses/MIT">MIT-license</a>.
This footer text can be edited in about.md</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat.</p>
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum
dolore eu fugiat nulla pariatur.</p>
<p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia
deserunt mollit anim id est laborum.</p>

</section>
<section class="copy">
<p>&copy; 2013 Someone &mdash; powered by&nbsp;<a href="https://github.com/jnordberg/wintersmith">Wintersmith</a>
</p>
</section>
</div>
</footer>
</body>
</html>
Loading

0 comments on commit 96888c7

Please sign in to comment.