html - 如何将 github 的 "current streak"贡献添加到我的博客?

标签 html ruby-on-rails ruby github html-parsing

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

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

enter image description here

我只需要几天的时间。

最佳答案

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

  • 抓取它(通过阅读用户的 GitHub 页面提取它)
    作为klampinghis 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 Johanssonanswer 中所列,已投票)

git-stats

https://github.com/akerl/githubchart

https://raw.github.com/k4rthik/git-cal/master/screenshots/img1.png

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)。
    然后您可以阅读该信息并在您的博客中进行报告。

Google Calendar streak


您可以找到各种抓取该信息的示例:

如:

$.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/

相关文章:

javascript - 在父容器调整大小上重绘谷歌地图

ruby-on-rails - ruby on rails 中的嵌套或正常路由

ruby-on-rails - 我们可以使用 Ruby on Rails 开发移动应用程序吗?

ruby - 在 Raspbian 上安装 Ruby Gem 错误 : Failed to Build Gem Native Extension

ruby - Watir,我如何获取运行测试脚本后显示的错误并将其放在文件中

html - <p> 文本左对齐,但我需要它在 <div> 类中的图像背景之上

iphone - 如何阻止我的长 <select> 下拉列表文本在 iPhone 上被缩短?

python - 根据阈值更改表格的颜色

ruby-on-rails - 1 个 CPU 上的 Ruby Rack 应用程序——我应该运行多少个进程?

sql - 列出重复值的数量