Open autermann opened 11 years ago
Are there already users with badges to test the feature?
I propose the following badge names:
friend
supporter
contributor
local-stakeholder
fan
regional-stakeholder
early-bird
partner
These pledges were not taken, so we can ignore them:
I added the badge to Christophs profile to test it:
{
"badges": [
"contributor"
],
"name": "staschc"
}
Add a later stage we also can use that field for something like achievements…
we could also add a badge for developers
+1 for the developer badge, this could be solved by allowing people to put their GitHub username in their profile in a specific field and then automatically bringing this together with https://github.com/enviroCar?tab=members.
Does the server provide an API for the existing badges? @matthesrieke ?
not to my knowledge. @autermann ?
Badges are already supported, but, as we don't have any admin interface, the only way to add (and sie existing) badges is directly in the database. The API just shows them in the user profiles.
// add a single batch to a single user
db.users.update({
_id: "username"
}, {
$addToSet: {
badges: "badge"
}
});
// add several badges to a single user
db.users.update({
_id: "username"
}, {
$addToSet: {
badges: {
$each: [ "badge1", "badge2" ]
}
}
});
// add several badges to several users
db.users.update({
_id: {
$in: [ "username1", "username2" ]
}
}, {
$addToSet: {
badges: {
$each: [ "badge1", "badge2" ]
}
}
}, {
multi: true
});
// get all existing badges
db.users.aggregate(
{ $project: { _id: false, badges: true} },
{ $unwind: "$badges" },
{ $group: { _id: 1, badges: { $addToSet: "$badges" } } }
).result[0].badges
The API:
curl -su ****:**** https://envirocar.org/api/dev/users/staschc \
| python -m json.tool
{
"badges": [
"contributor"
],
"name": "staschc"
}
Thanks for the clarifications, imho is a simple user interface important to manage the badges because that is a task that should not keep developers / admins busy: https://github.com/enviroCar/enviroCar-www/issues/115
going for a dedicated REST resource / mongo collection.
REST resource planned as
{
"badges": [
{
"name":"contributor",
"displayName": {
"en": "Contributor",
"de": "Unterstützer"
},
"description": {
"en": "an enviroCar contributor",
"de": "ein enviroCar unterstützer"
}
}
]
}
thoughts? @nuest
Is that for all available badges, or for the badges of one user?
For all available badges we should manage the Icon (full URL, or just the name?) server side as well.
for all available badges: e.g. https://envirocar.org/api/dev/badges
We can store those via the webapp, but I would not provide the URL in the JSON. Icon could then be available at https://envirocar.org/api/badges/name.png
Right. Ok - will you let me know at https://github.com/enviroCar/enviroCar-www/issues/39 when this is done? Thanks!
Accept-Language
header to reduce bandwidth. Same goes for termsOfUse
and announcements
./badges
and /users/:user/badges
?@autermann Regarding your second point, if I understood @matthesrieke correctly that's what he wants to do, "for all available badges: e.g. https://envirocar.org/api/dev/badges"
And Accept-Language for getting the image instead of json, right? Sounds great to me.
Accept-Language for reducing the JSON contents, e.g. only returning "de" for "description".
https://github.com/enviroCar/enviroCar-server/pull/142 already provides the /badges
. users/:user/badges
is also n2h, but as badges are currently encoded within the User resource, I would like to postpone this.
And Accept-Language for getting the image instead of json, right? Sounds great to me.
Not really :D Accept
would be the way to go there... I would use the Accept-Language
header to not have big map of translations in every object.
Ups :-). Ok, so I'm in favour of both Accept
for the icon and Accept-Language
to reduce the traffic footprint.
Although I was using the english webpages, the badges came up in German. If we can only show in one laguage, it should be in english.
I guess www is still using a mockup for that and not https://envirocar.org/api/stable/badges - thats probably the reason for the german names.
No the mockup I'am using is in both languages. For me it works in the "show all badges" modal window. The badge below my avatar on the dashboard however remains in english since this does not come from the mockup, but I will fix it. @ahitch I can not reproduce the error you are describing.
using FF
I add some more badges to the DB. @MartinDueren you could use that resource now. @ahitch could you review the contents? these are just drafts. still the names (e.g. "localStakeholder") should be final.
https://envirocar.org/api/stable/badges
edit: here is the markup well-formatted in case you do not have a browser plugin:
{
"badges":[
{
"name":"contributor",
"displayName":{
"de":"Erster Mitwirkender",
"en":"First Contributor"
},
"description":{
"de":"Einer der ersten enviroCar Mitwirkenden",
"en":"A first enviroCar contributor"
}
},
{
"name":"supporter",
"displayName":{
"de":"Erster Unterstützer",
"en":"First Supporter"
},
"description":{
"de":"Einer der ersten enviroCar Unterstützer, der zu dem Erfolg der Indiegogo-Kampagne beigetragen hat",
"en":"A first enviroCar supporter which helped to make the Indiegogo campaign a success"
}
},
{
"name":"localStakeholder",
"displayName":{
"de":"Erster lokaler Projektbeteiligter",
"en":"First local stakeholder"
},
"description":{
"de":"Einer der ersten lokalen enviroCar Projektbeteiligten, der die Indiegogo-Kampagne signifikant vorangetrieben hat",
"en":"A first enviroCar local stakeholder which pushed the Indiegogo campaign significantly"
}
},
{
"name":"regionalStakeholder",
"displayName":{
"de":"Erster regionaler Projektbeteiligter",
"en":"First regional stakeholder"
},
"description":{
"de":"Einer der ersten regionaler enviroCar Projektbeteiligten, der die Indiegogo-Kampagne signifikant vorangetrieben hat",
"en":"A first enviroCar local stakeholder which pushed the Indiegogo campaign significantly"
}
},
{
"name":"developer",
"displayName":{
"de":"enviroCar Entwickler",
"en":"enviroCar developer"
},
"description":{
"de":"einer der Entwickler!",
"en":"one of the devs!",
"1337":"I. Need. Coffee!"
}
}
]
}
Just for clarity: the "description" appears in the mouse over box, correct? If so, the current mouse over blurbs say "One of the first enviroCar contributors" Which I prefer to what I read (no browser plug in I guess). Thus: "One of the first enviroCar contributors" "One of the first enviroCar supporters, who helped make the Indiegogo campaign a success" "One of the first enviroCar local stakeholders, who significantly supported the Indiegogo campaign" "One of the first enviroCar regional stakeholders, who significantly supported the Indiegogo campaign" "One of the enviroCar developers!" (auch gerne mit dem I need coffee)
I would capitalize Each word in the badge, e.g. "First Regional Stakeholder", "enviroCar Developer"
thx. adjusted it accordingly.
Read Only! To add badges this snippet can be used: