Code Monkey home page Code Monkey logo

github-badge-2's Introduction

github-badge-2

Simpler implementation, utilizing GitHub's GraphQL API, and fork of:
https://github.com/berkerpeksag/github-badge

Setup

Option 1 - Self-Hosted

Simply update config.json with your username and github api_key that has user repo read access and user activity. Run the generate_badge.py script with python v3.4+, with jinja2 and requests installed.

Then, set up a cron job or whatever you can use for a recurring / scheduled tasks to run the script periodically (something like every 24hrs) to update the generated badge.html. Or you can setup a free jinja webapp like on pythonanywhere.com and simply check if the generated html exists or if modified date of the html file is greater than 1 day, see example script.

Remember to set permissions to deny requests all files other than the generated html file.

Option 2 - GitHub Actions & Pages

For GitHub Actions with GitHub Pages, see update-badge-html.yml for example usage. You will need to add a GitHub token as GH_BADGE_TOKEN in the repository secrets. You will also need to set the GitHub Pages repository setting to use the gh-pages branch. You will likely want to add repositories with automated commits to main/default branches in ignore_repos in config.json to prevent said automated commits from being considered. Otherwise, the latest commit for those repositories will nearly always be the last automated commit and not any commit by the actual user. So, the recent changes link presented in the widget will be point to potentially unwanted said commits.

Usage

You can then include the widget with the following code in similar form to:

<iframe src="https://MyWebsite.com/badge.html" style="border:0;height:128px;width:200px;overflow:hidden;" frameBorder="0"></iframe>

Dark theme / Night mode

You can use the dark theme by specifying class="dark" on <body> in the html template. Or you can add ?theme=dark to the end of the URL used for the iframe.

Preview

Light theme Dark theme

github-badge-2's People

Contributors

joedf avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

github-badge-2's Issues

Need to limit graph to handle low commit activity

Currently, if the number of commit are very low (say 0-2), the graph may look very busy / maxed out. This is misleading and arguably wrong. In the example below, zero commits were made for over a week, resulting in a maxed-out graph... should be me all zero with just minimal lines.
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.