Skip to content

Commit

Permalink
Update Bootstrap v3.0 and lots of thing. #1
Browse files Browse the repository at this point in the history
  • Loading branch information
hariadi committed Jun 12, 2013
1 parent c862026 commit a970fa0
Show file tree
Hide file tree
Showing 72 changed files with 5,865 additions and 4,818 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ node_modules/
temp/ temp/
*.sublime-project *.sublime-project
*.sublime-workspace *.sublime-workspace
src/
Gruntfile.js
.jshintrc .jshintrc
37 changes: 37 additions & 0 deletions Gruntfile.js
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* generator-assemble
* http://github.com/hariadi/generator-assemble
*
* Copyright (c) 2012 Hariadi Hinta
* Licensed under the MIT license.
*/

'use strict';

module.exports = function(grunt) {

// Project configuration.
grunt.initConfig({

jshint: {
all_files: [
'Gruntfile.js',
'test/*'
],
options: {
jshintrc: '.jshintrc',
}
},

clean: ['test/temp/**']

});

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

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

};
129 changes: 52 additions & 77 deletions app/index.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ var util = require('util');
var path = require('path'); var path = require('path');
var yeoman = require('yeoman-generator'); var yeoman = require('yeoman-generator');


var separator = '\n=====================================\n'; var separator = '\n===============================================\n';


var AssembleGenerator = module.exports = function AssembleGenerator(args, options, config) { var AssembleGenerator = module.exports = function AssembleGenerator(args, options, config) {
yeoman.generators.Base.apply(this, arguments); yeoman.generators.Base.apply(this, arguments);

this.gruntFile = this.readFileAsString(path.join(this.sourceRoot(), 'Gruntfile.js')); this.gruntFile = this.readFileAsString(path.join(this.sourceRoot(), 'Gruntfile.js'));
this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json'))); this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json')));

this.on('end', function () { this.on('end', function () {
this.installDependencies({ skipInstall: options['skip-install'] }); this.installDependencies({ skipInstall: options['skip-install'] });
}); });
Expand All @@ -21,7 +21,7 @@ util.inherits(AssembleGenerator, yeoman.generators.NamedBase);


AssembleGenerator.prototype.askFor = function askFor() { AssembleGenerator.prototype.askFor = function askFor() {
var cb = this.async(); var cb = this.async();

if(!this.options.silent){ if(!this.options.silent){


var assembleInfo = 'This task will create one or more files in the\n' + var assembleInfo = 'This task will create one or more files in the\n' +
Expand All @@ -31,15 +31,15 @@ AssembleGenerator.prototype.askFor = function askFor() {
'\n _-----_' + '\n _-----_' +
'\n | |' + '\n | |' +
'\n |'+'--(o)--'.red+'| .--------------------------.' + '\n |'+'--(o)--'.red+'| .--------------------------.' +
'\n `---------´ | '+'Welcome to Yeoman,'.yellow.bold+' |' + '\n `---------´ | '+'Welcome to Yeoman,'.yellow.bold+' |' +
'\n '+'( '.yellow+'_'+'´U`'.yellow+'_'+' )'.yellow+' | '+'ladies and gentlemen!'.yellow.bold+' |' + '\n '+'( '.yellow+'_'+'´U`'.yellow+'_'+' )'.yellow+' | '+'ladies and gentlemen!'.yellow.bold+' |' +
'\n /___A___\\ \'__________________________\'' + '\n /___A___\\ \'__________________________\'' +
'\n | ~ |'.yellow + '\n | ~ |'.yellow +
'\n __'+'\'.___.\''.yellow+'__' +' '+'Assemble Generators'.yellow.bold+ '\n __'+'\'.___.\''.yellow+'__' +' '+'Assemble Generators'.yellow.bold+
'\n ´ '+'` |'.red+'° '+'´ Y'.red+' `\n' + separator.yellow + '\n'+ assembleInfo +'\n'.red.bold + separator.yellow; '\n ´ '+'` |'.red+'° '+'´ Y'.red+' `\n' + separator.yellow + '\n'+ assembleInfo +'\n'.red.bold + separator.yellow;
console.log(welcome); console.log(welcome);
} }

var prompts = [{ var prompts = [{
name: 'includeReadMe', name: 'includeReadMe',
message: 'Would you like to include Assemble README configuration?', message: 'Would you like to include Assemble README configuration?',
Expand All @@ -52,6 +52,40 @@ AssembleGenerator.prototype.askFor = function askFor() {
warning: 'Yes: Sitemap config and files will be placed into the project directory.' warning: 'Yes: Sitemap config and files will be placed into the project directory.'
}]; }];


this.files = this.expandFiles('**/*', { cwd: this.sourceRoot(), dot: true });

this.dotfiles = [
'editorconfig',
'gitattributes',
'gitignore',
'jshint'
];

this._files = [ '_package.json' ];

this.readmefiles = [
'AUTHORS',
'CHANGELOG',
'ROADMAP',
'src/templates/readme.md.hbs',
'src/templates/partials/readme/contributing.md.hbs',
'src/templates/partials/readme/options.md.hbs',
'src/templates/partials/readme/documentation.md.hbs',
'src/templates/partials/readme/footer.md.hbs',
'src/templates/partials/readme/getting-started.md.hbs'
];

this.sitemapfiles = [
'src/data/sitemap.json',
'src/templates/sitemap.hbs'
];

this.gruntfiles = [ 'Gruntfile.js' ];

this.ignores = this.dotfiles.concat(this._files, this.readmefiles, this.sitemapfiles, this.gruntfiles);

//console.log('src/templates/partials/readme/contributing.md.hbs'.indexOf('/readme/'));

this.prompt(prompts, function (err, props) { this.prompt(prompts, function (err, props) {
if (err) { if (err) {
return this.emit('error', err); return this.emit('error', err);
Expand All @@ -64,80 +98,21 @@ AssembleGenerator.prototype.askFor = function askFor() {
}; };


AssembleGenerator.prototype.app = function app() { AssembleGenerator.prototype.app = function app() {
this.mkdir('dist'); var files = this.files;
this.mkdir('config'); files.forEach(function(file) {
this.mkdir('helper');
this.mkdir('src');
this.mkdir('src/content');
this.mkdir('src/data');
this.mkdir('src/templates');
this.mkdir('src/templates/layouts');
this.mkdir('src/templates/pages');
this.mkdir('src/templates/partials');
if (this.includeReadMe) {
this.mkdir('src/templates/partials/readme');
}
};


AssembleGenerator.prototype.config = function config() { if (!this.includeSitemap && this.readmefiles.indexOf(file) !== -1) {
this.copy('config/global.yml', 'config/global.yml'); return;
this.copy('config/site.yml', 'config/site.yml'); }

if (this.includeReadMe) {
this.copy('config/readme.yml', 'config/readme.yml');
this.copy('AUTHORS', 'AUTHORS');
this.copy('CHANGELOG', 'CHANGELOG');
this.copy('ROADMAP', 'ROADMAP');
this.copy('src/templates/readme.md', 'src/templates/readme.md.hbs');
this.copy('src/templates/partials/readme/contributing.md', 'src/templates/partials/readme/contributing.md.hbs');
this.copy('src/templates/partials/readme/documentation.md', 'src/templates/partials/readme/documentation.md.hbs');
this.copy('src/templates/partials/readme/footer.md', 'src/templates/partials/readme/footer.md.hbs');
this.copy('src/templates/partials/readme/getting-started.md', 'src/templates/partials/readme/getting-started.md.hbs');
}
if (this.includeSitemap) {
this.copy('config/sitemap.yml', 'config/sitemap.yml');
this.copy('src/data/sitemap.json', 'src/data/sitemap.json');
this.copy('src/templates/sitemap.hbs', 'src/templates/sitemap.hbs');
}
};


AssembleGenerator.prototype.basic = function basic() { if (!this.includeSitemap && this.sitemapfiles.indexOf(file) !== -1) {
this.copy('src/content/code.md', 'src/content/code.md'); return;
this.copy('src/content/links.md', 'src/content/links.md'); }
this.copy('src/data/alert.json', 'src/data/alert.json');
this.copy('src/data/button.json', 'src/data/button.json');
this.copy('src/templates/layouts/default.hbs', 'src/templates/layouts/default.hbs');
this.copy('src/templates/pages/basic.hbs', 'src/templates/pages/basic.hbs');
this.copy('src/templates/pages/index.hbs', 'src/templates/pages/index.hbs');
this.copy('src/templates/pages/markdown.hbs', 'src/templates/pages/markdown.hbs');
this.copy('src/templates/pages/partials.hbs', 'src/templates/pages/partials.hbs');
this.copy('src/templates/partials/alert.hbs', 'src/templates/partials/alert.hbs');
this.copy('src/templates/partials/button.hbs', 'src/templates/partials/button.hbs');
this.copy('src/templates/partials/nav.hbs', 'src/templates/partials/nav.hbs');
};


AssembleGenerator.prototype.helper = function helper() { this.copy(file, file);
this.copy('helper/helper.js', 'helper/helper.js');
};


AssembleGenerator.prototype.git = function git() { }, this);
this.copy('gitignore', '.gitignore');
this.copy('gitattributes', '.gitattributes');
}; };


AssembleGenerator.prototype.packageJSON = function packageJSON() {
this.template('_package.json', 'package.json');
};


AssembleGenerator.prototype.writeGruntFile = function writeGruntFile() {
this.copy('Gruntfile.js', 'Gruntfile.js');
};

AssembleGenerator.prototype.jshint = function jshint() {
this.copy('jshintrc', '.jshintrc');
};


AssembleGenerator.prototype.common = function common() {
this.copy('common/favicon.ico', 'dist/favicon.ico');
this.copy('common/robots.txt', 'dist/robots.txt');
};
14 changes: 14 additions & 0 deletions app/templates/.editorconfig
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,14 @@
# 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

[Makefile]
indent_style = tab
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions app/templates/AUTHORS
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1 @@
Hariadi Hinta (http://github.com/hariadi) Hariadi Hinta (http://github.com/hariadi)
Brian Woodward (http://github.com/doowb)
Jon Schlinkert (http://github.com/jonschlinkert)
2 changes: 1 addition & 1 deletion app/templates/CHANGELOG
Original file line number Original file line Diff line number Diff line change
@@ -1,7 +1,7 @@
v0.2.1: v0.2.1:
date: "2013-06-12" date: "2013-06-12"
changes: changes:
- Completely refactored. New custom helpers, examples and documentation. - Update Assemble example basic, custom helpers, examples and documentation.
- Update repo description. - Update repo description.
v0.1.1: v0.1.1:
date: "2013-03-01" date: "2013-03-01"
Expand Down
75 changes: 48 additions & 27 deletions app/templates/Gruntfile.js
Original file line number Original file line Diff line number Diff line change
@@ -1,9 +1,9 @@
/* /*
* Generated on <%= (new Date).toISOString().split('T')[0] %> * Generated on <%= (new Date).toISOString().split('T')[0] %>
* <%= pkg.name %> <%= pkg.version %> * <%= pkg.name %> <%= pkg.version %>
* https://github.com/hariadi/generator-assemble * <%= pkg.homepage %>
* *
* Copyright (c) 2013 Hariadi Hinta * Copyright (c) <%= (new Date).getFullYear() %> <%= pkg.author.name %>
* Licensed under the MIT license. * Licensed under the MIT license.
*/ */


Expand All @@ -23,48 +23,69 @@ module.exports = function(grunt) {


assemble: { assemble: {
// Global configuration // Global configuration
options: grunt.file.readYAML('config/global.yml'), options: {
assets: 'dist/assets',
data: 'src/data/*.{json,yml}',
partials: [
'src/templates/partials/{,*/}*.hbs',
'src/content/*.hbs'
],
registerFunctions: function(engine) {
var helpers = require('./helper/helpers');
engine.engine.registerFunctions(helpers);
}
},


site: { site: {
options: grunt.file.readYAML('config/site.yml'), options: {
src: 'src/templates/pages/{,*/}*.hbs', flatten: true,
dest: 'dist/' layout: 'src/templates/layouts/default.hbs'
},
files: [
{
expand: true,
cwd: 'src/templates/pages',
src: ['*.hbs', '!index.hbs'],
dest: 'dist/'
},
{
expand: true,
cwd: 'src/templates/pages',
src: ['index.hbs'],
dest: './' }
]
}<% if (includeReadMe) { %>, }<% if (includeReadMe) { %>,


readme: { readme: {
options: grunt.file.readYAML('config/readme.yml'), options: {
flatten: true,
partials: 'src/templates/partials/readme/{,*/}*.hbs',
data: './package.json',
ext: ''
},
src: 'src/templates/readme.md.hbs', src: 'src/templates/readme.md.hbs',
dest: 'dist/' dest: 'dist/'
}<% } %><% if (includeSitemap) { %>, }<% } %><% if (includeSitemap) { %>,


sitemap: { sitemap: {
options: grunt.file.readYAML('config/sitemap.yml'), options: {
component: {
name: 'generator-assemble',
description: 'Yeoman generator for Assemble'
},
ext: '.xml',
data: 'src/sitemap.json',
flatten: true
},
files: { files: {
'dist/sitemap.xml': ['src/templates/sitemap.hbs'] 'dist/sitemap.xml': ['src/templates/sitemap.hbs']
} }
}<% } %>, }<% } %>

helpers: {
options: {
flatten: true,
registerFunctions: function(engine) {
var helpers = require('./helper/custom-helpers');
engine.engine.registerFunctions(helpers);
}
},
files: [
{ expand: true, cwd: 'src/templates/custom-helpers', src: ['helpers.hbs'], dest: 'dist/' }
]
}
}, },


// Before generating any new files, // Before generating any new files,
// remove any previously-created files. // remove any previously-created files.
clean: { clean: ['dist/**/*.{html,xml}']
dest: {
pages: ['dist/{,*/}*.html']
}
}


}); });


Expand Down
2 changes: 1 addition & 1 deletion app/templates/LICENSE-MIT
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2013 Jon Schlinkert Copyright (c) <%= (new Date).getFullYear() %> <%= pkg.author.name %>


Permission is hereby granted, free of charge, to any person Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation obtaining a copy of this software and associated documentation
Expand Down
Loading

0 comments on commit a970fa0

Please sign in to comment.