1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-07 18:03:48 +00:00

[img_view] enable view prev/next & improved ui

This commit is contained in:
llj
2013-01-31 13:17:28 +08:00
parent c9fa7d3ff7
commit 37f284d11a
5 changed files with 79 additions and 9 deletions

View File

@@ -1353,6 +1353,30 @@ def repo_view_file(request, repo_id):
err = ''
file_content = ''
swf_exists = False
img_prev = None
img_next = None
if filetype == 'Image' and not view_history:
parent_dir = os.path.dirname(path)
try:
dirs = seafserv_threaded_rpc.list_dir_by_path(current_commit.id, parent_dir.encode('utf-8'))
except SearpcError, e:
raise Http404
img_list = []
for dirent in dirs:
if not stat.S_ISDIR(dirent.props.mode):
fltype, flext = valid_previewed_file(dirent.obj_name)
if fltype == 'Image':
img_list.append(dirent.obj_name)
if len(img_list) > 1:
img_list.sort(lambda x, y : cmp(x.lower(), y.lower()))
cur_img_index = img_list.index(u_filename)
if cur_img_index != 0:
img_prev = os.path.join(parent_dir, img_list[cur_img_index - 1])
if cur_img_index != len(img_list) - 1:
img_next = os.path.join(parent_dir, img_list[cur_img_index + 1])
if filetype == 'Text' or filetype == 'Markdown' or filetype == 'Sf':
err, file_content, encoding = repo_file_get(raw_path)
elif filetype == 'Document':
@@ -1479,6 +1503,8 @@ def repo_view_file(request, repo_id):
'repo_group_str': repogrp_str,
'is_starred': is_starred,
'user_perm': user_perm,
'img_prev': img_prev,
'img_next': img_next,
}, context_instance=RequestContext(request))
def file_comment(request):