From 17a1aa903ca5fc613aa62d77228baaa6b0f469d5 Mon Sep 17 00:00:00 2001 From: Roland Date: Sat, 26 Aug 2023 20:28:34 -0600 Subject: [PATCH] Modifying Archive page to match Video page, specifically using tabs for the about/files. --- app/src/components/Archive.js | 93 ++++++++++++++++++++++++------- app/src/components/Common.js | 4 +- app/src/components/FilePreview.js | 30 +++++----- app/src/components/VideoPlayer.js | 20 ++++--- 4 files changed, 103 insertions(+), 44 deletions(-) diff --git a/app/src/components/Archive.js b/app/src/components/Archive.js index 2aad26de..97f242ee 100644 --- a/app/src/components/Archive.js +++ b/app/src/components/Archive.js @@ -28,6 +28,7 @@ import { mimetypeColor, PageContainer, PreviewLink, + PreviewPath, SearchInput, SortButton, TabLinks, @@ -42,15 +43,29 @@ import {FileCards, FileRowTagIcon, FilesView} from "./Files"; import Grid from "semantic-ui-react/dist/commonjs/collections/Grid"; import _ from "lodash"; import {Media, ThemeContext} from "../contexts/contexts"; -import {Button, Card, CardIcon, Header, Icon, Loader, Placeholder, Segment} from "./Theme"; +import {Button, Card, CardIcon, darkTheme, Header, Loader, Placeholder, Segment, Tab, TabPane} from "./Theme"; import {SortableTable} from "./SortableTable"; import {taggedImageLabel, TagsSelector} from "../Tags"; import {toast} from "react-semantic-toasts-2"; +function archiveFileLink(path, directory = false) { + if (path) { + const href = directory ? + `/media/${encodeMediaPath(path)}/` + : `/media/${encodeMediaPath(path)}`; + return +
{path}
+
+ } else { + return

Unknown

+ } +} + function ArchivePage() { const navigate = useNavigate(); const {archiveId} = useParams(); const {archiveFile, history, fetchArchive} = useArchive(archiveId); + const {theme} = useContext(ThemeContext); let title; if (archiveFile && archiveFile.archive) { @@ -113,7 +128,10 @@ function ArchivePage() { confirmButton='Update' onClick={localUpdateArchive} obeyWROLMode={true} - >Update; + style={{marginTop: '0.5em'}} + > + Update + ; const deleteButton = Delete; + > + Delete + ; let historyList = ; if (history && history.length === 0) { @@ -131,7 +151,7 @@ function ArchivePage() { } const domain = data.domain ? data.domain : null; - let domainHeader; + let domainHeader =

Unknown

; if (domain) { const domainUrl = `/archive?domain=${domain}`; domainHeader =
@@ -141,16 +161,6 @@ function ArchivePage() {
; } - let urlHeader; - if (data.url) { - urlHeader =
- - - {textEllipsis(data.url)} - -
; - } - const localAddTag = async (name) => { await tagFileGroup(archiveFile, name); await fetchArchive(); @@ -161,6 +171,54 @@ function ArchivePage() { await fetchArchive(); } + const aboutPane = { + menuItem: 'About', render: () => +
Domain
+ {domainHeader} + +
Size
+ {humanFileSize(size)} + +
URL
+

{data.url ? {data.url} : 'N/A'}

+
+ }; + + const localPreviewPath = (path, mimetype) => { + if (path) { + return {path} + } else { + return 'Unknown' + } + } + + const filesPane = { + menuItem: 'Files', render: () => +
Singlefile File
+ {localPreviewPath(data.singlefile_path, 'text/html')} + +
Readability File
+ {localPreviewPath(data.readability_path, 'text/html')} + +
Readability Text File
+ {localPreviewPath(data.readability_txt_path, 'text/plain')} + +
Readability JSON File
+ {localPreviewPath(data.readability_json_path, 'application/json')} + +
Screenshot File
+ {data.screenshot_path ? + archiveFileLink(data.screenshot_path) + : 'Unknown'} + +
Directory
+ {archiveFileLink(archiveFile.directory, true)} +
+ }; + + const tabPanes = [aboutPane, filesPane]; + const tabMenu = theme === darkTheme ? {inverted: true, attached: true} : {attached: true}; + return <> @@ -170,12 +228,7 @@ function ArchivePage() {
{textEllipsis(archiveFile.title || data.url)}
{isoDatetimeToString(data.archive_datetime)}
- {domainHeader} - {urlHeader} -
{humanFileSize(size)}
- {singlefileButton} - {readabilityLink} {updateButton} {deleteButton} @@ -184,6 +237,8 @@ function ArchivePage() { + + } -export function PreviewPath({path, mimetype, ...props}) { - return +export function PreviewPath({path, mimetype, taggable = true, ...props}) { + return } export function RequiredAsterisk() { diff --git a/app/src/components/FilePreview.js b/app/src/components/FilePreview.js index d532c6e7..58dce63e 100644 --- a/app/src/components/FilePreview.js +++ b/app/src/components/FilePreview.js @@ -186,11 +186,13 @@ export function FilePreviewProvider({children}) { await localFetchFile(); } - function setModalContent(content, url, downloadURL, path) { + function setModalContent(content, url, downloadURL, path, taggable = true) { const openButton = url ? : null; const closeButton = ; - const tagsDisplay = ; + const tagsDisplay = taggable ? + + : null; const downloadButton = downloadURL ? : null; @@ -250,7 +252,7 @@ export function FilePreviewProvider({children}) { } if (previewFile && !_.isEmpty(previewFile)) { - const {mimetype, size} = previewFile; + const {mimetype, size, taggable} = previewFile; const path = previewFile['primary_path'] || previewFile['path']; console.debug('Previewing file', previewFile); const lowerPath = path.toLowerCase(); @@ -260,27 +262,27 @@ export function FilePreviewProvider({children}) { // Large text files should be downloaded. window.open(downloadURL); } else if (mimetype.startsWith('text/') || mimetype.startsWith('application/json')) { - setModalContent(getIframePreviewModal(previewFile), url, downloadURL, path); + setModalContent(getIframePreviewModal(previewFile), url, downloadURL, path, taggable); } else if (mimetype.startsWith('video/')) { - setModalContent(getVideoPreviewModal(previewFile), url, downloadURL, path); + setModalContent(getVideoPreviewModal(previewFile), url, downloadURL, path, taggable); } else if (mimetype.startsWith('audio/')) { - setModalContent(getAudioPreviewModal(previewFile), url, downloadURL, path); + setModalContent(getAudioPreviewModal(previewFile), url, downloadURL, path, taggable); } else if (mimetype.startsWith('application/epub')) { const viewerURL = getEpubViewerURL(previewFile); - setModalContent(getIframePreviewModal(previewFile, viewerURL), viewerURL, downloadURL, path); + setModalContent(getIframePreviewModal(previewFile, viewerURL), viewerURL, downloadURL, path, taggable); } else if (mimetype.startsWith('application/pdf')) { - setModalContent(getIframePreviewModal(previewFile), url, downloadURL, path); + setModalContent(getIframePreviewModal(previewFile), url, downloadURL, path, taggable); } else if (mimetype.startsWith('image/')) { - setModalContent(getImagePreviewModal(previewFile), url, null, path); + setModalContent(getImagePreviewModal(previewFile), url, null, path, taggable); } else if (mimetype.startsWith('model/stl')) { - setModalContent(getSTLPreviewModal(previewFile), null, downloadURL, path); + setModalContent(getSTLPreviewModal(previewFile), null, downloadURL, path, taggable); } else if (mimetype.startsWith('application/octet-stream') && lowerPath.endsWith('.mp3')) { - setModalContent(getAudioPreviewModal(previewFile), url, downloadURL, path); + setModalContent(getAudioPreviewModal(previewFile), url, downloadURL, path, taggable); } else if (mimetype.startsWith('application/octet-stream') && lowerPath.endsWith('.stl')) { - setModalContent(getSTLPreviewModal(previewFile), null, downloadURL, path); + setModalContent(getSTLPreviewModal(previewFile), null, downloadURL, path, taggable); } else { // No special handler for this file type, just open it. - setModalContent(getGenericPreviewModal(previewFile), url, downloadURL, path); + setModalContent(getGenericPreviewModal(previewFile), url, downloadURL, path, taggable); } } }, [previewFile]); diff --git a/app/src/components/VideoPlayer.js b/app/src/components/VideoPlayer.js index 7f5215b3..8e3ff424 100644 --- a/app/src/components/VideoPlayer.js +++ b/app/src/components/VideoPlayer.js @@ -150,28 +150,30 @@ function VideoPage({videoFile, prevFile, nextFile, fetchVideo, ...props}) { }; const {poster_file, info_json_file} = video; - let filesPane = { + const filesPane = { menuItem: 'Files', render: () =>

Video File

{videoFileLink(video['video_path'])}

Info JSON File

{info_json_file && - {info_json_file['path']} + + {info_json_file['path']} + }

Caption Files

{caption_files && - caption_files.map(i =>

{i['path']}

) + caption_files.map(i =>

+ {i['path']} +

) }

Poster File

{poster_file && - {poster_file['path']} + + {poster_file['path']} + }

Directory

@@ -179,7 +181,7 @@ function VideoPage({videoFile, prevFile, nextFile, fetchVideo, ...props}) {
} - let tabPanes = [descriptionPane, aboutPane, filesPane, captionsPane]; + const tabPanes = [descriptionPane, aboutPane, filesPane, captionsPane]; const tabMenu = theme === darkTheme ? {inverted: true, attached: true} : {attached: true}; const localAddTag = async (name) => {