Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Widgets work with both ~users and Teams #112

Closed
wants to merge 44 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
cf6b17c
Fix receiving link
mattbk Feb 7, 2016
04a5fcb
Update test/example data
mattbk Feb 7, 2016
132e0f7
Fix anonymous receiving
mattbk Feb 7, 2016
8e69562
Fix indents
mattbk Feb 9, 2016
bb98204
See if changing test title makes tests easier to read
mattbk Feb 11, 2016
1166a52
Make title tests more specific
mattbk Feb 11, 2016
17dace3
Update anon-user public.json
mattbk Feb 11, 2016
ff9f786
Remove anonymous receiving test
mattbk Feb 11, 2016
6efa3b8
Change how anonymous giving is tested
mattbk Feb 12, 2016
92eb322
Make anon-user giving anonymous
mattbk Feb 12, 2016
1b2d3af
Is 'null' null?
mattbk Feb 12, 2016
6a8b1e7
Revert "Is 'null' null?"
mattbk Feb 12, 2016
31f0c1d
Revert "Change how anonymous giving is tested"
mattbk Feb 12, 2016
91bb247
Comment out where I think the problem is
mattbk Feb 12, 2016
fd5b789
Revert "Comment out where I think the problem is"
mattbk Feb 12, 2016
b16b582
Distinguish between loading states
mattbk Feb 12, 2016
11e4fe9
Add temporary debug steps
mattbk Feb 13, 2016
0bdfc5b
Get around lack of username
mattbk Feb 14, 2016
ceefd3c
Fix indents
mattbk Feb 14, 2016
d62e22c
Fix indents
mattbk Feb 14, 2016
1bc8317
Fix indents
mattbk Feb 14, 2016
b945434
Fix indents?
mattbk Feb 14, 2016
47c0fc9
Pound head against wall
mattbk Feb 14, 2016
2e4783a
Revert "Pound head against wall"
mattbk Feb 14, 2016
1466ab2
Revert "Fix indents?"
mattbk Feb 14, 2016
83419e3
Revert "Fix indents"
mattbk Feb 14, 2016
47e5e90
Revert "Fix indents"
mattbk Feb 14, 2016
b326a1d
Revert "Fix indents"
mattbk Feb 14, 2016
23e0d2e
Revert "Get around lack of username"
mattbk Feb 14, 2016
27ee240
Revert and add note
mattbk Feb 14, 2016
efd1b30
Merge branch 'master' into team-experiments
mattbk Feb 16, 2016
d571da2
Debug tests
mattbk Feb 19, 2016
3c0ddb3
Remove debugging console output
mattbk Feb 20, 2016
c5bd7a8
Solve significant digits
mattbk Feb 20, 2016
c005194
Merge pull request #118 from gratipay/trailing-zero
mattbk Apr 2, 2016
48503cf
Merge branch 'master' into team-experiments
mattbk Apr 2, 2016
066ba6c
Revert "Merge pull request #118 from gratipay/trailing-zero"
mattbk Apr 2, 2016
089f7e2
Revert "Revert "Merge pull request #118 from gratipay/trailing-zero""
mattbk Apr 2, 2016
8ed5153
Remove console log
mattbk Apr 2, 2016
8b7e0eb
Remove duplicate API call
mattbk Apr 2, 2016
8f24139
Convert tabs to spaces
chadwhitacre Apr 9, 2016
d497f26
Revert newline changes
chadwhitacre Apr 9, 2016
7785ac2
Merge remote-tracking branch 'refs/remotes/origin/master' into team-e…
mattbk Apr 22, 2016
e41c3be
Merge branch 'team-experiments' of https://github.com/gratipay/grtp.c…
mattbk Apr 22, 2016
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
3 changes: 3 additions & 0 deletions bin/generate-mock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ get gratipay/charts.json

get rummik/public.json
get rummik/charts.json

get northern-plains-athletics/public.json
get northern-plains-athletics/charts.json
3 changes: 2 additions & 1 deletion lib/v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
}

// Slurp up widgets (identified by having the `data-gratipay-username` property)
// data-gratipay-username is defined in the widget script (see test widgets for examples)
var elements = $('[data-gratipay-username],[data-gittip-username]');

// Cache length
Expand Down Expand Up @@ -44,7 +45,7 @@
_grtp.push(element);
}

element.setAttribute('data-gratipay-readystatus', 'loading');
element.setAttribute('data-gratipay-readystatus', 'loading v1.js');
}
}
})();
16 changes: 12 additions & 4 deletions lib/v1/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,20 @@

Gratipay.users.getPublic(username, function(data) {
element.setAttribute('data-gratipay-readystatus', 'ready');
text('receiving', (data.receiving)? '$' + data.receiving : 'anonymously');
// Solve lack of two significant digits in some cases (http://stackoverflow.com/a/4937261/2152245)
text('receiving', (data.taking)? '$' + parseFloat(data.taking).toFixed(2) : '$' + parseFloat(data.receiving).toFixed(2));
text('username', data.username);
text('my-tip-button', data.my_tip == 'self' ? 'You!' : (+data.my_tip > 0 ? data.my_tip : 'Gratipay')); // jshint ignore:line
text('goal', '$' + data.goal);
text('giving', (data.giving)? '$' + data.giving : 'anonymously');
link('profile-link', gratipayURI + encodeURIComponent(data.username) + '/');

// If username exists, it's a ~user, not a team. Build URL accordingly.
if (data.username) {
link('profile-link', gratipayURI + encodeURIComponent(data.username) + '/');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we want to insert a ~ here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how those rewrites end up working. I know that if I don't put a ~ in, it still works. If it is better to include the ~, then we can do that.

} else {
link('profile-link', gratipayURI + encodeURIComponent(data.slug) + '/');
}

link('link', gratipayURI);
css('goal-progress-bar', 'width:' + (data.receiving / data.goal * 100) + '%');

Expand Down Expand Up @@ -175,7 +183,7 @@
var username = element.getAttribute('data-gratipay-username') || element.getAttribute('data-gittip-username');

// Set a readystate on the element
element.setAttribute('data-gratipay-readystatus', 'loading');
element.setAttribute('data-gratipay-readystatus', 'loading api.js');

// Skip to applying widget data if this is a custom/user-defined widget
if (['false', 'none', 'user-defined', 'custom'].indexOf(widgetType.toLowerCase()) != -1) {
Expand Down Expand Up @@ -223,7 +231,7 @@
});
}

// IE 8 requres .attachEvent(), everybody else can use .onload
// IE 8 requires .attachEvent(), everybody else can use .onload
if (container.attachEvent) {
container.attachEvent('onload', onload);
} else {
Expand Down
7 changes: 7 additions & 0 deletions test/default-widget-team.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!doctype html>
<script>grtpAPI = '/lib/v1/'</script>
<script>gratipayURI = '/test/gratipay.com/'</script>

<body>
<script src="/lib/v1.js" data-gratipay-username="northern-plains-athletics" async></script>
</body>
30 changes: 23 additions & 7 deletions test/gratipay.com/anon-user/public.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
{
"avatar": "https://avatars.githubusercontent.com/u/3893573?s=128",
"avatar": "https://avatars.githubusercontent.com/u/3893573?s=160",
"cryptocoins": {
"bitcoin": "3MNVEUyqYqnxF5jKBbfKRrWp5XYRDSjzDs"
},
"elsewhere": {
"bountysource": {
"id": 481481,
"user_id": "24752",
"user_name": null
},
"github": {
"id": 205991,
"user_id": "3893573",
"user_name": "rohitpaulk"
},
"google": {
"id": 476989,
"user_id": "103133617858201182649",
"user_name": "PaulKuruvilla"
},
"twitter": {
"id": 473541,
"user_id": "1079733008",
"user_name": "RohitPaulK"
}
},
"giving": null,
"goal": null,
"id": 145878,
"my_tip": "self",
"npatrons": 0,
"number": "singular",
"ngiving_to": 24,
"ntaking_from": 0,
"on": "gratipay",
"receiving": null,
"username": "rohitpaulk"
"taking": "0.00",
"username": "anon-user"
}
1 change: 0 additions & 1 deletion test/gratipay.com/gittip/charts.json

This file was deleted.

16 changes: 0 additions & 16 deletions test/gratipay.com/gittip/public.json

This file was deleted.

23 changes: 23 additions & 0 deletions test/gratipay.com/gratipay/public.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"avatar": "https://avatars.githubusercontent.com/u/1744073?s=160",
"cryptocoins": {},
"elsewhere": {
"github": {
"id": 435394,
"user_id": "1744073",
"user_name": "gratipay"
},
"twitter": {
"id": 80324,
"user_id": "1313765257",
"user_name": "Gratipay"
}
},
"giving": "0.00",
"id": 20176,
"ngiving_to": 0,
"ntaking_from": 1,
"on": "gratipay",
"taking": "270.60",
"username": "Gratipay"
}
11 changes: 11 additions & 0 deletions test/gratipay.com/northern-plains-athletics/public.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"homepage": "http://northernplainsathletics.com",
"name": "Northern Plains Athletics",
"nreceiving_from": 1,
"onboarding_url": "http://northernplainsathletics.com/about",
"owner": "~mattbk",
"receiving": 0.10,
"slug": "northern-plains-athletics",
"status": "approved",
"todo_url": "https://github.com/mattbk/npa/issues"
}
Loading