mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-22 07:56:18 -05:00
Renaming examples to avoid grouping of pdf with ebooks. Reworking URLs for media files to avoid escaping url safe characters.
This commit is contained in:
parent
b481334e1a
commit
44ebc876fa
21 changed files with 277 additions and 186 deletions
|
|
@ -18,8 +18,10 @@ import {
|
|||
CardLink,
|
||||
cardTitleWrapper,
|
||||
defaultSearchOrder,
|
||||
encodeMediaPath,
|
||||
ExternalCardLink,
|
||||
FileIcon,
|
||||
findPosterPath,
|
||||
HelpHeader,
|
||||
isoDatetimeToString,
|
||||
mimetypeColor,
|
||||
|
|
@ -68,8 +70,8 @@ function ArchivePage() {
|
|||
|
||||
const {data} = archiveFile;
|
||||
|
||||
const singlefileUrl = data.singlefile_path ? `/media/${encodeURIComponent(data.singlefile_path)}` : null;
|
||||
const screenshotUrl = data.screenshot_path ? `/media/${encodeURIComponent(data.screenshot_path)}` : null;
|
||||
const singlefileUrl = data.singlefile_path ? `/media/${encodeMediaPath(data.singlefile_path)}` : null;
|
||||
const screenshotUrl = data.screenshot_path ? `/media/${encodeMediaPath(data.screenshot_path)}` : null;
|
||||
const readabilityUrl = data.readability_path;
|
||||
|
||||
const singlefileButton = <ExternalCardLink to={singlefileUrl}>
|
||||
|
|
@ -178,8 +180,8 @@ export function ArchiveCard({file}) {
|
|||
const {s} = useContext(ThemeContext);
|
||||
const {data} = file;
|
||||
|
||||
const imageSrc = data.screenshot_path ? `/media/${encodeURIComponent(data.screenshot_path)}` : null;
|
||||
const singlefileUrl = data.singlefile_path ? `/media/${encodeURIComponent(data.singlefile_path)}` : null;
|
||||
const imageSrc = data.screenshot_path ? `/media/${encodeMediaPath(data.screenshot_path)}` : null;
|
||||
const singlefileUrl = data.singlefile_path ? `/media/${encodeMediaPath(data.singlefile_path)}` : null;
|
||||
|
||||
let screenshot = <CardIcon><FileIcon file={file}/></CardIcon>;
|
||||
const imageLabel = file.tags && file.tags.length ? taggedImageLabel : null;
|
||||
|
|
@ -436,7 +438,8 @@ export function ArchiveRowCells({file}) {
|
|||
const {data} = file;
|
||||
|
||||
const archiveUrl = `/archive/${data.id}`;
|
||||
const posterUrl = data.screenshot_path ? `/media/${encodeURIComponent(data.screenshot_path)}` : null;
|
||||
const posterPath = findPosterPath(file);
|
||||
const posterUrl = posterPath ? `/media/${encodeMediaPath(posterPath)}` : null;
|
||||
|
||||
let poster;
|
||||
if (posterUrl) {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
import React, {useContext, useEffect, useState} from "react";
|
||||
import {Card, Container, IconGroup, Image, Input, Modal, Pagination} from 'semantic-ui-react';
|
||||
import {Card, Container, IconGroup, Input, Modal, Pagination} from 'semantic-ui-react';
|
||||
import {Link, NavLink, useNavigate} from "react-router-dom";
|
||||
import Message from "semantic-ui-react/dist/commonjs/collections/Message";
|
||||
import {useDirectories, useDownloaders, useHotspot, useSettings, useThrottle} from "../hooks/customHooks";
|
||||
import {Media, StatusContext, ThemeContext} from "../contexts/contexts";
|
||||
import {Button, darkTheme, Form, Header, Icon, lightTheme, Menu, Popup, Statistic} from "./Theme";
|
||||
import {Button, CardIcon, darkTheme, Form, Header, Icon, lightTheme, Menu, Popup, Statistic} from "./Theme";
|
||||
import {FilePreviewContext} from "./FilePreview";
|
||||
import _ from "lodash";
|
||||
|
||||
export const API_URI = process.env && process.env.REACT_APP_API_URI ? process.env.REACT_APP_API_URI : `${window.location.protocol}//${window.location.host}/api`;
|
||||
export const VIDEOS_API = `${API_URI}/videos`;
|
||||
|
|
@ -441,23 +442,77 @@ export function CardGroupCentered(props) {
|
|||
</div>
|
||||
}
|
||||
|
||||
export function CardPosterLink({to, poster_url, imageLabel, external = false}) {
|
||||
export function findPosterPath(file) {
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
const {files, poster_path, cover_path, screenshot_path, video} = file;
|
||||
if (poster_path) {
|
||||
return poster_path;
|
||||
}
|
||||
if (cover_path) {
|
||||
return cover_path;
|
||||
}
|
||||
if (screenshot_path) {
|
||||
return screenshot_path;
|
||||
}
|
||||
if (video && video['poster_path']) {
|
||||
// file is a video model.
|
||||
return video['poster_path'];
|
||||
}
|
||||
if (!_.isEmpty(files)) {
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const file = files[i];
|
||||
if (file['mimetype'] && file['mimetype'].startsWith('image/')) {
|
||||
// Found an image file, use that as the poster.
|
||||
return file['path'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function CardPoster({to, file}) {
|
||||
const {s} = useContext(ThemeContext);
|
||||
// Used to center posters in CardIcon.
|
||||
const style = {display: 'flex', justifyContent: 'center', ...s['style']};
|
||||
const image = <Image src={poster_url} label={imageLabel}
|
||||
style={{maxHeight: '163px', width: 'auto'}}
|
||||
/>;
|
||||
if (external === true && to) {
|
||||
return <a href={to} target='_blank' rel='noreferrer' style={style}>
|
||||
{image}
|
||||
</a>
|
||||
} else if (to) {
|
||||
|
||||
const cardTagIcon = <div className="ui green left corner label">
|
||||
<i aria-hidden="true" className="tag icon"></i>
|
||||
</div>;
|
||||
let imageLabel = !_.isEmpty(file.tags) ? cardTagIcon : null;
|
||||
|
||||
let posterPath = findPosterPath(file);
|
||||
|
||||
if (!posterPath) {
|
||||
// No poster, use a FileIcon.
|
||||
return <PreviewLink file={file}>
|
||||
<CardIcon>
|
||||
{imageLabel}
|
||||
<FileIcon file={file}/>
|
||||
</CardIcon>
|
||||
</PreviewLink>
|
||||
}
|
||||
|
||||
posterPath = `/media/${encodeMediaPath(posterPath)}`;
|
||||
|
||||
const image = <>
|
||||
{/* Replicate <Image label/> but with maxHeight applied to image */}
|
||||
{imageLabel}
|
||||
<img alt='poster' src={posterPath} style={{maxHeight: '163px', width: 'auto'}}/>
|
||||
</>;
|
||||
|
||||
if (to) {
|
||||
// Link using React Router.
|
||||
return <Link to={to} style={style}>
|
||||
{image}
|
||||
</Link>
|
||||
} else {
|
||||
return <div style={style}>{image}</div>;
|
||||
// Preview the file.
|
||||
return <div style={style}>
|
||||
<PreviewLink file={file}>
|
||||
{image}
|
||||
</PreviewLink>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -840,7 +895,7 @@ export const filterToMimetypes = (filter) => {
|
|||
} else if (filter === 'image') {
|
||||
return ['image'];
|
||||
} else if (filter === 'zip') {
|
||||
return ['application/zip'];
|
||||
return ['application/zip', 'application/zlib', 'application/x-bzip2', 'application/x-xz', 'application/x-bzip', 'application/x-bzip2', 'application/gzip', 'application/vnd.rar', 'application/x-tar', 'application/x-7z-compressed'];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -874,3 +929,12 @@ function hexToRGBArray(color) {
|
|||
export function contrastingColor(color) {
|
||||
return (luma(color) >= 120) ? '#000000' : '#dddddd';
|
||||
}
|
||||
|
||||
export const encodeMediaPath = (path) => {
|
||||
// Replace % first to avoid replacing the other replacements.
|
||||
path = path.replaceAll('%', '%25');
|
||||
|
||||
path = path.replaceAll('#', '%23');
|
||||
path = path.replaceAll(' ', '%20');
|
||||
return path
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ class Downloader extends React.Component {
|
|||
}
|
||||
|
||||
handleInputChange = async (event, {name, value}) => {
|
||||
console.log(name, value);
|
||||
this.setState({[name]: value}, this.validateUrls);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import React from "react";
|
|||
import _ from "lodash";
|
||||
import {
|
||||
Button as SButton,
|
||||
Grid,
|
||||
Header as SHeader,
|
||||
Image,
|
||||
Modal,
|
||||
|
|
@ -9,33 +10,36 @@ import {
|
|||
ModalContent,
|
||||
ModalHeader
|
||||
} from "semantic-ui-react";
|
||||
import {TagsDisplay} from "../Tags";
|
||||
import {Media} from "../contexts/contexts";
|
||||
import {encodeMediaPath} from "./Common";
|
||||
|
||||
function getMediaPathURL(file) {
|
||||
if (file['primary_path']) {
|
||||
return `/media/${encodeURIComponent(file['primary_path'])}`;
|
||||
function getMediaPathURL(previewFile) {
|
||||
if (previewFile['primary_path']) {
|
||||
return `/media/${encodeMediaPath(previewFile['primary_path'])}`;
|
||||
} else {
|
||||
return `/media/${encodeURIComponent(file['path'])}`;
|
||||
return `/media/${encodeMediaPath(previewFile['path'])}`;
|
||||
}
|
||||
}
|
||||
|
||||
function getDownloadPathURL(file) {
|
||||
if (file['primary_path']) {
|
||||
return `/download/${encodeURIComponent(file['primary_path'])}`;
|
||||
function getDownloadPathURL(previewFile) {
|
||||
if (previewFile['primary_path']) {
|
||||
return `/download/${encodeMediaPath(previewFile['primary_path'])}`;
|
||||
} else {
|
||||
return `/download/${encodeURIComponent(file['path'])}`;
|
||||
return `/download/${encodeMediaPath(previewFile['path'])}`;
|
||||
}
|
||||
}
|
||||
|
||||
function getEpubViewerURL(file) {
|
||||
if (file['primary_path']) {
|
||||
return `/epub.html?url=download/${encodeURIComponent(file['primary_path'])}`;
|
||||
function getEpubViewerURL(previewFile) {
|
||||
if (previewFile['primary_path']) {
|
||||
return `/epub.html?url=download/${encodeMediaPath(previewFile['primary_path'])}`;
|
||||
} else {
|
||||
return `/epub.html?url=download/${encodeURIComponent(file['path'])}`;
|
||||
return `/epub.html?url=download/${encodeMediaPath(previewFile['path'])}`;
|
||||
}
|
||||
}
|
||||
|
||||
function getIframeModal(path) {
|
||||
const url = getMediaPathURL(path);
|
||||
function getIframeModal(previewFile) {
|
||||
const url = getMediaPathURL(previewFile);
|
||||
return <ModalContent>
|
||||
<div className='full-height'>
|
||||
<iframe title='textModal' src={url}
|
||||
|
|
@ -46,9 +50,11 @@ function getIframeModal(path) {
|
|||
</ModalContent>
|
||||
}
|
||||
|
||||
function getImageModal(path) {
|
||||
const url = getMediaPathURL(path);
|
||||
const name = path['path'].replace(/^.*[\\\/]/, '');
|
||||
function getImageModal(previewFile) {
|
||||
const path = previewFile.primary_path ?? previewFile.path;
|
||||
const url = getMediaPathURL(previewFile);
|
||||
// Get the file name from the absolute path.
|
||||
const name = path.replace(/^.*[\\\/]/, '');
|
||||
return <React.Fragment>
|
||||
<ModalHeader>
|
||||
{name}
|
||||
|
|
@ -61,8 +67,8 @@ function getImageModal(path) {
|
|||
</React.Fragment>
|
||||
}
|
||||
|
||||
function getEpubModal(path) {
|
||||
const downloadURL = getDownloadPathURL(path);
|
||||
function getEpubModal(previewFile) {
|
||||
const downloadURL = getDownloadPathURL(previewFile);
|
||||
const viewerUrl = `/epub.html?url=${downloadURL}`;
|
||||
return <ModalContent>
|
||||
<div className='full-height'>
|
||||
|
|
@ -74,10 +80,11 @@ function getEpubModal(path) {
|
|||
</ModalContent>
|
||||
}
|
||||
|
||||
function getVideoModal(path) {
|
||||
const url = getMediaPathURL(path);
|
||||
const name = path['path'].replace(/^.*[\\\/]/, '');
|
||||
const type = path['mimetype'] ? path['mimetype'] : 'video/mp4';
|
||||
function getVideoModal(previewFile) {
|
||||
const url = getMediaPathURL(previewFile);
|
||||
const path = previewFile.primary_path ?? previewFile.path;
|
||||
const name = path.replace(/^.*[\\\/]/, '');
|
||||
const type = previewFile.mimetype ? previewFile.mimetype : 'video/mp4';
|
||||
return <React.Fragment>
|
||||
<ModalHeader>
|
||||
{name}
|
||||
|
|
@ -96,11 +103,12 @@ function getVideoModal(path) {
|
|||
</React.Fragment>
|
||||
}
|
||||
|
||||
function getAudioModal(path) {
|
||||
const url = getMediaPathURL(path);
|
||||
const name = path['path'].replace(/^.*[\\\/]/, '');
|
||||
function getAudioModal(previewFile) {
|
||||
const url = getMediaPathURL(previewFile);
|
||||
const path = previewFile.primary_path ?? previewFile.path;
|
||||
const name = path.replace(/^.*[\\\/]/, '');
|
||||
// Some audio files may not have the correct mimetype. Trust the suffix identifies an audio file.
|
||||
const type = path['mimetype'] !== 'application/octet-stream' ? path['mimetype'] : 'audio/mpeg';
|
||||
const type = previewFile['mimetype'] !== 'application/octet-stream' ? previewFile['mimetype'] : 'audio/mpeg';
|
||||
return <React.Fragment>
|
||||
<ModalHeader>
|
||||
{name}
|
||||
|
|
@ -132,6 +140,16 @@ export function FilePreviewWrapper({children}) {
|
|||
};
|
||||
|
||||
function setModalContent(content, url, downloadURL) {
|
||||
const openButton = <SButton color='blue' as='a' href={url}>Open</SButton>;
|
||||
const closeButton = <SButton onClick={() => setPreviewFile(null)}>Close</SButton>;
|
||||
const tagsDisplay = <TagsDisplay fileGroup={previewFile}/>;
|
||||
let downloadButton;
|
||||
if (downloadURL) {
|
||||
downloadButton = <SButton color='yellow' as='a' href={downloadURL} floated='left'>
|
||||
Download
|
||||
</SButton>;
|
||||
}
|
||||
|
||||
setPreviewModal(<Modal closeIcon
|
||||
size='fullscreen'
|
||||
open={true}
|
||||
|
|
@ -139,10 +157,28 @@ export function FilePreviewWrapper({children}) {
|
|||
>
|
||||
{content}
|
||||
<ModalActions>
|
||||
{downloadURL &&
|
||||
<SButton color='yellow' onClick={() => window.open(downloadURL)} floated='left'>Download</SButton>}
|
||||
<SButton color='blue' onClick={() => window.open(url)}>Open</SButton>
|
||||
<SButton onClick={() => setPreviewFile(null)}>Close</SButton>
|
||||
<Media at='mobile'>
|
||||
<Grid>
|
||||
<Grid.Row>
|
||||
<Grid.Column width={6}>{downloadButton}</Grid.Column>
|
||||
<Grid.Column width={5}>{openButton}</Grid.Column>
|
||||
<Grid.Column width={5}>{closeButton}</Grid.Column>
|
||||
</Grid.Row>
|
||||
<Grid.Row>
|
||||
<Grid.Column width={16}>{tagsDisplay}</Grid.Column>
|
||||
</Grid.Row>
|
||||
</Grid>
|
||||
</Media>
|
||||
<Media greaterThanOrEqual='tablet'>
|
||||
<Grid>
|
||||
<Grid.Row>
|
||||
<Grid.Column width={2}>{downloadButton}</Grid.Column>
|
||||
<Grid.Column width={10}>{tagsDisplay}</Grid.Column>
|
||||
<Grid.Column width={2}>{openButton}</Grid.Column>
|
||||
<Grid.Column width={2}>{closeButton}</Grid.Column>
|
||||
</Grid.Row>
|
||||
</Grid>
|
||||
</Media>
|
||||
</ModalActions>
|
||||
</Modal>);
|
||||
}
|
||||
|
|
@ -173,6 +209,8 @@ export function FilePreviewWrapper({children}) {
|
|||
} else if (mimetype.startsWith('application/epub')) {
|
||||
const viewerURL = getEpubViewerURL(previewFile);
|
||||
setModalContent(getEpubModal(previewFile), viewerURL, downloadURL);
|
||||
} else if (mimetype.startsWith('application/pdf')) {
|
||||
setModalContent(getIframeModal(previewFile), url, downloadURL);
|
||||
} else if (mimetype.startsWith('image/')) {
|
||||
setModalContent(getImageModal(previewFile), url);
|
||||
} else if (mimetype.startsWith('application/octet-stream') && lowerPath.endsWith('.mp3')) {
|
||||
|
|
|
|||
|
|
@ -14,10 +14,12 @@ import {
|
|||
} from "semantic-ui-react";
|
||||
import {
|
||||
CardGroupCentered,
|
||||
CardPosterLink,
|
||||
CardPoster,
|
||||
cardTitleWrapper,
|
||||
encodeMediaPath,
|
||||
ExternalCardLink,
|
||||
FileIcon,
|
||||
findPosterPath,
|
||||
humanFileSize,
|
||||
isoDatetimeToString,
|
||||
mimetypeColor,
|
||||
|
|
@ -40,33 +42,24 @@ import _ from 'lodash';
|
|||
import {FileBrowser} from "./FileBrowser";
|
||||
import {refreshDirectoryFiles, refreshFiles} from "../api";
|
||||
import {useSubscribeEventName} from "../Events";
|
||||
import {FilePreviewContext} from "./FilePreview";
|
||||
import {taggedImageLabel, TagsContext} from "../Tags";
|
||||
import {TagsContext} from "../Tags";
|
||||
|
||||
function EbookCard({file}) {
|
||||
const {s} = useContext(ThemeContext);
|
||||
let {data} = file;
|
||||
|
||||
const downloadUrl = `/download/${encodeURIComponent(file.primary_path)}`;
|
||||
const downloadUrl = `/download/${encodeMediaPath(file.primary_path)}`;
|
||||
const isEpub = file['mimetype'].startsWith('application/epub');
|
||||
const viewerUrl = isEpub ? `/epub.html?url=${downloadUrl}` : null;
|
||||
|
||||
let cover = <FileIcon file={file}/>;
|
||||
if (data && data.cover_path) {
|
||||
const coverSrc = `/media/${encodeURIComponent(data.cover_path)}`;
|
||||
cover = <CardPosterLink poster_url={coverSrc}/>;
|
||||
}
|
||||
|
||||
const color = mimetypeColor(file.mimetype);
|
||||
return <Card color={color}>
|
||||
<PreviewLink file={file}>
|
||||
{cover}
|
||||
</PreviewLink>
|
||||
<CardPoster file={file} preview={true}/>
|
||||
<CardContent {...s}>
|
||||
<CardHeader>
|
||||
<Container textAlign='left'>
|
||||
<ExternalCardLink to={viewerUrl || downloadUrl}>
|
||||
{data ? data.title : file.title}
|
||||
{cardTitleWrapper(data ? data.title : file.title)}
|
||||
</ExternalCardLink>
|
||||
</Container>
|
||||
</CardHeader>
|
||||
|
|
@ -81,22 +74,11 @@ function EbookCard({file}) {
|
|||
|
||||
function ImageCard({file}) {
|
||||
const {s} = useContext(ThemeContext);
|
||||
const {setPreviewFile} = React.useContext(FilePreviewContext);
|
||||
const url = `/media/${encodeURIComponent(file.primary_path)}`;
|
||||
|
||||
let poster = <FileIcon file={file}/>;
|
||||
if (file.size && file.size < 50000000) {
|
||||
// Image is less than 5mb, use it.
|
||||
poster = <Image wrapped
|
||||
src={url}
|
||||
style={{position: 'relative', width: '100%'}}
|
||||
onClick={() => setPreviewFile(file)}
|
||||
/>
|
||||
}
|
||||
const url = `/media/${encodeMediaPath(file.primary_path)}`;
|
||||
|
||||
return <Card color={mimetypeColor(file.mimetype)}>
|
||||
<PreviewLink file={file}>
|
||||
{poster}
|
||||
<CardPoster file={file}/>
|
||||
</PreviewLink>
|
||||
<CardContent {...s}>
|
||||
<CardHeader>
|
||||
|
|
@ -114,18 +96,6 @@ function ImageCard({file}) {
|
|||
</Card>
|
||||
}
|
||||
|
||||
function findPosterPath(files) {
|
||||
if (_.isEmpty(files)) {
|
||||
return;
|
||||
}
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const file = files[i];
|
||||
if (file['mimetype'] && file['mimetype'].startsWith('image/')) {
|
||||
return file['path'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function FileCard({file}) {
|
||||
const {s} = useContext(ThemeContext);
|
||||
|
||||
|
|
@ -143,27 +113,17 @@ function FileCard({file}) {
|
|||
return <EbookCard key={file['primary_path']} file={file}/>;
|
||||
}
|
||||
|
||||
const {data, tags} = file;
|
||||
const {data} = file;
|
||||
let author;
|
||||
if (data) {
|
||||
author = data['author'];
|
||||
}
|
||||
const downloadUrl = `/download/${encodeURIComponent(file.primary_path)}`;
|
||||
const downloadUrl = `/download/${encodeMediaPath(file.primary_path)}`;
|
||||
const color = mimetypeColor(file.mimetype);
|
||||
const size = file.size !== null && file.size !== undefined ? humanFileSize(file.size) : null;
|
||||
|
||||
const posterFile = findPosterPath(file['files']);
|
||||
let poster = <CardIcon><FileIcon file={file}/></CardIcon>;
|
||||
let imageLabel = !_.isEmpty(tags) ? taggedImageLabel : null;
|
||||
if (posterFile) {
|
||||
const posterUrl = `/media/${encodeURIComponent(posterFile)}`;
|
||||
poster = <CardPosterLink to={downloadUrl} poster_url={posterUrl} imageLabel={imageLabel}/>;
|
||||
}
|
||||
|
||||
return <Card color={color}>
|
||||
<PreviewLink file={file}>
|
||||
{poster}
|
||||
</PreviewLink>
|
||||
<CardPoster to={downloadUrl} file={file}/>
|
||||
<CardContent {...s}>
|
||||
<CardHeader>
|
||||
<ExternalCardLink to={downloadUrl}>
|
||||
|
|
@ -190,7 +150,7 @@ export function FileCards({files}) {
|
|||
}
|
||||
|
||||
function ImageRowCells({file}) {
|
||||
const url = `/media/${encodeURIComponent(file.primary_path)}`;
|
||||
const url = `/media/${encodeMediaPath(file.primary_path)}`;
|
||||
|
||||
let poster = <FileIcon file={file} size='large'/>;
|
||||
if (file.size && file.size < 50000000) {
|
||||
|
|
@ -214,11 +174,10 @@ function ImageRowCells({file}) {
|
|||
}
|
||||
|
||||
export function EbookRowCells({file}) {
|
||||
const {data} = file;
|
||||
|
||||
let cover = <CardIcon><FileIcon file={file}/></CardIcon>;
|
||||
if (data && data.cover_path) {
|
||||
const coverSrc = `/media/${encodeURIComponent(data.cover_path)}`;
|
||||
const posterPath = findPosterPath(file);
|
||||
if (posterPath) {
|
||||
const coverSrc = `/media/${encodeMediaPath(posterPath)}`;
|
||||
cover = <Image wrapped src={coverSrc} width='50px'/>;
|
||||
}
|
||||
|
||||
|
|
@ -229,6 +188,7 @@ export function EbookRowCells({file}) {
|
|||
</TableCell>
|
||||
<TableCell>
|
||||
<PreviewLink file={file}>
|
||||
<FileRowTagIcon file={file}/>
|
||||
{textEllipsis(file.title || file.stem)}
|
||||
</PreviewLink>
|
||||
</TableCell>
|
||||
|
|
@ -256,7 +216,8 @@ function FileRow({file}) {
|
|||
<center><FileIcon file={file} size='large'/></center>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<PreviewLink file={file}>{textEllipsis(file.title)}</PreviewLink>
|
||||
<FileRowTagIcon file={file}/>
|
||||
<PreviewLink file={file}>{textEllipsis(file.title || file.name || file.stem)}</PreviewLink>
|
||||
</TableCell>
|
||||
</React.Fragment>
|
||||
}
|
||||
|
|
@ -397,7 +358,7 @@ export function FilesView({
|
|||
}
|
||||
|
||||
export function TagsFilesGroupDropdown({onChange}) {
|
||||
// Creates a dropdown that the User can use to manipulate the tag query.
|
||||
// Creates dropdown that the User can use to manipulate the tag query.
|
||||
const {searchParams, updateQuery} = useQuery();
|
||||
const activeTag = searchParams.get('tag');
|
||||
const {tags} = React.useContext(TagsContext);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ const links = [
|
|||
{text: 'Map', to: '/map', key: 'map'},
|
||||
{text: 'Files', to: '/files', key: 'files'},
|
||||
{text: 'Inventory', to: '/inventory', key: 'inventory'},
|
||||
{text: 'More', key: 'more',
|
||||
{
|
||||
text: 'More', key: 'more',
|
||||
links: [
|
||||
{to: '/more/otp', text: 'One Time Pad', end: true},
|
||||
{to: '/more/statistics', text: 'Statistics', end: true},
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import {Link, useNavigate, useParams} from "react-router-dom";
|
|||
import _ from "lodash";
|
||||
import {
|
||||
BackButton,
|
||||
encodeMediaPath,
|
||||
humanFileSize,
|
||||
humanNumber,
|
||||
isoDatetimeToString,
|
||||
|
|
@ -28,8 +29,8 @@ function videoFileLink(path, directory = false) {
|
|||
if (path) {
|
||||
const href = directory ?
|
||||
// Add / to end of directory.
|
||||
`${MEDIA_PATH}/${encodeURIComponent(path)}/` :
|
||||
`${MEDIA_PATH}/${encodeURIComponent(path)}`;
|
||||
`${MEDIA_PATH}/${encodeMediaPath(path)}/` :
|
||||
`${MEDIA_PATH}/${encodeMediaPath(path)}`;
|
||||
return <a href={href} target='_blank' rel='noopener noreferrer'>
|
||||
<pre>{path}</pre>
|
||||
</a>
|
||||
|
|
@ -78,11 +79,11 @@ function VideoPage({videoFile, prevFile, nextFile, fetchVideo, ...props}) {
|
|||
navigate(-1);
|
||||
}
|
||||
|
||||
let videoUrl = `${MEDIA_PATH}/${encodeURIComponent(video.video_path)}`;
|
||||
let downloadUrl = `/download/${encodeURIComponent(video.video_path)}`;
|
||||
let videoUrl = `${MEDIA_PATH}/${encodeMediaPath(video.video_path)}`;
|
||||
let downloadUrl = `/download/${encodeMediaPath(video.video_path)}`;
|
||||
|
||||
let posterUrl = video.poster_path ? `${MEDIA_PATH}/${encodeURIComponent(video.poster_path)}` : null;
|
||||
let captionsUrl = video.caption_path ? `${MEDIA_PATH}/${encodeURIComponent(video.caption_path)}` : null;
|
||||
let posterUrl = video.poster_path ? `${MEDIA_PATH}/${encodeMediaPath(video.poster_path)}` : null;
|
||||
let captionsUrl = video.caption_path ? `${MEDIA_PATH}/${encodeMediaPath(video.caption_path)}` : null;
|
||||
let vttCaptions = video.caption_path && video.caption_path.endsWith('.vtt');
|
||||
|
||||
let description = 'No description available.';
|
||||
|
|
|
|||
|
|
@ -2,12 +2,14 @@ import React, {Fragment, useContext, useEffect, useState} from 'react';
|
|||
import {Link, Route, Routes, useParams} from "react-router-dom";
|
||||
import {
|
||||
CardLink,
|
||||
CardPosterLink,
|
||||
CardPoster,
|
||||
cardTitleWrapper,
|
||||
defaultSearchOrder,
|
||||
defaultVideoOrder,
|
||||
Duration,
|
||||
encodeMediaPath,
|
||||
FileIcon,
|
||||
findPosterPath,
|
||||
isoDatetimeToString,
|
||||
mimetypeColor,
|
||||
PageContainer,
|
||||
|
|
@ -37,11 +39,10 @@ import {useChannel, useQuery, useSearchVideos, useVideo, useVideoStatistics} fro
|
|||
import {FileRowTagIcon, FilesView} from "./Files";
|
||||
import Grid from "semantic-ui-react/dist/commonjs/collections/Grid";
|
||||
import Icon from "semantic-ui-react/dist/commonjs/elements/Icon";
|
||||
import {Button, Card, CardIcon, Header, Loader, Placeholder, Segment, Statistic, StatisticGroup} from "./Theme";
|
||||
import {Button, Card, Header, Loader, Placeholder, Segment, Statistic, StatisticGroup} from "./Theme";
|
||||
import {deleteVideos} from "../api";
|
||||
import {ThemeContext} from "../contexts/contexts";
|
||||
import _ from "lodash";
|
||||
import {taggedImageLabel} from "../Tags";
|
||||
|
||||
export function VideoWrapper() {
|
||||
const {videoId} = useParams();
|
||||
|
|
@ -285,7 +286,7 @@ export function VideosRoute(props) {
|
|||
}
|
||||
|
||||
export function VideoCard({file}) {
|
||||
const {video, tags} = file;
|
||||
const {video} = file;
|
||||
const {s} = useContext(ThemeContext);
|
||||
|
||||
let video_url = `/videos/video/${video.id}`;
|
||||
|
|
@ -297,13 +298,8 @@ export function VideoCard({file}) {
|
|||
channel_url = `/videos/channel/${channel.id}/video`;
|
||||
video_url = `/videos/channel/${channel.id}/video/${video.id}`;
|
||||
}
|
||||
const poster_url = video.poster_path ? `/media/${encodeURIComponent(video.poster_path)}` : null;
|
||||
|
||||
let imageLabel = !_.isEmpty(tags) ? taggedImageLabel : null;
|
||||
let poster = <Link to={video_url}><CardIcon><FileIcon file={file}/></CardIcon></Link>;
|
||||
if (poster_url) {
|
||||
poster = <CardPosterLink to={video_url} poster_url={poster_url} imageLabel={imageLabel}/>;
|
||||
}
|
||||
let poster = <CardPoster to={video_url} file={file}/>;
|
||||
|
||||
const color = mimetypeColor(file.mimetype);
|
||||
return <Card color={color}>
|
||||
|
|
@ -333,7 +329,8 @@ export function VideoRowCells({file}) {
|
|||
const {video} = file;
|
||||
|
||||
let video_url = `/videos/video/${video.id}`;
|
||||
const poster_url = video.poster_path ? `/media/${encodeURIComponent(video.poster_path)}` : null;
|
||||
const poster_path = findPosterPath(file);
|
||||
const poster_url = poster_path ? `/media/${encodeMediaPath(poster_path)}` : null;
|
||||
|
||||
let poster;
|
||||
if (poster_url) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue