Static copy was bailing on unlinking the directory, now just overcopies
This commit is contained in:
parent
1c9c8b1a5a
commit
634bddc093
2 changed files with 38 additions and 27 deletions
41
post.js
41
post.js
|
@ -162,9 +162,9 @@ Post.prototype.build = function (callback) {
|
|||
year = moment(this.get("postDate")).format("YYYY");
|
||||
month = moment(this.get("postDate")).format("MM");
|
||||
|
||||
// Post.buildYearIndex(year, function (err) {
|
||||
// if (err) console.log(err);
|
||||
// });
|
||||
Post.buildYearIndex(year, function (err) {
|
||||
if (err) console.log(err);
|
||||
});
|
||||
Post.buildMonthIndex(year, month, function (err) {
|
||||
if (err) console.log(err);
|
||||
});
|
||||
|
@ -325,7 +325,7 @@ Post.getNeedsUpload = function (callback) {
|
|||
Post.buildMonthIndex = function (year, month, callback) {
|
||||
console.log('Rendering month index: '+year+'/'+month);
|
||||
|
||||
directory = config.buildDir
|
||||
var directory = config.buildDir
|
||||
directory += "/blog/";
|
||||
directory += year + '/' + month + '/';
|
||||
|
||||
|
@ -334,7 +334,8 @@ Post.buildMonthIndex = function (year, month, callback) {
|
|||
if (!err) {
|
||||
db.collection('posts').find({
|
||||
$where: '(this.postDate >= new Date('+year+', '+month+'-1, 1, 0, 0, 0)) \
|
||||
&& (this.postDate <= new Date('+year+', '+month+', 0, 23, 59, 59))'
|
||||
&& (this.postDate <= new Date('+year+', '+month+', 0, 23, 59, 59)) \
|
||||
&& this.published'
|
||||
}, {sort: [['postDate', 'desc'],['title', 'asc']]}
|
||||
).toArray(function (err, docs) {
|
||||
if (!err) {
|
||||
|
@ -372,35 +373,45 @@ Post.buildMonthIndex = function (year, month, callback) {
|
|||
Post.buildYearIndex = function (year, callback) {
|
||||
console.log('Rendering year index: '+year);
|
||||
|
||||
directory = config.buildDir
|
||||
var directory = config.buildDir
|
||||
directory += "/blog/";
|
||||
directory += year + '/';
|
||||
|
||||
start = new Date(year, 0, 1, 0, 0, 0);
|
||||
end = new Date((year+1), 0, 0, 23, 59, 59);
|
||||
console.log('Finding posts between '+start+' and '+end);
|
||||
console.log('Finding posts from '+year);
|
||||
|
||||
mkdirp(directory, function (err) {
|
||||
if (!err) {
|
||||
db.collection('posts').find({
|
||||
$where: '(this.postDate >= start) && (this.postDate <= end)'
|
||||
}).toArray(function (err, docs) {
|
||||
$where: '(this.postDate >= new Date('+year+', 0, 1, 0, 0, 0)) \
|
||||
&& (this.postDate <= new Date('+year+'+1, 0, 0, 23, 59, 59)) \
|
||||
&& this.published'
|
||||
}, {sort: [['postDate', 'desc'],['title', 'asc']]}
|
||||
).toArray(function (err, docs) {
|
||||
if (!err) {
|
||||
console.log('Found '+docs.length+' posts from '+year);
|
||||
posts = []
|
||||
for (i=0; i<docs.length; i++) {
|
||||
posts.push(new Post(docs[i]));
|
||||
}
|
||||
var options = {
|
||||
|
||||
var jadeOut = jade.renderFile('views/render-post-index.jade', {
|
||||
pretty: true,
|
||||
posts: posts,
|
||||
title: 'Posts from '+year
|
||||
};
|
||||
var jadeOut = jade.renderFile('views/render-post-index.jade', options);
|
||||
});
|
||||
|
||||
file = path.join(directory, 'index.html');
|
||||
|
||||
console.log(file);
|
||||
fs.writeFile(file, jadeOut, 'utf-8', function (err) {
|
||||
callback(err);
|
||||
});
|
||||
} else {
|
||||
callback(err)
|
||||
}
|
||||
});
|
||||
} else {
|
||||
callback(err);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
|
|
@ -2,4 +2,4 @@ article
|
|||
header
|
||||
h3: a(href="#{post.getURL()}") #{post.get("title")}
|
||||
p #{post.getShortDate()}
|
||||
!{post.renderMarkdown()}
|
||||
| !{post.renderMarkdown()}
|
||||
|
|
Loading…
Reference in a new issue