我如何添加“当前连胜” github对我博客的贡献? [英] How can I add "current streak" of contributions from github to my blog?
问题描述
我有一个使用rails构建的个人博客。我想在我的网站上添加一个显示我当前github贡献的部分。
编辑:澄清,这是我想要的:
天是我所需要的。
考虑到(Github贡献SVG generator)
- 或建立服务每天都会向Google日历报告该日期的任何新提交(使用Google Calendar API通过项目如
-
weekend-commits.js
code>
git-cal
是一个简单的脚本,用于在命令行上查看提交日历(类似于GitHub贡献日历)。
图中的每个块对应于一天,并且用一个阴影5种可能的颜色,每种代表当天提交的相对数量。
如:
$ .getJSON('https://github.com/users /'+ location.pathname.replace(/ \ // g,'')+'/ contributions_calendar_data',weekendWork);
Like:
leaderboard = members.map do | u |
user_stats = get(https://github.com/users/#{u}/contributions_calendar_data)
total = user_stats.map {| s | s< 1]} .reduce(&:+)
[u,total]
end
- ...(你明白了)
I have a personal blog I built using rails. I want to add a section to my site that displays my current streak of github contributions. What would be the best way about doing this?
edit: for clarification, here is what I want:
just the number of days is all that is necessary for me.
Considering the GitHub API for Users doesn't yet expose that particular information (number of days for current stream of contributions), you might have to:
scrape it (extract it by reading the user's GitHub page)
As klamping mentions in his answer (upvoted), the url to scrap would be:
https://github.com/users/<username>/contributions_calendar_data
https://github.com/users/<username>/contributions
(for public repos only, though)SherlockStd has an updated (May 2017) parsing code below:
https://github-stats.com/api/user/streak/current/:username
try projects which are using
https://github.com/users/<username>/contributions
(as listed in Marques Johansson's answer, upvoted)_calendar_data
- akerl/githubchart (Github contribution SVG generator)
- akerl/githubstats (Github contribution statistics)
- build that graph yourself: see the GitHub project git-cal
git-cal
is a simple script to view commits calendar (similar to GitHub contributions calendar) on command line.
Each block in the graph corresponds to a day and is shaded with one of the 5 possible colors, each representing relative number of commits on that day.
- or establish a service that will report, each day, any new commit for that given day to a Google Calendar (using the Google Calendar API through a project like nf/streak).
You can then read that information and report it in your blog.
You can find various example of scraping that information:
As in:
$.getJSON('https://github.com/users/' + location.pathname.replace(/\//g, '') + '/contributions_calendar_data', weekendWork);
Like:
leaderboard = members.map do |u|
user_stats = get("https://github.com/users/#{u}/contributions_calendar_data")
total = user_stats.map { |s| s[1] }.reduce(&:+)
[u, total]
end
- ... (you get the idea)
这篇关于我如何添加“当前连胜” github对我博客的贡献?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!