我有一个使用 Rails 构建的个人博客。我想在我的网站上添加一个部分来显示我当前对 github 的贡献。这样做的最佳方式是什么?
编辑:为了澄清,这是我想要的:
我只需要几天的时间。
最佳答案
考虑到 GitHub API for Users尚未公开该特定信息(当前贡献流的天数),您可能必须:
抓取它(通过阅读用户的 GitHub 页面提取它)
作为klamping在 his answer 中提到(已投票),报废的 url 将是:
<德尔>https://github.com/users/<username>/contributions_calendar_data
<强>https://github.com/users/<username>/contributions
强>
(虽然仅适用于公共(public) repo )SherlockStd有一个 updated (May 2017) parsing code下面:
https://github-stats.com/api/user/streak/current/:username
尝试使用
https://github.com/users/<username>/contributions
的项目<德尔>_calendar_data
(如 Marques Johansson 的 answer 中所列,已投票)
- akerl/githubchart (Github贡献SVG生成器)
- akerl/githubstats (Github贡献统计)
- 自己构建图表:参见 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.
- 或建立一项服务,每天向 Google 日历报告给定日期的任何新提交(通过 nf/streak 等项目使用 Google 日历 API)。
然后您可以阅读该信息并在您的博客中进行报告。
您可以找到各种抓取该信息的示例:
如:
$.getJSON('https://github.com/users/' + location.pathname.replace(/\//g, '') + '/contributions_calendar_data', weekendWork);
喜欢:
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
- ...(你懂的)
关于html - 如何将 github 的 "current streak"贡献添加到我的博客?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15978845/