diff --git a/app.js b/app.js index 43e8ebe..7331a02 100644 --- a/app.js +++ b/app.js @@ -116,6 +116,21 @@ app.get('/admin/view/uploads', } ); +// Admin page to view all the items that need to be built. +app.get('/admin/view/builds', + function(req, res, next) { + Post.getNeedsBuild(function (err, posts) { + if (err) console.log(err); + res.render('admin-view-builds', { + successNotice: req.flash('successNotice'), + failureNotice: req.flash('failureNotice'), + posts: posts, + user: req.user + }); + }); + } +); + // Admin dashboard page. app.get('/admin', function(req, res, next) { diff --git a/post.js b/post.js index 308142b..f2c18a9 100644 --- a/post.js +++ b/post.js @@ -251,7 +251,7 @@ Post.getPosts = function(count, start, callback) { // Function to find posts that need to be built // Inputs: Callback function // Returns: list of Post objects -Post.getNeedsGeneration = function (callback) { +Post.getNeedsBuild = function (callback) { db.collection("posts").find({ $where: "(this.lastBuildDate < this.updatedDate) && this.published" }).toArray( diff --git a/views/admin-view-builds.jade b/views/admin-view-builds.jade new file mode 100644 index 0000000..dfd9e8e --- /dev/null +++ b/views/admin-view-builds.jade @@ -0,0 +1,23 @@ +extends admin-layout + +block content + div(class="row") + include ./admin-sidebar.jade + + div(class="col-sm-10 col-sm-offset-2 main") + h1(class="page-header") Pending Builds + + include ./admin-messages.jade + + if Posts + h2 Posts + table(class="table table-striped") + each post in posts + tr + td: a(href="/admin/post/view/#{post.get('uuid')}") #{post.get("title")} + td #{post.getShortDate()} + td #{post.get("uuid")} + td + a(href="/admin/post/edit/#{post.get('uuid')}") Edit + | - + a(href="/admin/post/rebuild/#{post.get('uuid')}") Rebuild