How can I add the “current strip” of github contributions to my blog?

I have a personal blog that I built using rails. I want to add a section to my site that displays my current github contrib strip. What would be the best way to do this?

edit: for clarification, here is what I want:

enter image description here

I need only the number of days.

+27
html github ruby ruby-on-rails html-parsing
Apr 12 '13 at 18:55
source share
4 answers

Given the GitHub API for users , until it reveals this specific information (number of days for the current contribution stream), you should:

  • clean it (extract it by reading the GitHub user page)
    As klamping mentions in its answer (upvoted), url to scrap will be:
    https://github.com/users/<username>/contributions_calendar_data cases>
    https://github.com/users/<username>/contributions
    (for public repositions only)

    SherlockStd contains the updated (May 2017) analysis code below:

     https://github-stats.com/api/user/streak/current/:username 
  • try projects that use https://github.com/users/<username>/contributions _calendar_data (as stated in Marques Johansson answer , upvoted)

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 the commit calendar (similar to the GitHub contribution calendar) on the command line.
Each block on the graph corresponds to a day and is shaded by one of 5 possible colors, each of which represents the relative number of commits on that day.

  • or create a service that will report every day about any new commit for a given day in Google Calendar (using the Google Calendar API through a project, for example, a series ).
    You can then read this information and report it on your blog.

Google calendar streak




You can find a different example of scraping this information:

How in:

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

how

 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)
+36
Apr 13 '13 at
source share

The url for plain JSON data was : https://github.com/users/[username†/contributions_calendar_data [Edit: it seems this url is no longer working)

There is a URL that generates an SVG that pointed out other answers. Here: https://github.com/users/[username†/contributions

Just replace [username] with your github username in the url and you can see the graph. See Other Answers for more detailed explanations.

+17
Aug 02 '13 at 2:58
source share

If you want something that matches the visual appearance of the GitHub chart, check out these projects that use https://github.com/users/<username>/contributions_calendar_data but also apply other factors based on Github logic.

+2
Jul 17 '14 at 11:39
source share

Since the URL https://github.com/users/<username>/contributions_calendar_data no longer works, you need to parse the SVG from https://github.com/users/<username>/contributions .

Unfortunately, Github loves security, and CORS is disabled on its server.

To solve this problem, I configured the API for me and everyone who needs it, just GET https://github-stats.com/api/user/streak/current/{username} (CORS enabled), and you will get and reply So:

 { "success":true, "currentStreak": 3 } 

https://github-stats.com will soon realize more statistics endpoints :)

Request a new endpoint at https://github.com/SherlockStd/github-stats.com/issues , it will be nice to find a way to implement them!

+2
May 16 '17 at 16:53
source share



All Articles