Skip to content

Commit 4ed5f12

Browse files
committed
show more users on front page
1 parent d1c507e commit 4ed5f12

File tree

4 files changed

+111
-39
lines changed

4 files changed

+111
-39
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
# README
22

3-
Source files for [coderstats.net](http://coderstats.net/).
3+
Source files for [coderstats.net](http://coderstats.net/).
4+
5+
# Reference
6+
7+
* https://developer.github.com/v3/search/#search-users
8+
* https://jsfiddle.net/chrisvfritz/sbLgr0ad
9+
* https://github.com/GabrielBibiano/vue-github-profile/blob/master/GithubProfile.vue

src/js/events.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/js/front.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
Vue.component('user-link', {
2+
props: ['login', 'avatar_url'],
3+
template: `
4+
<div class="user">
5+
<a v-bind:href="'/github#' + login">
6+
<img :src="avatar_url" :alt="login">
7+
<i class="fa fa-user" aria-hidden="true"></i> {{ login }}
8+
</a>
9+
</div>
10+
`
11+
});
12+
13+
14+
new Vue({
15+
el: '#active-users',
16+
data: { events: null },
17+
computed: {
18+
users: function() {
19+
return d3.nest()
20+
.key(d => d.actor.login)
21+
.entries(this.events.filter(d => d.type === 'PushEvent'))
22+
.sort((a, b) => b.values.length - a.values.length);
23+
}
24+
},
25+
created: function() {
26+
// https://api.github.com/events
27+
this.$http.get('/data/events.json').then(response => {
28+
this.events = response.body;
29+
});
30+
}
31+
});
32+
33+
34+
new Vue({
35+
el: '#followed-users',
36+
data: {users: []},
37+
created: function () {
38+
// https://api.github.com/search/users?q=repos:%3E1&sort=followers&order=desc
39+
this.$http.get('/data/users.json').then(response => {
40+
this.users = response.body.items;
41+
});
42+
}
43+
});
44+
45+
46+
new Vue({
47+
el: '#most-repos-users',
48+
data: {users: []},
49+
created: function () {
50+
// https://api.github.com/search/users?q=repos:%3E1%20type:user&sort=repositories&order=desc
51+
this.$http.get('/data/most-repos-users.json').then(response => {
52+
this.users = response.body.items;
53+
});
54+
}
55+
});
56+
57+
58+
new Vue({
59+
el: '#earliest-users',
60+
data: {users: []},
61+
created: function () {
62+
// https://api.github.com/search/users?q=repos:%3E1%20type:user&sort=joined&order=asc
63+
this.$http.get('/data/earliest-users.json').then(response => {
64+
this.users = response.body.items;
65+
});
66+
}
67+
});

templates/front.html

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,51 @@ <h1 class="logo">{{ title }}</h1>
1313
</div>
1414
</form>
1515
</div>
16-
<div v-if="events" class="padv" id="events">
17-
{% raw %}
16+
<div v-if="events" id="active-users">
1817
<h2>Recently active users</h2>
1918
<div class="flex">
20-
<div v-for="user in users.slice(0, 10)" class="user">
21-
<a v-bind:href="'/github#' + user.key">
22-
<img :src="user.values[0].actor.avatar_url" :alt="user.key">
23-
<i class="fa fa-user" aria-hidden="true"></i> {{ user.key }}
24-
</a>
25-
</div>
19+
<user-link
20+
v-for="user in users.slice(0, 10)"
21+
v-bind:login="user.key"
22+
v-bind:avatar_url="user.values[0].actor.avatar_url"
23+
></user-link>
24+
</div>
25+
</div>
26+
<div v-if="users" id="followed-users">
27+
<h2>Most followed users</h2>
28+
<div class="flex">
29+
<user-link
30+
v-for="user in users.slice(0, 10)"
31+
v-bind:login="user.login"
32+
v-bind:avatar_url="user.avatar_url"
33+
></user-link>
34+
</div>
35+
</div>
36+
<div v-if="users" id="most-repos-users">
37+
<h2>Users with most repositories</h2>
38+
<div class="flex">
39+
<user-link
40+
v-for="user in users.slice(0, 10)"
41+
v-bind:login="user.login"
42+
v-bind:avatar_url="user.avatar_url"
43+
></user-link>
44+
</div>
45+
</div>
46+
<div v-if="users" id="earliest-users">
47+
<h2>Users with oldest accounts</h2>
48+
<div class="flex">
49+
<user-link
50+
v-for="user in users.slice(0, 10)"
51+
v-bind:login="user.login"
52+
v-bind:avatar_url="user.avatar_url"
53+
></user-link>
2654
</div>
27-
{% endraw %}
2855
</div>
2956
</div>
3057
{% endblock %}
3158

3259
{% block scripts %}
3360
{{ super() }}
34-
<script src="/compiled/events.js"></script>
61+
<script src="/compiled/front.js"></script>
3562
<script src="/compiled/search.js"></script>
3663
{% endblock %}

0 commit comments

Comments
 (0)