This project has been archived by its maintainers, and is no longer receiving any updates.
If you want to display snazzy Github participation graphs on your Django-based web site, this is for you.
This is a small Django app that provides a template tag to allow you to include sparklines of the 52-week commit history for a project on Github. Think of the graphs you see down the left-hand side of a Github user’s home page – only, as I said, snazzy sparklines instead of bar charts. Examples can be found on the introductory blog post. A real-world example can be found on the author’s “About” page:
Requirements
Other than Django itself, no external libraries are required. The sparklines are generated using Google Charts so no image processing is done locally. The app has been tested with the latest Subversion trunk version of Django, but should be quite happy working with older releases too.
Installation
You can download the package from PyPI using either PIP or easy_install:
pip install participationgraphs easy_install participationgraphs
Alternatively you can install the latest version from Github:
pip install -U -e git+git://github.com/flother/participationgraphs.git#egg=participationgraphs
Add the participationgraphs app to INSTALLED_APPS in your Django settings file:
INSTALLED_APPS = (
# ...
'participationgraphs',
)
If you’re been running the development server while you do this, restart it so Django can find the new template tag library.
Usage
In each template you want to show participation graphs, load the githubgraphs library:
{% load githubgraphs %}
This can appear anywhere in your template as long as it comes before the first use of the github_participation_graph template tag.
At the point in the template you want to display a participation graph, include:
{% github_participation_graph "brosner" "django" %}
This will output an img element for the sparkline, showing the commit history for the django project belonging to the Github user brosner. The img element’s src attribute will point to a dynamically-generated Google Charts image.
By default the sparkline will be a grey data-line on a white background, 400 pixels wide by 50 pixels high, but if you want to change the colours or dimensions you can. The following example will display a sparkline 100 pixels wide by 40 pixels high, with a red data-line on a black background:
{% github_participation_graph "brosner" "django" "100x40" "ff0000" "000000" %}
There are seven parameters in total; two are mandatory and five are optional:
username: Github username (mandatory)
project_name: Github project name (mandatory)
dimensions: height and width of the image in pixels in the format “HxW”
foreground_colour: six-digit hex colour of the sparkline data
background_colour: six-digit hex colour of the graph background
fill_colour: six-digit hex colour of the graph’s data fill
marker_colour: six-digit hex colour for the final data marker
Caveat emptor
To get the commit data for the graph the template tag makes an HTTP request to github.com – so for every sparkline there will be two HTTP requests: one client-side to a Google server to get the chart image and one server-side to Github. Although it’s optional I highly recommend using Django’s built-in caching to cache either the template or the template fragment.
Licence
All code in this repository is released under the GNU General Public licence version 2. For details see the LICENCE file in the root directory.
If you’d like to use the code under a different (open-source) licence, contact me and we’ll see what we can do.
Metadata
Release files for participationgraphs 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| participationgraphs-0.1.1.tar.gz | 5.6 kB | Without provenance | Details |
Release files / participationgraphs-0.1.1.tar.gz
| Download URL | participationgraphs-0.1.1.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
05ce4954beca8e6db66f216edc74a6e8417fbfbd04d784e1d6f70c7b7583b5ce
|
|
BLAKE2b-256 checksum How to use checksums |
4bde222dc9f74e474cd34f01b0d9fc78d528b98e4d85725cc176fff54bb46640
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for participationgraphs 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.