forked from jakekara/critical-edition-viewer
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from yale-fortunoff/FOR-10-add-aviary-video-blocks
FOR-10 add aviary video blocks
- Loading branch information
Showing
16 changed files
with
2,284 additions
and
2,079 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[build] | ||
# Directory to change to before starting a build. | ||
# This is where we will look for package.json/.nvmrc/etc. | ||
# If not set, defaults to the root directory. | ||
# base = "project/" | ||
|
||
# Directory that contains the deploy-ready HTML files and | ||
# assets generated by the build. This is relative to the base | ||
# directory if one has been set, or the root directory if | ||
# a base has not been set. This sample publishes the directory | ||
# located at the absolute path "root/project/build-output" | ||
publish = "build/" | ||
|
||
# Default build command. | ||
command = "npm run fetch-test-data && npm run build" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from hashlib import md5 | ||
import os | ||
import glob | ||
|
||
|
||
dirs = ["./build-2.1.0", "./build-2.0.0"] | ||
base = dirs[0] | ||
dir_b = dirs[1] | ||
files = glob.glob(f"{base}/**", recursive=True) | ||
|
||
def compare(fname, base_dir, dir_b): | ||
match_part = fname.replace(base_dir, "") | ||
|
||
# print(fname, "-", base_dir, "=", match_part) | ||
# file_b = os.path.join(dir_b, match_part) | ||
file_b = f"{dir_b}/{match_part}" | ||
|
||
if not os.path.exists(file_b): | ||
print(f"file not found: {file_b}") | ||
return | ||
# else: | ||
# print(f"file found: {file_b}") | ||
# print(fname, file_b) | ||
|
||
if not os.path.isfile(fname): | ||
return | ||
|
||
left_hash = md5(open(fname, "rb").read()).hexdigest() | ||
right_hash = md5(open(file_b, "rb").read()).hexdigest() | ||
|
||
if left_hash == right_hash: | ||
print(f"files match {fname} {file_b}") | ||
else: | ||
print(f"files don't match: {fname} {file_b}") | ||
|
||
for file in files: | ||
compare(file,base, dir_b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/CriticalEditionData/validators/validAviaryVideoBlockData.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { AviaryVideoBlockData } from '..'; | ||
import DebugLogger from '../../utils/DebugLogger'; | ||
import ValidatorFunction from './ValidatorFunction'; | ||
|
||
const logger = new DebugLogger('validImageBlockData').hush(); | ||
const validAviaryVideoBlockData: ValidatorFunction<AviaryVideoBlockData> = (data: any) => { | ||
|
||
logger.log('Validating video data ', data); | ||
logger.warn('Video data validation not implemented'); | ||
// TODO - make sure there's a src at least | ||
|
||
// if (data.embedCode && !(typeof data.embedCode === "string")) { throw new Error("FootnoteParagraphBlockData requires .embedCode to be undefined or String") } | ||
// if (!data.id || !(typeof data.id === "string")) { throw new Error("FootnoteParagraphBlockData requires .id String") } | ||
// if (!data.label || !(typeof data.label === "string")) { throw new Error("FootnoteParagraphBlockData requires .label String") } | ||
|
||
return data as AviaryVideoBlockData; | ||
}; | ||
|
||
export default validAviaryVideoBlockData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/components/Viewer/ContentBody/Block/AviaryVideoBlock/AviaryVideoBlock.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
.Aviary { | ||
width: 100%; | ||
/* use width as a way to constrain the height, which is | ||
determined using padding in the AviaryIframeContainer | ||
defined below */ | ||
max-width: 150vh; | ||
} | ||
|
||
.AviaryIframeContainer { | ||
background-color: lightgray; | ||
padding:56.25% 0 0 0; | ||
position:relative; | ||
overflow: hidden; | ||
width: 100%; | ||
} | ||
|
||
.Aviary iframe { | ||
position:absolute; | ||
top:0; | ||
left:0; | ||
bottom: 0; | ||
right: 0; | ||
width:100%; | ||
height:100%; | ||
} |
30 changes: 30 additions & 0 deletions
30
src/components/Viewer/ContentBody/Block/AviaryVideoBlock/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
import { AviaryVideoBlockData } from '../../../../../CriticalEditionData'; | ||
import { InlineEmbed } from '../InlineEmbed'; | ||
import styles from './AviaryVideoBlock.module.css'; | ||
|
||
export interface AviaryVideoBlockProps { | ||
data: AviaryVideoBlockData | ||
} | ||
|
||
export function AviaryVideoBlock(props: AviaryVideoBlockProps) { | ||
const { | ||
data: { ead_id, tape, start_time, end_time, caption }, | ||
} = props; | ||
|
||
const component = (<div className={styles.Aviary}> | ||
<div className={styles.AviaryIframeContainer}> | ||
<iframe src={`https://fortunoff.aviaryplatform.com/c/${ead_id}/${tape}/?t=${start_time}&e=${end_time}&embed=true&media_file=true`} allow="fullscreen" frameborder="0"></iframe> | ||
</div> | ||
</div>) | ||
|
||
console.log("Rendering video block", props.data) | ||
|
||
return ( | ||
<InlineEmbed | ||
embedComponent={component} | ||
data={{caption}} | ||
/> | ||
) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
import React from 'react'; | ||
import { ImageBlockData } from '../../../../../CriticalEditionData'; | ||
import { InlineEmbed } from '../InlineEmbed'; | ||
import styles from './Image.module.css'; | ||
|
||
export interface ImageProps { | ||
data: ImageBlockData; | ||
} | ||
|
||
export function Image(props: ImageProps) { | ||
const { | ||
data: { src, srcset, sizes, caption }, | ||
} = props; | ||
|
||
const component = (<div className={styles.Image}> | ||
<img srcSet={srcset} sizes={sizes} src={src} alt={caption || ''} /> | ||
</div>) | ||
return ( | ||
<div className={`sans-copy-ff ${styles.Image}`}> | ||
<div className={styles.ImgContainer}> | ||
<img srcSet={srcset} sizes={sizes} src={src} alt={caption || ''} /> | ||
</div> | ||
<div | ||
// eslint-disable-next-line react/no-danger | ||
dangerouslySetInnerHTML={{ __html: caption || '' }} | ||
className={styles.Caption} | ||
<InlineEmbed | ||
embedComponent={component} | ||
data={{caption}} | ||
/> | ||
</div> | ||
); | ||
) | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
src/components/Viewer/ContentBody/Block/InlineEmbed/InlineEmbed.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
.InlineEmbed { | ||
padding: 10px; | ||
} | ||
|
||
.InlineEmbed { | ||
max-width: 100%; | ||
height: 100%; | ||
overflow: hidden; | ||
} | ||
|
||
.EmbedContainer { | ||
display: flex; | ||
justify-content: center; | ||
} | ||
|
||
.Caption { | ||
margin-top: 13px; | ||
font-size: 15px; | ||
line-height: 2em; | ||
color: #333; | ||
} |
28 changes: 28 additions & 0 deletions
28
src/components/Viewer/ContentBody/Block/InlineEmbed/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React, { ComponentType } from 'react'; | ||
import { InlineEmbedBlockData } from '../../../../../CriticalEditionData'; | ||
import styles from './InlineEmbed.module.css'; | ||
|
||
export interface InlineEmbedProps { | ||
data: InlineEmbedBlockData | ||
embedComponent: JSX.Element | ||
} | ||
|
||
export function InlineEmbed(props: InlineEmbedProps) { | ||
const { | ||
embedComponent: EmbedComponent, | ||
data: { caption }, | ||
} = props; | ||
|
||
return ( | ||
<div className={`sans-copy-ff ${styles.InlineEmbed}`}> | ||
<div className={styles.EmbedContainer}> | ||
{EmbedComponent} | ||
</div> | ||
<div | ||
// eslint-disable-next-line react/no-danger | ||
dangerouslySetInnerHTML={{ __html: caption || '' }} | ||
className={styles.Caption} | ||
/> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.