mirror of
https://github.com/correl/codereview.git
synced 2024-12-18 19:21:31 +00:00
Added some browsing abilities
This commit is contained in:
parent
eafa3947b9
commit
753b942d66
5 changed files with 39 additions and 7 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import os
|
||||||
from django.template import Library
|
from django.template import Library
|
||||||
from django.template.defaultfilters import stringfilter
|
from django.template.defaultfilters import stringfilter
|
||||||
|
|
||||||
|
@ -8,3 +9,13 @@ register = Library()
|
||||||
def oneline(value):
|
def oneline(value):
|
||||||
line = value.split('\n')[0].strip()
|
line = value.split('\n')[0].strip()
|
||||||
return line
|
return line
|
||||||
|
|
||||||
|
@register.filter
|
||||||
|
@stringfilter
|
||||||
|
def dirname(value):
|
||||||
|
return os.path.dirname(value)
|
||||||
|
|
||||||
|
@register.filter
|
||||||
|
@stringfilter
|
||||||
|
def basename(value):
|
||||||
|
return os.path.basename(value)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from django.conf.urls.defaults import *
|
from django.conf.urls.defaults import *
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
(r'^(?P<repository>.*?)/log/(?P<path>(.*?/)+)?$', 'codereview.browser.views.log'),
|
(r'^(?P<repository>.*?)/log/$', 'codereview.browser.views.log'),
|
||||||
|
(r'^(?P<repository>.*?)/log/(?P<path>.*?/?)$', 'codereview.browser.views.log'),
|
||||||
(r'^(?P<repository>.*?)/view/(?P<ref>.*?)/$', 'codereview.browser.views.view'),
|
(r'^(?P<repository>.*?)/view/(?P<ref>.*?)/$', 'codereview.browser.views.view'),
|
||||||
)
|
)
|
||||||
|
|
|
@ -14,9 +14,9 @@ def log(request,repository, path=None):
|
||||||
offset = int(request.GET['o']) if 'o' in request.GET else 0
|
offset = int(request.GET['o']) if 'o' in request.GET else 0
|
||||||
limit = 20
|
limit = 20
|
||||||
|
|
||||||
path = os.path.dirname(path) if path else ''
|
path = path if path else ''
|
||||||
log = repo.log(ref, path=path, max=limit, offset=offset)
|
log = repo.log(ref, path=path, max=limit, offset=offset)
|
||||||
navigation = dict(zip(('dirs', 'files'), repo.browse()))
|
navigation = dict(zip(('dirs', 'files'), repo.browse(ref, os.path.dirname(path))))
|
||||||
|
|
||||||
newer = offset - limit if offset > limit else 0
|
newer = offset - limit if offset > limit else 0
|
||||||
# Inspect the last commit. If it has no parents, we can't go any further
|
# Inspect the last commit. If it has no parents, we can't go any further
|
||||||
|
|
|
@ -6,14 +6,21 @@ a {
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
div.navigation {
|
div.navigation {
|
||||||
width: 200px;
|
width: 300px;
|
||||||
float: left;
|
float: left;
|
||||||
background-color: #ddd;
|
background-color: #ddd;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
div.content {
|
div.content {
|
||||||
margin-left: 200px;
|
margin-left: 300px;
|
||||||
background-color: #eee;
|
background-color: #eee;
|
||||||
}
|
}
|
||||||
|
ul.tree li.dir {
|
||||||
|
list-style-type: circle;
|
||||||
|
}
|
||||||
|
ul.tree li.file {
|
||||||
|
list-style-type: square;
|
||||||
|
}
|
||||||
span.marker {
|
span.marker {
|
||||||
display: block;
|
display: block;
|
||||||
float: left;
|
float: left;
|
||||||
|
|
|
@ -1,9 +1,22 @@
|
||||||
|
{% load vcs %}
|
||||||
<h2><a href="{% url codereview.browser.views.log repository=repository.name %}">{{ repository.name }}</a></h2>
|
<h2><a href="{% url codereview.browser.views.log repository=repository.name %}">{{ repository.name }}</a></h2>
|
||||||
|
{% if path|dirname %}
|
||||||
|
<strong>{{ path|dirname }}/</strong><br />
|
||||||
|
<a href="{% url codereview.browser.views.log repository=repository.name path=path|dirname %}">Up one</a>
|
||||||
|
{% endif %}
|
||||||
<ul class="tree">
|
<ul class="tree">
|
||||||
{% for dir in navigation.dirs %}
|
{% for dir in navigation.dirs %}
|
||||||
<li class="dir">{{ dir }}</li>
|
<li class="dir">
|
||||||
|
<a href="{% url codereview.browser.views.log repository=repository.name path=dir %}/">{{ dir|basename }}</a>
|
||||||
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% for file in navigation.files %}
|
{% for file in navigation.files %}
|
||||||
<li class="file">{{ file }}</li>
|
<li class="file">
|
||||||
|
{% if file == path %}
|
||||||
|
<strong>{{ file|basename }}</strong>
|
||||||
|
{% else %}
|
||||||
|
<a href="{% url codereview.browser.views.log repository=repository.name path=file %}">{{ file|basename }}</a>
|
||||||
|
{% endif %}
|
||||||
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
Loading…
Reference in a new issue