UNPKG

2.61 kBJavaScriptView Raw
1(function() {
2 'use strict';
3 var SlideGenerator, fs, path, yeoman,
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 fs = require('fs');
8
9 path = require('path');
10
11 yeoman = require('yeoman-generator');
12
13 module.exports = SlideGenerator = (function(_super) {
14 __extends(SlideGenerator, _super);
15
16 function SlideGenerator() {
17 return SlideGenerator.__super__.constructor.apply(this, arguments);
18 }
19
20 SlideGenerator.prototype.configuring = function() {
21 this.option('notes', {
22 desc: 'Include speaker notes',
23 type: Boolean,
24 "default": false
25 });
26 this.option('markdown', {
27 desc: 'Use markdown',
28 type: Boolean,
29 "default": false
30 });
31 return this.option('attributes', {
32 desc: 'Include attributes on slide sections, e.g. data-background, class, etc.',
33 type: Boolean,
34 "default": false
35 });
36 };
37
38 SlideGenerator.prototype.writing = function() {
39 var fullPath, list;
40 fullPath = this.destinationPath('slides/list.json');
41 list = this.fs.readJSON(fullPath);
42 if (this.options.markdown) {
43 this.filename = "" + (this._.slugify(this.name)) + ".md";
44 this.log.info('Using Markdown.');
45 if (this.options.notes) {
46 this.template('slide-withnotes.md', "slides/" + this.filename);
47 } else {
48 this.template('slide.md', "slides/" + this.filename);
49 }
50 } else {
51 this.filename = "" + (this._.slugify(this.name)) + ".html";
52 this.log.info('Using HTML.');
53 if (this.options.notes) {
54 this.template('slide-withnotes.html', "slides/" + this.filename);
55 } else {
56 this.template('slide.html', "slides/" + this.filename);
57 }
58 }
59 if (this.options.attributes) {
60 this.log.info("Appending slides/" + this.filename + " to slides/list.json.");
61 list.push({
62 filename: this.filename,
63 attr: {
64 'data-background': '#ff0000'
65 }
66 });
67 } else {
68 this.log.info("Appending slides/" + this.filename + " to slides/list.json.");
69 list.push(this.filename);
70 }
71 return fs.writeFileSync(fullPath, JSON.stringify(list, null, 4));
72 };
73
74 return SlideGenerator;
75
76 })(yeoman.generators.NamedBase);
77
78}).call(this);