diff --git a/app/src/components/Archive.js b/app/src/components/Archive.js
index 2ef471da..a75da88f 100644
--- a/app/src/components/Archive.js
+++ b/app/src/components/Archive.js
@@ -23,7 +23,8 @@ import {
HelpHeader,
isoDatetimeToString,
mimetypeColor,
- PageContainer, PreviewLink,
+ PageContainer,
+ PreviewLink,
SearchInput,
TabLinks,
textEllipsis,
@@ -68,14 +69,14 @@ function ArchivePage() {
const singlefileUrl = archive.singlefile_path ? `/media/${encodeURIComponent(archive.singlefile_path)}` : null;
const screenshotUrl = archive.screenshot_path ? `/media/${encodeURIComponent(archive.screenshot_path)}` : null;
- const readabilityUrl = archive.readability_path ? `/media/${encodeURIComponent(archive.readability_path)}` : null;
+ const readabilityUrl = archive.readability_path;
const singlefileButton =
;
const readabilityLink = readabilityUrl ?
- :
+ :
;
const screenshot = screenshotUrl ?
diff --git a/app/src/components/Common.js b/app/src/components/Common.js
index 30fa9867..552eaeb9 100644
--- a/app/src/components/Common.js
+++ b/app/src/components/Common.js
@@ -144,11 +144,11 @@ export function ExternalCardLink({to, ...props}) {
export function PreviewLink({file, children, className, ...props}) {
const {t} = useContext(ThemeContext);
- const {setPreviewPath} = React.useContext(FilePreviewContext);
+ const {setPreviewFile} = React.useContext(FilePreviewContext);
className = className ? `clickable ${className}` : `clickable `;
- return
setPreviewPath(file)} {...props} {...t}>
+ return setPreviewFile(file)} {...props} {...t}>
{children}
-
+
}
export function RequiredAsterisk() {
diff --git a/app/src/components/FileBrowser.js b/app/src/components/FileBrowser.js
index 38a34358..38b872a4 100644
--- a/app/src/components/FileBrowser.js
+++ b/app/src/components/FileBrowser.js
@@ -100,7 +100,7 @@ export function FileBrowser() {
key: 'path', text: 'Path', sortBy: i => i['path'].toLowerCase()
}, {key: 'size', text: 'Size', sortBy: 'size'},];
- const {setPreviewPath} = React.useContext(FilePreviewContext);
+ const {setPreviewFile} = React.useContext(FilePreviewContext);
const onSelect = (path) => {
if (path.endsWith('/') && selectedPath === path) {
@@ -185,7 +185,7 @@ export function FileBrowser() {
key={i['key']}
path={i}
onFolderClick={onFolderClick}
- onFileClick={(i) => setPreviewPath(i)}
+ onFileClick={(i) => setPreviewFile(i)}
sortData={sortData}
selectedPath={selectedPath}
onSelect={onSelect}
diff --git a/app/src/components/FilePreview.js b/app/src/components/FilePreview.js
index 255024f2..96164b51 100644
--- a/app/src/components/FilePreview.js
+++ b/app/src/components/FilePreview.js
@@ -63,15 +63,15 @@ function getVideoModal(path) {
}
export const FilePreviewContext = React.createContext({
- previewPath: null, setPreviewPath: null, previewModal: null, setPreviewModal: null,
+ previewFile: null, setPreviewFile: null, previewModal: null, setPreviewModal: null,
});
export function FilePreviewWrapper({children}) {
- const [previewPath, setPreviewPath] = React.useState(null);
+ const [previewFile, setPreviewFile] = React.useState(null);
const [previewModal, setPreviewModal] = React.useState(null);
const value = {
- previewPath, setPreviewPath, previewModal, setPreviewModal,
+ previewFile, setPreviewFile, previewModal, setPreviewModal,
};
function setModalContent(content, url, downloadURL) {
@@ -85,38 +85,36 @@ export function FilePreviewWrapper({children}) {
{downloadURL &&
window.open(downloadURL)} floated='left'>Download}
window.open(url)}>Open
- setPreviewPath(null)}>Close
+ setPreviewFile(null)}>Close
);
}
React.useEffect(() => {
setPreviewModal(null);
- if (previewPath && !_.isEmpty(previewPath)) {
- const {mimetype, size} = previewPath;
- console.debug(`useFilePreview path=${previewPath['path']} mimetype=${mimetype}`);
- const url = getMediaPathURL(previewPath);
- const downloadURL = getDownloadPathURL(previewPath);
+ if (previewFile && !_.isEmpty(previewFile)) {
+ const {mimetype, size} = previewFile;
+ console.debug(`useFilePreview path=${previewFile['path']} mimetype=${mimetype}`);
+ const url = getMediaPathURL(previewFile);
+ const downloadURL = getDownloadPathURL(previewFile);
if (mimetype.startsWith('text/') && size >= 10000) {
// Large text files should be downloaded.
window.open(downloadURL);
} else if (mimetype.startsWith('text/') || mimetype.startsWith('application/json')) {
- setModalContent(getIframeModal(previewPath), url, downloadURL);
+ setModalContent(getIframeModal(previewFile), url, downloadURL);
} else if (mimetype.startsWith('video/')) {
- setModalContent(getVideoModal(previewPath), url, downloadURL);
+ setModalContent(getVideoModal(previewFile), url, downloadURL);
} else if (mimetype.startsWith('application/epub')) {
- const viewerURL = getEpubViewerURL(previewPath);
- console.dir(previewPath);
- console.log(viewerURL);
- setModalContent(getEpubModal(previewPath), viewerURL, downloadURL);
+ const viewerURL = getEpubViewerURL(previewFile);
+ setModalContent(getEpubModal(previewFile), viewerURL, downloadURL);
} else if (mimetype.startsWith('image/')) {
- setModalContent(getImageModal(previewPath), url);
+ setModalContent(getImageModal(previewFile), url);
} else {
// No special handler for this file type, just open it.
window.open(downloadURL);
}
}
- }, [previewPath]);
+ }, [previewFile]);
return
{children}
diff --git a/app/src/components/Files.js b/app/src/components/Files.js
index 4226a88c..caac113f 100644
--- a/app/src/components/Files.js
+++ b/app/src/components/Files.js
@@ -88,7 +88,7 @@ function EbookCard({file}) {
function ImageCard({file}) {
const {s} = useContext(ThemeContext);
- const {setPreviewPath} = React.useContext(FilePreviewContext);
+ const {setPreviewFile} = React.useContext(FilePreviewContext);
const url = `/media/${encodeURIComponent(file.path)}`;
let poster = ;
@@ -97,7 +97,7 @@ function ImageCard({file}) {
poster = setPreviewPath(file)}
+ onClick={() => setPreviewFile(file)}
/>
}