Giter Club home page Giter Club logo

klaus's Introduction

travis-badge Join the chat at https://gitter.im/jonashaag/klaus

klaus: a simple, easy-to-set-up Git web viewer that Just Works™.

(If it doesn't Just Work for you, please file a bug.)

  • Super easy to set up -- no configuration required
  • Syntax highlighting
  • Markdown + RestructuredText rendering support
  • Pull + push support (Git Smart HTTP)
  • Code navigation using Exuberant ctags
Demo:http://klausdemo.lophus.org
Mailing list:http://groups.google.com/group/klaus-users
On PyPI:http://pypi.python.org/pypi/klaus/
Wiki:https://github.com/jonashaag/klaus/wiki
License:ISC (BSD)

Running with Docker

The easiest way to get started. We maintain a Docker image that has syntax highlighting, Markdown rendering, code navigation, etc. pre-configured:

docker run -v /path/to/your/repos:/repos \
           -p 7777:80 \
           -it jonashaag/klaus:latest \
           klaus --host 0.0.0.0 --port 80 /repos/repo1 /repos/repo2 ...

(Replace /path/to/your/repos with the folder that contains your Git repositories on the Docker host. You can also pass in multiple -v arguments if your repos are in multiple folders on the host.)

Go to http://localhost:7777 on the Docker host et voilà!

The command line above simply runs the klaus script -- for usage details, see the "Using the klaus script" section below.

Local setup

pip install klaus

(Optional dependencies: see Markup rendering in the wiki.)

Usage

See also: Klaus wiki

Using the klaus script

NOTE: This is intended for testing/low-traffic local installations only! The klaus script uses wsgiref internally which doesn't scale at all (in fact it's single-threaded and non-asynchronous).

To run klaus using the default options:

# With Docker:
docker run ... jonashaag/klaus:latest klaus [repo1 [repo2 ...]]
# Local setup:
klaus [repo1 [repo2 ...]]

For more options, see:

 # With Docker:
docker run ... jonashaag/klaus:latest klaus --help
# Local setup:
klaus --help

Using a real server

The klaus module contains a make_app function which returns a WSGI app.

An example WSGI helper script is provided with klaus (see klaus/contrib/wsgi.py), configuration being read from environment variables. Use it like this (uWSGI example):

uwsgi -w klaus.contrib.wsgi \
      --env KLAUS_SITE_NAME="Klaus Demo" \
      --env KLAUS_REPOS="/path/to/repo1 /path/to/repo2 ..." \
      ...

Gunicorn example:

gunicorn --env KLAUS_SITE_NAME="Klaus Demo" \
         --env KLAUS_REPOS="/path/to/repo1 /path/to/repo2 ..." \
         klaus.contrib.wsgi

The Docker image also has uwsgi preinstalled:

docker run ... jonashaag/klaus:latest uwsgi ...

See also deployment section in the wiki.

Contributing

Please do it!

I'm equally happy with bug reports/feature ideas and code contributions. If you have any questions/issues, I'm happy to help!

For starters, here are a few ideas what to work on. :-)

img1 img2 img3

klaus's People

Contributors

bittracker avatar chaosblog avatar cpressey avatar danajpl avatar eclectickmedia avatar ewdurbin avatar gitter-badger avatar insertjokehere avatar jelmer avatar jimmyppi avatar jonashaag avatar mechazawa avatar philipdexter avatar posativ avatar pre-commit-ci[bot] avatar rjw57 avatar rotsix avatar royneary avatar s-ol avatar sbraz avatar srinivas32 avatar wsldankers avatar yedpodtrzitko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

klaus's Issues

history of a file is broken

An example traceback. The tree object in klaus/views.py:92 is a Blob object, not a tree object (check with tree.type).

127.0.0.1 - - [31/Jul/2012 13:01:53] "GET /acrylamid/tree/master/.gitignore HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/Users/ich/dev/klaus/lib/python2.7/site-packages/Flask-0.9-py2.7.egg/flask/app.py", line 1701, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Users/ich/dev/klaus/klaus/utils.py", line 46, in __call__
    return self.app(environ, start_response)
  File "/Users/ich/dev/klaus/lib/python2.7/site-packages/Flask-0.9-py2.7.egg/flask/app.py", line 1689, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/Users/ich/dev/klaus/lib/python2.7/site-packages/Flask-0.9-py2.7.egg/flask/app.py", line 1687, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/ich/dev/klaus/lib/python2.7/site-packages/Flask-0.9-py2.7.egg/flask/app.py", line 1360, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/ich/dev/klaus/lib/python2.7/site-packages/Flask-0.9-py2.7.egg/flask/app.py", line 1358, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/ich/dev/klaus/lib/python2.7/site-packages/Flask-0.9-py2.7.egg/flask/app.py", line 1344, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/ich/dev/klaus/lib/python2.7/site-packages/Flask-0.9-py2.7.egg/flask/views.py", line 83, in view
    return self.dispatch_request(*args, **kwargs)
  File "/Users/ich/dev/klaus/klaus/views.py", line 46, in dispatch_request
    self.make_context(repo, commit_id, path)
  File "/Users/ich/dev/klaus/klaus/views.py", line 116, in make_context
    super(HistoryView, self).make_context(*args)
  File "/Users/ich/dev/klaus/klaus/views.py", line 79, in make_context
    self.context['tree'] = self.listdir()
  File "/Users/ich/dev/klaus/klaus/views.py", line 94, in listdir
    for entry in tree.iteritems():
AttributeError: 'Blob' object has no attribute 'iteritems'

Klaus cannot be run from a subdir

All the links generated by klaus are generated relative to /, which is definitely bad if someone will want to run klaus inside site's subdir.

quickstart doesn't

arnouten@bird:~/dev/klaus$ tools/quickstart.py 127.0.0.1 8080 ../gitwikicontent/
Traceback (most recent call last):
File "tools/quickstart.py", line 48, in
main()
File "tools/quickstart.py", line 41, in main
from klaus import app
ImportError: No module named klaus

Rewrite CSS with proper grid system

Currently the CSS is written with percentage sizes for containers and fonts (e.g. font-size: 60%, width: 72%, ...). This works well except for margin, padding, top, right, ... since they are always based on the width of the page -- even margin-top and top are calculated based on the width. Also, font-size does not change with the screen size.

Rewrite the CSS using pixels as unit for all sizes, based on a proper grid system. Maybe even some responsive one to make klaus work well with mobile/small-screen devices.

Running 'klaus' inside of a repository with no arguments should work

When running klaus, I need to specify the repository directory on the command line in order to actually see any repositories in the web interface -- if I simply run 'klaus' from inside the root of my git repository, the repository list is empty and I can't browse any commits, etc.

This problem is compounded by the fact that klaus prints a message on startup "fatal: Not a git repository (or any of the parent directories): .git" when run from outside a git repository, erroneously giving the impression that you need to run it from inside a repository in order for it to work.

Error 500 if the title is an str object containing non-ascii characters

Here is a script to trigger the problem:

# -*- encoding: utf-8 -*-
from wsgiref.simple_server import make_server
from klaus import make_app

application = make_app([], "Éléphant")
print "Serving on http://localhost:8000"
httpd = make_server('', 8000, application)
httpd.serve_forever()

This triggers an error 500:

$ curl http://localhost:8000 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error and was unable to complete your request.  Either the server is overloaded or there is an error in the application.</p>

It works fine if the title is a unicode object (eg. u"Éléphant" rather than "Éléphant"). The problem also occurs under mod_wsgi.

Tested with klaus 0.2. For some reason I don't seem to be able to run the code from the master branch.

History of deleted/moved files

When visiting a URL pointing to a file that no longer exists on that branch, it would be cute to show the history of the file with that name up to the point where it got (re)moved

Tests

We need some basic tests that at least test Python version backwards compatibility. Selenium tests should be a good start.

UnicodeDecodeError: 'utf8' codec can't decode byte 0xef in position 636: invalid continuation byte

Get a unicode error on: http://klausdemo.lophus.org/klaus/commit/73e1e9d9f58a70d4034301992492d3e4c6183028/

Traceback (most recent call last):
File "./nano/nano.py", line 179, in call
retval = callback(environ, **kwargs)
File "/home/jonas/klaus/klaus.py", line 33, in wrapper
*_callback(env, *_kwargs))
File "/home/jonas/klaus/klaus.py", line 42, in render_template
return self.jinja_env.get_template(template_name).render(**kwargs)
File "/home/jonas/.local/lib/python2.7/site-packages/jinja2/environment.py", line 891, in render
return self.environment.handle_exception(exc_info, True)
File "templates/view_commit.html", line 2, in top-level template code
{% extends 'base.html' %}
File "templates/base.html", line 1, in top-level template code
{% extends 'skeleton.html' %}
File "templates/skeleton.html", line 12, in top-level template code
{% block content %}{% endblock %}
File "templates/view_commit.html", line 23, in block "content"
{%- for file in repo.commit_diff(commit) %}
File "/home/jonas/klaus/repo.py", line 100, in commit_diff
return prepare_udiff(stringio.getvalue().decode('utf-8'),
File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xef in position 636: invalid continuation byte

Fail to load content of a submodule

I get this Traceback, when entering a submodule (i tried with the cream/cream repo):

Traceback (most recent call last):
  File "nano/nano.py", line 179, in __call__
    retval = callback(environ, **kwargs)
  File "/tmp/git/klaus/klaus.py", line 31, in wrapper
    **callback(env, **kwargs))
  File "/tmp/git/klaus/klaus.py", line 159, in __init__
    super(BaseRepoView, self).__init__(env)
  File "/tmp/git/klaus/klaus.py", line 122, in __init__
    self.view()
  File "/tmp/git/klaus/klaus.py", line 184, in view
    self['tree'] = self.listdir(self['path'])
  File "/tmp/git/klaus/klaus.py", line 199, in listdir
    for name, entry in self['repo'].listdir(self['commit'], path):
  File "/tmp/git/klaus/repo.py", line 89, in listdir
    tree = self.get_tree(commit, root)
  File "/tmp/git/klaus/repo.py", line 85, in get_tree
    tree = self[tree[directory][1]]
  File "/usr/lib/python2.7/site-packages/dulwich/repo.py", line 996, in __getitem__
    return self.object_store[self.refs[name]]
  File "/usr/lib/python2.7/site-packages/dulwich/repo.py", line 270, in __getitem__
    raise KeyError(name)
KeyError: '38bdce3108e1002cf4d99e44a8242f97ccd66e6c'

Should be able to glob directory for repos

If there is a decent amount of repositories inside single dir then it should be possible just to let the app know about that dir and make sure it globs it instead of specifying all the repos by hands

Logging causes reverse DNS lookups

The klaus logging includes the hostname of the machine making the request. I think this is undesirable both for security (can we trust reverse DNS?) and performance (a reverse DNS lookup for each request? really?).

The change at raboof@56cf106 imho is a rather terrible hack, but it does improve performance significantly.

(it is especially dramatic in my personal case - I seem to have some DNS misconfiguration that sometimes makes reverse DNS lookups take 5 or even 20 seconds :) )

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.