зеркало из https://github.com/mozilla/CSOL-site.git
added similar badges to /mybadges page. fixes #595
This commit is contained in:
Родитель
83e01071fa
Коммит
de48678662
|
@ -128,49 +128,22 @@ module.exports = function (app) {
|
|||
items: data.badges
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/mybadges/:id', [
|
||||
isLearner,
|
||||
openbadger.middleware('getUserBadge')
|
||||
openbadger.middleware('getUserBadge'),
|
||||
openbadger.middleware('getBadgeRecommendations', {limit:4})
|
||||
], function (req, res, next) {
|
||||
var user = req.session.user;
|
||||
var data = req.remote;
|
||||
|
||||
// XXX: replace with API call to openbadger
|
||||
var similar = [
|
||||
{
|
||||
url: "/mybadges/this-badge",
|
||||
image: "http://openbadger-csol.mofostaging.net/badge/image/this-badge.png",
|
||||
name: "Test Badge CLM",
|
||||
description: "This is a test badge!"
|
||||
},
|
||||
{
|
||||
url: "/mybadges/this-badge",
|
||||
image: "http://openbadger-csol.mofostaging.net/badge/image/this-badge.png",
|
||||
name: "Test Badge CLM",
|
||||
description: "This is a test badge!"
|
||||
},
|
||||
{
|
||||
url: "/mybadges/this-badge",
|
||||
image: "http://openbadger-csol.mofostaging.net/badge/image/this-badge.png",
|
||||
name: "Test Badge CLM",
|
||||
description: "This is a test badge!"
|
||||
},
|
||||
{
|
||||
url: "/mybadges/this-badge",
|
||||
image: "http://openbadger-csol.mofostaging.net/badge/image/this-badge.png",
|
||||
name: "Test Badge CLM",
|
||||
description: "This is a test badge!"
|
||||
}
|
||||
];
|
||||
|
||||
const NSIMILAR = 4;
|
||||
var similar = data.badges;
|
||||
|
||||
if (user.underage) {
|
||||
return res.render('user/badge.html', {
|
||||
badge: data.badge,
|
||||
user: req.session.user,
|
||||
similar: similar.slice(0, NSIMILAR),
|
||||
similar: similar,
|
||||
share: false
|
||||
});
|
||||
}
|
||||
|
@ -199,7 +172,7 @@ module.exports = function (app) {
|
|||
return res.render('user/badge.html', {
|
||||
badge: data.badge,
|
||||
user: req.session.user,
|
||||
similar: similar.slice(0, NSIMILAR),
|
||||
similar: similar,
|
||||
share: share
|
||||
});
|
||||
});
|
||||
|
@ -238,7 +211,7 @@ module.exports = function (app) {
|
|||
});
|
||||
|
||||
app.post('/share/toggle/:token', [
|
||||
isLearner
|
||||
isLearner
|
||||
], function (req, res, next) {
|
||||
var token = req.params.token;
|
||||
var user = req.session.user;
|
||||
|
|
|
@ -356,12 +356,16 @@ var openbadger = new Api(ENDPOINT, {
|
|||
},
|
||||
|
||||
getBadgeRecommendations: function getBadgeRecommendations (query, callback) {
|
||||
var id = query.badgeName;
|
||||
var badgename = query.badgeName;
|
||||
var id = query.id;
|
||||
var limit = query.limit;
|
||||
var params = {
|
||||
limit: limit
|
||||
};
|
||||
|
||||
if (badgename)
|
||||
id = badgename
|
||||
|
||||
if (!id)
|
||||
return callback(new errors.BadRequest('Invalid badge key'));
|
||||
|
||||
|
@ -477,7 +481,7 @@ openbadgerHooks.testHandler = function(req, res, next) {
|
|||
|
||||
if (req.body.isTesting !== true)
|
||||
return res.send(200, "body.isTesting !== true");
|
||||
|
||||
|
||||
if (!(claimCode && typeof(claimCode) == "string"))
|
||||
return res.send(200, "body.claimCode is empty");
|
||||
|
||||
|
|
|
@ -56,8 +56,7 @@
|
|||
|
||||
<div class="row">
|
||||
<h3>Similar Badges</h3>
|
||||
<p>Cupcake <a href="#">link to Badges page</a> something about badges
|
||||
should go here.</p>
|
||||
<p>If you're interested in this badge, you might be interested in these too. These are badges on similar STEAM topics or ones that can take you to the next level.</p>
|
||||
|
||||
{% for item in similar %}
|
||||
<div class="span3">
|
||||
|
|
Загрузка…
Ссылка в новой задаче