提交 f76efaf9 编写于 作者: J Jason Park

Remove docs submodule and add a link to it

上级 f6431e7a
[submodule "src/backend/public/algorithms"] [submodule "src/backend/public/algorithms"]
path = src/backend/public/algorithms path = src/backend/public/algorithms
url = git@github.com:algorithm-visualizer/algorithms.git url = git@github.com:algorithm-visualizer/algorithms.git
[submodule "src/backend/public/docs"]
path = src/backend/public/docs
url = git@github.com:algorithm-visualizer/tracers.wiki.git
const proxy = require('http-proxy-middleware'); const proxy = require('http-proxy-middleware');
const { const {
__PROD__,
__DEV__, __DEV__,
proxyPort, proxyPort,
backendBuildPath, backendBuildPath,
......
const express = require('express'); const express = require('express');
const { const {
__PROD__,
__DEV__, __DEV__,
frontendSrcPath, frontendSrcPath,
algorithmApiSrcPath,
wikiApiSrcPath,
frontendBuildPath, frontendBuildPath,
apiEndpoint,
} = require('../environment'); } = require('../environment');
if (__DEV__) { if (__DEV__) {
......
import express from 'express';
import fs from 'fs';
import path from 'path';
import { NotFoundError } from '/common/error';
const router = express.Router();
const getPath = (...args) => path.resolve(__dirname, '..', 'public', 'docs', ...args);
const readDocs = () => {
const createKey = name => name.slice(0, -3);
const list = dirPath => fs.readdirSync(dirPath).filter(filename => /(\.md)$/.test(filename));
return list(getPath()).map(docName => ({
key: createKey(docName),
name: docName,
}));
};
const docs = readDocs();
const getDocs = (req, res, next) => {
res.json({ docs: docs });
};
const getDoc = (req, res, next) => {
const { docKey } = req.params;
const doc = docs.find(doc => doc.key === docKey);
if (!doc) return next(new NotFoundError());
const docPath = getPath(doc.name);
res.sendFile(docPath);
};
router.route('/')
.get(getDocs);
router.route('/:docKey')
.get(getDoc);
export default router;
\ No newline at end of file
export { default as auth } from './auth'; export { default as auth } from './auth';
export { default as categories } from './categories'; export { default as categories } from './categories';
export { default as compilers } from './compilers'; export { default as compilers } from './compilers';
export { default as docs } from './docs';
Subproject commit 08dc9b2369dd65a69fa5e3d9eb0e2c268fdb94fd
...@@ -58,11 +58,6 @@ const CategoryApi = { ...@@ -58,11 +58,6 @@ const CategoryApi = {
getAlgorithm: GET('/categories/:categoryKey/:algorithmKey'), getAlgorithm: GET('/categories/:categoryKey/:algorithmKey'),
}; };
const DocApi = {
getDocs: GET('/docs'),
getDoc: GET('/docs/:docKey'),
};
const GitHubApi = { const GitHubApi = {
auth: token => axios.defaults.headers.common['Authorization'] = `token ${token}`, auth: token => axios.defaults.headers.common['Authorization'] = `token ${token}`,
getProfile: GET('https://api.github.com/user'), getProfile: GET('https://api.github.com/user'),
...@@ -86,7 +81,6 @@ const CompilerApi = { ...@@ -86,7 +81,6 @@ const CompilerApi = {
export { export {
CategoryApi, CategoryApi,
DocApi,
GitHubApi, GitHubApi,
CompilerApi, CompilerApi,
}; };
\ No newline at end of file
...@@ -14,7 +14,6 @@ import { ...@@ -14,7 +14,6 @@ import {
TabContainer, TabContainer,
ToastContainer, ToastContainer,
VisualizationViewer, VisualizationViewer,
WikiViewer,
} from '/components'; } from '/components';
import { CategoryApi, GitHubApi } from '/apis'; import { CategoryApi, GitHubApi } from '/apis';
import { tracerManager } from '/core'; import { tracerManager } from '/core';
...@@ -199,11 +198,10 @@ class App extends React.Component { ...@@ -199,11 +198,10 @@ class App extends React.Component {
visibles={[navigatorOpened, true, true]} visibles={[navigatorOpened, true, true]}
onChangeWeights={weights => this.handleChangeWorkspaceWeights(weights)}> onChangeWeights={weights => this.handleChangeWorkspaceWeights(weights)}>
<Navigator loadAlgorithm={params => this.loadAlgorithm(params)} /> <Navigator loadAlgorithm={params => this.loadAlgorithm(params)} />
<TabContainer titles={['Description', 'Visualization', 'Tracer API']} tabIndex={viewerTabIndex} <TabContainer titles={['Description', 'Visualization']} tabIndex={viewerTabIndex}
onChangeTabIndex={tabIndex => this.handleChangeViewerTabIndex(tabIndex)}> onChangeTabIndex={tabIndex => this.handleChangeViewerTabIndex(tabIndex)}>
<MarkdownViewer source={readmeFile ? readmeFile.content : 'README.md not found'} /> <MarkdownViewer source={readmeFile ? readmeFile.content : 'README.md not found'} />
<VisualizationViewer /> <VisualizationViewer />
<WikiViewer />
</TabContainer> </TabContainer>
<TabContainer titles={[...files.map(file => file.name), <FontAwesomeIcon fixedWidth icon={faPlus} />]} <TabContainer titles={[...files.map(file => file.name), <FontAwesomeIcon fixedWidth icon={faPlus} />]}
tabIndex={editorTabIndex} tabIndex={editorTabIndex}
......
...@@ -3,6 +3,7 @@ import { connect } from 'react-redux'; ...@@ -3,6 +3,7 @@ import { connect } from 'react-redux';
import FontAwesomeIcon from '@fortawesome/react-fontawesome' import FontAwesomeIcon from '@fortawesome/react-fontawesome'
import faSearch from '@fortawesome/fontawesome-free-solid/faSearch'; import faSearch from '@fortawesome/fontawesome-free-solid/faSearch';
import faCode from '@fortawesome/fontawesome-free-solid/faCode'; import faCode from '@fortawesome/fontawesome-free-solid/faCode';
import faBook from '@fortawesome/fontawesome-free-solid/faBook';
import faGithub from '@fortawesome/fontawesome-free-brands/faGithub'; import faGithub from '@fortawesome/fontawesome-free-brands/faGithub';
import { ExpandableListItem, ListItem } from '/components'; import { ExpandableListItem, ListItem } from '/components';
import { classes } from '/common/util'; import { classes } from '/common/util';
...@@ -122,6 +123,8 @@ class Navigator extends React.Component { ...@@ -122,6 +123,8 @@ class Navigator extends React.Component {
<ListItem icon={faCode} label="Scratch Paper" <ListItem icon={faCode} label="Scratch Paper"
onClick={() => this.props.showSuccessToast('Sign In Required')} /> onClick={() => this.props.showSuccessToast('Sign In Required')} />
} }
<ListItem icon={faBook} label="Tracers API"
href="https://github.com/algorithm-visualizer/tracers/wiki" />
<ListItem icon={faGithub} label="Fork me on GitHub" <ListItem icon={faGithub} label="Fork me on GitHub"
href="https://github.com/algorithm-visualizer/algorithm-visualizer" /> href="https://github.com/algorithm-visualizer/algorithm-visualizer" />
</div> </div>
......
import React from 'react';
import { DocApi } from '/apis';
import { MarkdownViewer } from '/components';
import { classes } from '/common/util';
import styles from './stylesheet.scss';
class WikiViewer extends React.Component {
constructor(props) {
super(props);
this.state = {
source: null,
};
}
componentDidMount() {
this.loadMarkdown('Tracer');
}
loadMarkdown(href) {
DocApi.getDoc(href)
.then(source => this.setState({ source }));
}
render() {
const { className, source } = this.state;
return (
<MarkdownViewer className={classes(styles.wiki_viewer, className)} source={source}
onClickLink={href => this.loadMarkdown(href)} />
);
}
}
export default WikiViewer;
@import "~/common/stylesheet/index";
.wiki_viewer {
}
\ No newline at end of file
...@@ -13,4 +13,3 @@ export { default as ResizableContainer } from './ResizableContainer'; ...@@ -13,4 +13,3 @@ export { default as ResizableContainer } from './ResizableContainer';
export { default as TabContainer } from './TabContainer'; export { default as TabContainer } from './TabContainer';
export { default as ToastContainer } from './ToastContainer'; export { default as ToastContainer } from './ToastContainer';
export { default as VisualizationViewer } from './VisualizationViewer'; export { default as VisualizationViewer } from './VisualizationViewer';
export { default as WikiViewer } from './WikiViewer';
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册