mirror of
https://github.com/bellingcat/ukraine-timemap.git
synced 2026-06-13 05:48:36 +03:00
enables inline PDFs for sources
This commit is contained in:
@@ -153,17 +153,24 @@ export function selectTypeFromPath (path) {
|
|||||||
return { type, path }
|
return { type, path }
|
||||||
}
|
}
|
||||||
|
|
||||||
export function selectTypeFromPathWithPoster (path, poster) {
|
export function typeForPath (path) {
|
||||||
let type
|
let type
|
||||||
|
path = path.trim()
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case /\.(png|jpg)$/.test(path):
|
case /\.((png)|(jpg))$/.test(path):
|
||||||
type = 'Image'; break
|
type = 'Image'; break
|
||||||
case /\.(mp4)$/.test(path):
|
case /\.(mp4)$/.test(path):
|
||||||
type = 'Video'; break
|
type = 'Video'; break
|
||||||
case /\.(md)$/.test(path):
|
case /\.(md)$/.test(path):
|
||||||
type = 'Text'; break
|
type = 'Text'; break
|
||||||
|
case /\.(pdf)$/.test(path):
|
||||||
|
type = 'Document'; break
|
||||||
default:
|
default:
|
||||||
type = 'Unknown'; break
|
type = 'Unknown'; break
|
||||||
}
|
}
|
||||||
return { type, path, poster }
|
return type
|
||||||
|
}
|
||||||
|
|
||||||
|
export function selectTypeFromPathWithPoster (path, poster) {
|
||||||
|
return { type: typeForPath(path), path, poster }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export default ({ media, viewIdx, translations, switchLanguage, langIdx }) => {
|
|||||||
const shiftW = el ? el.getBoundingClientRect().width : 0
|
const shiftW = el ? el.getBoundingClientRect().width : 0
|
||||||
|
|
||||||
function renderMedia (media) {
|
function renderMedia (media) {
|
||||||
const { path, type, poster } = media
|
let { path, type, poster } = media
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'Image':
|
case 'Image':
|
||||||
return (
|
return (
|
||||||
@@ -53,6 +53,10 @@ export default ({ media, viewIdx, translations, switchLanguage, langIdx }) => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
case 'Document':
|
||||||
|
return (
|
||||||
|
<iframe className='source-document' src={path} />
|
||||||
|
)
|
||||||
default:
|
default:
|
||||||
return (
|
return (
|
||||||
<NoSource failedUrls={[`Application does not support extension: ${path.split('.')[1]}`]} />
|
<NoSource failedUrls={[`Application does not support extension: ${path.split('.')[1]}`]} />
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import Img from 'react-image'
|
import Img from 'react-image'
|
||||||
|
|
||||||
import Spinner from '../Spinner'
|
import Spinner from '../Spinner'
|
||||||
|
import { typeForPath } from '../../../common/utilities'
|
||||||
|
|
||||||
const CardSource = ({ source, isLoading, onClickHandler }) => {
|
const CardSource = ({ source, isLoading, onClickHandler }) => {
|
||||||
function renderIconText (type) {
|
function renderIconText (type) {
|
||||||
@@ -21,6 +21,8 @@ const CardSource = ({ source, isLoading, onClickHandler }) => {
|
|||||||
return 'photo'
|
return 'photo'
|
||||||
case 'Photobook':
|
case 'Photobook':
|
||||||
return 'photo_album'
|
return 'photo_album'
|
||||||
|
case 'Document':
|
||||||
|
return 'picture_as_pdf'
|
||||||
default:
|
default:
|
||||||
return 'help'
|
return 'help'
|
||||||
}
|
}
|
||||||
@@ -43,6 +45,9 @@ const CardSource = ({ source, isLoading, onClickHandler }) => {
|
|||||||
thumbnail = imgs.length > 0 ? imgs[0] : null
|
thumbnail = imgs.length > 0 ? imgs[0] : null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (source.type === '' && source.paths.length >= 1) {
|
||||||
|
source.type = typeForPath(source.paths[0])
|
||||||
|
}
|
||||||
const fallbackIcon = (
|
const fallbackIcon = (
|
||||||
<i className='material-icons source-icon'>
|
<i className='material-icons source-icon'>
|
||||||
{renderIconText(source.type)}
|
{renderIconText(source.type)}
|
||||||
|
|||||||
@@ -347,6 +347,11 @@ $overlay-bg: rgba(239,239,239,0.9);
|
|||||||
height: 400px;
|
height: 400px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.source-document {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 80vh;
|
||||||
|
}
|
||||||
|
|
||||||
.video-react .video-react-progress-control {
|
.video-react .video-react-progress-control {
|
||||||
align-self: center;
|
align-self: center;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user