Skip to content

Differ from flagged listings; Fixes https://github.com/OpenUserJs/OpenUserJS.org/issues/178 #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 18, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions controllers/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,24 @@ exports.view = function (req, res, next) {
if (options.groupList)
pageMetaKeywords.push(group.name);
options.pageMetaKeywords = pageMetaKeywords.join(', ');

// Empty list
options.scriptListIsEmptyMessage = 'No scripts.';
if (options.isFlagged) {
if (options.librariesOnly) {
options.scriptListIsEmptyMessage = 'No flagged libraries.';
} else {
options.scriptListIsEmptyMessage = 'No flagged scripts.';
}
} else if (options.searchBarValue) {
if (options.librariesOnly) {
options.scriptListIsEmptyMessage = 'We couldn\'t find any libraries with this search value.';
} else {
options.scriptListIsEmptyMessage = 'We couldn\'t find any scripts with this search value.';
}
} else if (options.isUserScriptListPage) {
options.scriptListIsEmptyMessage = 'This user hasn\'t added any scripts yet.';
}
};
function render(){ res.render('pages/groupScriptListPage', options); }
function asyncComplete(){ preRender(); render(); }
Expand Down
20 changes: 19 additions & 1 deletion controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,24 @@ exports.home = function (req, res) {

// Pagination
options.paginationRendered = pagination.renderDefault(req);

// Empty list
options.scriptListIsEmptyMessage = 'No scripts.';
if (options.isFlagged) {
if (options.librariesOnly) {
options.scriptListIsEmptyMessage = 'No flagged libraries.';
} else {
options.scriptListIsEmptyMessage = 'No flagged scripts.';
}
} else if (options.searchBarValue) {
if (options.librariesOnly) {
options.scriptListIsEmptyMessage = 'We couldn\'t find any libraries with this search value.';
} else {
options.scriptListIsEmptyMessage = 'We couldn\'t find any scripts with this search value.';
}
} else if (options.isUserScriptListPage) {
options.scriptListIsEmptyMessage = 'This user hasn\'t added any scripts yet.';
}
};
function render(){ res.render('pages/scriptListPage', options); }
function asyncComplete(){ preRender(); render(); }
Expand Down Expand Up @@ -250,7 +268,7 @@ exports.logout = function (req, res) {

User.findOne({ _id: authedUser._id }, function (err, user) {
removeSession(req, user, function () {
res.redirect('/');
res.redirect('/');
});
});
};
26 changes: 26 additions & 0 deletions controllers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ exports.userListPage = function (req, res, next) {

// Pagination
options.paginationRendered = pagination.renderDefault(req);

// Empty list
options.userListIsEmptyMessage = 'No users.';
if (options.isFlagged) {
options.userListIsEmptyMessage = 'No flagged users.';
} else if (options.searchBarValue) {
options.userListIsEmptyMessage = 'We couldn\'t find any users by this name.';
}
};
function render(){ res.render('pages/userListPage', options); }
function asyncComplete(err){ if (err) { return next(); } else { preRender(); render(); } };
Expand Down Expand Up @@ -399,6 +407,24 @@ exports.userScriptListPage = function(req, res, next) {

// Pagination
options.paginationRendered = pagination.renderDefault(req);

// Empty list
options.scriptListIsEmptyMessage = 'No scripts.';
if (options.isFlagged) {
if (options.librariesOnly) {
options.scriptListIsEmptyMessage = 'No flagged libraries.';
} else {
options.scriptListIsEmptyMessage = 'No flagged scripts.';
}
} else if (options.searchBarValue) {
if (options.librariesOnly) {
options.scriptListIsEmptyMessage = 'We couldn\'t find any libraries with this search value.';
} else {
options.scriptListIsEmptyMessage = 'We couldn\'t find any scripts with this search value.';
}
} else if (options.isUserScriptListPage) {
options.scriptListIsEmptyMessage = 'This user hasn\'t added any scripts yet.';
}
};
function render(){ res.render('pages/userScriptListPage', options); }
function asyncComplete(){ preRender(); render(); }
Expand Down
1 change: 1 addition & 0 deletions libs/modelQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ var applyModelListQueryFlaggedFilter = function(modelListQuery, options, flagged
// Mod
if (flaggedQuery) {
if (flaggedQuery == 'true') {
options.isFlagged = true;
modelListQuery.and({flags: {$gt: 0 }});
} else if (flaggedQuery == false) {
// modelListQuery.and({$or: [
Expand Down
12 changes: 1 addition & 11 deletions views/includes/scriptList.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,7 @@
{{^scriptList}}
<tr class="tr-link">
<td colspan="4">
{{#searchBarValue}}
{{#librariesOnly}}
<em>We couldn't find any libraries with this search value.</em>
{{/librariesOnly}}
{{^librariesOnly}}
<em>We couldn't find any scripts with this search value.</em>
{{/librariesOnly}}
{{/searchBarValue}}
{{^searchBarValue}}
<em>This user hasn't added any scripts yet.</em>
{{/searchBarValue}}
<em>{{scriptListIsEmptyMessage}}</em>
</td>
</tr>
{{/scriptList}}
Expand Down
4 changes: 1 addition & 3 deletions views/includes/userList.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
{{^userList}}
<tr class="tr-link">
<td colspan="4">
{{#searchBarValue}}
<em>We couldn't find any users by this name.</em>
{{/searchBarValue}}
<em>{{userListIsEmptyMessage}}</em>
</td>
</tr>
{{/userList}}
Expand Down