mirror of
https://github.com/haiwen/seahub.git
synced 2025-04-28 03:10:45 +00:00
remove xmind (#7688)
Co-authored-by: 孙永强 <11704063+s-yongqiang@user.noreply.gitee.com>
This commit is contained in:
parent
d58584e0d7
commit
efe9ecce29
@ -11,7 +11,6 @@ const {
|
||||
thumbnailSizeForOriginal,
|
||||
previousImage, nextImage, rawPath,
|
||||
lastModificationTime,
|
||||
xmindImageSrc // for xmind file
|
||||
} = window.app.pageOptions;
|
||||
|
||||
let previousImageUrl;
|
||||
@ -62,9 +61,6 @@ class FileContent extends React.Component {
|
||||
thumbnailURL = `${siteRoot}thumbnail/${repoID}/${thumbnailSizeForOriginal}${Utils.encodePath(filePath)}?mtime=${lastModificationTime}`;
|
||||
}
|
||||
|
||||
// for xmind file
|
||||
const xmindSrc = xmindImageSrc ? `${siteRoot}${xmindImageSrc}` : '';
|
||||
|
||||
const { scale, angle } = this.props;
|
||||
let style = {};
|
||||
if (scale && angle != undefined) {
|
||||
@ -84,7 +80,7 @@ class FileContent extends React.Component {
|
||||
{nextImage && (
|
||||
<a href={nextImageUrl} id="img-next" title={gettext('you can also press →')}><span className="sf3-font sf3-font-down rotate-270 d-inline-block"></span></a>
|
||||
)}
|
||||
<img src={xmindSrc || thumbnailURL || rawPath} alt={fileName} id="image-view" onError={this.handleLoadFailure} style={ style } />
|
||||
<img src={thumbnailURL || rawPath} alt={fileName} id="image-view" onError={this.handleLoadFailure} style={ style } />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -59,9 +59,6 @@ class InnerFileView extends React.Component {
|
||||
case 'Image':
|
||||
content = <Image tip={<FileViewTip />} scale={imageScale} angle={imageAngle} />;
|
||||
break;
|
||||
case 'XMind':
|
||||
content = <Image tip={<FileViewTip />} />;
|
||||
break;
|
||||
case 'SVG':
|
||||
content = <SVG />;
|
||||
break;
|
||||
|
@ -20,10 +20,10 @@ from seahub.api2.views import get_dir_file_recursively
|
||||
from seahub.thumbnail.utils import get_thumbnail_src
|
||||
from seahub.views import check_folder_permission
|
||||
from seahub.utils import check_filename_with_rename, is_valid_dirent_name, \
|
||||
normalize_dir_path, is_pro_version, FILEEXT_TYPE_MAP, get_file_type_and_ext
|
||||
normalize_dir_path, is_pro_version, FILEEXT_TYPE_MAP
|
||||
from seahub.utils.timeutils import timestamp_to_isoformat_timestr
|
||||
from seahub.utils.file_tags import get_files_tags_in_dir
|
||||
from seahub.utils.file_types import IMAGE, VIDEO, XMIND, SEADOC, PDF
|
||||
from seahub.utils.file_types import IMAGE, VIDEO, PDF
|
||||
from seahub.base.models import UserStarredFiles
|
||||
from seahub.base.templatetags.seahub_tags import email2nickname, \
|
||||
email2contact_email
|
||||
@ -162,7 +162,7 @@ def get_dir_file_info_list(username, request_type, repo_obj, parent_dir,
|
||||
fileExt = os.path.splitext(file_name)[1][1:].lower()
|
||||
file_type = FILEEXT_TYPE_MAP.get(fileExt)
|
||||
|
||||
if file_type in (IMAGE, XMIND, PDF) or \
|
||||
if file_type in (IMAGE, PDF) or \
|
||||
(file_type == VIDEO and ENABLE_VIDEO_THUMBNAIL):
|
||||
|
||||
# if thumbnail has already been created, return its src.
|
||||
|
@ -40,7 +40,7 @@ from seahub.utils import gen_shared_link, is_org_context, normalize_file_path, \
|
||||
check_filename_with_rename, gen_file_upload_url, \
|
||||
get_password_strength_level, is_valid_password, is_valid_email, string2list, gen_file_get_url_by_sharelink
|
||||
from seahub.utils.file_op import if_locked_by_online_office
|
||||
from seahub.utils.file_types import IMAGE, VIDEO, XMIND, PDF
|
||||
from seahub.utils.file_types import IMAGE, VIDEO, PDF
|
||||
from seahub.utils.file_tags import get_tagged_files, get_files_tags_in_dir
|
||||
from seahub.utils.timeutils import datetime_to_isoformat_timestr, \
|
||||
timestamp_to_isoformat_timestr
|
||||
@ -983,7 +983,7 @@ class ShareLinkDirents(APIView):
|
||||
dirent_info['file_name'] = dirent.obj_name
|
||||
|
||||
file_type, file_ext = get_file_type_and_ext(dirent.obj_name)
|
||||
if file_type in (IMAGE, XMIND) or \
|
||||
if file_type == IMAGE or \
|
||||
(file_type == VIDEO and ENABLE_VIDEO_THUMBNAIL) or \
|
||||
(file_type == PDF and ENABLE_PDF_THUMBNAIL):
|
||||
|
||||
|
@ -25,7 +25,7 @@ from seahub.base.templatetags.seahub_tags import email2nickname, \
|
||||
email2contact_email
|
||||
from seahub.settings import ENABLE_VIDEO_THUMBNAIL, \
|
||||
THUMBNAIL_ROOT, THUMBNAIL_DEFAULT_SIZE
|
||||
from seahub.utils.file_types import IMAGE, VIDEO, XMIND
|
||||
from seahub.utils.file_types import IMAGE, VIDEO
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -62,7 +62,7 @@ class StarredItems(APIView):
|
||||
item_info['deleted'] = False if dirent else True
|
||||
if dirent and not starred_item.is_dir:
|
||||
file_type, file_ext = get_file_type_and_ext(item_info['obj_name'])
|
||||
if file_type in (IMAGE, XMIND) or \
|
||||
if file_type == IMAGE or \
|
||||
(file_type == VIDEO and ENABLE_VIDEO_THUMBNAIL):
|
||||
thumbnail_size = THUMBNAIL_DEFAULT_SIZE
|
||||
thumbnail_file_path = os.path.join(THUMBNAIL_ROOT,
|
||||
|
@ -10,7 +10,7 @@ from seahub.base.models import UserStarredFiles
|
||||
from seahub.base.templatetags.seahub_tags import email2nickname, email2contact_email
|
||||
from seahub.settings import ENABLE_VIDEO_THUMBNAIL, THUMBNAIL_ROOT
|
||||
from seahub.thumbnail.utils import get_thumbnail_src
|
||||
from seahub.utils import is_pro_version, FILEEXT_TYPE_MAP, IMAGE, XMIND, VIDEO
|
||||
from seahub.utils import is_pro_version, FILEEXT_TYPE_MAP, IMAGE, VIDEO
|
||||
from seahub.utils.file_tags import get_files_tags_in_dir
|
||||
from seahub.utils.repo import is_group_repo_staff, is_repo_owner
|
||||
from seahub.utils.timeutils import timestamp_to_isoformat_timestr
|
||||
@ -212,7 +212,7 @@ def get_dir_file_info_list(username, request_type, repo_obj, parent_dir,
|
||||
fileExt = os.path.splitext(file_name)[1][1:].lower()
|
||||
file_type = FILEEXT_TYPE_MAP.get(fileExt)
|
||||
|
||||
if file_type in (IMAGE, XMIND) or \
|
||||
if file_type == IMAGE or \
|
||||
(file_type == VIDEO and ENABLE_VIDEO_THUMBNAIL):
|
||||
|
||||
# if thumbnail has already been created, return its src.
|
||||
|
@ -19,7 +19,7 @@
|
||||
{% render_bundle 'sharedFileViewMarkdown' 'css' %}
|
||||
{% elif filetype == 'Text' %}
|
||||
{% render_bundle 'sharedFileViewText' 'css' %}
|
||||
{% elif filetype == 'Image' or filetype == 'XMind' %}
|
||||
{% elif filetype == 'Image' %}
|
||||
{% render_bundle 'sharedFileViewImage' 'css' %}
|
||||
{% elif filetype == 'SVG' %}
|
||||
{% render_bundle 'sharedFileViewSVG' 'css' %}
|
||||
@ -117,7 +117,7 @@ body {
|
||||
{% render_bundle 'sharedFileViewMarkdown' 'js' %}
|
||||
{% elif filetype == 'Text' %}
|
||||
{% render_bundle 'sharedFileViewText' 'js' %}
|
||||
{% elif filetype == 'Image' or filetype == 'XMind' %}
|
||||
{% elif filetype == 'Image' %}
|
||||
{% render_bundle 'sharedFileViewImage' 'js' %}
|
||||
{% elif filetype == 'SVG' %}
|
||||
{% render_bundle 'sharedFileViewSVG' 'js' %}
|
||||
|
@ -19,7 +19,7 @@ from seaserv import get_file_id_by_path, get_repo, get_file_size, \
|
||||
seafile_api
|
||||
|
||||
from seahub.utils import gen_inner_file_get_url, get_file_type_and_ext
|
||||
from seahub.utils.file_types import VIDEO, XMIND, PDF
|
||||
from seahub.utils.file_types import VIDEO, PDF
|
||||
from seahub.settings import THUMBNAIL_IMAGE_SIZE_LIMIT, \
|
||||
THUMBNAIL_EXTENSION, THUMBNAIL_ROOT, THUMBNAIL_IMAGE_ORIGINAL_SIZE_LIMIT,\
|
||||
ENABLE_VIDEO_THUMBNAIL, THUMBNAIL_VIDEO_FRAME_TIME
|
||||
@ -32,8 +32,6 @@ except ImportError:
|
||||
# Get an instance of a logger
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
XMIND_IMAGE_SIZE = 1024
|
||||
|
||||
def get_thumbnail_src(repo_id, size, path):
|
||||
return posixpath.join("thumbnail", repo_id, str(size), path.lstrip('/'))
|
||||
|
||||
@ -128,8 +126,6 @@ def generate_thumbnail(request, repo_id, size, path):
|
||||
# pdf thumbnails
|
||||
return create_pdf_thumbnails(repo, file_id, path, size,
|
||||
thumbnail_file, file_size)
|
||||
if filetype == XMIND:
|
||||
return extract_xmind_image(repo_id, path, size)
|
||||
|
||||
# image thumbnails
|
||||
if file_size > THUMBNAIL_IMAGE_SIZE_LIMIT * 1024**2:
|
||||
@ -297,38 +293,6 @@ def _create_thumbnail_common(fp, thumbnail_file, size):
|
||||
image.save(thumbnail_file, save_type, icc_profile=icc_profile)
|
||||
return (True, 200)
|
||||
|
||||
def extract_xmind_image(repo_id, path, size=XMIND_IMAGE_SIZE):
|
||||
|
||||
# get inner path
|
||||
file_name = os.path.basename(path)
|
||||
file_id = seafile_api.get_file_id_by_path(repo_id, path)
|
||||
fileserver_token = seafile_api.get_fileserver_access_token(repo_id,
|
||||
file_id, 'view', '')
|
||||
inner_path = gen_inner_file_get_url(fileserver_token, file_name)
|
||||
|
||||
# extract xmind image
|
||||
xmind_file = urllib.request.urlopen(inner_path)
|
||||
xmind_file_str = BytesIO(xmind_file.read())
|
||||
try:
|
||||
xmind_zip_file = zipfile.ZipFile(xmind_file_str, 'r')
|
||||
except Exception as e:
|
||||
return (False, 500)
|
||||
extracted_xmind_image = xmind_zip_file.read('Thumbnails/thumbnail.png')
|
||||
extracted_xmind_image_str = BytesIO(extracted_xmind_image)
|
||||
|
||||
# save origin xmind image to thumbnail folder
|
||||
thumbnail_dir = os.path.join(THUMBNAIL_ROOT, str(size))
|
||||
if not os.path.exists(thumbnail_dir):
|
||||
os.makedirs(thumbnail_dir)
|
||||
local_xmind_image = os.path.join(thumbnail_dir, file_id)
|
||||
|
||||
try:
|
||||
ret = _create_thumbnail_common(extracted_xmind_image_str, local_xmind_image, size)
|
||||
return ret
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
return (False, 500)
|
||||
|
||||
def get_thumbnail_image_path(obj_id, image_size):
|
||||
thumbnail_dir = os.path.join(THUMBNAIL_ROOT, str(image_size))
|
||||
thumbnail_image_path = os.path.join(thumbnail_dir, obj_id)
|
||||
|
@ -128,7 +128,6 @@ PREVIEW_FILEEXT = {
|
||||
VIDEO: ('mp4', 'ogv', 'webm', 'mov'),
|
||||
AUDIO: ('mp3', 'oga', 'ogg', 'wav', 'flac', 'opus'),
|
||||
#'3D': ('stl', 'obj'),
|
||||
XMIND: ('xmind',),
|
||||
SEADOC: ('sdoc',),
|
||||
TLDRAW: ('draw',),
|
||||
EXCALIDRAW: ('exdraw',),
|
||||
|
@ -8,7 +8,6 @@ MARKDOWN = 'Markdown'
|
||||
VIDEO = 'Video'
|
||||
AUDIO = 'Audio'
|
||||
SPREADSHEET = 'SpreadSheet'
|
||||
XMIND = 'XMind'
|
||||
SEADOC = 'SDoc'
|
||||
TLDRAW = 'Tldraw'
|
||||
EXCALIDRAW = 'Excalidraw'
|
||||
|
@ -45,7 +45,7 @@ from seahub.utils import check_filename_with_rename, EMPTY_SHA1, \
|
||||
gen_file_upload_url, is_org_context, is_pro_version, normalize_dir_path, \
|
||||
FILEEXT_TYPE_MAP
|
||||
from seahub.utils.star import get_dir_starred_files
|
||||
from seahub.utils.file_types import IMAGE, VIDEO, XMIND
|
||||
from seahub.utils.file_types import IMAGE, VIDEO
|
||||
from seahub.utils.file_op import check_file_lock, ONLINE_OFFICE_LOCK_OWNER
|
||||
from seahub.utils.repo import get_locked_files_by_dir, get_repo_owner, \
|
||||
repo_has_been_shared_out, parse_repo_perm
|
||||
@ -259,10 +259,7 @@ def list_lib_dir(request, repo_id):
|
||||
if file_type == VIDEO and ENABLE_VIDEO_THUMBNAIL:
|
||||
f_['is_video'] = True
|
||||
|
||||
if file_type == XMIND:
|
||||
f_['is_xmind'] = True
|
||||
|
||||
if file_type in (IMAGE, XMIND) or \
|
||||
if file_type == IMAGE or \
|
||||
(file_type == VIDEO and ENABLE_VIDEO_THUMBNAIL):
|
||||
# if thumbnail has already been created, return its src.
|
||||
# Then web browser will use this src to get thumbnail instead of
|
||||
|
@ -61,7 +61,7 @@ from seahub.utils import render_error, is_org_context, \
|
||||
from seahub.utils.ip import get_remote_ip
|
||||
from seahub.utils.file_types import (IMAGE, PDF, SVG,
|
||||
DOCUMENT, SPREADSHEET, AUDIO,
|
||||
MARKDOWN, TEXT, VIDEO, XMIND, SEADOC, TLDRAW, EXCALIDRAW)
|
||||
MARKDOWN, TEXT, VIDEO, SEADOC, TLDRAW, EXCALIDRAW)
|
||||
from seahub.utils.timeutils import timestamp_to_isoformat_timestr
|
||||
from seahub.utils.star import is_file_starred
|
||||
from seahub.utils.http import json_response, \
|
||||
@ -73,8 +73,6 @@ from seahub.views import check_folder_permission, \
|
||||
get_unencry_rw_repos_by_user
|
||||
from seahub.utils.repo import is_repo_owner, parse_repo_perm, is_repo_admin
|
||||
from seahub.group.utils import is_group_member
|
||||
from seahub.thumbnail.utils import extract_xmind_image, get_thumbnail_src, \
|
||||
XMIND_IMAGE_SIZE, get_share_link_thumbnail_src, get_thumbnail_image_path
|
||||
from seahub.seadoc.utils import get_seadoc_file_uuid, gen_seadoc_access_token, is_seadoc_revision
|
||||
from seahub.seadoc.models import SeadocRevision
|
||||
|
||||
@ -698,7 +696,7 @@ def view_lib_file(request, repo_id, path):
|
||||
if filetype in FILE_TYPE_FOR_NEW_FILE_LINK:
|
||||
raw_path = gen_file_get_url_new(repo_id, path)
|
||||
|
||||
if filetype in (IMAGE, VIDEO, AUDIO, PDF, SVG, XMIND, 'Unknown'):
|
||||
if filetype in (IMAGE, VIDEO, AUDIO, PDF, SVG, 'Unknown'):
|
||||
template = 'common_file_view_react.html'
|
||||
|
||||
if filetype == SEADOC:
|
||||
@ -869,16 +867,6 @@ def view_lib_file(request, repo_id, path):
|
||||
send_file_access_msg(request, repo, path, 'web')
|
||||
return render(request, template, return_dict)
|
||||
|
||||
elif filetype == XMIND:
|
||||
xmind_image_path = get_thumbnail_image_path(file_id, XMIND_IMAGE_SIZE)
|
||||
if not os.path.exists(xmind_image_path) and not extract_xmind_image(repo_id, path)[0]:
|
||||
error_msg = _('Unable to view file')
|
||||
return_dict['err'] = error_msg
|
||||
else:
|
||||
return_dict['xmind_image_src'] = quote(get_thumbnail_src(repo_id, XMIND_IMAGE_SIZE, path))
|
||||
|
||||
return render(request, template, return_dict)
|
||||
|
||||
elif filetype == IMAGE:
|
||||
|
||||
if file_size > FILE_PREVIEW_MAX_SIZE:
|
||||
@ -1423,13 +1411,6 @@ def view_shared_file(request, fileshare):
|
||||
handle_document(raw_path, obj_id, fileext, ret_dict)
|
||||
elif filetype == SPREADSHEET:
|
||||
handle_spreadsheet(raw_path, obj_id, fileext, ret_dict)
|
||||
elif filetype == XMIND:
|
||||
xmind_image_path = get_thumbnail_image_path(obj_id, XMIND_IMAGE_SIZE)
|
||||
if not os.path.exists(xmind_image_path) and not extract_xmind_image(repo_id, path)[0]:
|
||||
error_msg = _('Unable to view file')
|
||||
ret_dict['err'] = error_msg
|
||||
else:
|
||||
raw_path = quote(SITE_ROOT + get_share_link_thumbnail_src(token, XMIND_IMAGE_SIZE, path))
|
||||
else:
|
||||
ret_dict['err'] = err_msg
|
||||
|
||||
@ -1688,13 +1669,6 @@ def view_file_via_shared_dir(request, fileshare):
|
||||
img_prev = posixpath.join(parent_dir, img_list[cur_img_index - 1])
|
||||
if cur_img_index != len(img_list) - 1:
|
||||
img_next = posixpath.join(parent_dir, img_list[cur_img_index + 1])
|
||||
elif filetype == XMIND:
|
||||
xmind_image_path = get_thumbnail_image_path(obj_id, XMIND_IMAGE_SIZE)
|
||||
if not os.path.exists(xmind_image_path) and not extract_xmind_image(repo_id, real_path)[0]:
|
||||
error_msg = _('Unable to view file')
|
||||
ret_dict['err'] = error_msg
|
||||
else:
|
||||
raw_path = quote(SITE_ROOT + get_share_link_thumbnail_src(token, XMIND_IMAGE_SIZE, req_path))
|
||||
else:
|
||||
ret_dict['err'] = err_msg
|
||||
|
||||
|
@ -33,8 +33,6 @@ from seahub.settings import ENABLE_UPLOAD_FOLDER, \
|
||||
MAX_NUMBER_OF_FILES_FOR_FILEUPLOAD, SHARE_LINK_EXPIRE_DAYS_MIN, \
|
||||
SHARE_LINK_EXPIRE_DAYS_MAX, \
|
||||
ENABLE_SHARE_LINK_REPORT_ABUSE, ENABLE_PDF_THUMBNAIL
|
||||
from seahub.utils.file_types import IMAGE, VIDEO, XMIND
|
||||
from seahub.thumbnail.utils import get_share_link_thumbnail_src
|
||||
from seahub.group.utils import is_group_admin
|
||||
from seahub.api2.endpoints.group_owned_libraries import get_group_id_by_repo_owner
|
||||
from seahub.constants import PERMISSION_INVISIBLE
|
||||
|
Loading…
Reference in New Issue
Block a user