Coder Social home page Coder Social logo

bloggify / github-calendar Goto Github PK

View Code? Open in Web Editor NEW
1.2K 14.0 212.0 215 KB

:bar_chart: Embed your GitHub calendar everywhere.

Home Page: https://bloggify.github.io/github-calendar/example/

License: MIT License

JavaScript 62.08% CSS 6.34% HTML 16.27% PHP 15.31%
hacktoberfest

github-calendar's Introduction

github-calendar.js

Version Downloads

Embed your GitHub contributions calendar anywhere.

Everybodywell, haters gonna hate loves GitHub and everybody loves stats. So, why not making the GitHub contributions calendar available for being embeded in your web pages? Now you can. 🎉

☁️ Installation

Check out the dist directory to download the needed files and include them on your page.

If you're using this module in a CommonJS environment, you can install it using npm or yarn and require it:

# Using npm
npm install --save github-calendar

# Using yarn
yarn add github-calendar
<!-- Include the library. -->
<script
  src="https://unpkg.com/github-calendar@latest/dist/github-calendar.min.js">
</script>

<!-- Optionally, include the theme (if you don't want to struggle to write the CSS) -->
<link
  rel="stylesheet"
  href="https://unpkg.com/github-calendar@latest/dist/github-calendar-responsive.css"
/>

<!-- Prepare a container for your calendar. -->
<div class="calendar">
    <!-- Loading stuff -->
    Loading the data just for you.
</div>

<script>
    GitHubCalendar(".calendar", "your-username");

    // or enable responsive functionality:
    GitHubCalendar(".calendar", "your-username", { responsive: true });

    // Use a proxy
    GitHubCalendar(".calendar", "your-username", {
       proxy (username) {
         return fetch(`https://your-proxy.com/github?user=${username}`)
       }
    }).then(r => r.text())
</script>

Here you can see this example in action.

❓ Get Help

There are few ways to get help:

  1. Please post questions on Stack Overflow. You can open issues with questions, as long you add a link to your Stack Overflow question.
  2. For bug reports and feature requests, open issues. 🐛

📝 Documentation

GitHubCalendar(container, username, options)

Brings the contributions calendar from GitHub (provided username) into your page.

Params

  • String|HTMLElement container: The calendar container (query selector or the element itself).
  • String username: The GitHub username.
  • Object options: An object containing the following fields:
    • summary_text (String): The text that appears under the calendar (defaults to: "Summary of pull requests, issues opened, and commits made by <username>").
    • proxy (Function): A function that receives as argument the username (string) and should return a promise resolving the HTML content of the contributions page. The default is using @Bloggify's APIs.
    • global_stats (Boolean): If false, the global stats (total, longest and current streaks) will not be calculated and displayed. By default this is enabled.
    • responsive (Boolean): If true, the graph is changed to scale with the container. Custom CSS should be applied to the element to scale it appropriately. By default this is disabled.
    • tooltips (Boolean): If true, tooltips will be shown when hovered over calendar days. By default this is disabled.
    • cache (Number) The cache time in seconds.

Return

  • Promise A promise returned by the fetch() call.

😋 How to contribute

Have an idea? Found a bug? See how to contribute.

💫 Where is this library used?

If you are using this library in one of your projects, add it in this list. ✨

  • @axetroy/react-github-calendar
  • @dotnetthailand/gatsby-theme-minimal-portfolio
  • @jiratki/gatsby-theme-minimal-portfolio
  • @pengliheng/github-report
  • @philipwhiuk/react-github-calendar
  • github-alike-calendar
  • github-calendar-element
  • github-calendar-web-component
  • github-contributions-react
  • react-ts-github-calendar

📜 License

MIT © Bloggify

github-calendar's People

Contributors

benprime avatar francescotonini avatar georgiabains avatar giselak avatar ionicabizau avatar jalopezg-git avatar khaledmostafame avatar miroslavvidovic avatar mn6 avatar onkar-shaligram avatar palmerev avatar rathirohit avatar redmike avatar rembrandtsx avatar rhnvrm avatar rodrigograca31 avatar snowztail avatar togami2864 avatar totoroot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

github-calendar's Issues

responsive

I don't think the responsive layout is actually implemented?

How to add a minimal version of the calendar using Jekyll

  1. Make a .html file with the following content (I have it as my index) and save as index.html
---
layout: default
---

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>GitHub Calendar</title>
        <link rel="stylesheet" href="assets/dist/style.css">
    </head>
    <body>
        <div class="bag fixed">
            <div class="calendar">
                <img src="https://assets-cdn.github.com/images/spinners/octocat-spinner-128.gif" class="spinner"/>
            </div>
            <script src="https://cdnjs.cloudflare.com/ajax/libs/es6-promise/3.0.2/es6-promise.min.js"></script>
            <script src="https://cdnjs.cloudflare.com/ajax/libs/fetch/0.10.1/fetch.min.js"></script>
            <script src="assets/dist/github-calendar.min.js"></script>
            <script src="assets/dist/main.js"></script>
        </div>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.0.0/highlight.min.js"></script>
        <script>hljs.highlightBlock(document.querySelector("pre"))</script>
    </body>
</html>
  1. Under a subfolder (e.g. assets) make a new folder (dist) and add github-calendar.css, github-calendar.min.js, main.js and style.css from @IonicaBizau repository. Change the links in your index.html file accordingly. E.g. <script src="assets/dist/main.js"></script>.

This (and a bit of tweaking the main.js and style.css) will generate the result as seen on my site.

Grid doesn't load on the first page load, or on update

I am loading the calendar using the example code in the README:

<!-- Prepare a container for your calendar. -->
<script
  src="https://cdn.rawgit.com/IonicaBizau/github-calendar/gh-pages/dist/github-calendar.min.js"
</script>

<!-- Optionally, include the theme (if you don't want to struggle to write the CSS) -->
<link
  rel="stylesheet"
  href="https://cdn.rawgit.com/IonicaBizau/github-calendar/gh-pages/dist/github-calendar.css"
/>

<!-- Prepare a container for your calendar. -->
<div class="calendar">
    <!-- Loading stuff -->
    Loading the data just for you.
</div>

<script>
    GitHubCalendar(".calendar", "palmerev");
</script>

When I first load the page, the basic contribution data loads into the calendar, but the grid doesn't load. I waited about 10 minutes, but the spinner just keeps spinning. If I refresh the page, then it loads immediately. If I visit the page again for the same user, then it always loads immediately.

The first page visit:

firstrequest
After refreshing, or visiting the page again:

afterrefresh

I am running a local Python/Django development server.

The same thing happens when I visit this site, which has the calendar embedded. The first time I visited, no grid, and the spinner just spins. Refresh or visit again, and it loads correctly:
http://themes.3rdwavemedia.com/demo/developer/tom-najdek/

I can do this for any username and it's the same. The grid doesn't load the first time.
I've tested in Chrome and Firefox with 4 different usernames. Clearing browsing data has no effect.

UPDATE: It turns out that this also happens whenever a new contribution is made. If the response returns the spinner image instead of the grid SVG, then it won't change unless the request is made again. To fix this, it should test if the response contains the spinner image and if it does, make the request again. I can submit a pull request soon.

Erratum in README

Hi.
First comment in the source code example is
<!-- Prepare a container for your calendar. -->
and then script tag. Container itself is placed few lines lower, with the same comment.
And this is definely an erratum :)

Example of using Object options

Hi Ionica. I asked you on stackoverflow about adding your github-calendar to Jekyll. I am writing up a guide now. Before I do so, can you perhaps give a few examples of how to use the "options object" in the GitHubCalendar (main.js) function? I think that a lot of people using Jekyll are using a theme, and e.g. the theme I am using squeezes the information in the calendar slightly. So it would be nice to be able to see a minimal representation.

It does not seem to work when calling <options "global_stats=false"> in GitHubCalendar. Perhaps I am doing it wrong?

Thanks!

Customizing Theme Colors

Is it possible to color the colors for each contribution square? I tried modifying t.exports (line 164) but that didn't work. I also updated where we grab the original code to return a new fill value (line 175...), but that didn't work.

The example (codepan) doesn't work - Loading the data just for you all the time

Problem: Widget doesn't work as described, it always shows "Loading the data just for you." and nothing happens.

Steps to reproduce:

Developer console reports the next errors:
image

Browsers: Chrome 80.0.3987.87 (Official Build) (64-bit) and Firefox 72.0.2 (64-bit) all on macOs 11.15.3

Fix

  • Change https://cdn.rawgit.com/IonicaBizau/github-calendar/master/dist/github-calendar.min.js to https://cdn.rawgit.com/IonicaBizau/github-calendar/gh-pages/dist/github-calendar.min.js fixes the problem.

TypeError: f.querySelector(...) is null

The GitHub calendar is not loading and I have the following error:

TypeError: f.querySelector(...) is null

in the github-calendar.min.js file. When I unminify the file it shows the error is on line 56.
I think the problem is with the querySelector() function not matching any CSS selector for the class .left.text-muted:

if (f.querySelector(".left.text-muted").innerHTML = c.summary_text, f.querySelector("include-fragment")) setTimeout(l, 500);

Cannot read property 'querySelector' of null

2018-08-23 11 23 20

github-calendar.js worked well until yesterday, but I have some issue with github-calendar.js today. console said “TypeError: Cannot read property ‘querySelector’ of null”. I tested it with chrome and safari.

Example not working

Hey.

Not sure if the intended behavior of your example was what it's actually doing ( only displaying "Loading the data just for you." and not the actual calendar.

I did manage to embed it so no big deal really, just pointing this out.

TypeScript support

I think this project will be more awesome if it supports TypeScript. Actually, I wrote a type declaration file already, but I faced a little problem.

  1. A new keyword can't use for function, so GitHubCalendar function must be called like GithubCalendar(...) not new GitHubCalendar(...).
  2. If the function is declared as a class, the constructor can't return value, so GitHubCalendar(...) can't return the promise.

What do you think about this issue?

Query selector for calendar needs to be changed

GitHub had again some style changes and the github-calendar widget won't load:

Div containing the calendar graph has changed from
div id="contributions-calendar"
to
div class="js-contribution-graph"

github-calendar in react.js

I'm trying to implement this module in my react.js application.

Here is my code.

It gives me error, can you help me resolving it?

Running the script changes the tab .ico to the github logo

The summary more or less says it all. I am using a code snippet I saw you provide against a Stackoverflow answer which I will show below;

<script src="https://cdn.rawgit.com/IonicaBizau/github-calendar/gh-pages/dist/github-calendar.min.js"></script>
<link rel="stylesheet" href="https://cdn.rawgit.com/IonicaBizau/github-calendar/gh-pages/dist/github-calendar.css"/>
<div class="calendar">Loading Github contributions.</div>
<script> new GitHubCalendar(".calendar", "rudikershaw");</script>

After the script finishes running on the page, the page tab ico is swapped out for the github logo. I'm going to look into this, but I am not holding up hope of finding a solution myself.

Browser: Firefox 70.0.1 (64-bit) for Ubuntu canonical - 1.0
OS: Ubuntu 18.04

Not Working

It doesn't load in the script. It keeps the "Loading the data just for you.". This is on the codePen as well. It doesn't render properly.

how to integrate this with vue?

hi,
I'm trying to integrate this with my Vue project. but it doesn't work.

main.js
import GitHubCalendar from "github-calendar" import "github-calendar/dist/github-calendar-responsive.css" Vue.use(GitHubCalendar(".calendar", "SaadKhanMalik"))

my console spits out
index.js?02ed:99 TypeError: Cannot set property 'innerHTML' of null at eval (index.js?02ed:96) (anonymous) @ index.js?02ed:99
would really love to intergrate this.

thanks

Rectangle Colors

Hi All,

I'd like to add an option field for changing the rectangle colors.

GitHubCalendar(domObject, uName, { summary_text: 'blah', global_stats: true, responsive: true, base_color: '#FF5733' });

Base color would correspond to the current #239a3b slot (2nd to last). It would overwrite the last three values, leaving the base gray (#ebedf0) in place. Other colors would be calculated from the base color (darker, lighter).

The legend would also be changed to correspond.

dist-it not in devDependencies

Kind of key to have this listed in deps since it's the sole component responsible for releasing. I'd also highly recommend leveraging david to keep your deps up to date.

Empty space exists

GitHub update interface of the contributions calendar on May 20, 2016. As part of this update, code streaks are no longer featured on the contributions calendar.
https://github.com/blog/2173-more-contributions-on-your-profile

But some codes related to code streaks are still existing in this project. Due to this, empty space is shown.

github-calendar_screenshot

OS: OSX El Capitan 10.11.5, Browser: Safari 9.1.1

c.querySelector issue

The snippet won't show.
Line error: github-calendar.min.js:1:1667

TypeError: null is not an object (evaluating 'c.querySelector')

Tested in Safari and Firefox

Appspot quota

It looks like this script growth very fast. Couldn't bare with 1GB AppSpot quote per day. It works most of hours in a day still.

Bad looking border

The border of the calendar diverges from the border of the global stats, as the prior is looking thicker and not very nice.

Screen Shot 2019-08-14 at 01 10 54

From my tests, by removing the class border from the inner div that contains the classes border border-gray-dark py-2 graph-before-activity-overview the border looks good again.

Please, can you check? (Tested with Firefox and Safari)

Individual Repository Stats

I just wanted to start by saying your script is awesome and thank you for sharing your work with the world. I wanted to use your script for showing details of repositories instead of based on a person. Is it possible to use your script so I can display the stats on just one of my public repositories instead of all of my activity on all repositories? I hope that makes sense.

Ideally you would pass your repository url
example: IonicaBizau/github-calendar
Would display the activity calendar on only that repository.

Again wonderful script =)

How to edit the styling definition in elements ?

Hi, I am building a GitHub page for myself with embedding this calendar into my source code, and I am customizing the styling definitions for the calendar elements.

The image bellow shows what it actually looks like in browser developing tool,
image

while this is the source code given to embed this GitHub calendar into the webpage,
image

Does anyone know how can I find the source code in the black rectangle, so I can redefine the styling definition for those elements ?
image
I know there are some of the styling attribute declaration can be found in the JavaScript code, while it is only partial are found by me. For example, how can I remove the styling attribute mx-3 in <div class="contrib-footer ..."> element?

CORS is preventing the request

The script was running fine until today.

Failed to load resource: Origin http://mywebsite.com is not allowed by Access-Control-Allow-Origin.

Tested under Safari and Firefox.

github-loader-error

Stats displayed offset to left

Hi,
I've been using your nice calendar for a while but I noticed recently that the stats at the bottom are displayed off set to the left. See image attached. You can see my webpage here: jamesjmccormac.com. Do you have any ideas why this happens? I get the same in Safari and Firefox.

Cheers,
James

screenshot 2018-03-28 17 15 44

Adding tooltip hover event

I would like to see a fully responsive tooltip for each day just like it does github where it shows you the amount of commits per day.

Mixed Content Error

On Chrome (v47.0.2526.106) I get a Mixed Content error preventing the Calendar from being loaded.

image

This can be fixed by clicking the 'Load Unsafe Scripts' image button in the url bar.

I know you mentioned the proxy (urlreq) only supports HTTP, but is there a work-around for getting this to work on secure pages?

Provide customizable colors

It would be really nice if we can also provide color customization where we can generate graphs of different shades.

Undocumented dev dependencies

I tried running npm run release, but uglify-js was throwing a syntax error. I realized that I also needed babel-preset-es2015 for it to work. Then adding the preset in the release command works:
browserify lib/index.js -o dist/github-calendar.min.js -s GitHubCalendar && babel --presets es2015 dist/github-calendar.min.js | uglifyjs -c -m -o dist/github-calendar.min.js

Or, adding babel config to package.json:

"babel": {
    "presets": ["es2015"]
  }

I think it would be a good idea to have everything that the release command uses be declared in devDependencies in the package.json, something like:

"devDependencies": {
    "babel-cli": "^6.8.0",
    "babel-preset-es2015": "^6.6.0",
    "browserify": "^13.0.0",
    "uglify-js": "^2.6.2"
  }

There could also be a note in the CONTRIBUTING.md about this. 📝

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.