Giter Club home page Giter Club logo

shields-io-visitor-counter's Introduction

Shields.IO Visitor Counter

Warning

This project has been archived (September 2023), as its CountAPI dependency no longer works. See pinned issue #17 for further details.

GPL-3.0 GitHub release Python 3.8+Ÿ Codecov Visitor count

A simple visitor counter displayed as a Shields.IO static badge.

How it works

This application is deployed on Heroku, and creates a Shields.IO static badge that you can embed on your page. Every time your page loads, it reloads the badge, which pings CountAPI to increase the counter!

Creating your own visitor counter

If you've used Shields.IO before, it's really straightforward! Let's use the octocat/Spoon-Knife GitHub repository as an example.

To create a counter with all default options, add the page argument with your username.repo to the application URL:

https://shields-io-visitor-counter.herokuapp.com/badge?page=octocat.Spoon-Knife

to get this:

Default counter

And to embed this in Markdown, just use:

![Visitor count](https://shields-io-visitor-counter.herokuapp.com/badge?page=octocat.Spoon-Knife)

Options

The only mandatory argument is page, but you can use almost all options available on Shields.IO — the only unavailable one is message, as this is the count! To add option, just add it to URL query component.

Let's take our previous example, and modify it! Say we want the following:

  • Label (left-hand side) to say My First Counter on a black background, with a white GitHub logo;
  • Message (right-hand side) to have a blue background; and
  • Style it with the Shields.IO for-the-badge style

From the Shields.IO documentation, we can:

  • Change the label text using the label parameter;
  • Change the label background colour using the labelColor parameter;
  • Add a logo to the label, and change its colour using the logo, and logoColor parameters, respectively;
  • Change the message background colour with the color parameter; and
  • Change the badge style use the style parameter.

All in all, the previous URL becomes:

https://shields-io-visitor-counter.herokuapp.com/badge?page=octocat.Spoon-Knife&label=My First Counter&labelColor=000000&logo=GitHub&logoColor=FFFFFF&color=1D70B8&style=for-the-badge

which gives us:

Custom counter

Note we used hex colours in the URL, but Shields.IO also supports (some) colours by name!

Caveats

  • It's not smart enough to track users by IP address, for example. So if you reload the page, the counter will also increase!
  • It runs on Heroku Free Tier as part of my 1,000 free dyno hours per month — if this runs out, the application will be down!
  • Applications on Heroku Free Tier should timeout after 30 minutes, but I'm using cron-job.org to wake it up every 15 minutes, so it should always be on!

If the application is down, and doesn't wake up, raise an issue, and I'll look at it as soon as possible!

Contributing

If you'd like to contribute to this work, take a look at CONTRIBUTING.md to get started!

Attribution

This work is based on Visitor Badge by Jiang Wenjian, and their excellent blog post on its development.

shields-io-visitor-counter's People

Contributors

eskyoung avatar

Stargazers

 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

shields-io-visitor-counter's Issues

CountAPI no longer works — this project will be archived

As of earlier this year (April 2023), CountAPI no longer works. This means that this app will received a 500 response, and not show a badge. See jwenjian/visitor-badge for further details, and the referenced issue for possible alternatives.

This issue, coupled with Heroku no longer having a free tier, means I'll archive this project in the coming weeks. I'll leave this pinned for folks to see!

Thanks for using the app so far!

Visitor count request taking too long

Hi,
I am using this visitor counter for few months. Everything was working fine. Today the request is taking too long and within github page it times out.

Here is a screenshot of your own page. Same thing is happening with all my repos:

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.