Giter Site home page Giter Site logo

elyda66 / shields-io-visitor-counter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from eskyoung/shields-io-visitor-counter

0.0 0.0 0.0 77 KB

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

Home Page: https://shields-io-visitor-counter.herokuapp.com

License: GNU General Public License v3.0

Makefile 4.29% Python 95.17% HTML 0.54%

shields-io-visitor-counter's Introduction

Shields.IO Visitor Counter

GPL-3.0 GitHub release Python 3.6+ Travis CI 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

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.