Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9735d7a

Browse files
committed
first commit
0 parents  commit9735d7a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2730
-0
lines changed

‎.gitignore‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Logya
2+
deploy/
3+
static/compiled/
4+
static/data/
5+
6+
# nodejs
7+
.sass-cache/
8+
node_modules/
9+
package-lock.json

‎README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#README
2+
3+
Source files for[coderstats.net](http://coderstats.net/).

‎content/404.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
title:Page not found
3+
created:2014-02-09 00:37:47
4+
template:page.html
5+
noindex:1
6+
---
7+
The page you were looking for was not found.

‎content/github.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title:CoderStats
3+
template:coder.html
4+
created:2017-09-22T22:12:48
5+
---

‎content/index.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
noindex:1
3+
url:/
4+
title:CoderStats - View Statistics for Millions of GitHub Users
5+
template:front.html
6+
created:2017-09-22T22:02:05
7+
---

‎deploy.sh‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
deploy_repo=~/repos/deploy/coderstats.net
5+
6+
logya gen
7+
cp -r deploy/*"$deploy_repo"
8+
cd"$deploy_repo"
9+
git add.
10+
git commit -am'new deployment'
11+
git push

‎gulpfile.js‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
vargulp=require('gulp'),
2+
babel=require('gulp-babel'),
3+
minify=require('gulp-babel-minify'),
4+
cleanCSS=require('gulp-clean-css'),
5+
concat=require('gulp-concat'),
6+
spawn=require('child_process').spawn,
7+
sass=require('gulp-sass');
8+
9+
vardo_minify=true;
10+
11+
varpaths={
12+
babel:'src/js/*.js',
13+
compiled:'static/compiled',
14+
scss:'src/scss/*.scss',
15+
scss_coder:'src/scss/coder.scss',
16+
scss_main:'src/scss/style.scss'
17+
};
18+
19+
// Compile babel scripts
20+
gulp.task('babel',function(){
21+
varret=gulp.src(paths.babel).pipe(babel());
22+
if(do_minify)
23+
ret=ret.pipe(minify())
24+
returnret.pipe(gulp.dest(paths.compiled));
25+
});
26+
27+
// Run dev server
28+
gulp.task('serve',function(){
29+
varlog=function(data){console.log(data.toString())};
30+
lserve=spawn('logya',['serve']);
31+
lserve.stdout.on('data',log);
32+
lserve.stderr.on('data',log);
33+
});
34+
35+
// Compile and copy scss styles
36+
gulp.task('scss',function(){
37+
gulp.src(paths.scss_coder)
38+
.pipe(sass().on('error',sass.logError))
39+
.pipe(cleanCSS())
40+
.pipe(concat('coder.css'))
41+
.pipe(gulp.dest(paths.compiled));
42+
43+
returngulp.src(paths.scss_main)
44+
.pipe(sass().on('error',sass.logError))
45+
.pipe(cleanCSS())
46+
.pipe(concat('style.css'))
47+
.pipe(gulp.dest(paths.compiled));
48+
});
49+
50+
// Rerun task when a file changes
51+
gulp.task('watch',function(){
52+
// don't minify while working on code
53+
do_minify=false;
54+
gulp.watch(paths.scss,['scss']);
55+
gulp.watch(paths.babel,['babel']);
56+
});
57+
58+
// Build the JavaScript and CSS files
59+
gulp.task('dist',['babel','scss']);
60+
61+
// The default task (called when you run `gulp` from cli)
62+
gulp.task('default',['dist','watch','serve']);

‎package.json‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name":"coderstats.net",
3+
"version":"0.0.1",
4+
"description":"coderstats.net",
5+
"keywords": [
6+
"visualization",
7+
"github"
8+
],
9+
"author": {
10+
"name":"Ramiro Gómez",
11+
"url":"http://ramiro.org"
12+
},
13+
"license":"MIT",
14+
"devDependencies": {
15+
"babel-core":"^6.26.0",
16+
"babel-loader":"^7.1.2",
17+
"gulp":"^3.9.1",
18+
"gulp-babel":"^7.0.0",
19+
"gulp-babel-minify":"^0.2.0",
20+
"gulp-clean-css":"^3.8.0",
21+
"gulp-concat":"^2.6.1",
22+
"gulp-connect":"^5.0.0",
23+
"gulp-sass":"^3.1.0",
24+
"gulp-uglify":"^3.0.0"
25+
},
26+
"dependencies": {
27+
"getbase":"^3.5.1"
28+
}
29+
}

‎site.yaml‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# General settings that will be available in templates.
2+
site:
3+
base_url:http://localhost:8080
4+
disqus_shortname:null
5+
author:Author Name
6+
brand:Brand Name
7+
8+
9+
# Settings that affect collections in the document index. Top-level keys of
10+
# collections can be used as document attributes for grouping it in the
11+
# corresponding collecion.
12+
collections:
13+
tags:
14+
path:tags
15+
template:index.html
16+
17+
18+
# Content specific settings, at the moment only templates are specified.
19+
content:
20+
index:
21+
template:index.html# default template used for collections
22+
doc:
23+
template:page.html
24+
rss:
25+
template:rss2.xml
26+
27+
28+
# Template specific settings.
29+
template:
30+
trim_whitespace:true

‎src/js/coder.js‎

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
constDEV=0;
2+
3+
letbar_options={
4+
axisX:{onlyInteger:true},
5+
axisY:{offset:100,showGrid:false},
6+
horizontalBars:true,
7+
reverseData:true
8+
};
9+
10+
letgithub_user=null;
11+
if(document.location.hash){
12+
github_user=document.location.hash.replace('#','');
13+
}else{
14+
document.location.href='/';
15+
}
16+
// Set these values here because they are outside of vue's scope.
17+
document.title=`CoderStats(${github_user})`;
18+
document.getElementsByClassName('brand')[0].textContent=document.title;
19+
20+
leturl_user=`https://api.github.com/users/${github_user}`,
21+
url_repos=`${url_user}/repos?sort=pushed&per_page=100`,
22+
months_short='Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split(' ');
23+
24+
if(DEV){
25+
url_user='/data/user.json';
26+
url_repos='/data/repos.json';
27+
}
28+
29+
letcoder=newVue({
30+
el:'#coder',
31+
data:{
32+
repos:[],
33+
response:{},
34+
sort_orders:{},
35+
sort_key:'',
36+
user:null
37+
},
38+
computed:{
39+
// Only repos the user actually pushed at, i.e. no forks with no user commits.
40+
repos_pushed:function(){
41+
returnthis.repos.filter(d=>d.pushed_at>d.created_at);
42+
},
43+
repos_pushed_ratio:function(){
44+
returnthis.repos.length ?this.repos_pushed.length/this.repos.length :0;
45+
},
46+
languages:function(){
47+
returnd3.nest()
48+
.key(d=>d.language)
49+
.rollup(leaves=>leaves.length)
50+
.entries(this.repos_pushed.filter(d=>d.language))
51+
.sort((a,b)=>b.value-a.value);
52+
},
53+
issues:function(){
54+
returnthis.repoRanking('open_issues_count');
55+
},
56+
forks:function(){
57+
returnthis.repoRanking('forks_count');
58+
},
59+
stars:function(){
60+
returnthis.repoRanking('stargazers_count');
61+
},
62+
total_forks:function(){
63+
returnd3.sum(this.forks,d=>d.forks_count);
64+
},
65+
total_issues:function(){
66+
returnd3.sum(this.issues,d=>d.open_issues_count);
67+
},
68+
total_stars:function(){
69+
returnd3.sum(this.stars,d=>d.stargazers_count);
70+
}
71+
},
72+
filters:{
73+
fixURL:value=>{
74+
if(!value.startsWith('http')){
75+
value=`http://${value}`;
76+
}
77+
returnvalue;
78+
},
79+
formatDate:value=>{
80+
letdt=newDate(value);
81+
return`${dt.getDate()}${months_short[dt.getMonth()]}${dt.getYear()+1900}`;
82+
},
83+
formatURL:value=>{
84+
returnvalue.split('://').pop().replace(/\/$/,'');
85+
}
86+
},
87+
created:function(){
88+
this.fetchRepos();
89+
this.fetchUser();
90+
},
91+
updated:function(){
92+
letlanguage_ranking=this.languages.slice(0,10);
93+
newChartist.Bar('#language-ranking',{
94+
labels:language_ranking.map(d=>d.key),
95+
series:[language_ranking.map(d=>d.value)]
96+
},bar_options);
97+
98+
this.rankingGraph(this.issues.slice(0,10),'open_issues_count','#issues-ranking');
99+
this.rankingGraph(this.forks.slice(0,10),'forks_count','#forks-ranking');
100+
this.rankingGraph(this.stars.slice(0,10),'stargazers_count','#stars-ranking');
101+
},
102+
methods:{
103+
fetchRepos:function(){
104+
this.$http.get(url_repos).then(response=>{
105+
this.response.repos=response;
106+
this.repos=response.body;
107+
});
108+
},
109+
fetchUser:function(){
110+
this.$http.get(url_user).then(response=>{
111+
this.response.user=response;
112+
this.user=response.body;
113+
if(!this.user.name)this.user.name=this.user.login;
114+
});
115+
},
116+
order:function(key){
117+
// asc is default, because sort orders are initially unset
118+
returnthis.sort_orders[key]<0 ?'dsc' :'asc';
119+
},
120+
rankingGraph:function(series,property,selector){
121+
if(series.length){
122+
newChartist.Bar(selector,{
123+
labels:series.map(d=>d.name),
124+
series:[series.map(d=>d[property])]
125+
},bar_options);
126+
}
127+
},
128+
repoRanking:function(property){
129+
returnthis.repos_pushed.filter(d=>d[property])
130+
.sort((a,b)=>b[property]-a[property]);
131+
},
132+
sortBy:function(key,type='number'){
133+
letdefault_value=type==='string' ?'' :0;
134+
this.sort_key=key;
135+
this.sort_orders[key]=(this.sort_orders[key]||1)*-1;
136+
this.repos.sort((a,b)=>{
137+
letx=a[key]||default_value,
138+
y=b[key]||default_value;
139+
if(type==='string'){
140+
x=x.toLowerCase();
141+
y=y.toLowerCase();
142+
}
143+
return(x===y ?0 :x>y ?1 :-1)*this.sort_orders[key];
144+
});
145+
}
146+
}
147+
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp