Spaces:
Sleeping
Sleeping
File size: 3,384 Bytes
d7e58f0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
/**
* Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
const React = require('react');
const fs = require('fs-extra');
const path = require('path');
const CWD = process.cwd();
const CompLibrary = require(`${CWD}/node_modules/docusaurus/lib/core/CompLibrary.js`);
const Container = CompLibrary.Container;
const TutorialSidebar = require(`${CWD}/core/TutorialSidebar.js`);
function renderDownloadIcon() {
return (
<svg
aria-hidden="true"
focusable="false"
data-prefix="fas"
data-icon="file-download"
className="svg-inline--fa fa-file-download fa-w-12"
role="img"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 384 512">
<path
fill="currentColor"
d="M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm76.45 211.36l-96.42 95.7c-6.65 6.61-17.39 6.61-24.04 0l-96.42-95.7C73.42 337.29 80.54 320 94.82 320H160v-80c0-8.84 7.16-16 16-16h32c8.84 0 16 7.16 16 16v80h65.18c14.28 0 21.4 17.29 11.27 27.36zM377 105L279.1 7c-4.5-4.5-10.6-7-17-7H256v128h128v-6.1c0-6.3-2.5-12.4-7-16.9z"
/>
</svg>
);
}
class Tutorial extends React.Component {
render() {
const {baseUrl, tutorialID} = this.props;
const htmlFile = `${CWD}/_tutorials/${tutorialID}.html`;
const normalizedHtmlFile = path.normalize(htmlFile);
return (
<div className="docMainWrapper wrapper">
<TutorialSidebar currentTutorialID={tutorialID} />
<Container className="mainContainer">
<div className="tutorialButtonsWrapper">
<div className="tutorialButtonWrapper buttonWrapper">
<a
className="tutorialButton button"
download
href={`https://colab.research.google.com/github/facebookresearch/pytorch3d/blob/stable/docs/tutorials/${tutorialID}.ipynb`}
target="_blank">
<img
className="colabButton"
align="left"
src={`${baseUrl}img/colab_icon.png`}
/>
{'Run in Google Colab'}
</a>
</div>
<div className="tutorialButtonWrapper buttonWrapper">
<a
className="tutorialButton button"
download
href={`${baseUrl}files/${tutorialID}.ipynb`}
target="_blank">
{renderDownloadIcon()}
{'Download Tutorial Jupyter Notebook'}
</a>
</div>
<div className="tutorialButtonWrapper buttonWrapper">
<a
className="tutorialButton button"
download
href={`${baseUrl}files/${tutorialID}.py`}
target="_blank">
{renderDownloadIcon()}
{'Download Tutorial Source Code'}
</a>
</div>
</div>
<div
className="tutorialBody"
dangerouslySetInnerHTML={{
__html: fs.readFileSync(normalizedHtmlFile, {encoding: 'utf8'}),
}}
/>
</Container>
</div>
);
}
}
module.exports = Tutorial;
|