From 818434c65b689f6da0d9856c79a6a9e824f8e75f Mon Sep 17 00:00:00 2001 From: llj Date: Mon, 10 Aug 2015 13:26:29 +0800 Subject: [PATCH] [repo] removed image 'thumbnail' & 'preview', bugfix for 'path link' --- seahub/templates/repo.html | 105 ------------------- seahub/templates/repo_shared_link.html | 1 + seahub/templates/snippets/repo_dir_data.html | 2 +- seahub/templates/snippets/repo_dirents.html | 12 +-- seahub/views/ajax.py | 18 ---- 5 files changed, 5 insertions(+), 133 deletions(-) diff --git a/seahub/templates/repo.html b/seahub/templates/repo.html index 2e9c23b7b3..365f363860 100644 --- a/seahub/templates/repo.html +++ b/seahub/templates/repo.html @@ -1901,40 +1901,6 @@ $('.file-share, .dir-share', context).click(function() { return false; }); -{% if not repo.encrypted and ENABLE_THUMBNAIL %} -// get thumbnails for image files -$(function() { - var img_icons = $('.not-thumbnail'); - if (img_icons.length == 0) { - return; - } - var get_thumbnail = function(i) { - var img_icon = $(img_icons[i]), - file_name = img_icon.closest('.file-item').attr('data-name'); - $.ajax({ - url: '{% url 'thumbnail_create' repo.id %}?path=' + e(parent_dir + file_name), - cache: false, - dataType: 'json', - success: function(data) { - if (data) { - img_icon.attr("src", data.thumbnail_src).load(function() { - $(this).removeClass("not-thumbnail").addClass("thumbnail"); - }); - } - }, - complete: function() { - // cur_path may be changed. e.g., the user enter another directory - if (i < img_icons.length - 1 && parent_dir == cur_path) { - get_thumbnail(++i); - } - } - }); - }; - var parent_dir = cur_path; - get_thumbnail(0); -}); -{% endif %} - } //function 'opOnDirent' ends here $('#add-new-file-form, #add-new-dir-form, #rename-form, #mv-form').submit(function() { @@ -2391,77 +2357,6 @@ function updateCmt() { }); {% endif %} -{% if not repo.encrypted and ENABLE_THUMBNAIL %} -var timer, ajaxRequest = {}, - default_size = {{PREVIEW_DEFAULT_SIZE}}, - preview_wrap = $('
') - .appendTo("body") - .css({'width':default_size + 'px', 'height':default_size + 'px'}) - .hide(), - image_preview = $("#image-preview"), - caret = image_preview.next(); - -$("#repo-file-list").on({ - mouseenter: function() { - var thumbnail = $('.thumbnail', $(this)), - file_item = thumbnail.closest('.file-item'); - - timer = setTimeout(function () { - ajaxRequest = $.ajax({ - url: '{% url 'thumbnail_create' repo.id %}?path=' + e(cur_path+file_item.attr('data-name')) + '&size=' + default_size, - cache: false, - dataType: 'json', - success: function(data) { - if (data) { - image_preview.attr("src", data.thumbnail_src); - - var file_item_offset = file_item.offset(), - thumbnail_offset = thumbnail.offset(), - - wrap_width = preview_wrap.outerWidth(), - wrap_padding = parseInt(preview_wrap.css('padding-top')), - - caret_width = parseInt(caret.css('border-top-width')), - caret_pos_x = (default_size)/2 + wrap_padding - caret_width, - caret_pos_y = default_size + 2 * wrap_padding, - - wrap_left = file_item_offset.left - wrap_width - caret_width; - - if (wrap_left >= 0) { - caret.removeClass('bottom-outer-caret') - .addClass('right-outer-caret') - .css({'top':caret_pos_x + 'px', 'left':caret_pos_y + 'px'}); - - preview_wrap.css({ - 'top' : (thumbnail_offset.top + (thumbnail.height() - wrap_width)/2) + 'px', - 'left' : wrap_left + 'px' - }).fadeIn(); - } else { - caret.removeClass("right-outer-caret") - .addClass("bottom-outer-caret") - .css({'top':caret_pos_y + 'px', 'left':caret_pos_x + 'px'}); - - preview_wrap.css({ - 'top' : (file_item_offset.top - wrap_width) - caret_width + 'px', - 'left' : (thumbnail_offset.left + (thumbnail.width() - wrap_width)/2) + 'px' - }).fadeIn(); - } - } - } - }); - }, 200); - }, - mouseleave: function() { - if (ajaxRequest.hasOwnProperty('abort')) { - ajaxRequest.abort(); - } - clearTimeout(timer); - preview_wrap.hide(); - image_preview.attr('src', ''); // for ff. In ff, when hover, the last preview image would be shown first, then the right one. - } -}, ".dirent-icon:has('.thumbnail')"); -{% endif %} - {% include "snippets/shared_link_js.html" %} {% include "snippets/bottom_bar.html" %} {# moved to the right side. Tue Nov 11 15:47:08 CST 2014 #} diff --git a/seahub/templates/repo_shared_link.html b/seahub/templates/repo_shared_link.html index 6b393cad41..231b53296d 100644 --- a/seahub/templates/repo_shared_link.html +++ b/seahub/templates/repo_shared_link.html @@ -107,6 +107,7 @@ $('#shared-links .rm-link').click(function() { } $.ajax({ url: ajax_url + '?t=' + e(link_token), + cache: false, dataType: 'json', success: function(data) { op.parents('tr').remove(); diff --git a/seahub/templates/snippets/repo_dir_data.html b/seahub/templates/snippets/repo_dir_data.html index aa0a1b89f4..c1cd6fa3f4 100644 --- a/seahub/templates/snippets/repo_dir_data.html +++ b/seahub/templates/snippets/repo_dir_data.html @@ -3,7 +3,7 @@

{% for name, link in zipped %} {% if forloop.first or not forloop.last %} - {{ name }} / + {{ name }} / {% else %} {{ name }} / {% endif %} diff --git a/seahub/templates/snippets/repo_dirents.html b/seahub/templates/snippets/repo_dirents.html index 4cc1b9b830..96b488f91c 100644 --- a/seahub/templates/snippets/repo_dirents.html +++ b/seahub/templates/snippets/repo_dirents.html @@ -55,15 +55,9 @@ {% endif %} - {% if dirent.allow_generate_thumbnail %} - {% if dirent.thumbnail_src %} - {% trans - {% else %} - {% trans - {% endif %} - {% else %} - {% trans - {% endif %} + + {% trans + {% if repo.encrypted and repo.enc_version == 2 and not server_crypto %} {{ dirent.obj_name }} diff --git a/seahub/views/ajax.py b/seahub/views/ajax.py index 63602b0d76..539f40d1f2 100644 --- a/seahub/views/ajax.py +++ b/seahub/views/ajax.py @@ -297,14 +297,6 @@ def list_dir(request, repo_id): uploadlink = get_uploadlink(repo.id, username, path) dir_shared_upload_link = get_dir_shared_upload_link(uploadlink) - for f in file_list: - file_path = posixpath.join(path, f.obj_name) - if allow_generate_thumbnail(request, repo_id, file_path): - f.allow_generate_thumbnail = True - if os.path.exists(os.path.join(THUMBNAIL_ROOT, str(THUMBNAIL_DEFAULT_SIZE), f.obj_id)): - src = get_thumbnail_src(repo.id, THUMBNAIL_DEFAULT_SIZE, file_path) - f.encoded_thumbnail_src = urlquote(src) - ctx = { 'repo': repo, 'zipped': zipped, @@ -324,7 +316,6 @@ def list_dir(request, repo_id): 'enable_upload_folder': settings.ENABLE_UPLOAD_FOLDER, 'current_commit': head_commit, 'info_commit': info_commit, - 'ENABLE_THUMBNAIL': ENABLE_THUMBNAIL, } html = render_to_string('snippets/repo_dir_data.html', ctx, context_instance=RequestContext(request)) @@ -388,14 +379,6 @@ def list_dir_more(request, repo_id): if dirent_more: more_start = offset + 100 - for f in file_list: - file_path = posixpath.join(path, f.obj_name) - if allow_generate_thumbnail(request, repo_id, file_path): - f.allow_generate_thumbnail = True - if os.path.exists(os.path.join(THUMBNAIL_ROOT, str(THUMBNAIL_DEFAULT_SIZE), f.obj_id)): - src = get_thumbnail_src(repo.id, THUMBNAIL_DEFAULT_SIZE, file_path) - f.encoded_thumbnail_src = urlquote(src) - ctx = { 'repo': repo, 'user_perm': user_perm, @@ -405,7 +388,6 @@ def list_dir_more(request, repo_id): 'file_list': file_list, 'ENABLE_SUB_LIBRARY': ENABLE_SUB_LIBRARY, 'sub_lib_enabled': sub_lib_enabled, - 'ENABLE_THUMBNAIL': ENABLE_THUMBNAIL, } html = render_to_string('snippets/repo_dirents.html', ctx, context_instance=RequestContext(request))