Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
claen up url structure; add functionality to display blob of file
- Loading branch information
Showing
6 changed files
with
71 additions
and
26 deletions.
There are no files selected for viewing
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,30 @@ | |||
{% extends "base.html" %} | |||
|
|||
{% load stylize %} | |||
{% load repositories %} | |||
|
|||
{% block extra_head %} | |||
<script src="/static/js/commit.js" type="text/javascript" charset="utf-8"></script> | |||
{% endblock %} | |||
|
|||
{% block title %} | |||
{{ repo.path|name }} : {{ commit|first_eight }} | |||
{% endblock %} | |||
|
|||
{% block main_content %} | |||
<p id="commit" style="display: none;">{{ commit }}</p> | |||
{% if diffs %} | |||
{% for d in diffs %} | |||
<p> | |||
<span id="f{{ forloop.counter }}">{{ d.a_path }}</span> | |||
| |||
<a href="#" onclick="$('#d{{ forloop.counter }}').toggle(); return false;">diff</a> | | |||
<a href="#" id="{{ forloop.counter }}" class="blob-link">blob</a> | |||
</p> | |||
<div id="d{{ forloop.counter }}" style="display: none;">{% stylize 'diff' %}{{ d.diff|safe }}{% endstylize %}</div> | |||
<div id="b{{ forloop.counter }}" style="display: none;"></div> | |||
{% endfor %} | |||
{% else %} | |||
<p>No diff information.</p> | |||
{% endif %} | |||
{% endblock %} |
This file was deleted.
Oops, something went wrong.
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
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
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
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,13 +1,24 @@ | |||
from pygments import highlight | |||
from pygments.lexers import guess_lexer_for_filename | |||
from pygments.formatters import HtmlFormatter | |||
|
|||
from django.http import HttpResponse | |||
from django.shortcuts import render_to_response, get_object_or_404, get_list_or_404 | from django.shortcuts import render_to_response, get_object_or_404, get_list_or_404 | ||
from django.template import RequestContext | from django.template import RequestContext | ||
|
|
||
from django_git.utils import get_repos, get_repo, get_diff | from django_git.utils import * | ||
|
|
||
def index(request, template_name='django_git/index.html'): | def index(request, template_name='django_git/index.html'): | ||
return render_to_response(template_name, {'repos': get_repos()}, context_instance=RequestContext(request)) | return render_to_response(template_name, {'repos': get_repos()}, context_instance=RequestContext(request)) | ||
|
|
||
def repo(request, repo, template_name='django_git/repo.html'): | def repo(request, repo, template_name='django_git/repo.html'): | ||
return render_to_response(template_name, {'repo': get_repo(repo)}, context_instance=RequestContext(request)) | return render_to_response(template_name, {'repo': get_repo(repo)}, context_instance=RequestContext(request)) | ||
|
|
||
def diff(request, repo, commit, template_name='django_git/diff.html'): | def commit(request, repo, commit, template_name='django_git/commit.html'): | ||
return render_to_response(template_name, {'diffs': get_diff(repo, commit), 'repo': get_repo(repo), 'commit': commit }, context_instance=RequestContext(request)) | return render_to_response(template_name, {'diffs': get_commit(repo, commit).diffs, 'repo': get_repo(repo), 'commit': commit }, context_instance=RequestContext(request)) | ||
|
|||
def blob(request, repo, commit): | |||
file = request.GET.get('file', '') | |||
blob = get_blob(repo, commit, file) | |||
lexer = guess_lexer_for_filename(blob.basename, blob.data) | |||
return HttpResponse(highlight(blob.data, lexer, HtmlFormatter(cssclass="pygment_highlight"))) |