Skip to content

Commit 4f6b266

Browse files
committed
grunt enabled
1 parent a02e69a commit 4f6b266

File tree

6 files changed

+175
-131
lines changed

6 files changed

+175
-131
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/.idea
22
/node_modules
3-
/out
3+
/out
4+
5+
/.grunt

Gruntfile.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
module.exports = function (grunt) {
2+
'use strict';
3+
4+
var path = require('path');
5+
6+
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
7+
8+
grunt.loadTasks('./tasks')
9+
10+
grunt.initConfig({
11+
pkg: grunt.file.readJSON('package.json'),
12+
clean: {
13+
out: [
14+
'out/**/*'
15+
]
16+
},
17+
'gh-pages': {
18+
options: {
19+
base: 'out',
20+
branch: 'master',
21+
repo: 'https://github.com/DefinitelyTyped/definitelytyped.github.io.git'
22+
},
23+
src: '**/*'
24+
},
25+
docpad: {
26+
options: require('./docpad'),
27+
generate: {
28+
action: 'generate'
29+
},
30+
run: {
31+
action: 'run'
32+
}
33+
}
34+
});
35+
36+
grunt.registerTask('prep', [
37+
'clean:out',
38+
]);
39+
grunt.registerTask('build', [
40+
'prep',
41+
'docpad:generate',
42+
]);
43+
grunt.registerTask('test', [
44+
'build',
45+
]);
46+
grunt.registerTask('publish', [
47+
'test',
48+
'gh-pages',
49+
]);
50+
51+
grunt.registerTask('watch', [
52+
'prep',
53+
'docpad:run',
54+
]);
55+
56+
grunt.registerTask('default', ['build']);
57+
};

docpad.coffee

Lines changed: 0 additions & 124 deletions
This file was deleted.

docpad.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
var docpadConfig = {
2+
templateData: {
3+
site: {
4+
url: "http://definitelytyped.github.io",
5+
oldUrls: [],
6+
title: "DefinitelyTyped",
7+
description: "The repository for high quality TypeScript type definitions.",
8+
keywords: "typescript, type, definition, declaration, repository, typing",
9+
styles: ['/vendor/normalize.css', '/vendor/h5bp.css', '/styles/style.css'],
10+
scripts: ["<script src=\"//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js\"></script>\n<script>window.jQuery || document.write('<script src=\"/vendor/jquery.js\"><\\/script>')</script>", '/vendor/log.js', '/vendor/modernizr.js', '/scripts/script.js']
11+
},
12+
getPreparedTitle: function() {
13+
if (this.document.title) {
14+
return "" + this.document.title + " | " + this.site.title;
15+
} else {
16+
return this.site.title;
17+
}
18+
},
19+
getPreparedDescription: function() {
20+
return this.document.description || this.site.description;
21+
},
22+
getPreparedKeywords: function() {
23+
return this.site.keywords.concat(this.document.keywords || []).join(', ');
24+
}
25+
},
26+
collections: {
27+
posts: function() {
28+
return this.getCollection('documents').findAllLive({
29+
relativeOutDirPath: 'posts'
30+
});
31+
}
32+
},
33+
environments: {
34+
development: {
35+
templateData: {
36+
site: {
37+
url: false
38+
}
39+
}
40+
}
41+
},
42+
events: {
43+
serverExtend: function(opts) {
44+
var server = opts.server;
45+
var docpad = this.docpad;
46+
var latestConfig = docpad.getConfig();
47+
var oldUrls = latestConfig.templateData.site.oldUrls || [];
48+
var newUrl = latestConfig.templateData.site.url;
49+
return server.use(function(req, res, next) {
50+
if (oldUrls.indexOf(req.headers.host) >= 0) {
51+
return res.redirect(newUrl + req.url, 301);
52+
} else {
53+
return next();
54+
}
55+
});
56+
}
57+
}
58+
};
59+
60+
module.exports = docpadConfig;

package.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,18 @@
2222
"node": "0.10",
2323
"npm": "1.3"
2424
},
25-
"dependencies": {
26-
"docpad": "~6.64.0",
25+
"dependencies": {},
26+
"devDependencies": {
27+
"docpad": "~6.63.0",
2728
"docpad-plugin-eco": "~2.0.3",
2829
"docpad-plugin-marked": "~2.2.0",
2930
"docpad-plugin-partials": "~2.9.0",
30-
"docpad-plugin-less": "~2.4.1"
31-
},
32-
"devDependencies": {
33-
"docpad-plugin-livereload": "~2.6.0"
31+
"docpad-plugin-less": "~2.4.1",
32+
"docpad-plugin-livereload": "~2.6.0",
33+
"grunt": "^0.4.4",
34+
"grunt-gh-pages": "^0.9.1",
35+
"grunt-contrib-clean": "^0.5.0",
36+
"matchdep": "^0.3.0"
3437
},
3538
"main": "node_modules/docpad/bin/docpad-server"
3639
}

tasks/docpad.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* grunt-docs
3+
* https://github.com/shama/grunt-docs
4+
*
5+
* Copyright (c) 2013 Kyle Robinson Young
6+
* Licensed under the MIT license.
7+
*/
8+
9+
module.exports = function (grunt) {
10+
'use strict';
11+
12+
var assert = require('assert');
13+
var docpad = require('docpad');
14+
15+
var watchFull = ['server', 'watch', 'run'];
16+
function isWatch(action) {
17+
return action.split(/ +/).some(function(action) {
18+
return watchFull.indexOf(action) > -1;
19+
})
20+
}
21+
22+
grunt.registerMultiTask('docpad', 'Fun with DocPad', function () {
23+
var options = this.options({});
24+
var action = this.data.action;
25+
assert((typeof action === 'string'), 'action not defined');
26+
27+
// To allow paths config to use patterns
28+
Object.keys(options).forEach(function (key) {
29+
if (key.slice(-5) === 'Paths') {
30+
options[key] = grunt.file.expand(config[key]);
31+
}
32+
});
33+
34+
var done = this.async();
35+
docpad.createInstance(options, function (err, inst) {
36+
inst.action(action, function (err) {
37+
if (err) {
38+
return grunt.warn(err);
39+
}
40+
if (!isWatch(action)) {
41+
done();
42+
}
43+
});
44+
});
45+
});
46+
};

0 commit comments

Comments
 (0)