mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-27 11:10:10 +00:00
Show repo path on repo page
This commit is contained in:
parent
db2419c598
commit
17f79f729a
@ -44,6 +44,11 @@
|
|||||||
{% if not is_owner and repo_ap == 'own' and not share_to_me %}
|
{% if not is_owner and repo_ap == 'own' and not share_to_me %}
|
||||||
<p>该同步目录web匿名访问未开启,不能在线查看。</p>
|
<p>该同步目录web匿名访问未开启,不能在线查看。</p>
|
||||||
{% else %}
|
{% 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>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th width="70%">名字</th>
|
<th width="70%">名字</th>
|
||||||
@ -53,7 +58,7 @@
|
|||||||
{% for dirent in dirs %}
|
{% for dirent in dirs %}
|
||||||
<tr>
|
<tr>
|
||||||
{% if dirent.is_dir %}
|
{% 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>
|
<td></td>
|
||||||
{% else %}
|
{% else %}
|
||||||
<td>{{ dirent.props.obj_name }}</td>
|
<td>{{ dirent.props.obj_name }}</td>
|
||||||
|
44
views.py
44
views.py
@ -125,24 +125,36 @@ def repo(request, repo_id):
|
|||||||
|
|
||||||
latest_commit = {}
|
latest_commit = {}
|
||||||
dirs = []
|
dirs = []
|
||||||
|
path = ''
|
||||||
|
zipped = []
|
||||||
if not repo.props.encrypted:
|
if not repo.props.encrypted:
|
||||||
latest_commit = get_commits(repo_id, 0, 1)[0]
|
latest_commit = get_commits(repo_id, 0, 1)[0]
|
||||||
if not request.GET.get('root_id'):
|
path = request.GET.get('p', '')
|
||||||
# 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')
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
dirs = seafserv_rpc.list_dir(root_id)
|
dirs = seafserv_rpc.list_dir_by_path(latest_commit.id, path)
|
||||||
for dirent in dirs:
|
except SearpcError, e:
|
||||||
if stat.S_ISDIR(dirent.props.mode):
|
return go_error(request, e.msg)
|
||||||
dirent.is_dir = True
|
for dirent in dirs:
|
||||||
else:
|
if stat.S_ISDIR(dirent.props.mode):
|
||||||
dirent.is_dir = False
|
dirent.is_dir = True
|
||||||
except:
|
else:
|
||||||
pass
|
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
|
# 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,
|
# 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,
|
"repo_size": repo_size,
|
||||||
"dirs": dirs,
|
"dirs": dirs,
|
||||||
"share_to_me": share_to_me,
|
"share_to_me": share_to_me,
|
||||||
|
"path" : path,
|
||||||
|
"zipped" : zipped or None,
|
||||||
}, context_instance=RequestContext(request))
|
}, context_instance=RequestContext(request))
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user