diff options
Diffstat (limited to 'gulpfile.js')
-rw-r--r-- | gulpfile.js | 47 |
1 files changed, 40 insertions, 7 deletions
diff --git a/gulpfile.js b/gulpfile.js index a76cafa..0e0f792 100644 --- a/gulpfile.js +++ b/gulpfile.js | |||
@@ -69,14 +69,15 @@ | |||
69 | var files = fs.readdirSync(paths.talks); | 69 | var files = fs.readdirSync(paths.talks); |
70 | 70 | ||
71 | for (var i = 0; i < files.length; i++) { | 71 | for (var i = 0; i < files.length; i++) { |
72 | var file = paths.talks + '/' + files[i] + '/index.html'; | 72 | var file = paths.talks + '/' + files[i]; |
73 | try { | 73 | try { |
74 | var stat = fs.statSync(file); | 74 | var stat = fs.statSync(file); |
75 | var $ = cheerio.load(fs.readFileSync(file)); | 75 | var $ = cheerio.load(fs.readFileSync(file)); |
76 | presentations.push({ | 76 | presentations.push({ |
77 | 'title': $("head title").text(), | 77 | 'title': $("head title").text(), |
78 | 'description': $("head meta[name='description']").attr('content'), | ||
78 | 'mtime': stat.mtime, | 79 | 'mtime': stat.mtime, |
79 | 'path': files[i] + '/index.html' | 80 | 'path': 'talks/' + files[i].replace('.hbs', '.html') |
80 | }); | 81 | }); |
81 | } catch (e) { | 82 | } catch (e) { |
82 | // Do nothing | 83 | // Do nothing |
@@ -123,6 +124,12 @@ | |||
123 | return fs.readFileSync(file, {'encoding': 'utf-8'}); | 124 | return fs.readFileSync(file, {'encoding': 'utf-8'}); |
124 | } | 125 | } |
125 | 126 | ||
127 | function performTalkTemplateChange(content) { | ||
128 | var file = dir.src + '/layout/talk.hbs'; | ||
129 | var stat = fs.statSync(file); | ||
130 | return fs.readFileSync(file, {'encoding': 'utf-8'}); | ||
131 | } | ||
132 | |||
126 | /** | 133 | /** |
127 | * Clean the output directory. | 134 | * Clean the output directory. |
128 | * | 135 | * |
@@ -201,7 +208,7 @@ | |||
201 | /** | 208 | /** |
202 | * Package the handlebars files. | 209 | * Package the handlebars files. |
203 | */ | 210 | */ |
204 | gulp.task('package:talks', function () { | 211 | gulp.task('package:talkindex', function () { |
205 | 212 | ||
206 | var templateData = { | 213 | var templateData = { |
207 | 'presentations': buildPresentationManifest(), | 214 | 'presentations': buildPresentationManifest(), |
@@ -209,7 +216,7 @@ | |||
209 | }; | 216 | }; |
210 | 217 | ||
211 | // Automatically build the site list. | 218 | // Automatically build the site list. |
212 | return gulp.src(paths.talks + '/index.hbs', {'base': dir.src}) | 219 | return gulp.src(dir.src + '/talks.hbs', {'base': dir.src}) |
213 | .pipe(handlebars(templateData, handlebarsConfig)) | 220 | .pipe(handlebars(templateData, handlebarsConfig)) |
214 | .pipe(rename(function (path) { | 221 | .pipe(rename(function (path) { |
215 | path.extname = ".html"; | 222 | path.extname = ".html"; |
@@ -260,6 +267,31 @@ | |||
260 | .pipe(gulp.dest(dir.dist)); | 267 | .pipe(gulp.dest(dir.dist)); |
261 | }); | 268 | }); |
262 | 269 | ||
270 | |||
271 | gulp.task('package:talks', function () { | ||
272 | |||
273 | var templateData = { | ||
274 | 'author': packageJson.author | ||
275 | }; | ||
276 | |||
277 | // Automatically build the site list. | ||
278 | return gulp.src(dir.src + '/talks/*.hbs', {'base': dir.src}) | ||
279 | .pipe(data(function(file) { | ||
280 | var stat = fs.statSync(file.path); | ||
281 | var $ = cheerio.load(fs.readFileSync(file.path)); | ||
282 | return { | ||
283 | 'title': $("head title").text(), | ||
284 | 'description': $("head meta[name='description']").attr('content'), | ||
285 | 'body': $("body").html(), | ||
286 | }})) | ||
287 | .pipe(change(performTalkTemplateChange)) | ||
288 | .pipe(handlebars(templateData, handlebarsConfig)) | ||
289 | .pipe(rename(function (path) { | ||
290 | path.extname = ".html"; | ||
291 | })) | ||
292 | .pipe(gulp.dest(dir.dist)); | ||
293 | }); | ||
294 | |||
263 | /** | 295 | /** |
264 | * Copy the HTML files into the dist folder. | 296 | * Copy the HTML files into the dist folder. |
265 | */ | 297 | */ |
@@ -328,9 +360,10 @@ | |||
328 | /** | 360 | /** |
329 | * Package the entire site into the dist folder. | 361 | * Package the entire site into the dist folder. |
330 | */ | 362 | */ |
331 | gulp.task('package', ['package:html', 'package:talks', | 363 | gulp.task('package', ['package:html', |
332 | 'package:posts', | 364 | 'package:talks', 'package:talkindex', |
333 | 'package:postindex', 'package:libs', | 365 | 'package:posts', 'package:postindex', |
366 | 'package:libs', | ||
334 | 'package:images', 'package:css', 'package:js']); | 367 | 'package:images', 'package:css', 'package:js']); |
335 | 368 | ||
336 | gulp.task('rsync', function () { | 369 | gulp.task('rsync', function () { |