-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into tkd-fix-Signing
- Loading branch information
Showing
113 changed files
with
2,495 additions
and
2,677 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,27 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { secondsToHHMMSS } from '../utils/playerUtils'; | ||
|
||
import { | ||
StyledCaption, | ||
MetaData, | ||
Text | ||
} from '../stylesheets/application/ProjectShow/Caption'; | ||
|
||
export default function Caption({ caption, contentType, figureIndex, isLast }) { | ||
return ( | ||
<StyledCaption isLast={isLast}> | ||
<MetaData> | ||
{contentType}#{figureIndex + 1}: {secondsToHHMMSS(caption.start_sec)} | ||
</MetaData> | ||
<Text>{caption.text}</Text> | ||
</StyledCaption> | ||
); | ||
} | ||
|
||
Caption.propTypes = { | ||
caption: PropTypes.object, | ||
contentType: PropTypes.string, | ||
figureIndex: PropTypes.number, | ||
isLast: PropTypes.bool | ||
}; |
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,97 @@ | ||
const{ ipcRenderer } = require('electron'); | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import JSZip from 'jszip'; | ||
import JSZipUtils from 'jszip-utils'; | ||
|
||
import { assetsPath } from '../utils/assetsUtils' | ||
import { getVttUrl } from '../utils/playerUtils' | ||
|
||
import Caption from './Caption' | ||
|
||
import { | ||
StyledCaptionList, | ||
StyledList, | ||
StyledDownloadButton, | ||
} from '../stylesheets/application/ProjectShow/CaptionList'; | ||
|
||
import { | ||
StyledHead | ||
} from '../stylesheets/application/ProjectShow/StyledProjectDetail'; | ||
|
||
|
||
const downloadIcon = `${assetsPath}/images/download.svg`; | ||
|
||
const downloadFile = async (zip, url, index) => { | ||
return new Promise((resolve, reject) => { | ||
JSZipUtils.getBinaryContent(url, (error, data) => { | ||
if(error) reject(error); | ||
zip.file(`${index}.vtt`, data, { binary: true }); | ||
resolve(data); | ||
}) | ||
}) | ||
}; | ||
|
||
const downloadFiles = async (zip, vttList) => { | ||
return Promise.all(vttList.map((vtt) => downloadFile(zip, vtt.url, vtt.index))); | ||
}; | ||
|
||
const createVttList = (figures) => { | ||
return figures.map((figure, index) => ( | ||
{ | ||
url: getVttUrl(figure.captions, 'captions'), | ||
index: index + 1 | ||
} | ||
)); | ||
}; | ||
|
||
const createZipURL = async (figures) => { | ||
const vttList = createVttList(figures); | ||
const zip = new JSZip(); | ||
await downloadFiles(zip, vttList); | ||
const blob = await zip.generateAsync({ type: 'blob' }); | ||
return URL.createObjectURL(blob); | ||
} | ||
|
||
|
||
export default function CaptionList({ figures, contentType }) { | ||
return ( | ||
<StyledCaptionList> | ||
<StyledHead> | ||
Captions | ||
<StyledDownloadButton src={downloadIcon} onClick={async () => { | ||
const url = await createZipURL(figures); | ||
ipcRenderer.send('download', { | ||
url: url, | ||
properties: { saveAs: true } | ||
}) | ||
}} /> | ||
</StyledHead> | ||
<StyledList> | ||
{ | ||
figures.map((figure, figureIndex) => ( | ||
{ | ||
entities: figure.captions.sort((a, b) => (a.start_sec - b.start_sec)), | ||
figureIndex | ||
} | ||
)).map((captions) => { | ||
return captions.entities.map((caption, index) => ( | ||
<Caption | ||
caption={caption} | ||
figureIndex={captions.figureIndex} | ||
isLast={(index === captions.entities.length - 1)} | ||
contentType={contentType} | ||
key={index} | ||
/> | ||
)) | ||
}) | ||
} | ||
</StyledList> | ||
</StyledCaptionList> | ||
); | ||
} | ||
|
||
CaptionList.propTypes = { | ||
figures: PropTypes.array, | ||
contentType: PropTypes.string | ||
}; |
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
Oops, something went wrong.