From 89ae9df5de906ef45968830bac4569274bc9315a Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Sat, 1 Aug 2015 06:21:17 +1000 Subject: Try to make a templated layout --- gulpfile.js | 38 +++++++++++++++++++++++-- package.json | 2 ++ src/posts/big-tent.html | 73 ++++--------------------------------------------- src/templates/post.hbs | 66 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 110 insertions(+), 69 deletions(-) create mode 100644 src/templates/post.hbs diff --git a/gulpfile.js b/gulpfile.js index 612ebee..3f63fa6 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -10,6 +10,8 @@ var git = require('gulp-git'); var filter = require('gulp-filter'); var less = require('gulp-less'); + var data = require('gulp-data'); + var change = require('gulp-change'); var rsync = require('gulp-rsync'); var webserver = require('gulp-webserver'); var streamqueue = require('streamqueue'); @@ -101,6 +103,8 @@ var $ = cheerio.load(fs.readFileSync(file)); posts.push({ 'title': $("head title").text(), + 'description': $("head meta[name='description']").attr('content'), + 'body': $("body").text(), 'mtime': stat.mtime, 'path': 'posts/' + files[i] }); @@ -114,6 +118,12 @@ return posts; } + function performTemplateChange(content) { + var file = dir.src + '/templates/post.hbs'; + var stat = fs.statSync(file); + return fs.readFileSync(file, {'encoding': 'utf-8'}); + } + /** * Clean the output directory. * @@ -211,7 +221,7 @@ /** * Package the handlebars files. */ - gulp.task('package:posts', function () { + gulp.task('package:postindex', function () { var templateData = { 'posts': buildPostManifest(), @@ -227,6 +237,30 @@ .pipe(gulp.dest(dir.dist)); }); + gulp.task('package:posts', function () { + + var templateData = { + 'author': packageJson.author + }; + + // Automatically build the site list. + return gulp.src(dir.src + '/posts/*.html', {'base': dir.src}) + .pipe(data(function(path) { + var stat = fs.statSync(path); + var $ = cheerio.load(fs.readFileSync(path)); + return { + 'title': $("head title").text(), + 'description': $("head meta[name='description']").attr('content'), + 'body': $("body").text(), + }})) + .pipe(change(performTemplateChange)) + .pipe(handlebars(templateData, handlebarsConfig)) + .pipe(rename(function (path) { + path.extname = ".html"; + })) + .pipe(gulp.dest(dir.dist)); + }); + /** * Copy the HTML files into the dist folder. */ @@ -296,7 +330,7 @@ * Package the entire site into the dist folder. */ gulp.task('package', ['package:html', 'package:talks', 'package:posts', - 'package:libs', + 'package:postindex', 'package:libs', 'package:images', 'package:css', 'package:js']); gulp.task('rsync', function () { diff --git a/package.json b/package.json index de762dc..8346b66 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,9 @@ "bower": "^1.4.1", "cheerio": "^0.19.0", "gulp": "^3.9.0", + "gulp-change": "^1.0.0", "gulp-compile-handlebars": "^0.5.0", + "gulp-data": "^1.2.0", "gulp-filter": "^3.0.0", "gulp-git": "^1.2.4", "gulp-ignore": "^1.2.1", diff --git a/src/posts/big-tent.html b/src/posts/big-tent.html index 8b71e0c..981913a 100644 --- a/src/posts/big-tent.html +++ b/src/posts/big-tent.html @@ -1,47 +1,9 @@ - - - - - The Big Tent - - - - - - - - - - - - - - - -
-
-

- - The Big Tent -

-

OpenStack as Layers but also tents but also cats

-
-
- -
+ + + + The Big Tent + +

I'd like to build on the ideas in Sean's Layers. I've been noodling on it for a while and have had a several interesting conversations with people. Before I tell you how I've taxonomied things in my head, I want to spend a second on why.

Why do we care?

Our choices in organizing our work effect a few different unrelated things:

@@ -223,28 +185,5 @@ designate call-that-ip 'blog.inaugust.com' --also-reverse-dns-kthxbai #

We can actually let the market decided more on the relative importance of things without us needing to predecide that.

We can take a much stronger position on some of the topics, such as "Compute instances need IP Addresses" without having to put ourselves in the position to take such a strong stance on everything else.

Who's with me?

- -
- - - diff --git a/src/templates/post.hbs b/src/templates/post.hbs new file mode 100644 index 0000000..dd2187e --- /dev/null +++ b/src/templates/post.hbs @@ -0,0 +1,66 @@ + + + + + {{ title }} + + + + + + + + + + + + + + +
+
+

+ + {{ title }} +

+

{{ description }}

+
+
+ +
+ {{{ body }}} +
+ + + + + -- cgit v1.2.3