1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-27 03:01:26 +00:00

Show repo path on repo page

This commit is contained in:
xiez 2012-05-17 22:43:47 +08:00
parent db2419c598
commit 17f79f729a
2 changed files with 35 additions and 16 deletions

View File

@ -44,6 +44,11 @@
{% if not is_owner and repo_ap == 'own' and not share_to_me %}
<p>该同步目录web匿名访问未开启不能在线查看。</p>
{% else %}
<div>
{% for name, link in zipped %}
<a href="{{ SITE_ROOT }}repo/{{ repo.id }}/?root_id={{ dirent.obj_id }}&p={{ link }}">{{ name }}</a> /
{% endfor %}
</div>
<table>
<tr>
<th width="70%">名字</th>
@ -53,7 +58,7 @@
{% for dirent in dirs %}
<tr>
{% if dirent.is_dir %}
<td><a href="{{ SITE_ROOT }}repo/{{ repo.props.id }}/?root_id={{ dirent.props.obj_id }}">{{ dirent.props.obj_name }}</a></td>
<td><a href="{{ SITE_ROOT }}repo/{{ repo.id }}/?root_id={{ dirent.obj_id }}&p={{ path }}/{{ dirent.obj_name }}">{{ dirent.obj_name }}</a></td>
<td></td>
{% else %}
<td>{{ dirent.props.obj_name }}</td>

View File

@ -125,24 +125,36 @@ def repo(request, repo_id):
latest_commit = {}
dirs = []
path = ''
zipped = []
if not repo.props.encrypted:
latest_commit = get_commits(repo_id, 0, 1)[0]
if not request.GET.get('root_id'):
# use HEAD commit's root id
commit = seafserv_rpc.get_commit(repo.props.head_cmmt_id)
root_id = commit.props.root_id
else:
root_id = request.GET.get('root_id')
path = request.GET.get('p', '')
try:
dirs = seafserv_rpc.list_dir(root_id)
for dirent in dirs:
if stat.S_ISDIR(dirent.props.mode):
dirent.is_dir = True
else:
dirent.is_dir = False
except:
pass
dirs = seafserv_rpc.list_dir_by_path(latest_commit.id, path)
except SearpcError, e:
return go_error(request, e.msg)
for dirent in dirs:
if stat.S_ISDIR(dirent.props.mode):
dirent.is_dir = True
else:
dirent.is_dir = False
# generate path and link
paths = []
links = []
if path and path != '/':
paths = path[1:].split('/')
i=1
for name in paths:
link = '/' + '/'.join(paths[:i])
i = i + 1
links.append(link)
paths.insert(0, repo.name)
links.insert(0, '/')
zipped = zip(paths, links)
# used to determin whether show repo content in repo.html
# if a repo is shared to me, or repo shared to the group I joined,
@ -160,6 +172,8 @@ def repo(request, repo_id):
"repo_size": repo_size,
"dirs": dirs,
"share_to_me": share_to_me,
"path" : path,
"zipped" : zipped or None,
}, context_instance=RequestContext(request))