Remove semicolons

main
Andrew 7 years ago committed by Jake Dexheimer
parent 7e69ca2897
commit 3cbcb49c27

@ -1,4 +1,5 @@
{
singleQuote: true,
printWidth: 100
printWidth: 100,
semi: false
}

@ -1,5 +1,5 @@
import React from 'react';
import { COLORS } from '../lib/constants';
import React from 'react'
import { COLORS } from '../lib/constants'
export default props => (
<button
@ -30,4 +30,4 @@ export default props => (
}
`}</style>
</button>
);
)

@ -1,14 +1,14 @@
import { EOL } from 'os';
import * as hljs from 'highlight.js';
import React from 'react';
import domtoimage from 'dom-to-image';
import CodeMirror from 'react-codemirror';
import Spinner from 'react-spinner';
import toHash from 'tohash';
import WindowControls from '../components/WindowControls';
import { COLORS, DEFAULT_LANGUAGE, LANGUAGES } from '../lib/constants';
const LANGUAGE_HASH = toHash(LANGUAGES, 'module');
import { EOL } from 'os'
import * as hljs from 'highlight.js'
import React from 'react'
import domtoimage from 'dom-to-image'
import CodeMirror from 'react-codemirror'
import Spinner from 'react-spinner'
import toHash from 'tohash'
import WindowControls from '../components/WindowControls'
import { COLORS, DEFAULT_LANGUAGE, LANGUAGES } from '../lib/constants'
const LANGUAGE_HASH = toHash(LANGUAGES, 'module')
const DEFAULT_SETTINGS = {
paddingVertical: '50px',
@ -18,56 +18,56 @@ const DEFAULT_SETTINGS = {
background: '#fed0ec',
theme: 'seti',
language: DEFAULT_LANGUAGE
};
}
class Carbon extends React.Component {
constructor(props) {
super(props);
super(props)
this.state = {
loading: true,
language: props.config.language
};
}
this.handleLanguageChange = this.handleLanguageChange.bind(this);
this.codeUpdated = this.codeUpdated.bind(this);
this.handleLanguageChange = this.handleLanguageChange.bind(this)
this.codeUpdated = this.codeUpdated.bind(this)
}
componentDidMount() {
this.setState({
loading: false
});
})
this.handleLanguageChange(this.props.children);
this.handleLanguageChange(this.props.children)
}
componentWillReceiveProps(newProps) {
this.handleLanguageChange(newProps.children, { customProps: newProps });
this.handleLanguageChange(newProps.children, { customProps: newProps })
}
codeUpdated(newCode) {
this.handleLanguageChange(newCode);
this.props.updateCode(newCode);
this.handleLanguageChange(newCode)
this.props.updateCode(newCode)
}
handleLanguageChange(newCode, config) {
const props = (config && config.customProps) || this.props;
const props = (config && config.customProps) || this.props
if (props.config.language === 'auto') {
// try to set the language
const detectedLanguage = hljs.highlightAuto(newCode).language;
const languageModule = LANGUAGE_HASH[detectedLanguage];
const detectedLanguage = hljs.highlightAuto(newCode).language
const languageModule = LANGUAGE_HASH[detectedLanguage]
if (languageModule) {
this.setState({ language: languageModule.module });
this.setState({ language: languageModule.module })
}
} else {
this.setState({ language: props.config.language });
this.setState({ language: props.config.language })
}
}
render() {
const config = Object.assign(DEFAULT_SETTINGS, this.props.config);
const config = Object.assign(DEFAULT_SETTINGS, this.props.config)
const options = {
lineNumbers: false,
@ -76,13 +76,13 @@ class Carbon extends React.Component {
scrollBarStyle: null,
viewportMargin: Infinity,
lineWrapping: true
};
}
// create styles
const containerStyle = {
background: config.background,
padding: `${config.paddingVertical} ${config.paddingHorizontal}`
};
}
// set content to spinner if loading, else editor
let content = (
@ -96,7 +96,7 @@ class Carbon extends React.Component {
`}
</style>
</div>
);
)
if (this.state.loading === false) {
content = (
<div id="container" style={containerStyle}>
@ -150,7 +150,7 @@ class Carbon extends React.Component {
}
`}</style>
</div>
);
)
}
return (
@ -165,8 +165,8 @@ class Carbon extends React.Component {
}
`}</style>
</div>
);
)
}
}
export default Carbon;
export default Carbon

@ -1,27 +1,27 @@
import React from 'react';
import enhanceWithClickOutside from 'react-click-outside';
import { TwitterPicker } from 'react-color';
import WindowPointer from './WindowPointer';
import { COLORS } from '../lib/constants';
import React from 'react'
import enhanceWithClickOutside from 'react-click-outside'
import { TwitterPicker } from 'react-color'
import WindowPointer from './WindowPointer'
import { COLORS } from '../lib/constants'
class ColorPicker extends React.Component {
constructor() {
super();
this.state = { isVisible: false };
this.toggle = this.toggle.bind(this);
this.handlePickColor = this.handlePickColor.bind(this);
super()
this.state = { isVisible: false }
this.toggle = this.toggle.bind(this)
this.handlePickColor = this.handlePickColor.bind(this)
}
toggle() {
this.setState({ isVisible: !this.state.isVisible });
this.setState({ isVisible: !this.state.isVisible })
}
handleClickOutside() {
this.setState({ isVisible: false });
this.setState({ isVisible: false })
}
handlePickColor(color) {
this.props.onChange(color.hex);
this.props.onChange(color.hex)
}
render() {
@ -104,8 +104,8 @@ class ColorPicker extends React.Component {
}
`}</style>
</div>
);
)
}
}
export default enhanceWithClickOutside(ColorPicker);
export default enhanceWithClickOutside(ColorPicker)

@ -1,33 +1,33 @@
import React from 'react';
import enhanceWithClickOutside from 'react-click-outside';
import ArrowDown from './svg/Arrowdown';
import Checkmark from './svg/Checkmark';
import { COLORS } from '../lib/constants';
import React from 'react'
import enhanceWithClickOutside from 'react-click-outside'
import ArrowDown from './svg/Arrowdown'
import Checkmark from './svg/Checkmark'
import { COLORS } from '../lib/constants'
class Dropdown extends React.Component {
constructor(props) {
super();
super()
this.state = {
isVisible: false,
selected: props.selected || props.list[0]
};
this.select = this.select.bind(this);
this.toggle = this.toggle.bind(this);
}
this.select = this.select.bind(this)
this.toggle = this.toggle.bind(this)
}
select(item) {
if (this.state.selected !== item) {
this.props.onChange(item);
this.setState({ selected: item });
this.props.onChange(item)
this.setState({ selected: item })
}
}
toggle() {
this.setState({ isVisible: !this.state.isVisible });
this.setState({ isVisible: !this.state.isVisible })
}
handleClickOutside() {
this.setState({ isVisible: false });
this.setState({ isVisible: false })
}
renderListItems() {
@ -52,7 +52,7 @@ class Dropdown extends React.Component {
}
`}</style>
</div>
));
))
}
render() {
@ -60,7 +60,7 @@ class Dropdown extends React.Component {
const MIN_WIDTH = this.props.list.reduce(
(max, { name }) => (name.length > max ? name.length : max),
0
);
)
return (
<div
@ -121,8 +121,8 @@ class Dropdown extends React.Component {
}
`}</style>
</div>
);
)
}
}
export default enhanceWithClickOutside(Dropdown);
export default enhanceWithClickOutside(Dropdown)

@ -1,6 +1,6 @@
import React from 'react';
import Link from 'next/link';
import { COLORS } from '../lib/constants';
import React from 'react'
import Link from 'next/link'
import { COLORS } from '../lib/constants'
const Footer = props => (
<div className="mt3">
@ -47,6 +47,6 @@ const Footer = props => (
}
`}</style>
</div>
);
)
export default Footer;
export default Footer

@ -1,5 +1,5 @@
import React from 'react';
import Logo from './svg/Logo';
import React from 'react'
import Logo from './svg/Logo'
const Header = ({ enableHeroText }) => (
<div className="header mb4">
@ -34,6 +34,6 @@ const Header = ({ enableHeroText }) => (
}
`}</style>
</div>
);
)
export default Header;
export default Header

@ -1,5 +1,5 @@
import React from 'react';
import { Controls, ControlsBW } from './svg/Controls';
import React from 'react'
import { Controls, ControlsBW } from './svg/Controls'
export default ({ language }) => (
<div className="language">
@ -19,4 +19,4 @@ export default ({ language }) => (
`}
</style>
</div>
);
)

@ -1,7 +1,7 @@
import Head from 'next/head';
import { THEMES_ARRAY, COLORS } from '../lib/constants';
import Reset from './style/Reset';
import Typography from './style/Typography';
import Head from 'next/head'
import { THEMES_ARRAY, COLORS } from '../lib/constants'
import Reset from './style/Reset'
import Typography from './style/Typography'
export default () => (
<div className="meta">
@ -52,4 +52,4 @@ export default () => (
}
`}</style>
</div>
);
)

@ -22,6 +22,6 @@ const Overlay = props => (
}
`}</style>
</div>
);
)
export default Overlay;
export default Overlay

@ -1,7 +1,7 @@
import React from 'react';
import Meta from './Meta';
import Header from './Header';
import Footer from './Footer';
import React from 'react'
import Meta from './Meta'
import Header from './Header'
import Footer from './Footer'
export default ({ children, enableHeroText }) => (
<div className="main mt4 mb4">
@ -20,4 +20,4 @@ export default ({ children, enableHeroText }) => (
}
`}</style>
</div>
);
)

@ -1,27 +1,27 @@
import React from 'react';
import enhanceWithClickOutside from 'react-click-outside';
import SettingsIcon from './svg/Settings';
import ThemeSelect from './ThemeSelect';
import Slider from './Slider';
import Toggle from './Toggle';
import WindowPointer from './WindowPointer';
import { COLORS } from '../lib/constants';
import React from 'react'
import enhanceWithClickOutside from 'react-click-outside'
import SettingsIcon from './svg/Settings'
import ThemeSelect from './ThemeSelect'
import Slider from './Slider'
import Toggle from './Toggle'
import WindowPointer from './WindowPointer'
import { COLORS } from '../lib/constants'
class Settings extends React.Component {
constructor(props) {
super();
super()
this.state = {
isVisible: false
};
this.toggle = this.toggle.bind(this);
}
this.toggle = this.toggle.bind(this)
}
toggle() {
this.setState({ isVisible: !this.state.isVisible });
this.setState({ isVisible: !this.state.isVisible })
}
handleClickOutside() {
this.setState({ isVisible: false });
this.setState({ isVisible: false })
}
render() {
@ -108,8 +108,8 @@ class Settings extends React.Component {
}
`}</style>
</div>
);
)
}
}
export default enhanceWithClickOutside(Settings);
export default enhanceWithClickOutside(Settings)

@ -1,21 +1,21 @@
import React from 'react';
import React from 'react'
export default class extends React.Component {
constructor(props) {
super();
this.state = { value: props.initialValue || 0 };
this.handleChange = this.handleChange.bind(this);
super()
this.state = { value: props.initialValue || 0 }
this.handleChange = this.handleChange.bind(this)
}
handleChange(e) {
this.setState({ value: e.target.value }, () => {
this.props.onChange(`${this.state.value}px`);
});
this.props.onChange(`${this.state.value}px`)
})
}
render() {
const minValue = this.props.minValue || 0;
const maxValue = this.props.maxValue || 100;
const minValue = this.props.minValue || 0
const maxValue = this.props.maxValue || 100
return (
<div className="slider">
@ -70,6 +70,6 @@ export default class extends React.Component {
}
`}</style>
</div>
);
)
}
}

@ -1,27 +1,27 @@
import React from 'react';
import { None, BW, Sharp } from './svg/WindowThemes';
import { COLORS } from '../lib/constants';
import React from 'react'
import { None, BW, Sharp } from './svg/WindowThemes'
import { COLORS } from '../lib/constants'
const WINDOW_THEMES_MAP = { none: None, sharp: Sharp, bw: BW };
export const WINDOW_THEMES = Object.keys(WINDOW_THEMES_MAP);
const WINDOW_THEMES_MAP = { none: None, sharp: Sharp, bw: BW }
export const WINDOW_THEMES = Object.keys(WINDOW_THEMES_MAP)
export default class extends React.Component {
constructor(props) {
super();
this.state = { selected: props.selected || WINDOW_THEMES[0] };
this.select = this.select.bind(this);
super()
this.state = { selected: props.selected || WINDOW_THEMES[0] }
this.select = this.select.bind(this)
}
select(theme) {
if (this.state.selected !== theme) {
this.props.onChange(theme);
this.setState({ selected: theme });
this.props.onChange(theme)
this.setState({ selected: theme })
}
}
renderThemes() {
return WINDOW_THEMES.map((theme, i) => {
const Img = WINDOW_THEMES_MAP[theme];
const Img = WINDOW_THEMES_MAP[theme]
return (
<div
className={`theme ${this.state.selected === theme ? 'selected' : ''}`}
@ -45,8 +45,8 @@ export default class extends React.Component {
}
`}</style>
</div>
);
});
)
})
}
render() {
@ -71,6 +71,6 @@ export default class extends React.Component {
}
`}</style>
</div>
);
)
}
}

@ -1,17 +1,17 @@
import React from 'react';
import Checkmark from './svg/Checkmark';
import React from 'react'
import Checkmark from './svg/Checkmark'
export default class extends React.Component {
constructor(props) {
super();
this.state = { isEnabled: props.enabled || false };
this.toggle = this.toggle.bind(this);
super()
this.state = { isEnabled: props.enabled || false }
this.toggle = this.toggle.bind(this)
}
toggle() {
this.setState({ isEnabled: !this.state.isEnabled }, () => {
this.props.onChange(this.state.isEnabled);
});
this.props.onChange(this.state.isEnabled)
})
}
render() {
@ -30,6 +30,6 @@ export default class extends React.Component {
}
`}</style>
</div>
);
)
}
}

@ -1,4 +1,4 @@
import React from 'react';
import React from 'react'
const Toolbar = props => (
<div id="toolbar">
{props.children}
@ -23,6 +23,6 @@ const Toolbar = props => (
}
`}</style>
</div>
);
)
export default Toolbar;
export default Toolbar

@ -1,5 +1,5 @@
import React from 'react';
import { Controls, ControlsBW } from './svg/Controls';
import React from 'react'
import { Controls, ControlsBW } from './svg/Controls'
export default ({ theme }) => (
<div className="window-controls">
@ -16,4 +16,4 @@ export default ({ theme }) => (
`}
</style>
</div>
);
)

@ -1,4 +1,4 @@
import React from 'react';
import React from 'react'
export default ({ fromLeft }) => (
<div style={{ left: fromLeft }}>
@ -16,4 +16,4 @@ export default ({ fromLeft }) => (
}
`}</style>
</div>
);
)

@ -1,4 +1,4 @@
import { COLORS } from '../../lib/constants';
import { COLORS } from '../../lib/constants'
export default () => (
<style jsx global>{`
@ -192,4 +192,4 @@ export default () => (
background: none;
}
`}</style>
);
)

@ -175,4 +175,4 @@ export default () => (
font-weight: bold;
}
`}</style>
);
)

@ -1,4 +1,4 @@
import React from 'react';
import React from 'react'
export default () => (
<svg xmlns="http://www.w3.org/2000/svg" width="10" height="6" viewBox="0 0 10 6">
@ -9,4 +9,4 @@ export default () => (
transform="translate(-89 -14)"
/>
</svg>
);
)

@ -1,4 +1,4 @@
import React from 'react';
import React from 'react'
export default () => (
<svg xmlns="http://www.w3.org/2000/svg" width="9" height="8" viewBox="0 0 9 7">
@ -8,4 +8,4 @@ export default () => (
points="2.852 5.016 8.275 0 9 .67 2.852 6.344 0 3.711 .713 3.042"
/>
</svg>
);
)

@ -1,4 +1,4 @@
import React from 'react';
import React from 'react'
export const Controls = () => (
<svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14">
@ -8,7 +8,7 @@ export const Controls = () => (
<circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" strokeWidth=".5" />
</g>
</svg>
);
)
export const ControlsBW = () => (
<svg xmlns="http://www.w3.org/2000/svg" width="54" height="16" viewBox="0 0 54 14">
@ -18,4 +18,4 @@ export const ControlsBW = () => (
<circle cx="46" cy="6" r="6" />
</g>
</svg>
);
)

File diff suppressed because one or more lines are too long

@ -1,4 +1,4 @@
import React from 'react';
import React from 'react'
export default () => (
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 18 18">
@ -9,4 +9,4 @@ export default () => (
transform="translate(-191 -357)"
/>
</svg>
);
)

@ -1,4 +1,4 @@
import React from 'react';
import React from 'react'
export const Sharp = () => (
<svg
@ -47,7 +47,7 @@ export const Sharp = () => (
</g>
</g>
</svg>
);
)
export const BW = () => (
<svg
@ -79,7 +79,7 @@ export const BW = () => (
</g>
</g>
</svg>
);
)
export const None = () => (
<svg
@ -110,4 +110,4 @@ export const None = () => (
</g>
</g>
</svg>
);
)

@ -1,46 +1,46 @@
const Twitter = require('twitter');
const morph = require('morphmorph');
const Twitter = require('twitter')
const morph = require('morphmorph')
const RATE_LIMIT_CODE = 420;
const RATE_LIMIT_CODE = 420
const client = new Twitter({
consumer_key: process.env.TWITTER_CONSUMER_KEY,
consumer_secret: process.env.TWITTER_CONSUMER_SECRET,
access_token_key: process.env.TWITTER_ACCESS_TOKEN_KEY,
access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET
});
})
const uploadImage = data => client.post('media/upload', { media_data: data });
const uploadImage = data => client.post('media/upload', { media_data: data })
const uploadTweet = (media = {}) =>
client.post('statuses/update', {
status: `Carbon Copy #${media.media_id_string.slice(0, 8)}`,
media_ids: media.media_id_string
});
})
const extractImageUrl = morph.get('entities.media.0.display_url');
const extractErrorCode = morph.get('0.code');
const extractImageUrl = morph.get('entities.media.0.display_url')
const extractErrorCode = morph.get('0.code')
const respondSuccess = (res, url) => res.json({ url });
const respondSuccess = (res, url) => res.json({ url })
const respondFail = (res, err) => {
const errorCode = extractErrorCode(err);
const errorCode = extractErrorCode(err)
// check for rate limit
if (errorCode === RATE_LIMIT_CODE) {
return res.status(420).send();
return res.status(420).send()
}
console.error(`Error: ${err.message || JSON.stringify(err, null, 2)}`);
res.status(500).send();
};
console.error(`Error: ${err.message || JSON.stringify(err, null, 2)}`)
res.status(500).send()
}
module.exports = (req, res) => {
if (!req.body.data) {
return res.status(400).send();
return res.status(400).send()
}
uploadImage(req.body.data)
.then(uploadTweet)
.then(extractImageUrl)
.then(respondSuccess.bind(null, res))
.catch(respondFail.bind(null, res));
};
.catch(respondFail.bind(null, res))
}

@ -1,9 +1,9 @@
import axios from 'axios';
import debounce from 'lodash.debounce';
import ms from 'ms';
import axios from 'axios'
import debounce from 'lodash.debounce'
import ms from 'ms'
const DOMAIN = process.browser ? document.location.origin : '';
const RATE_LIMIT_CODE = 420;
const DOMAIN = process.browser ? document.location.origin : ''
const RATE_LIMIT_CODE = 420
const gistClient = axios.create({
baseURL: 'https://api.github.com',
@ -12,10 +12,10 @@ const gistClient = axios.create({
Accept: 'application/vnd.github.v3+json',
'Content-Type': 'application/json'
}
});
})
async function tweet(encodedImage) {
const processedData = encodedImage.split(',')[1];
const processedData = encodedImage.split(',')[1]
return axios
.post(`${DOMAIN}/twitter`, { data: processedData })
@ -23,42 +23,42 @@ async function tweet(encodedImage) {
.then(url => encodeURIComponent(`Built with #Carbon, by @dawn_labs ${url}`))
.then(uri => `https://twitter.com/intent/tweet?text=${uri}`)
.then(openTwitterUrl)
.catch(checkIfRateLimited);
.catch(checkIfRateLimited)
}
const getGist = id => {
const uid = id.split('/').pop();
const uid = id.split('/').pop()
return gistClient
.get(`/gists/${uid}`)
.then(res => res.data)
.then(gist => gist.files)
.then(files => files[Object.keys(files)[0]])
.then(file => file.content);
};
.then(file => file.content)
}
// private
function openTwitterUrl(twitterUrl) {
const width = 575,
height = 400;
const left = (window.outerWidth - width) / 2;
const right = (window.outerHeight - height) / 2;
const opts = `status=1,width=${width},height=${height},top=${top},left=${left}`;
height = 400
const left = (window.outerWidth - width) / 2
const right = (window.outerHeight - height) / 2
const opts = `status=1,width=${width},height=${height},top=${top},left=${left}`
window.open(twitterUrl, 'twitter', opts);
window.open(twitterUrl, 'twitter', opts)
}
function checkIfRateLimited(err) {
if (err.response.status === RATE_LIMIT_CODE) {
alert(
"Oh no! Looks like to many people are trying to tweet right now and we've been rate limited. Try again soon or save and upload manually!"
);
return;
)
return
}
throw err;
throw err
}
export default {
getGist,
tweet: debounce(tweet, ms('5s'), { leading: true, trailing: true })
};
}

@ -1,4 +1,4 @@
import toHash from 'tohash';
import toHash from 'tohash'
export const THEMES_ARRAY = [
{
@ -67,9 +67,9 @@ export const THEMES_ARRAY = [
id: 'zenburn',
name: 'Zenburn'
}
];
]
export const THEMES = toHash(THEMES_ARRAY);
export const THEMES = toHash(THEMES_ARRAY)
export const LANGUAGES = [
{
@ -277,16 +277,16 @@ export const LANGUAGES = [
name: 'YAML',
module: 'yaml'
}
];
]
export const DEFAULT_LANGUAGE = 'auto';
export const DEFAULT_LANGUAGE = 'auto'
export const COLORS = {
BLACK: '#121212',
PRIMARY: '#F8E81C',
SECONDARY: '#fff',
GRAY: '#858585'
};
}
export const DEFAULT_CODE = `const pluckDeep = key => obj => key.split('.').reduce((accum, key) => accum[key], obj)
@ -298,14 +298,14 @@ const unfold = (f, seed) => {
return res ? go(f, res[1], acc.concat([res[0]])) : acc
}
return go(f, seed, [])
}`;
}`
if (typeof window !== 'undefined' && typeof window.navigator !== 'undefined') {
LANGUAGES.filter(language => language.module !== 'auto').forEach(language => {
if (language.module) {
!language.custom
? require(`codemirror/mode/${language.module}/${language.module}`)
: require(`./customModes/${language.module}`);
: require(`./customModes/${language.module}`)
}
});
})
}

@ -1,203 +1,203 @@
const CodeMirror = require('codemirror');
const CodeMirror = require('codemirror')
CodeMirror.defineMode('kotlin', function(config, parserConfig) {
function words(str) {
var obj = {},
words = str.split(' ');
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
return obj;
words = str.split(' ')
for (var i = 0; i < words.length; ++i) obj[words[i]] = true
return obj
}
var multiLineStrings = parserConfig.multiLineStrings;
var multiLineStrings = parserConfig.multiLineStrings
var keywords = words(
'package continue return object while break class data trait throw super ' +
'when type this else This try val var fun for is in if do as true false null get set ' +
'import where by get set abstract enum open annotation override private public internal ' +
'protected catch out vararg inline finally final ref const'
);
var blockKeywords = words('catch class do else finally for if where try while enum');
var atoms = words('null true false this');
)
var blockKeywords = words('catch class do else finally for if where try while enum')
var atoms = words('null true false this')
var builtins = words(
'Int Double Float Long Short Byte IntArray ShortArray ByteArray String Boolean List Set ' +
'Map MutableList MutableSet print println shl shr ushr and or xor inv '
);
)
var curPunc;
var curPunc
function tokenBase(stream, state) {
var ch = stream.next();
var ch = stream.next()
if (ch == '"' || ch == "'") {
return startString(ch, stream, state);
return startString(ch, stream, state)
}
// Wildcard import w/o trailing semicolon (import smth.*)
if (ch == '.' && stream.eat('*')) {
return 'word';
return 'word'
}
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
curPunc = ch;
return null;
curPunc = ch
return null
}
if (/\d/.test(ch)) {
if (stream.eat(/eE/)) {
stream.eat(/\+\-/);
stream.eatWhile(/\d/);
stream.eat(/\+\-/)
stream.eatWhile(/\d/)
}
return 'number';
return 'number'
}
if (ch == '/') {
if (stream.eat('*')) {
state.tokenize.push(tokenComment);
return tokenComment(stream, state);
state.tokenize.push(tokenComment)
return tokenComment(stream, state)
}
if (stream.eat('/')) {
stream.skipToEnd();
return 'comment';
stream.skipToEnd()
return 'comment'
}
if (expectExpression(state.lastToken)) {
return startString(ch, stream, state);
return startString(ch, stream, state)
}
}
// Commented
if (ch == '-' && stream.eat('>')) {
curPunc = '->';
return null;
curPunc = '->'
return null
}
if (/[\-+*&%=<>!?|\/~]/.test(ch)) {
stream.eatWhile(/[\-+*&%=<>|~]/);
return 'operator';
stream.eatWhile(/[\-+*&%=<>|~]/)
return 'operator'
}
stream.eatWhile(/[\w\$_]/);
stream.eatWhile(/[\w\$_]/)
var cur = stream.current();
var cur = stream.current()
if (atoms.propertyIsEnumerable(cur)) {
return 'atom';
return 'atom'
}
if (keywords.propertyIsEnumerable(cur)) {
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = 'newstatement';
return 'keyword';
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = 'newstatement'
return 'keyword'
}
if (builtins.propertyIsEnumerable(cur)) {
return 'builtin';
return 'builtin'
}
return 'word';
return 'word'
}
tokenBase.isBase = true;
tokenBase.isBase = true
function startString(quote, stream, state) {
var tripleQuoted = false;
var tripleQuoted = false
if (quote != '/' && stream.eat(quote)) {
if (stream.eat(quote)) tripleQuoted = true;
else return 'string';
if (stream.eat(quote)) tripleQuoted = true
else return 'string'
}
function t(stream, state) {
var escaped = false,
next,
end = !tripleQuoted;
end = !tripleQuoted
while ((next = stream.next()) != null) {
if (next == quote && !escaped) {
if (!tripleQuoted) {
break;
break
}
if (stream.match(quote + quote)) {
end = true;
break;
end = true
break
}
}
if (quote == '"' && next == '$' && !escaped && stream.eat('{')) {
state.tokenize.push(tokenBaseUntilBrace());
return 'string';
state.tokenize.push(tokenBaseUntilBrace())
return 'string'
}
if (next == '$' && !escaped && !stream.eat(' ')) {
state.tokenize.push(tokenBaseUntilSpace());
return 'string';
state.tokenize.push(tokenBaseUntilSpace())
return 'string'
}
escaped = !escaped && next == '\\';
escaped = !escaped && next == '\\'
}
if (multiLineStrings) state.tokenize.push(t);
if (multiLineStrings) state.tokenize.push(t)
if (end) state.tokenize.pop();
if (end) state.tokenize.pop()
return 'string';
return 'string'
}
state.tokenize.push(t);
return t(stream, state);
state.tokenize.push(t)
return t(stream, state)
}
function tokenBaseUntilBrace() {
var depth = 1;
var depth = 1
function t(stream, state) {
if (stream.peek() == '}') {
depth--;
depth--
if (depth == 0) {
state.tokenize.pop();
return state.tokenize[state.tokenize.length - 1](stream, state);
state.tokenize.pop()
return state.tokenize[state.tokenize.length - 1](stream, state)
}
} else if (stream.peek() == '{') {
depth++;
depth++
}
return tokenBase(stream, state);
return tokenBase(stream, state)
}
t.isBase = true;
return t;
t.isBase = true
return t
}
function tokenBaseUntilSpace() {
function t(stream, state) {
if (stream.eat(/[\w]/)) {
var isWord = stream.eatWhile(/[\w]/);
var isWord = stream.eatWhile(/[\w]/)
if (isWord) {
state.tokenize.pop();
return 'word';
state.tokenize.pop()
return 'word'
}
}
state.tokenize.pop();
return 'string';
state.tokenize.pop()
return 'string'
}
t.isBase = true;
return t;
t.isBase = true
return t
}
function tokenComment(stream, state) {
var maybeEnd = false,
ch;
ch
while ((ch = stream.next())) {
if (ch == '/' && maybeEnd) {
state.tokenize.pop();
break;
state.tokenize.pop()
break
}
maybeEnd = ch == '*';
maybeEnd = ch == '*'
}
return 'comment';
return 'comment'
}
function expectExpression(last) {
@ -209,25 +209,25 @@ CodeMirror.defineMode('kotlin', function(config, parserConfig) {
last == 'newstatement' ||
last == 'keyword' ||
last == 'proplabel'
);
)
}
function Context(indented, column, type, align, prev) {
this.indented = indented;
this.column = column;
this.type = type;
this.align = align;
this.prev = prev;
this.indented = indented
this.column = column
this.type = type
this.align = align
this.prev = prev
}
function pushContext(state, col, type) {
return (state.context = new Context(state.indented, col, type, null, state.context));
return (state.context = new Context(state.indented, col, type, null, state.context))
}
function popContext(state) {
var t = state.context.type;
if (t == ')' || t == ']' || t == '}') state.indented = state.context.indented;
return (state.context = state.context.prev);
var t = state.context.type
if (t == ')' || t == ']' || t == '}') state.indented = state.context.indented
return (state.context = state.context.prev)
}
// Interface
@ -240,67 +240,67 @@ CodeMirror.defineMode('kotlin', function(config, parserConfig) {
indented: 0,
startOfLine: true,
lastToken: null
};
}
},
token: function(stream, state) {
var ctx = state.context;
var ctx = state.context
if (stream.sol()) {
if (ctx.align == null) ctx.align = false;
state.indented = stream.indentation();
state.startOfLine = true;
if (ctx.align == null) ctx.align = false
state.indented = stream.indentation()
state.startOfLine = true
// Automatic semicolon insertion
if (ctx.type == 'statement' && !expectExpression(state.lastToken)) {
popContext(state);
ctx = state.context;
popContext(state)
ctx = state.context
}
}
if (stream.eatSpace()) return null;
curPunc = null;
var style = state.tokenize[state.tokenize.length - 1](stream, state);
if (style == 'comment') return style;
if (ctx.align == null) ctx.align = true;
if ((curPunc == ';' || curPunc == ':') && ctx.type == 'statement') popContext(state);
if (stream.eatSpace()) return null
curPunc = null
var style = state.tokenize[state.tokenize.length - 1](stream, state)
if (style == 'comment') return style
if (ctx.align == null) ctx.align = true
if ((curPunc == ';' || curPunc == ':') && ctx.type == 'statement') popContext(state)
else if (curPunc == '->' && ctx.type == 'statement' && ctx.prev.type == '}') {
// Handle indentation for {x -> \n ... }
popContext(state);
state.context.align = false;
} else if (curPunc == '{') pushContext(state, stream.column(), '}');
else if (curPunc == '[') pushContext(state, stream.column(), ']');
else if (curPunc == '(') pushContext(state, stream.column(), ')');
popContext(state)
state.context.align = false
} else if (curPunc == '{') pushContext(state, stream.column(), '}')
else if (curPunc == '[') pushContext(state, stream.column(), ']')
else if (curPunc == '(') pushContext(state, stream.column(), ')')
else if (curPunc == '}') {
while (ctx.type == 'statement') ctx = popContext(state);
if (ctx.type == '}') ctx = popContext(state);
while (ctx.type == 'statement') ctx = popContext(state);
} else if (curPunc == ctx.type) popContext(state);
while (ctx.type == 'statement') ctx = popContext(state)
if (ctx.type == '}') ctx = popContext(state)
while (ctx.type == 'statement') ctx = popContext(state)
} else if (curPunc == ctx.type) popContext(state)
else if (
ctx.type == '}' ||
ctx.type == 'top' ||
(ctx.type == 'statement' && curPunc == 'newstatement')
)
pushContext(state, stream.column(), 'statement');
state.startOfLine = false;
state.lastToken = curPunc || style;
return style;
pushContext(state, stream.column(), 'statement')
state.startOfLine = false
state.lastToken = curPunc || style
return style
},
indent: function(state, textAfter) {
if (!state.tokenize[state.tokenize.length - 1].isBase) return 0;
if (!state.tokenize[state.tokenize.length - 1].isBase) return 0
var firstChar = textAfter && textAfter.charAt(0),
ctx = state.context;
if (ctx.type == 'statement' && !expectExpression(state.lastToken)) ctx = ctx.prev;
var closing = firstChar == ctx.type;
ctx = state.context
if (ctx.type == 'statement' && !expectExpression(state.lastToken)) ctx = ctx.prev
var closing = firstChar == ctx.type
if (ctx.type == 'statement') {
return ctx.indented + (firstChar == '{' ? 0 : config.indentUnit);
} else if (ctx.align) return ctx.column + (closing ? 0 : 1);
else return ctx.indented + (closing ? 0 : config.indentUnit);
return ctx.indented + (firstChar == '{' ? 0 : config.indentUnit)
} else if (ctx.align) return ctx.column + (closing ? 0 : 1)
else return ctx.indented + (closing ? 0 : config.indentUnit)
},
closeBrackets: {
triples: '\'"'
},
electricChars: '{}'
};
});
}
})
CodeMirror.defineMIME('text/x-kotlin', 'kotlin');
CodeMirror.defineMIME('text/x-kotlin', 'kotlin')

@ -1,14 +1,14 @@
const CodeMirror = require('codemirror');
const CodeMirror = require('codemirror')
CodeMirror.defineMode('nimrod', function(conf, parserConf) {
var ERRORCLASS = 'error';
var ERRORCLASS = 'error'
function wordRegexp(words) {
return new RegExp('^((' + words.join(')|(') + '))\\b');
return new RegExp('^((' + words.join(')|(') + '))\\b')
}
var operators = new RegExp('\\=\\+\\-\\*\\/\\<\\>\\@\\$\\~\\&\\%\\|\\!\\?\\^\\:\\\\');
var identifiers = new RegExp('^[_A-Za-z][_A-Za-z0-9]*');
var operators = new RegExp('\\=\\+\\-\\*\\/\\<\\>\\@\\$\\~\\&\\%\\|\\!\\?\\^\\:\\\\')
var identifiers = new RegExp('^[_A-Za-z][_A-Za-z0-9]*')
var commonkeywords = [
'addr',
@ -81,7 +81,7 @@ CodeMirror.defineMode('nimrod', function(conf, parserConf) {
'in',
'as',
'of'
];
]
var commonBuiltins = [
'int',
@ -294,272 +294,272 @@ CodeMirror.defineMode('nimrod', function(conf, parserConf) {
'EFloatOverflow',
'EFloatInexact',
'EDeadThrea'
];
]
if (parserConf.extra_keywords != undefined)
commonkeywords = commonkeywords.concat(parserConf.extra_keywords);
commonkeywords = commonkeywords.concat(parserConf.extra_keywords)
if (parserConf.extra_builtins != undefined)
commonBuiltins = commonBuiltins.concat(parserConf.extra_builtins);
commonBuiltins = commonBuiltins.concat(parserConf.extra_builtins)
var keywords = wordRegexp(commonkeywords);
var builtins = wordRegexp(commonBuiltins);
var keywords = wordRegexp(commonkeywords)
var builtins = wordRegexp(commonBuiltins)
var indentInfo = null;
var indentInfo = null
var stringPrefixes = new RegExp('^((\'{3}|"{3}|[\'"]))', 'i');
var stringPrefixes = new RegExp('^((\'{3}|"{3}|[\'"]))', 'i')
// tokenizers
function tokenBase(stream, state) {
// Handle scope changes
if (stream.sol()) {
var scopeOffset = state.scopes[0].offset;
var scopeOffset = state.scopes[0].offset
if (stream.eatSpace()) {
var lineOffset = stream.indentation();
var lineOffset = stream.indentation()
if (lineOffset > scopeOffset) {
indentInfo = 'indent';
indentInfo = 'indent'
} else if (lineOffset < scopeOffset) {
indentInfo = 'dedent';
indentInfo = 'dedent'
}
return null;
return null
} else {
if (scopeOffset > 0) {
dedent(stream, state);
dedent(stream, state)
}
}
}
if (stream.eatSpace()) return null;
if (stream.eatSpace()) return null
var ch = stream.peek();
var ch = stream.peek()
// Handle Comments
if (ch === '#') {
stream.skipToEnd();
return 'comment';
stream.skipToEnd()
return 'comment'
}
// Handle Number Literals
if (stream.match(/^[0-9\.]/, false)) {
var floatLiteral = false;
var floatLiteral = false
// Floats
if (stream.match(/^\d*\.\d+(e[\+\-]?\d+)?/i)) {
floatLiteral = true;
floatLiteral = true
}
if (stream.match(/^\d+\.\d*/)) {
floatLiteral = true;
floatLiteral = true
}
if (stream.match(/^\.\d+/)) {
floatLiteral = true;
floatLiteral = true
}
if (floatLiteral) {
// Float literals may be "imaginary"
stream.eat(/J/i);
return 'number';
stream.eat(/J/i)
return 'number'
}
// Integers
var intLiteral = false;
var intLiteral = false
// Hex
if (stream.match(/^0x[0-9a-f]+/i)) {
intLiteral = true;
intLiteral = true
}
// Binary
if (stream.match(/^0b[01]+/i)) {
intLiteral = true;
intLiteral = true
}
// Octal
if (stream.match(/^0o[0-7]+/i)) {
intLiteral = true;
intLiteral = true
}
// Decimal
if (stream.match(/^[1-9]\d*(e[\+\-]?\d+)?/)) {
// Decimal literals may be "imaginary"
stream.eat(/J/i);
stream.eat(/J/i)
// TODO - Can you have imaginary longs?
intLiteral = true;
intLiteral = true
}
// Zero by itself with no other piece of number.
if (stream.match(/^0(?![\dx])/i)) {
intLiteral = true;
intLiteral = true
}
if (intLiteral) {
// Integer literals may be "long"
stream.eat(/L/i);
return 'number';
stream.eat(/L/i)
return 'number'
}
}
// Handle Strings
if (stream.match(stringPrefixes)) {
state.tokenize = tokenStringFactory(stream.current());
return state.tokenize(stream, state);
state.tokenize = tokenStringFactory(stream.current())
return state.tokenize(stream, state)
}
if (stream.match(operators)) return 'operator';
if (stream.match(operators)) return 'operator'
if (stream.match(keywords)) return 'keyword';
if (stream.match(keywords)) return 'keyword'
if (stream.match(builtins)) return 'builtin';
if (stream.match(builtins)) return 'builtin'
if (stream.match(identifiers)) {
if (
state.lastToken != null &&
state.lastToken.match(/proc|iterator|macro|template|class|converter/)
) {
return 'def';
return 'def'
}
return 'variable';
return 'variable'
}
// Handle non-detected items
stream.next();
return ERRORCLASS;
stream.next()
return ERRORCLASS
}
function tokenStringFactory(delimiter) {
var singleline = delimiter.length == 1;
var OUTCLASS = 'string';
var singleline = delimiter.length == 1
var OUTCLASS = 'string'
function tokenString(stream, state) {
while (!stream.eol()) {
stream.eatWhile(/[^'"\\]/);
stream.eatWhile(/[^'"\\]/)
if (stream.eat('\\')) {
stream.next();
stream.next()
if (singleline && stream.eol()) {
return OUTCLASS;
return OUTCLASS
}
} else if (stream.match(delimiter)) {
state.tokenize = tokenBase;
return OUTCLASS;
state.tokenize = tokenBase
return OUTCLASS
} else {
stream.eat(/['"]/);
stream.eat(/['"]/)
}
}
if (singleline) {
if (parserConf.singleLineStringErrors) {
return ERRORCLASS;
return ERRORCLASS
} else {
state.tokenize = tokenBase;
state.tokenize = tokenBase
}
}
return OUTCLASS;
return OUTCLASS
}
tokenString.isString = true;
return tokenString;
tokenString.isString = true
return tokenString
}
function indent(stream, state, type) {
type = type || 'nim';
var indentUnit = 0;
type = type || 'nim'
var indentUnit = 0
if (type === 'nim') {
if (state.scopes[0].type !== 'nim') {
state.scopes[0].offset = stream.indentation();
return;
state.scopes[0].offset = stream.indentation()
return
}
for (var i = 0; i < state.scopes.length; ++i) {
if (state.scopes[i].type === 'nim') {
indentUnit = state.scopes[i].offset + conf.indentUnit;
break;
indentUnit = state.scopes[i].offset + conf.indentUnit
break
}
}
} else {
indentUnit = stream.column() + stream.current().length;
indentUnit = stream.column() + stream.current().length
}
state.scopes.unshift({
offset: indentUnit,
type: type
});
})
}
function dedent(stream, state, type) {
type = type || 'nim';
if (state.scopes.length == 1) return;
type = type || 'nim'
if (state.scopes.length == 1) return
if (state.scopes[0].type === 'nim') {
var _indent = stream.indentation();
var _indent_index = -1;
var _indent = stream.indentation()
var _indent_index = -1
for (var i = 0; i < state.scopes.length; ++i) {
if (_indent === state.scopes[i].offset) {
_indent_index = i;
break;
_indent_index = i
break
}
}
if (_indent_index === -1) {
return true;
return true
}
while (state.scopes[0].offset !== _indent) {
state.scopes.shift();
state.scopes.shift()
}
return false;
return false
} else {
if (type === 'nim') {
state.scopes[0].offset = stream.indentation();
return false;
state.scopes[0].offset = stream.indentation()
return false
} else {
if (state.scopes[0].type != type) {
return true;
return true
}
state.scopes.shift();
return false;
state.scopes.shift()
return false
}
}
}
function tokenLexer(stream, state) {
indentInfo = null;
var style = state.tokenize(stream, state);
var current = stream.current();
indentInfo = null
var style = state.tokenize(stream, state)
var current = stream.current()
// Handle '.' connected identifiers
if (current === '.') {
style = stream.match(identifiers, false) ? null : ERRORCLASS;
style = stream.match(identifiers, false) ? null : ERRORCLASS
if (style === null && state.lastStyle === 'meta') {
// Apply 'meta' style to '.' connected identifiers when
// appropriate.
style = 'meta';
style = 'meta'
}
return style;
return style
}
if ((style === 'variable' || style === 'builtin') && state.lastStyle === 'meta') {
style = 'meta';
style = 'meta'
}
// Handle scope changes.
if (current.match(/return|break|continue|raise/) || (current === 'discard' && stream.eol()))
state.dedent += 1;
state.dedent += 1
if (current === 'lambda' || current === 'proc') state.lambda = true;
if (current === 'lambda' || current === 'proc') state.lambda = true
var delimiter_index = '[({'.indexOf(current);
var delimiter_index = '[({'.indexOf(current)
if (delimiter_index !== -1) {
indent(stream, state, '])}'.slice(delimiter_index, delimiter_index + 1));
indent(stream, state, '])}'.slice(delimiter_index, delimiter_index + 1))
} else if (stream.eol() && current.match(/\=|\:|import|include|type|const|var|let/)) {
indent(stream, state);
indent(stream, state)
}
if (indentInfo === 'dedent') {
if (dedent(stream, state)) {
return ERRORCLASS;
return ERRORCLASS
}
}
delimiter_index = '])}'.indexOf(current);
delimiter_index = '])}'.indexOf(current)
if (delimiter_index !== -1) {
if (dedent(stream, state, current)) {
return ERRORCLASS;
return ERRORCLASS
}
}
if (state.dedent > 0 && stream.eol() && state.scopes[0].type == 'nim') {
if (state.scopes.length > 1) state.scopes.shift();
state.dedent -= 1;
if (state.scopes.length > 1) state.scopes.shift()
state.dedent -= 1
}
return style;
return style
}
var external = {
@ -571,33 +571,33 @@ CodeMirror.defineMode('nimrod', function(conf, parserConf) {
lastToken: null,
lambda: false,
dedent: 0
};
}
},
token: function(stream, state) {
var style = tokenLexer(stream, state);
var style = tokenLexer(stream, state)
state.lastStyle = style;
state.lastStyle = style
var current = stream.current();
if (current && style) state.lastToken = current;
var current = stream.current()
if (current && style) state.lastToken = current
if (stream.eol() && state.lambda) state.lambda = false;
if (stream.eol() && state.lambda) state.lambda = false
return style;
return style
},
indent: function(state) {
if (state.tokenize != tokenBase) return state.tokenize.isString ? CodeMirror.Pass : 0;
if (state.tokenize != tokenBase) return state.tokenize.isString ? CodeMirror.Pass : 0
return state.scopes[0].offset;
return state.scopes[0].offset
},
lineComment: '#',
fold: 'indent'
};
}
return external;
});
return external
})
CodeMirror.defineMIME('text/x-nimrod', 'nimrod');
CodeMirror.defineMIME('text/x-nimrod', 'nimrod')

@ -1,8 +1,8 @@
import Page from '../components/Page';
import Meta from '../components/Meta';
import Header from '../components/Header';
import Footer from '../components/Footer';
import { COLORS } from '../lib/constants';
import Page from '../components/Page'
import Meta from '../components/Meta'
import Header from '../components/Header'
import Footer from '../components/Footer'
import { COLORS } from '../lib/constants'
export default () => (
<Page>
@ -71,4 +71,4 @@ export default () => (
}
`}</style>
</Page>
);
)

@ -1,20 +1,20 @@
// Theirs
import React from 'react';
import HTML5Backend from 'react-dnd-html5-backend';
import { DragDropContext } from 'react-dnd';
import domtoimage from 'dom-to-image';
import ReadFileDropContainer from 'dropperx';
import React from 'react'
import HTML5Backend from 'react-dnd-html5-backend'
import { DragDropContext } from 'react-dnd'
import domtoimage from 'dom-to-image'
import ReadFileDropContainer from 'dropperx'
// Ours
import Page from '../components/Page';
import Button from '../components/Button';
import Dropdown from '../components/Dropdown';
import ColorPicker from '../components/ColorPicker';
import Settings from '../components/Settings';
import Toolbar from '../components/Toolbar';
import Overlay from '../components/Overlay';
import Carbon from '../components/Carbon';
import api from '../lib/api';
import Page from '../components/Page'
import Button from '../components/Button'
import Dropdown from '../components/Dropdown'
import ColorPicker from '../components/ColorPicker'
import Settings from '../components/Settings'
import Toolbar from '../components/Toolbar'
import Overlay from '../components/Overlay'
import Carbon from '../components/Carbon'
import api from '../lib/api'
import {
THEMES_ARRAY,
THEMES,
@ -22,7 +22,7 @@ import {
DEFAULT_LANGUAGE,
COLORS,
DEFAULT_CODE
} from '../lib/constants';
} from '../lib/constants'
class Editor extends React.Component {
/* pathname, asPath, err, req, res */
@ -30,17 +30,17 @@ class Editor extends React.Component {
try {
// TODO fix this hack
if (asPath.length > 30) {
const content = await api.getGist(asPath);
return { content };
const content = await api.getGist(asPath)
return { content }
}
} catch (e) {
console.log(e);
console.log(e)
}
return {};
return {}
}
constructor(props) {
super(props);
super(props)
this.state = {
background: '#ABB8C3',
theme: THEMES.seti.id,
@ -51,15 +51,15 @@ class Editor extends React.Component {
paddingHorizontal: '32px',
uploading: false,
code: props.content || DEFAULT_CODE
};
}
this.save = this.save.bind(this);
this.upload = this.upload.bind(this);
this.updateCode = this.updateCode.bind(this);
this.save = this.save.bind(this)
this.upload = this.upload.bind(this)
this.updateCode = this.updateCode.bind(this)
}
getCarbonImage() {
const node = document.getElementById('section');
const node = document.getElementById('section')
const config = {
style: {
@ -68,35 +68,35 @@ class Editor extends React.Component {
},
width: node.offsetWidth * 2,
height: node.offsetHeight * 2
};
}
return domtoimage.toPng(node, config);
return domtoimage.toPng(node, config)
}
updateCode(code) {
this.setState({ code });
this.setState({ code })
}
save() {
this.getCarbonImage().then(dataUrl => {
const link = document.createElement('a');
link.download = 'carbon.png';
link.href = dataUrl;
document.body.appendChild(link);
link.click();
link.remove();
});
const link = document.createElement('a')
link.download = 'carbon.png'
link.href = dataUrl
document.body.appendChild(link)
link.click()
link.remove()
})
}
upload() {
this.setState({ uploading: true });
this.setState({ uploading: true })
this.getCarbonImage()
.then(api.tweet)
.then(() => this.setState({ uploading: false }))
.catch(err => {
console.error(err);
this.setState({ uploading: false });
});
console.error(err)
this.setState({ uploading: false })
})
}
render() {
@ -162,8 +162,8 @@ class Editor extends React.Component {
`}
</style>
</Page>
);
)
}
}
export default DragDropContext(HTML5Backend)(Editor);
export default DragDropContext(HTML5Backend)(Editor)

@ -1,2 +1,2 @@
import Editor from './editor';
export default Editor;
import Editor from './editor'
export default Editor

@ -1,38 +1,38 @@
const express = require('express');
const morgan = require('morgan');
const bodyParser = require('body-parser');
const next = require('next');
const express = require('express')
const morgan = require('morgan')
const bodyParser = require('body-parser')
const next = require('next')
const port = parseInt(process.env.PORT, 10) || 3000;
const dev = process.env.NODE_ENV !== 'production' && !process.env.NOW;
const app = next({ dev });
const handle = app.getRequestHandler();
const port = parseInt(process.env.PORT, 10) || 3000
const dev = process.env.NODE_ENV !== 'production' && !process.env.NOW
const app = next({ dev })
const handle = app.getRequestHandler()
function wrap(handler) {
return (req, res) =>
handler(req, res).catch(err => {
console.log('ERR:', err);
});
console.log('ERR:', err)
})
}
app.prepare().then(() => {
const server = express();
const server = express()
server.use(morgan('tiny'));
server.use(morgan('tiny'))
server.get('/about', (req, res) => app.render(req, res, '/about'));
server.get('/about', (req, res) => app.render(req, res, '/about'))
// if root, render webpage from next
server.get('/*', (req, res) => app.render(req, res, '/', req.query));
server.get('/*', (req, res) => app.render(req, res, '/', req.query))
// otherwise, try and get gist
server.get('*', handle);
server.get('*', handle)
// api endpoints
server.post('/twitter', bodyParser.json({ limit: '5mb' }), require('./handlers/twitter'));
server.post('/twitter', bodyParser.json({ limit: '5mb' }), require('./handlers/twitter'))
server.listen(port, err => {
if (err) throw err;
console.log(`> Ready on http://localhost:${port}`);
});
});
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})

Loading…
Cancel
Save