Package: handkerchief
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 nameI 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 pipThis is the easiest way and probably the right choice for most people. Make
sure you havepipinstalled and typepipinstallhandkerchiefinto your terminal to install handkerchief and all dependencies onto your
computer. This might require admin access.You can now invoke handkerchief from everywhere usinghandkerchiefIn a virtualenvIf a system wide installation with pip is too intrusive for you, and you need
handkerchief only in a certain environment, you can tryvirtualenv. Within the activated
virtualenv, just typepipinstallhandkerchiefYou can then invoke handkerchief while you are in the virtualenv by typinghandkerchiefAs standalone scriptYou 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 withpythonhandkerchief.py--remote-layoutsFrom repositoryYou 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.functionhandkerchief{# change this path to the location of handkerchief.pyhand=~/handkerchief/handkerchief.pyif[[$1!=""]];thenpython$hand--remote-layouts$1elserepo=$(gitremote-v|head-n1|awk'{print $2}'|sed-e's,.*:\(.*/\)\?,,'-e's/\.git$//')if[[$repo==*https://*]];thenpython$hand${repo#https://github.com/}elif[[$repo==*git@github.com*]];thenpython$hand${repo#git@github.com:}elseecho"Provide parameter"fifi}Specifying repositoriesThe simplest way to use handkerchief is to call it with the user or
organisation and repository namehandkerchiefjreinhardt/tissuesIf you are calling handkerchief from within a git repository, it tries to figure out a GitHub repo for itcd/path/to/repositoryhandkerchiefOr 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/htmlshandkerchiefCommandline parametersThere 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 seehandkerchief--help`.LayoutsHandkerchief 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-layoutsoption.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 filecss: a list of filenames of stylesheets to inlinejs: a list of filenames of javascript files to inlineThe template is processed byJinja2, and the
following variables are available:reponame: a string with the name of the repository in the form
username/reponamerepo: a dictionary containing information about the repository, seeGitHub API docs (1)issues: a list of dictionaries containing issue data, seeGitHub 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
(seeGitHub API docs (3)).
The comment data is augmented by a string incomment[‘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, seeGitHub API docs (4)milestones: a list of dictionaries containing milestone data, seeGitHub API docs (5)assignees: a list of dictionaries contining information about assigness, seeGitHub 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 formavatar_usernamethat
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!DependenciesRequiresPython 2.7, theJinja2 template systemand therequests library.For most Linux distributions, these should be available via the package
manager. On MacOS you can install the dependencies by:# using homebrewbrewinstallpython# using pippipinstall-rrequirements.txtFor Windows there is an installer for Python available from thePython Website, and the rest can be
installed via pip:pipinstall-rrequirements.txtContributorsThere are a few people that contributed to handkerchief and therefore deserve to credit:lukasoppermann turned the initial HTML template from horrible to beauti- and usefullaurentj contributed several small layout fixesDonnchaC added code for authenticating by tokenphilfreo contributed a requirements.txtLicenseHandkerchief is licensed under theMIT licenseThe 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.