Created
May 25, 2014 19:47
-
-
Save aodag/3aa9df2f10587370fd11 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul> | |
{% for commit in commits %} | |
<li> | |
{{ commit.id}} {{ commit.message }} | |
</li> | |
{% endfor %} | |
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
import pygit2 | |
import waitress | |
import jinja2 | |
from webob.dec import wsgify | |
templates = jinja2.Environment( | |
loader=jinja2.FileSystemLoader(os.path.dirname(__file__))) | |
class Application(object): | |
def __init__(self, repository_dir): | |
self.repository_dir = repository_dir | |
@wsgify | |
def __call__(self, request): | |
commits = self.get_commits() | |
tmpl = templates.get_template('index.html') | |
return tmpl.render(commits=commits) | |
def get_commits(self): | |
repo = pygit2.Repository(self.repository_dir) | |
last = repo[repo.head.target] | |
for commit in repo.walk(last.id, pygit2.GIT_SORT_TIME): | |
yield commit | |
def main(): | |
app = Application(".") | |
waitress.serve(app) | |
if __name__ == '__main__': | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Jinja2==2.7.2 | |
MarkupSafe==0.23 | |
WebOb==1.4 | |
pygit2==0.20.3 | |
waitress==0.8.9 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment