Skip to content
This repository has been archived by the owner on Aug 22, 2019. It is now read-only.

Commit

Permalink
Merge pull request #979 from stenington/fix-demo
Browse files Browse the repository at this point in the history
Make demo badges not rename themselves or duplicte DEMO: in title
  • Loading branch information
stenington committed Dec 16, 2013
2 parents 4328571 + 98aea94 commit 200d7da
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions controllers/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ exports.massAward = function (req, res) {
baseName: f,
imgData: fs.readFileSync(path.join(demoBadgeDir, f)),
assertion: assertion,
assertionUrl: ORIGIN + '/demo/badge.json?' + qs.stringify({title: 'raaad', image: imgUrl, recipient: recipient})
assertionUrl: getDemoUrl(assertion)
};
})
.forEach(function (item) {
Expand Down Expand Up @@ -85,6 +85,9 @@ exports.badBadge = function (req, res) {
};

function makeDemoAssertion(email, image, title, description) {
title = title || 'Open Badges Demo Badge';
if (title.indexOf('DEMO:') !== 0)
title = 'DEMO: ' + title;
return ({
recipient: email,
salt: 'ballertime',
Expand All @@ -93,7 +96,7 @@ function makeDemoAssertion(email, image, title, description) {
issued_on: '2011-08-23',
badge: {
version: 'v0.5.0',
name: 'DEMO: ' + (title || 'Open Badges Demo Badge'),
name: title,
description: description || 'For rocking in the "free world"',
image: image,
criteria: '/demo/criteria',
Expand All @@ -104,3 +107,11 @@ function makeDemoAssertion(email, image, title, description) {
}
});
}

function getDemoUrl(assertion) {
return assertion.badge.issuer.origin + '/demo/badge.json?' + qs.stringify({
title: assertion.badge.name,
image: assertion.badge.image,
recipient: assertion.recipient
});
}

0 comments on commit 200d7da

Please sign in to comment.