1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-17 07:41:26 +00:00

Allow viewing encrypted repo directory/file.

This commit is contained in:
killing
2012-06-06 19:32:27 +08:00
parent 01f65e4f22
commit a6dcdda71c
2 changed files with 33 additions and 40 deletions

View File

@@ -8,8 +8,7 @@
</h2> </h2>
<div class="side fright"> <div class="side fright">
{% if not repo.props.encrypted %} {% if is_owner or repo_ap == 'public' or share_to_me %}
{% if is_owner or repo_ap == 'public' or share_to_me %}
<div class="latest-commit"> <div class="latest-commit">
<h3>修改信息</h3> <h3>修改信息</h3>
<p>{{ current_commit.props.desc|translate_commit_desc }}</p> <p>{{ current_commit.props.desc|translate_commit_desc }}</p>
@@ -24,7 +23,6 @@
<span class="time">{{ current_commit.props.ctime|translate_commit_time }}</span> <span class="time">{{ current_commit.props.ctime|translate_commit_time }}</span>
</p> </p>
</div> </div>
{% endif %}
{% endif %} {% endif %}
<h3>操作</h3> <h3>操作</h3>
<ul class="with-bg"> <ul class="with-bg">
@@ -33,20 +31,17 @@
</div> </div>
<div class="main fleft"> <div class="main fleft">
{% if repo.props.encrypted %} {% if not is_owner and repo_ap == 'own' and not share_to_me %}
<p class="access-notice">该同步目录已加密,不能在线查看。</p>
{% else %}
{% if not is_owner and repo_ap == 'own' and not share_to_me %}
<p class="access-notice">该同步目录web匿名访问未开启不能在线查看。</p> <p class="access-notice">该同步目录web匿名访问未开启不能在线查看。</p>
{% else %} {% else %}
<p class="path">当前路径: <p class="path">当前路径:
{% for name, link in zipped %} {% for name, link in zipped %}
{% if not forloop.last %} {% if not forloop.last %}
<a href="{{ SITE_ROOT }}repo/history/dir/{{ repo.id }}/?commit_id={{ current_commit.id}}&p={{ link|urlencode }}">{{ name }}</a> / <a href="{{ SITE_ROOT }}repo/history/dir/{{ repo.id }}/?commit_id={{ current_commit.id}}&p={{ link|urlencode }}">{{ name }}</a> /
{% else %} {% else %}
{{ name }} {{ name }}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</p> </p>
<table> <table>
<tr> <tr>
@@ -56,16 +51,16 @@
<th width="15%">操作</th> <th width="15%">操作</th>
</tr> </tr>
{% for dirent in dir_list %} {% for dirent in dir_list %}
<tr> <tr>
<td><img src="{{ MEDIA_URL }}img/folder-icon-24.png" /></td> <td><img src="{{ MEDIA_URL }}img/folder-icon-24.png" /></td>
<td><a href="{{ SITE_ROOT }}repo/history/dir/{{ repo.id }}/?commit_id={{ current_commit.id }}&p={{ path|urlencode }}{{ dirent.obj_name|urlencode }}">{{ dirent.obj_name }}</a></td> <td><a href="{{ SITE_ROOT }}repo/history/dir/{{ repo.id }}/?commit_id={{ current_commit.id }}&p={{ path|urlencode }}{{ dirent.obj_name|urlencode }}">{{ dirent.obj_name }}</a></td>
<td></td> <td></td>
<td></td> <td></td>
</tr> </tr>
{% endfor %} {% endfor %}
{% for dirent in file_list %} {% for dirent in file_list %}
<tr> <tr>
<td><img src="{{ MEDIA_URL }}img/{{ dirent.obj_name|file_icon_filter }}" /></td> <td><img src="{{ MEDIA_URL }}img/{{ dirent.obj_name|file_icon_filter }}" /></td>
<td>{{ dirent.props.obj_name }}</td> <td>{{ dirent.props.obj_name }}</td>
@@ -75,9 +70,8 @@
<a class="op" href="{{ SITE_ROOT }}repo/{{ repo.props.id }}/{{ dirent.props.obj_id }}/?file_name={{ dirent.props.obj_name }}&op=download">下载</a> <a class="op" href="{{ SITE_ROOT }}repo/{{ repo.props.id }}/{{ dirent.props.obj_id }}/?file_name={{ dirent.props.obj_name }}&op=download">下载</a>
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
{% endif %}
{% endif %} {% endif %}
</div> </div>
{% endblock %} {% endblock %}

View File

@@ -344,29 +344,28 @@ def repo_history_dir(request, repo_id):
zipped = [] zipped = []
dir_list = [] dir_list = []
file_list = [] file_list = []
if not repo.props.encrypted: path = request.GET.get('p', '/')
path = request.GET.get('p', '/') if path[-1] != '/':
if path[-1] != '/': path = path + '/'
path = path + '/' try:
try: dirs = seafserv_rpc.list_dir_by_path(current_commit.id,
dirs = seafserv_rpc.list_dir_by_path(current_commit.id, path.encode('utf-8'))
path.encode('utf-8')) except SearpcError, e:
except SearpcError, e: return go_error(request, e.msg)
return go_error(request, e.msg) for dirent in dirs:
for dirent in dirs: if stat.S_ISDIR(dirent.props.mode):
if stat.S_ISDIR(dirent.props.mode): dir_list.append(dirent)
dir_list.append(dirent) else:
else: file_list.append(dirent)
file_list.append(dirent) try:
try: dirent.file_size = seafserv_rpc.get_file_size(dirent.obj_id)
dirent.file_size = seafserv_rpc.get_file_size(dirent.obj_id) except:
except: dirent.file_size = 0
dirent.file_size = 0 dir_list.sort(lambda x, y : cmp(x.obj_name.lower(), y.obj_name.lower()))
dir_list.sort(lambda x, y : cmp(x.obj_name.lower(), y.obj_name.lower())) file_list.sort(lambda x, y : cmp(x.obj_name.lower(), y.obj_name.lower()))
file_list.sort(lambda x, y : cmp(x.obj_name.lower(), y.obj_name.lower()))
# generate path and link # generate path and link
zipped = gen_path_link(path, repo.name) zipped = gen_path_link(path, repo.name)
# 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,