Skip to content

Commit

Permalink
initial commit commited..
Browse files Browse the repository at this point in the history
  • Loading branch information
hariadi committed Mar 11, 2014
0 parents commit e9518fe
Show file tree
Hide file tree
Showing 20 changed files with 395 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
temp/
21 changes: 21 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"node": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
"latedef": true,
"newcap": true,
"noarg": true,
"quotmark": "single",
"regexp": true,
"undef": true,
"unused": true,
"strict": true,
"trailing": true,
"smarttabs": true,
"white": true
}
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
language: node_js
node_js:
- '0.10'
before_install:
- currentfolder=${PWD##*/}
- if [ "$currentfolder" != 'generator-metalsmith' ]; then cd .. && eval "mv $currentfolder generator-metalsmith" && cd generator-metalsmith; fi

52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# generator-metalsmith [![Build Status](https://secure.travis-ci.org/hariadi/generator-metalsmith.png?branch=master)](https://travis-ci.org/hariadi/generator-metalsmith)

> [Yeoman](http://yeoman.io) generator for [Metalsmith](http://metalsmith.io)

## Getting Started

### What is Yeoman?

Trick question. It's not a thing. It's this guy:

![](http://i.imgur.com/JHaAlBJ.png)

Basically, he wears a top hat, lives in your computer, and waits for you to tell him what kind of application you wish to create.

Not every new computer comes with a Yeoman pre-installed. He lives in the [npm](https://npmjs.org) package repository. You only have to ask for him once, then he packs up and moves into your hard drive. *Make sure you clean up, he likes new and shiny things.*

```
$ npm install -g yo
```

### Yeoman Generators

Yeoman travels light. He didn't pack any generators when he moved in. You can think of a generator like a plug-in. You get to choose what type of application you wish to create, such as a Backbone application or even a Chrome extension.

To install generator-metalsmith from npm, run:

```
$ npm install -g generator-metalsmith
```

Finally, initiate the generator:

```
$ yo metalsmith
```

### Getting To Know Yeoman

Yeoman has a heart of gold. He's a person with feelings and opinions, but he's very easy to work with. If you think he's too opinionated, he can be easily convinced.

If you'd like to get to know Yeoman better and meet some of his friends, [Grunt](http://gruntjs.com) and [Bower](http://bower.io), check out the complete [Getting Started Guide](https://github.com/yeoman/yeoman/wiki/Getting-Started).


## License

Copyright (c) 2014, Hariadi Hinta

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

3 changes: 3 additions & 0 deletions app/USAGE
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Example:
yo metalsmith
yo metalsmith [--skip-install] [--skip-welcome-message]
98 changes: 98 additions & 0 deletions app/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
'use strict';

var yeoman = require('yeoman-generator');
var chalk = require('chalk');

var MetalsmithGenerator = yeoman.generators.Base.extend({

init: function () {
this.pkg = require('../package.json');

this.on('end', function () {
this.installDependencies({
skipInstall: this.options['skip-install'] || this.options['s'],
callback: function () {
this.spawnCommand('make', ['build']);
}.bind(this)
});
});

},

askFor: function () {
var done = this.async();

if (!this.options['skip-welcome-message'] || !this.options['w']) {
this.log(this.yeoman);
}

this.log(chalk.magenta('You\'re using the fantastic Metalsmith generator.'));

/*
TODO:
1. build type
2. metalsmith-templates engine
*/

var prompts = [{
type : 'input',
name : 'msTitle',
message : 'Site Title',
default : this.appname
}, {
type : 'input',
name : 'msDesc',
message : 'Site Description',
default : 'My Metalsmith-Powered Site'
}, {
type : "input",
name : "msAuthor",
message : "Author name",
default : this.user.git.username || 'Metal Smith'
}, {
type : "input",
name : "msGithubUser",
message : "Would you mind telling me your username on Github?",
default : process.env.username || 'metalsmith'
}];

this.prompt(prompts, function (answers) {

for (var key in answers) {
if (answers.hasOwnProperty(key)) {
this[key] = answers[key];
}
}

done();
}.bind(this));
},

site: function () {
this.mkdir('_site');
},

layouts: function () {
this.mkdir('_layouts');
this.directory('_layouts', '_layouts');
},

posts: function () {
this.mkdir('_posts');
this.directory('_posts', '_posts');
},

gitfiles: function () {
this.copy('gitignore', '.gitignore');
},

app: function () {
this.copy('_package.json', 'package.json');
this.copy('_metalsmith.json', 'metalsmith.json');
this.copy('Makefile', 'Makefile');
this.copy('README.md', 'README.md');
},

});

module.exports = MetalsmithGenerator;
8 changes: 8 additions & 0 deletions app/templates/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

build: node_modules
node_modules/.bin/metalsmith

node_modules: package.json
npm install

.PHONY: build
10 changes: 10 additions & 0 deletions app/templates/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# <%= _.capitalize(msTitle) %>

> <%= _.capitalize(msDesc) %>.
This boilerplate static site uses Metalsmith to emulate a Jekyll static site. To test it out yourself just run:

$ make

## Release History
* <%= (new Date).toISOString().split('T')[0] %>   v0.1.0   Generated by the [Yeoman Generator](https://github.com/hariadi/generator-metalsmith) for [Metalsmith](http://metalsmith.io/)
10 changes: 10 additions & 0 deletions app/templates/_layouts/post.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<html>
<head>
<title><%= _.capitalize(msTitle) %></title>
</head>
<body>
<h1>{{ title }}</h1>
<time>{{ date | date('Y-m-d') }}</time>
{{ contents | safe }}
</body>
</html>
19 changes: 19 additions & 0 deletions app/templates/_metalsmith.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"source": "./_posts",
"destination": "./_site",
"metadata": {
"title": "<%= _.capitalize(msTitle) %>",
"description": "<%= msDesc %>"
},
"plugins": {
"metalsmith-drafts": {},
"metalsmith-markdown": {},
"metalsmith-permalinks": {
"pattern": ":title"
},
"metalsmith-templates": {
"engine": "swig",
"directory": "_layouts"
}
}
}
21 changes: 21 additions & 0 deletions app/templates/_package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "<%= _.slugify(msTitle) %>",
"version": "0.1.0",
"description": "<%= msDesc %>",
"author": {
"name": "<%= msAuthor %>",
"url": "https://github.com/<%= msGithubUser %>"
},
"repository": {
"type": "git",
"url": "https://github.com/<%= msGithubUser %>/<%= _.slugify(msTitle) %>"
},
"dependencies": {
"metalsmith-drafts": "0.0.1",
"metalsmith-templates": "^0.1.0",
"metalsmith-markdown": "^0.2.1",
"metalsmith-permalinks": "^0.1.0",
"swig": "^1.3.2",
"metalsmith": "^0.2.3"
}
}
7 changes: 7 additions & 0 deletions app/templates/_posts/2012-08-20-first-post.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: First Post
date: 2012-08-20
template: post.html
---

An interesting post about how it's going to be different this time around. I'm going write a lot more nowadays and use this blog to improve my writing.
7 changes: 7 additions & 0 deletions app/templates/_posts/2012-08-23-second-post.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: Second Post
date: 2012-08-23
template: post.html
---

A super-interesting piece of prose I had already written weeks ago.
7 changes: 7 additions & 0 deletions app/templates/_posts/2012-09-28-third-post.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: Third Post
date: 2012-09-28
template: post.html
---

A slightly late, less interesting piece of prose.
7 changes: 7 additions & 0 deletions app/templates/_posts/2012-12-07-fourth-post.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: Fourth Post
date: 2012-12-07
template: post.html
---

A really short, rushed-feeling string of words.
1 change: 1 addition & 0 deletions app/templates/gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
46 changes: 46 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "generator-metalsmith",
"version": "0.1.0",
"homepage": "https://github.com/hariadi/generator-metalsmith",
"description": "Yeoman generator for Metalsmith",
"author": {
"name": "Hariadi Hinta",
"url": "https://github.com/hariadi"
},
"license": "ISC",
"main": "app/index.js",
"repository": {
"type": "git",
"url": "https://github.com/hariadi/generator-metalsmith.git"
},
"bugs": {
"url": "https://github.com/hariadi/generator-metalsmith/issues"
},

"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha --reporter spec"
},
"files": [
"app"
],
"dependencies": {
"yeoman-generator": "~0.16.0",
"chalk": "~0.4.0"
},
"devDependencies": {
"mocha": "*"
},
"peerDependencies": {
"yo": ">=1.0.0"
},
"keywords": [
"yeoman-generator",
"metalsmith",
"generator",
"static",
"site"
]
}
Loading

0 comments on commit e9518fe

Please sign in to comment.