Skip to content

Commit

Permalink
Added subgenerator for jekyll
Browse files Browse the repository at this point in the history
Added a subgenerator for Jekyll, updated the main app index.js file
accordingly, added tests for Jekyll (currently not 100% complete),
and updated tests and such for it. Everything should now work as it did
before starting to split things up, at least the tests indicate so.
  • Loading branch information
sondr3 committed May 19, 2015
1 parent 66e580d commit b74a88b
Show file tree
Hide file tree
Showing 41 changed files with 1,455 additions and 48 deletions.
79 changes: 70 additions & 9 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,72 @@ module.exports = generators.Base.extend({
},

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

var prompts = [{
name: 'projectName',
message: 'What is the name of your project?'
message: 'What is the name of your project?',
store: true
}, {
name: 'projectDescription',
message: 'Describe your project'
message: 'Describe your project',
store: true
}, {
name: 'projectURL',
message: chalk.red('If you are using GHPages use username.github.io') +
'\nWhat will the URL for your project be?'
'\nWhat will the URL for your project be?',
store: true
}, {
name: 'authorName',
message: 'What\'s your name?'
message: 'What\'s your name?',
store: true
}, {
name: 'authorEmail',
message: 'What\'s your email?'
message: 'What\'s your email?',
store: true
}, {
name: 'authorBio',
message: 'Write a short description about yourself'
message: 'Write a short description about yourself',
store: true
}, {
name: 'authorTwitter',
message: 'Your Twitter handle'
message: 'Your Twitter handle',
store: true,
}, {
name: 'uploading',
type: 'list',
message: 'How do you want to upload your site?',
choices: ['Amazon S3', 'Rsync', 'Github Pages', 'None'],
store: true
}, {
name: 'jekyllPermalinks',
type: 'list',
message: 'Permalink style' + (chalk.red(
'\n pretty: /:year/:month/:day/:title/' +
'\n date: /:year/:month/:day/:title.html' +
'\n none: /:categories/:title.html')) + '\n',
choices: ['pretty', 'date', 'none'],
store: true
}, {
name: 'jekyllPaginate',
message: 'How many posts do you want to show on your front page?' +
chalk.red('\nMust be a number or all'),
store: true,
default: 10,
validate: function(input) {
if (/^[0-9]*$/.test(input)) {
return true;
}
if (/^all*$/i.test(input)) {
return true;
}
return 'Must be a number or all';
}
}];

this.prompt(prompts, function(props) {
this.props = _.extend(this.props, props);
this.config.set(this.props);

done();
}.bind(this));
Expand All @@ -65,8 +102,32 @@ module.exports = generators.Base.extend({
local: require.resolve('../boilerplate')
});

this.composeWith('jekyllized:gulp', {}, {
this.composeWith('jekyllized:gulp', {
options: {
uploading: this.props.uploading
}
}, {
local: require.resolve('../gulp')
});

this.composeWith('jekyllized:jekyll', {
options: {
projectName: this.props.projectName,
projectDescription: this.props.projectDescription,
projectURL: this.props.projectURL,
authorName: this.props.authorName,
authorEmail: this.props.authorEmail,
authorBio: this.props.authorBio,
authorTwitter: this.props.authorTwitter,
jekyllPermalinks: this.props.jekyllPermalinks,
jekyllPaginate: this.props.jekyllPaginate
}
}, {
local: require.resolve('../jekyll')
});
},

installing: function() {
this.npmInstall();
}
});
45 changes: 15 additions & 30 deletions generators/gulp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,12 @@ module.exports = generators.Base.extend({
constructor: function() {
generators.Base.apply(this, arguments);

this.option('amazonS3', {
type: Boolean,
name: 'amazonS3',
desc: 'Do you want to upload to Amazon S3?'
});

this.option('rsync', {
type: Boolean,
name: 'rsync',
desc: 'Do you want to upload to Rsync?'
});

this.option('ghpages', {
type: Boolean,
name: 'ghPages',
desc: 'Do you want to upload to GitHub Pages?'
});
this.option('noUpload', {
type: Boolean,
name: 'noUpload',
desc: 'No uploading'
this.option('uploading', {
required: true,
name: 'uploading',
type: 'list',
message: 'How do you want to upload your site?',
choices: ['Amazon S3', 'Rsync', 'Github Pages', 'None'],
});
},

Expand Down Expand Up @@ -69,17 +54,17 @@ module.exports = generators.Base.extend({
'trash': '^1.4.0'
});

if (this.options.amazonS3) {
if (this.options.uploading === 'Amazon S3') {
pkg.devDependencies['gulp-awspublish'] = '^0.1.0';
pkg.devDependencies['gulp-awspublish-router'] = '^0.1.0';
pkg.devDependencies['concurrent-transform'] = '^1.0.0';
}

if (this.options.rsync) {
if (this.options.uploading === 'Rsync') {
pkg.devDependencies['gulp-rsync'] = '^0.0.2';
}

if (this.options.ghPages) {
if (this.options.uploading === 'Github Pages') {
pkg.devDependencies['gulp-gh-pages'] = '^0.4.0';
}

Expand All @@ -91,21 +76,21 @@ module.exports = generators.Base.extend({
this.templatePath('gulpfile.js'),
this.destinationPath('gulpfile.js'),
{
amazonS3: this.options.amazonS3,
rsync: this.options.rsync,
ghPages: this.options.ghPages,
noUpload: this.options.noUpload
amazonS3: this.options.uploading === 'Amazon S3',
rsync: this.options.uploading === 'Rsync',
ghpages: this.options.uploading === 'Github Pages',
noUpload: this.options.uploading === 'None'
}
);

if (this.options.amazonS3) {
if (this.options.uploading === 'Amazon S3') {
this.fs.copyTpl(
this.templatePath('aws-credentials.json'),
this.destinationPath('aws-credentials.json')
);
}

if (this.options.rsync) {
if (this.options.uploading === 'Rsync') {
this.fs.copyTpl(
this.templatePath('rsync-credentials.json'),
this.destinationPath('rsync-credentials.json')
Expand Down
2 changes: 1 addition & 1 deletion generators/gulp/templates/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ function deploy() {
}));
}

<% } -%><% if (ghPages) { -%>
<% } -%><% if (ghpages) { -%>
// Task to upload your site to your personal GH Pages repo
function deploy() {
// Deploys your optimized site, you can change the settings in the html task if you want to
Expand Down
113 changes: 113 additions & 0 deletions generators/jekyll/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
'use strict';

var _ = require('lodash');
var chalk = require('chalk');
var generators = require('yeoman-generator');
var path = require('path');
var yosay = require('yosay');
var shelljs = require('shelljs');

module.exports = generators.Base.extend({
constructor: function() {
generators.Base.apply(this, arguments);

var dependenciesInstalled = ['bundle', 'ruby'].every(function(depend) {
return shelljs.which(depend);
});

if (!dependenciesInstalled) {
this.log('MISSING DEPENDENCIES:' +
'\nEither ' + chalk.white('Ruby') + ' or ' + chalk.white('Bundler') +
' is not installed or missing from $PATH.' +
'\nMake sure that they are either installed or added to $PATH.');
shelljs.exit(1);
}

this.option('projectName', {
type: String,
required: true,
desc: 'Project name'
});

this.option('projectDescription', {
type: String,
required: true,
desc: 'Project description'
});

this.option('projectURL', {
type: String,
required: true,
desc: 'Project URL'
});

this.option('authorName', {
type: String,
required: true,
desc: 'Author name'
});

this.option('authorEmail', {
type: String,
required: true,
desc: 'Author email'
});

this.option('authorBio', {
type: String,
required: true,
desc: 'Author bio'
});

this.option('authorTwitter', {
type: String,
required: true,
desc: 'Author twitter'
});

this.option('jekyllPermalink', {
type: String,
required: true,
desc: 'Jekyll permalinks'
});

this.option('jekyllPaginate', {
type: String,
required: true,
desc: 'Jekyll paginate'
});
},

writing: function() {
this.fs.copy(
this.templatePath('Gemfile'),
this.destinationPath('Gemfile')
);

this.fs.copyTpl(
this.templatePath('config.yml'),
this.destinationPath('_config.yml'),
{
projectName: this.options.projectName,
projectDescription: this.options.projectDescription,
projectURL: this.options.projectURL,
authorName: this.options.authorName,
authorEmail: this.options.authorEmail,
authorBio: this.options.authorBio,
authorTwitter: this.options.authorTwitter,
jekyllPermalinks: this.options.jekyllPermalinks,
jekyllPaginate: this.options.jekyllPaginate
}
);

this.fs.copyTpl(
this.templatePath('config.build.yml'),
this.destinationPath('_config.build.yml')
);

this.fs.copy(
this.templatePath('app'),
this.destinationPath('src')
);
}
});
8 changes: 8 additions & 0 deletions generators/jekyll/templates/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
source "http://rubygems.org"

gem 'jekyll'
gem 'redcarpet'

# jekyll plugins
gem 'jekyll-archives', :git => 'https://github.com/jekyll/jekyll-archives'
gem 'jekyll-sitemap'
11 changes: 11 additions & 0 deletions generators/jekyll/templates/app/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
layout: default
title: "404: Page not found"
---

<div class="page">
<h1 class="page-title">404: Page not found</h1>
<p class="lead">Sorry, we've misplaced that URL or it's pointing to something
that doesn't exist. <a href="/">Head back home</a> to try finding it
again.</p>
</div>
Loading

0 comments on commit b74a88b

Please sign in to comment.