提交 3e5a2f02 编写于 作者: J Jason Park

Add facebook share and add todo's

上级 b44161ee
...@@ -25,6 +25,7 @@ const getJsWorker = (req, res, next) => { ...@@ -25,6 +25,7 @@ const getJsWorker = (req, res, next) => {
const execute = (imageId, srcPath, command, ErrorClass) => new Promise((resolve, reject) => { const execute = (imageId, srcPath, command, ErrorClass) => new Promise((resolve, reject) => {
const libPath = getLibPath(); const libPath = getLibPath();
// TODO: memory limit + time limit + space limit?
const dockerCommand = `docker run --rm -w=/usr/judge -t -v=${libPath}:/usr/bin/tracers:ro -v=${srcPath}:/usr/judge:rw -e MAX_TRACES=1000000 -e MAX_TRACERS=100 ${imageId}`; const dockerCommand = `docker run --rm -w=/usr/judge -t -v=${libPath}:/usr/bin/tracers:ro -v=${srcPath}:/usr/judge:rw -e MAX_TRACES=1000000 -e MAX_TRACERS=100 ${imageId}`;
child_process.exec(`${dockerCommand} ${command}`, (error, stdout, stderr) => { child_process.exec(`${dockerCommand} ${command}`, (error, stdout, stderr) => {
if (error) return reject(new ErrorClass(stdout)); if (error) return reject(new ErrorClass(stdout));
......
...@@ -127,6 +127,7 @@ class App extends React.Component { ...@@ -127,6 +127,7 @@ class App extends React.Component {
.catch(this.props.showErrorToast); .catch(this.props.showErrorToast);
} }
// TODO: warn before loading or quiting if not saved
loadAlgorithm({ categoryKey, algorithmKey, gistId }) { loadAlgorithm({ categoryKey, algorithmKey, gistId }) {
const { ext } = this.props.env; const { ext } = this.props.env;
let fetchPromise = null; let fetchPromise = null;
...@@ -142,7 +143,7 @@ class App extends React.Component { ...@@ -142,7 +143,7 @@ class App extends React.Component {
contributors: undefined, contributors: undefined,
}, { }, {
name: `code.${ext}`, name: `code.${ext}`,
content: '', content: '', // TODO: put import statements as default
contributors: undefined, contributors: undefined,
}], }],
}); });
......
...@@ -4,7 +4,6 @@ import InputRange from 'react-input-range'; ...@@ -4,7 +4,6 @@ import InputRange from 'react-input-range';
import AutosizeInput from 'react-input-autosize'; import AutosizeInput from 'react-input-autosize';
import screenfull from 'screenfull'; import screenfull from 'screenfull';
import Promise from 'bluebird'; import Promise from 'bluebird';
import { withRouter } from 'react-router-dom';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import faAngleRight from '@fortawesome/fontawesome-free-solid/faAngleRight'; import faAngleRight from '@fortawesome/fontawesome-free-solid/faAngleRight';
import faCaretDown from '@fortawesome/fontawesome-free-solid/faCaretDown'; import faCaretDown from '@fortawesome/fontawesome-free-solid/faCaretDown';
...@@ -16,7 +15,7 @@ import faExpandArrowsAlt from '@fortawesome/fontawesome-free-solid/faExpandArrow ...@@ -16,7 +15,7 @@ import faExpandArrowsAlt from '@fortawesome/fontawesome-free-solid/faExpandArrow
import faGithub from '@fortawesome/fontawesome-free-brands/faGithub'; import faGithub from '@fortawesome/fontawesome-free-brands/faGithub';
import faTrashAlt from '@fortawesome/fontawesome-free-solid/faTrashAlt'; import faTrashAlt from '@fortawesome/fontawesome-free-solid/faTrashAlt';
import faSave from '@fortawesome/fontawesome-free-solid/faSave'; import faSave from '@fortawesome/fontawesome-free-solid/faSave';
import faShare from '@fortawesome/fontawesome-free-solid/faShare'; import faFacebook from '@fortawesome/fontawesome-free-brands/faFacebook';
import faStar from '@fortawesome/fontawesome-free-solid/faStar'; import faStar from '@fortawesome/fontawesome-free-solid/faStar';
import { GitHubApi } from '/apis'; import { GitHubApi } from '/apis';
import { classes, refineGist } from '/common/util'; import { classes, refineGist } from '/common/util';
...@@ -26,7 +25,6 @@ import { Button, Ellipsis, ListItem } from '/components'; ...@@ -26,7 +25,6 @@ import { Button, Ellipsis, ListItem } from '/components';
import { tracerManager } from '/core'; import { tracerManager } from '/core';
import styles from './stylesheet.scss'; import styles from './stylesheet.scss';
@withRouter
@connect(({ current, env }) => ({ current, env }), actions) @connect(({ current, env }) => ({ current, env }), actions)
class Header extends React.Component { class Header extends React.Component {
constructor(props) { constructor(props) {
...@@ -86,6 +84,7 @@ class Header extends React.Component { ...@@ -86,6 +84,7 @@ class Header extends React.Component {
.then(algorithm => this.props.setCurrent(categoryKey, algorithmKey, algorithm.gistId, algorithm.titles, algorithm.files)) .then(algorithm => this.props.setCurrent(categoryKey, algorithmKey, algorithm.gistId, algorithm.titles, algorithm.files))
.then(this.props.loadScratchPapers) .then(this.props.loadScratchPapers)
.catch(this.props.showErrorToast); .catch(this.props.showErrorToast);
// TODO: create a new gist in case of permission error
} }
deleteGist() { deleteGist() {
...@@ -127,7 +126,8 @@ class Header extends React.Component { ...@@ -127,7 +126,8 @@ class Header extends React.Component {
onClick={() => this.saveGist()}>Save</Button> onClick={() => this.saveGist()}>Save</Button>
<Button icon={faTrashAlt} primary disabled={!gistId} onClick={() => this.deleteGist()} <Button icon={faTrashAlt} primary disabled={!gistId} onClick={() => this.deleteGist()}
confirmNeeded>Delete</Button> confirmNeeded>Delete</Button>
<Button icon={faShare} primary disabled={gistId === 'new'} onClick={() => this.shareLink()}>Share</Button> <Button icon={faFacebook} primary disabled={gistId === 'new'}
href={`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(window.location.href)}`}>Share</Button>
<Button icon={faExpandArrowsAlt} primary <Button icon={faExpandArrowsAlt} primary
onClick={() => this.handleClickFullScreen()}>Fullscreen</Button> onClick={() => this.handleClickFullScreen()}>Fullscreen</Button>
</div> </div>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册