Package: participationgraphs
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 theintroductory blog post. Areal-world examplecan be found on the author’s
“About” page:RequirementsOther 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.InstallationYou can download the package from PyPI using either PIP oreasy_install:pip install participationgraphs
easy_install participationgraphsAlternatively you can install the latest version from Github:pip install -U -e git+git://github.com/flother/participationgraphs.git#egg=participationgraphsAdd theparticipationgraphsapp toINSTALLED_APPSin 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.UsageIn each template you want to show participation graphs, load thegithubgraphslibrary:{% load githubgraphs %}This can appear anywhere in your template as long as it comes before the first
use of thegithub_participation_graphtemplate 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 thedjangoproject belonging to the Github userbrosner. Theimgelement’ssrcattribute 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 databackground_colour: six-digit hex colour of the graph backgroundfill_colour: six-digit hex colour of the graph’s data fillmarker_colour: six-digit hex colour for the final data markerCaveat emptorTo get the commit data for the graph the template tag makes an HTTP request togithub.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.LicenceAll 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.