gpt4 book ai didi

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

转载 作者:技术小花猫 更新时间:2023-10-29 11:45:16 26 4
gpt4 key购买 nike

我有一个使用 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com