Skip to main content

simple offline issue reader for GitHub Issues

Project description

This script allows you to easily download the open issues of a GitHub Repository and store them in a offline browsable, single standalone html file.

The name

I chose the name, because the obvious pun name “tissues” was already taken. It also fits, because being offline is somewhat oldfashioned, just like the word handkerchief.

There are three ways to set handkerchief up:

Using pip

This is the easiest way and probably the right choice for most people. Make sure you have pip installed and type

pip install handkerchief

into your terminal to install handkerchief and all dependencies onto your computer. This might require admin access.

You can now invoke handkerchief from everywhere using

handkerchief

In a virtualenv

If a system wide installation with pip is too intrusive for you, and you need handkerchief only in a certain environment, you can try virtualenv. Within the activated virtualenv, just type

pip install handkerchief

You can then invoke handkerchief while you are in the virtualenv by typing

handkerchief

As standalone script

You can take just the handkerchief.py from the repository and put it where you need it. No installation required. From there you can invoke it with

python handkerchief.py --remote-layouts

From repository

You can also clone the repository to some place on your computer and use it from there. Depending on your system, you might want to make it available from everywhere by putting the repo in your PATH, define an alias or something else.

For example, if you are on a mac you can optionally add the following to your ~/.bash_profile.

function handkerchief {
  # change this path to the location of handkerchief.py
  hand=~/handkerchief/handkerchief.py
  if [[ $1 != "" ]] ; then
    python $hand --remote-layouts $1
     else
    repo=$(git remote -v | head -n1 | awk '{print $2}' | sed -e 's,.*:\(.*/\)\?,,' -e 's/\.git$//')
    if [[ $repo == *https://* ]] ; then
      python $hand ${repo#https://github.com/}
    elif [[ $repo == *git@github.com* ]] ; then
      python $hand ${repo#git@github.com:}
    else
      echo "Provide parameter"
    fi
  fi
}

Specifying repositories

The simplest way to use handkerchief is to call it with the user or organisation and repository name

handkerchief jreinhardt/tissues

If you are calling handkerchief from within a git repository, it tries to figure out a GitHub repo for it

cd /path/to/repository
handkerchief

Or if you have one or many .html files generated by handkerchief in a directory, it extracts the repositories to check from them.

cd /path/to/directory/with/handkerchief/htmls
handkerchief

Commandline parameters

There are a few options available, for example to choose a layout, specify how to authenticate (to avoid GitHubs rate limits) and much more.

For details see

handkerchief --help`.

Layouts

Handkerchief offers a simple way to modify the visual appearance and functionality of the resulting offline html file, by changing to a different layout.

Handkerchief ships with a default layout that is available when installing with pip. For developing layouts it is convenient to ask handkerchief to search for layouts in a specific place using the –layout-dir. When using handkerchief as a standalone script, it can look layouts up at the handkerchief GitHub repository using the –remote-layouts option.

A layout consists of a parameter and a template file, and a number of javascript and css files, which reside in a subfolder of the layouts folder in the handkerchief repository. To produce the output file, the template file gets populated with the data, and the javascript and css files are inlined. If not told otherwise, handkerchief will fetch layouts from the handkerchief GitHub repository, so that always the most up to date version of the layout is used.

The parameter file is a json file with the same name as the subfolder in which it resides. It contains an associative array with three keys:

  • html: the file name of the template file

  • css: a list of filenames of stylesheets to inline

  • js: a list of filenames of javascript files to inline

The template is processed by Jinja2, and the following variables are available:

  • reponame: a string with the name of the repository in the form username/reponame

  • repo: a dictionary containing information about the repository, see GitHub API docs (1)

  • issues: a list of dictionaries containing issue data, see GitHub API docs (2). Each issue has an additional field: - ‘labelnames’ with a list of all labels for this issue

    • ‘comments_list’ with a list of all comments for this issue (see GitHub API docs (3)). The comment data is augmented by a string in comment[‘user’][‘avatar_class’] which contains a css class that sets the avatar of the user as background image of the element.

    • issue[‘user’][‘avatar_class’] which works in the same way as in comments.

  • labels: a list of dictionaries containing label data, see GitHub API docs (4)

  • milestones: a list of dictionaries containing milestone data, see GitHub API docs (5)

  • assignees: a list of dictionaries contining information about assigness, see GitHub API docs (6)

  • javascript: a list of dictionaries with the names and contents of the javascript files.

  • stylesheets: a list with the contents of the stylesheets. Additionally it contains a stylesheet that defines classes of the form avatar_username that set the avatar of a user as background image of an element.

If you have created a new layout or improved a existing one, feel free to open a pull request, contributions are always welcome!

Dependencies

Requires Python 2.7, the Jinja2 template system and the requests library.

For most Linux distributions, these should be available via the package manager. On MacOS you can install the dependencies by:

# using homebrew
brew install python
# using pip
pip install -r requirements.txt

For Windows there is an installer for Python available from the Python Website, and the rest can be installed via pip:

pip install -r requirements.txt

Contributors

There are a few people that contributed to handkerchief and therefore deserve to credit:

  • lukasoppermann turned the initial HTML template from horrible to beauti- and useful

  • laurentj contributed several small layout fixes

  • DonnchaC added code for authenticating by token

  • philfreo contributed a requirements.txt

License

Handkerchief is licensed under the MIT license

The MIT License (MIT)

Copyright (c) 2013 Johannes Reinhardt <jreinhardt@ist-dein-freund.de>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Release history Release notifications | RSS feed

This version

0.2

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

handkerchief-0.2.tar.gz (748.7 kB view details)

Uploaded Source

Built Distribution

handkerchief-0.2-py2-none-any.whl (752.6 kB view details)

Uploaded Python 2

File details

Details for the file handkerchief-0.2.tar.gz.

File metadata

  • Download URL: handkerchief-0.2.tar.gz
  • Upload date:
  • Size: 748.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for handkerchief-0.2.tar.gz
Algorithm Hash digest
SHA256 6f20c38bacd20b784bbc67e6e79186974d65c4784e5d037dc1b7c18d615ad56e
MD5 1ba00d457448529bb7d8d4fa95427857
BLAKE2b-256 bea69e7b219eef223dea085ff6f1eb64737b58a7d2d213ec8f8b6321d4a54c4a

See more details on using hashes here.

File details

Details for the file handkerchief-0.2-py2-none-any.whl.

File metadata

File hashes

Hashes for handkerchief-0.2-py2-none-any.whl
Algorithm Hash digest
SHA256 b949cbe2347270c3bca1ef459a0aa4816c1ddd5fef79a316a364e46112100ab6
MD5 7f1b0729c3199dbb5a49a4b81cb4f45c
BLAKE2b-256 51140ca69ed7fb2d73ca9f662b4d593dec9c89f4b0ba335d01dba4eb1eaab8b6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page