我有一个使用Rails构建的个人博客。我想在我的网站上添加一个部分,以显示我当前的github贡献。这样做的最佳方法是什么?

编辑:为了澄清,这是我想要的:



对我来说只需要几天的时间。

最佳答案

考虑到GitHub API for Users尚未公开该特定信息(当前捐款流的天数),您可能必须:

  • 抓取它(通过阅读用户的GitHub页面进行提取)
    正如klampinghis answer中提到的(已赞成),要报废的网址为:https://github.com/users/<username>/contributions_calendar_data https://github.com/users/<username>/contributions
    (不过,仅适用于公共(public)回购)

    SherlockStd在下面有一个updated (May 2017) parsing code:
    https://github-stats.com/api/user/streak/current/:username
    
  • 尝试使用https://github.com/users/<username>/contributions _calendar_data的项目(如Marques Johanssonanswer中所列,已投票)
  • IonicaBizau/git-stats:


  • akerl/githubchart(Github贡献SVG生成器)
  • akerl/githubstats(Github贡献统计)


  • 自己构建该图:请参见GitHub project git-cal



  • 或建立一个服务,每天将给定日期的任何新提交报告给Google日历(通过nf/streak等项目使用Google Calendar API)。
    然后,您可以阅读该信息并在您的博客中进行报告。



  • 您可以找到刮取该信息的各种示例:
  • github_team_calendar.py
  • weekend-commits.js

  • 如:
    $.getJSON('https://github.com/users/' + location.pathname.replace(/\//g, '') + '/contributions_calendar_data', weekendWork);
    
  • leaderboard.rb :

  • 喜欢:
    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
    
  • ...(您的想法)
  • 10-05 20:57
    查看更多