Skip to content

Commit

Permalink
update series output to not include posts if the seriesHideFuturePost…
Browse files Browse the repository at this point in the history
…s is true
  • Loading branch information
staxmanade committed Sep 10, 2015
1 parent 3ad408e commit b0a17dc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
22 changes: 17 additions & 5 deletions lib/App/Series.js
@@ -1,14 +1,26 @@
'use strict';

var Series = function (about) {
this.posts = [];
var Series = function (about, hideFuturePosts) {
this._posts = [];
this.about = about;
this.totalCount = 0;
this.publishedCount = 0;
this.hideFuturePosts = hideFuturePosts;
};

Series.prototype = {
about: 'TODO (fill in the series subject/title)',

get posts() {
if (this.hideFuturePosts) {
return this._posts.filter(function(item){ return item.isPublished });
}
return this._posts;
},

addPost: function(post) {
this._posts.push(post);
},
getTitle: function (post) {

// if (post.seriesIndex === 1) {
Expand All @@ -20,9 +32,9 @@ Series.prototype = {
getPostIndex: function (post) {
var index = -1;

for (var i = 0; i < this.posts.length; i++) {
for (var i = 0; i < this._posts.length; i++) {

if (this.posts[i].___postId === post.___postId) {
if (this._posts[i].___postId === post.___postId) {
index = i;
break;
}
Expand All @@ -32,7 +44,7 @@ Series.prototype = {
console.error({
post: post,
__postId: post.___postId,
series: this.posts.map(function (p) { return p.___postId; })
series: this._posts.map(function (p) { return p.___postId; })
});
throw 'Could not find the post in the series with seriesId[' + post.seriesId + '] (see console.error above)';
}
Expand Down
4 changes: 2 additions & 2 deletions lib/App/Site.js
Expand Up @@ -118,7 +118,7 @@ module.exports = function (opts) {

var series = this.seriesList[post.seriesId];
if (!series) {
series = new Series(post.seriesAbout);
series = new Series(post.seriesAbout, post.seriesHideFuturePosts === true);
this.seriesList[post.seriesId] = series;
}

Expand All @@ -131,7 +131,7 @@ module.exports = function (opts) {
}

//console.log('pushing:', post.seriesTitle, post.getSiteId());
series.posts.push(post);
series.addPost(post);

++series.totalCount;
if (post.published === true) {
Expand Down

0 comments on commit b0a17dc

Please sign in to comment.