1 | (function() {
|
2 | 'use strict';
|
3 | var RevealGenerator, chalk, path, semver, yeoman, yosay,
|
4 | __hasProp = {}.hasOwnProperty,
|
5 | __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
6 |
|
7 | path = require('path');
|
8 |
|
9 | yeoman = require('yeoman-generator');
|
10 |
|
11 | semver = require('semver');
|
12 |
|
13 | yosay = require('yosay');
|
14 |
|
15 | chalk = require('chalk');
|
16 |
|
17 | module.exports = RevealGenerator = (function(_super) {
|
18 | __extends(RevealGenerator, _super);
|
19 |
|
20 | function RevealGenerator() {
|
21 | return RevealGenerator.__super__.constructor.apply(this, arguments);
|
22 | }
|
23 |
|
24 | RevealGenerator.prototype.initializing = function() {
|
25 | this.pkg = this.fs.readJSON(path.join(__dirname, '../package.json'));
|
26 | return this.config.defaults({
|
27 | presentationTitle: 'Reveal.js and Yeoman is Awesomeness',
|
28 | packageVersion: '0.0.0',
|
29 | revealTheme: 'default',
|
30 | useSass: false,
|
31 | deployToGithubPages: false
|
32 | });
|
33 | };
|
34 |
|
35 | RevealGenerator.prototype.prompting = {
|
36 | askFor: function() {
|
37 | var cb, prompts;
|
38 | cb = this.async();
|
39 | this.log(yosay());
|
40 | this.log(chalk.magenta('This includes the amazing Reveal.js Framework\n' + 'and a Grunt file for your presentation pleasure.\n'));
|
41 | prompts = [
|
42 | {
|
43 | name: 'presentationTitle',
|
44 | message: 'What are you going to talk about?',
|
45 | "default": this.config.get('presentationTitle')
|
46 | }, {
|
47 | name: 'packageVersion',
|
48 | message: 'What version should we put in the package.json file?',
|
49 | "default": this.config.get('packageVersion'),
|
50 | validate: function(input) {
|
51 | if (!semver.valid(input)) {
|
52 | return 'Please enter a correct semver version, i.e. MAJOR.MINOR.PATCH.';
|
53 | }
|
54 | return true;
|
55 | }
|
56 | }, {
|
57 | name: 'useSass',
|
58 | message: 'Do you want to use SASS to create a custom theme? This requires you to have Ruby and Sass installed.',
|
59 | type: 'confirm',
|
60 | "default": this.config.get('useSass')
|
61 | }, {
|
62 | name: 'revealTheme',
|
63 | type: 'list',
|
64 | message: 'What Reveal.js theme would you like to use?',
|
65 | when: function(props) {
|
66 | return props.useSass === false;
|
67 | },
|
68 | choices: this.fs.readJSON(path.join(__dirname, './theme_choices.json')),
|
69 | "default": this.config.get('revealTheme')
|
70 | }, {
|
71 | name: 'deployToGithubPages',
|
72 | message: 'Do you want to deploy your presentation to Github Pages? This requires an empty Github repository.',
|
73 | type: 'confirm',
|
74 | "default": this.config.get('deployToGithubPages')
|
75 | }, {
|
76 | name: 'githubUsername',
|
77 | message: 'What is your Github username?',
|
78 | "default": this.config.get('githubUsername'),
|
79 | when: function(props) {
|
80 | return props.deployToGithubPages === true;
|
81 | }
|
82 | }, {
|
83 | name: 'githubRepository',
|
84 | message: 'What is the Github repository name?',
|
85 | "default": this.config.get('githubRepository'),
|
86 | when: function(props) {
|
87 | return props.deployToGithubPages === true;
|
88 | }
|
89 | }
|
90 | ];
|
91 | return this.prompt(prompts, (function(_this) {
|
92 | return function(props) {
|
93 | _this.config.set('presentationTitle', props.presentationTitle);
|
94 | _this.config.set('packageVersion', props.packageVersion);
|
95 | _this.config.set('useSass', props.useSass);
|
96 | _this.config.set('revealTheme', props.revealTheme);
|
97 | _this.config.set('deployToGithubPages', props.deployToGithubPages);
|
98 | _this.config.set('githubUsername', props.githubUsername);
|
99 | _this.config.set('githubRepository', props.githubRepository);
|
100 | return cb();
|
101 | };
|
102 | })(this));
|
103 | }
|
104 | };
|
105 |
|
106 | RevealGenerator.prototype.writing = {
|
107 | app: function() {
|
108 | this.fs.copyTpl(this.templatePath('_index.md'), this.destinationPath('slides/index.md'), this);
|
109 | this.fs.copyTpl(this.templatePath('_Gruntfile.coffee'), this.destinationPath('Gruntfile.coffee'), this);
|
110 | this.fs.copyTpl(this.templatePath('_package.json'), this.destinationPath('package.json'), this);
|
111 | this.fs.copyTpl(this.templatePath('_bower.json'), this.destinationPath('bower.json'), this);
|
112 | this.fs.copy(this.templatePath('loadhtmlslides.js'), this.destinationPath('js/loadhtmlslides.js'));
|
113 | this.fs.copy(this.templatePath('list.json'), this.destinationPath('slides/list.json'));
|
114 | if (this.config.get('useSass')) {
|
115 | this.fs.copy(this.templatePath('theme.scss'), this.destinationPath('css/source/theme.scss'));
|
116 | }
|
117 | this.copy(this.templatePath('__index.html'), this.destinationPath('templates/_index.html'));
|
118 | return this.copy(this.templatePath('__section.html'), this.destinationPath('templates/_section.html'));
|
119 | },
|
120 | projectfiles: function() {
|
121 | this.fs.copy(this.templatePath('editorconfig'), this.destinationPath('.editorconfig'));
|
122 | return this.fs.copy(this.templatePath('jshintrc'), this.destinationPath('.jshintrc'));
|
123 | },
|
124 | runtime: function() {
|
125 | this.fs.copy(this.templatePath('bowerrc'), this.destinationPath('.bowerrc'));
|
126 | return this.fs.copy(this.templatePath('gitignore'), this.destinationPath('.gitignore'));
|
127 | }
|
128 | };
|
129 |
|
130 | RevealGenerator.prototype.install = function() {
|
131 | return this.installDependencies({
|
132 | skipInstall: this.options['skip-install']
|
133 | });
|
134 | };
|
135 |
|
136 | return RevealGenerator;
|
137 |
|
138 | })(yeoman.generators.Base);
|
139 |
|
140 | }).call(this);
|