Changing from using the word 'generate' to 'build'
This commit is contained in:
parent
62a38c1695
commit
821b431eec
9 changed files with 27 additions and 24 deletions
4
app.js
4
app.js
|
@ -121,7 +121,7 @@ app.get('/admin',
|
|||
function(req, res, next) {
|
||||
Post.countPosts(function (err, postCount) {
|
||||
Category.countCategories(function (err, categoryCount) {
|
||||
Post.getLastGenerateDate(function (err, lastGenerateDate) {
|
||||
Post.getLastBuildDate(function (err, lastBuildDate) {
|
||||
Post.getLastUploadDate( function (err, lastUploadDate) {
|
||||
res.render('admin-dashboard', {
|
||||
successNotice: req.flash('successNotice'),
|
||||
|
@ -131,7 +131,7 @@ app.get('/admin',
|
|||
galleries: "###",
|
||||
photos: "###",
|
||||
tags: "###",
|
||||
regenerateDate: moment(lastGenerateDate).format("YYYY-MM-DD HH:mm"),
|
||||
regenerateDate: moment(lastBuildDate).format("YYYY-MM-DD HH:mm"),
|
||||
uploadDate: moment(lastUploadDate).format("YYYY-MM-DD HH:mm"),
|
||||
user: req.user});
|
||||
})
|
||||
|
|
22
post.js
22
post.js
|
@ -148,10 +148,10 @@ Post.prototype.makeSlug = function () {
|
|||
return str;
|
||||
};
|
||||
|
||||
// Function to generate static renderings of a particular post.
|
||||
// Function to build static renderings of a particular post.
|
||||
// Arguments: Callback function
|
||||
// Returns: err
|
||||
Post.prototype.generatePost = function (callback) {
|
||||
Post.prototype.buildPost = function (callback) {
|
||||
var options = {
|
||||
pretty: false,
|
||||
post: this
|
||||
|
@ -164,8 +164,8 @@ Post.prototype.generatePost = function (callback) {
|
|||
|
||||
mkdirp(self.getDirectory(), function (err) {
|
||||
fs.writeFile(self.getFilePath(), jadeOut, 'utf-8', function (err) {
|
||||
self.set('lastGenerateDate', new Date());
|
||||
self.save(self.get('lastGenerateDate'), function (err) {
|
||||
self.set('lastBuildDate', new Date());
|
||||
self.save(self.get('lastBuildDate'), function (err) {
|
||||
callback(err);
|
||||
});
|
||||
});
|
||||
|
@ -181,10 +181,10 @@ Post.prototype.generatePost = function (callback) {
|
|||
|
||||
// Function to find the most recent post generation.
|
||||
// Returns a date object
|
||||
Post.getLastGenerateDate = function (callback) {
|
||||
db.collection("posts").findOne({}, {lastGenerateDate: 1}, {sort: {lastGenerateDate: -1}},
|
||||
Post.getLastBuildDate = function (callback) {
|
||||
db.collection("posts").findOne({}, {lastBuildDate: 1}, {sort: {lastBuildDate: -1}},
|
||||
function(err, doc) {
|
||||
callback(err, doc.lastGenerateDate);
|
||||
callback(err, doc.lastBuildDate);
|
||||
}
|
||||
)
|
||||
};
|
||||
|
@ -248,11 +248,13 @@ Post.getPosts = function(count, start, callback) {
|
|||
});
|
||||
}
|
||||
|
||||
// Function to find posts that need to be generated
|
||||
// Function to find posts that need to be built
|
||||
// Inputs: Callback function
|
||||
// Returns: list of Post objects
|
||||
Post.getNeedsGeneration = function (callback) {
|
||||
db.collection("posts").find({$where: "this.lastGenerateDate < this.updatedDate"}).toArray(
|
||||
db.collection("posts").find({
|
||||
$where: "(this.lastBuildDate < this.updatedDate) && this.published"
|
||||
}).toArray(
|
||||
function (err, docs) {
|
||||
if (err) console.log(err);
|
||||
posts = [];
|
||||
|
@ -270,7 +272,7 @@ Post.getNeedsGeneration = function (callback) {
|
|||
Post.getNeedsUpload = function (callback) {
|
||||
db.collection("posts").find({
|
||||
$where: '(this.lastUploadDate < this.updatedDate) && \
|
||||
(this.lastGenerateDate >= this.updatedDate) && \
|
||||
(this.lastBuildDate >= this.updatedDate) && \
|
||||
this.published'
|
||||
}).toArray( function (err, docs) {
|
||||
if (err) console.log(err);
|
||||
|
|
|
@ -143,8 +143,8 @@ module.exports = function(app) {
|
|||
}
|
||||
);
|
||||
|
||||
// GET /admin/post/regenerate
|
||||
app.get('/admin/post/regenerate/:uuid?',
|
||||
// GET /admin/post/rebuild
|
||||
app.get('/admin/post/rebuild/:uuid?',
|
||||
function(req, res, next) {
|
||||
if (req.params.uuid) {
|
||||
Static.updateBuildFolder(function (err) {
|
||||
|
@ -153,9 +153,9 @@ module.exports = function(app) {
|
|||
post = Post.getByUUID(req.params.uuid, function (err, post) {
|
||||
console.log("Got post: "+post.get("title"));
|
||||
if (err) console.log(err);
|
||||
post.generatePost(function (err) {
|
||||
post.buildPost(function (err) {
|
||||
if (!err) {
|
||||
req.flash('successNotice', 'Post regenerated successfully.');
|
||||
req.flash('successNotice', 'Post rebuilt successfully.');
|
||||
res.redirect('/admin/post/view/'+req.params.uuid);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -21,7 +21,7 @@ schemas = {
|
|||
category: null,
|
||||
tags: [],
|
||||
updateIndexesNeeded: false,
|
||||
lastGenerateDate: new Date("Mon Jan 1 1900 00:00:00 GMT-0500"),
|
||||
lastBuildDate: new Date("Mon Jan 1 1900 00:00:00 GMT-0500"),
|
||||
lastUploadDate: new Date("Mon Jan 1 1900 00:00:00 GMT-0500")
|
||||
},
|
||||
category: {
|
||||
|
|
|
@ -21,10 +21,10 @@ block content
|
|||
div(class="col-md-6")
|
||||
div(class="panel panel-danger")
|
||||
div(class="panel-heading")
|
||||
h3(class="panel-title") Last Regenerate (UTC)
|
||||
h3(class="panel-title") Last Rebuild (UTC)
|
||||
|
||||
div(class="panel-body")
|
||||
h3 #{regenerateDate}
|
||||
h3 #{rebuildDate}
|
||||
|
||||
div(class="row")
|
||||
div(class="col-md-4")
|
||||
|
|
|
@ -20,7 +20,7 @@ block content
|
|||
| -
|
||||
a(href="/admin/post/delete/#{post.get('uuid')}") Delete
|
||||
| -
|
||||
a(href="/admin/post/regenerate/#{post.get('uuid')}") Regenerate
|
||||
a(href="/admin/post/rebuild/#{post.get('uuid')}") Rebuild
|
||||
| -
|
||||
a(href="/admin/post/publish/#{post.get('uuid')}") Publish
|
||||
|
||||
|
|
|
@ -15,6 +15,6 @@ block content
|
|||
| #{post.getShortDate()} --
|
||||
a(href="/admin/post/edit/#{post.get('uuid')}") Edit
|
||||
| -
|
||||
a(href="/admin/post/regenerate/#{post.get('uuid')}") Regenerate
|
||||
a(href="/admin/post/rebuild/#{post.get('uuid')}") Rebuild
|
||||
|
||||
div(class='row') !{content}
|
||||
|
|
|
@ -2,6 +2,7 @@ div(class="col-sm-2 sidebar")
|
|||
ul(class="nav nav-sidebar")
|
||||
li: a #{user.get("username")}
|
||||
li: a(href="/admin/") Dashboard
|
||||
li: a(href='/admin/view/uploads') Pending Uploads
|
||||
|
||||
ul(class="nav nav-sidebar")
|
||||
li: a(href="/admin/post/new") New Post
|
||||
|
@ -16,9 +17,9 @@ div(class="col-sm-2 sidebar")
|
|||
li: a(href="/admin/gallery/list") All Galleries
|
||||
|
||||
ul(class="nav nav-sidebar")
|
||||
form(action="/admin/regenerate/", method="get")
|
||||
form(action="/admin/rebuild/", method="get")
|
||||
button(class="btn btn-lg btn-success")
|
||||
span(class="glyphicon glyphicon-repeat") Generate
|
||||
span(class="glyphicon glyphicon-repeat") Build
|
||||
|
||||
ul(class="nav nav-sidebar")
|
||||
form(action="/admin/publish/", method="get")
|
||||
|
|
|
@ -20,6 +20,6 @@ block content
|
|||
| -
|
||||
a(href="/admin/post/delete/#{post.get('uuid')}") Delete
|
||||
| -
|
||||
a(href="/admin/post/regenerate/#{post.get('uuid')}") Regenerate
|
||||
a(href="/admin/post/rebuild/#{post.get('uuid')}") Rebuild
|
||||
| -
|
||||
a(href="/admin/post/publish/#{post.get('uuid')}") Publish
|
||||
|
|
Loading…
Reference in a new issue