diff --git a/frontend/src/pages/markdown-editor/index.js b/frontend/src/pages/markdown-editor/index.js index 60f7230367..489172e6e7 100644 --- a/frontend/src/pages/markdown-editor/index.js +++ b/frontend/src/pages/markdown-editor/index.js @@ -211,13 +211,9 @@ class MarkdownEditor extends React.Component { const fileInfoRes = await seafileAPI.getFileInfo(repoID, filePath); const { mtime, size, starred, permission, last_modifier_name, id } = fileInfoRes.data; const lastModifier = last_modifier_name; - - // get file download url - const fileDownloadUrlRes = await seafileAPI.getFileDownloadLink(repoID, filePath); - const downloadUrl = fileDownloadUrlRes.data; - + const { rawPath } = window.app.pageOptions; // get file content - const fileContentRes = await seafileAPI.getFileContent(downloadUrl); + const fileContentRes = await seafileAPI.getFileContent(rawPath); const markdownContent = fileContentRes.data; // init permission diff --git a/seahub/templates/markdown_file_view_react.html b/seahub/templates/markdown_file_view_react.html index e0a1e85c78..d20eb1698b 100644 --- a/seahub/templates/markdown_file_view_react.html +++ b/seahub/templates/markdown_file_view_react.html @@ -40,6 +40,7 @@ repoName: '{{ repo.name|escapejs }}', filePath: '{{ path|escapejs }}', fileName: '{{ filename|escapejs }}', + rawPath: '{{ raw_path|escapejs }}', domain: '{{ domain }}', protocol: '{{ protocol }}', lang: '{{ language_code }}', diff --git a/seahub/views/file.py b/seahub/views/file.py index 9e398943ed..e57aa55dc7 100644 --- a/seahub/views/file.py +++ b/seahub/views/file.py @@ -643,9 +643,10 @@ def view_lib_file(request, repo_id, path): # template = 'view_file_%s.html' % filetype.lower() template = '%s_file_view_react.html' % filetype.lower() + if filetype in [VIDEO, PDF, MARKDOWN]: + raw_path = gen_file_get_url_new(repo_id, path) + if filetype in (IMAGE, VIDEO, AUDIO, PDF, SVG, XMIND, 'Unknown'): - if filetype == VIDEO: - raw_path = gen_file_get_url_new(repo_id, path) template = 'common_file_view_react.html' if filetype == SEADOC: @@ -746,6 +747,7 @@ def view_lib_file(request, repo_id, path): return_dict['share_link_expire_days_Default'] = SHARE_LINK_EXPIRE_DAYS_DEFAULT return_dict['share_link_expire_days_min'] = SHARE_LINK_EXPIRE_DAYS_MIN return_dict['share_link_expire_days_max'] = SHARE_LINK_EXPIRE_DAYS_MAX + return_dict['raw_path'] = raw_path can_edit_file = True if parse_repo_perm(permission).can_edit_on_web is False: @@ -1231,8 +1233,8 @@ def view_shared_file(request, fileshare): ret_dict = {'err': '', 'file_content': '', 'encoding': '', 'file_enc': '', 'file_encoding_list': [], 'filetype': filetype} - if filetype == VIDEO: - raw_path = gen_file_get_url_new(repo_id, path) + if filetype in [VIDEO, PDF, MARKDOWN]: + raw_path = gen_file_get_url_by_sharelink(fileshare.token) if filetype == SEADOC: file_uuid = get_seadoc_file_uuid(repo, path)