mirror of https://github.com/sgoudham/carbon.git
Add prettier
parent
6b1e0aedaa
commit
7e69ca2897
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
singleQuote: true,
|
||||||
|
printWidth: 100
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
language: node_js
|
||||||
|
node_js: stable
|
||||||
|
cache:
|
||||||
|
yarn: true
|
||||||
|
directories:
|
||||||
|
- node_modules
|
||||||
|
install:
|
||||||
|
- yarn
|
||||||
|
script:
|
||||||
|
- yarn lint
|
@ -0,0 +1,22 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Controls, ControlsBW } from './svg/Controls';
|
||||||
|
|
||||||
|
export default ({ language }) => (
|
||||||
|
<div className="language">
|
||||||
|
{language.name}
|
||||||
|
<style jsx>
|
||||||
|
{`
|
||||||
|
.language {
|
||||||
|
position: absolute;
|
||||||
|
top: 7px;
|
||||||
|
right: 7px;
|
||||||
|
background: rgba(0, 0, 0, 0.3);
|
||||||
|
font-size: 12px;
|
||||||
|
padding: 5px;
|
||||||
|
border-radius: 3px;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
`}
|
||||||
|
</style>
|
||||||
|
</div>
|
||||||
|
);
|
@ -1,7 +1,12 @@
|
|||||||
import React from 'react'
|
import React from 'react';
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="10" height="6" viewBox="0 0 10 6">
|
<svg xmlns="http://www.w3.org/2000/svg" width="10" height="6" viewBox="0 0 10 6">
|
||||||
<path fill="#fff" fillRule="evenodd" d="M93.7890633,17.6396882 L97.4926052,14.0851393 C97.6061243,13.9716202 97.7196417,13.9716202 97.8331608,14.0851393 L98.4929872,14.723681 C98.6065063,14.8372001 98.6065063,14.9507175 98.4929872,15.0642366 L93.9593411,19.4063203 C93.9167714,19.4488899 93.8600127,19.4701744 93.7890633,19.4701744 C93.7181138,19.4701744 93.6613552,19.4488899 93.6187855,19.4063203 L89.0851393,15.0642366 C88.9716202,14.9507175 88.9716202,14.8372001 89.0851393,14.723681 L89.7449658,14.0851393 C89.8584849,13.9716202 89.9720022,13.9716202 90.0855213,14.0851393 L93.7890633,17.6396882 Z" transform="translate(-89 -14)"/>
|
<path
|
||||||
|
fill="#fff"
|
||||||
|
fillRule="evenodd"
|
||||||
|
d="M93.7890633,17.6396882 L97.4926052,14.0851393 C97.6061243,13.9716202 97.7196417,13.9716202 97.8331608,14.0851393 L98.4929872,14.723681 C98.6065063,14.8372001 98.6065063,14.9507175 98.4929872,15.0642366 L93.9593411,19.4063203 C93.9167714,19.4488899 93.8600127,19.4701744 93.7890633,19.4701744 C93.7181138,19.4701744 93.6613552,19.4488899 93.6187855,19.4063203 L89.0851393,15.0642366 C88.9716202,14.9507175 88.9716202,14.8372001 89.0851393,14.723681 L89.7449658,14.0851393 C89.8584849,13.9716202 89.9720022,13.9716202 90.0855213,14.0851393 L93.7890633,17.6396882 Z"
|
||||||
|
transform="translate(-89 -14)"
|
||||||
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
)
|
);
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
import React from 'react'
|
import React from 'react';
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="9" height="8" viewBox="0 0 9 7">
|
<svg xmlns="http://www.w3.org/2000/svg" width="9" height="8" viewBox="0 0 9 7">
|
||||||
<polygon fill="#FFFFFF" fillRule="evenodd" points="2.852 5.016 8.275 0 9 .67 2.852 6.344 0 3.711 .713 3.042"/>
|
<polygon
|
||||||
|
fill="#FFFFFF"
|
||||||
|
fillRule="evenodd"
|
||||||
|
points="2.852 5.016 8.275 0 9 .67 2.852 6.344 0 3.711 .713 3.042"
|
||||||
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
)
|
);
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
import React from 'react'
|
import React from 'react';
|
||||||
|
|
||||||
export const Controls = () => (
|
export const Controls = () => (
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14">
|
<svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14">
|
||||||
<g fill="none" fillRule="evenodd" transform="translate(1 1)">
|
<g fill="none" fillRule="evenodd" transform="translate(1 1)">
|
||||||
<circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" strokeWidth=".5"/>
|
<circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" strokeWidth=".5" />
|
||||||
<circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" strokeWidth=".5"/>
|
<circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" strokeWidth=".5" />
|
||||||
<circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" strokeWidth=".5"/>
|
<circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" strokeWidth=".5" />
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
)
|
);
|
||||||
|
|
||||||
export const ControlsBW = () => (
|
export const ControlsBW = () => (
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="54" height="16" viewBox="0 0 54 14">
|
<svg xmlns="http://www.w3.org/2000/svg" width="54" height="16" viewBox="0 0 54 14">
|
||||||
<g fill="none" fillRule="evenodd" stroke="#878787" transform="translate(1 1)">
|
<g fill="none" fillRule="evenodd" stroke="#878787" transform="translate(1 1)">
|
||||||
<circle cx="6" cy="6" r="6"/>
|
<circle cx="6" cy="6" r="6" />
|
||||||
<circle cx="26" cy="6" r="6"/>
|
<circle cx="26" cy="6" r="6" />
|
||||||
<circle cx="46" cy="6" r="6"/>
|
<circle cx="46" cy="6" r="6" />
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
)
|
);
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,7 +1,12 @@
|
|||||||
import React from 'react'
|
import React from 'react';
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 18 18">
|
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 18 18">
|
||||||
<path fill="#fff" fillRule="evenodd" d="M206.532032,366.702224 L208.523318,368.142728 C208.69279,368.3122 208.721035,368.509915 208.608053,368.735877 L206.786238,371.74399 C206.673257,371.969953 206.503788,372.040565 206.277825,371.955829 L203.989964,371.066106 C203.283831,371.546276 202.775423,371.842848 202.464724,371.955829 L202.125782,374.286058 C202.069291,374.51202 201.913944,374.625 201.659736,374.625 L198.058474,374.625 C197.804266,374.625 197.648919,374.51202 197.592428,374.286058 L197.253486,371.955829 C196.829806,371.786357 196.321398,371.489786 195.728246,371.066106 L193.440385,371.955829 C193.214422,372.068811 193.044953,371.998198 192.931972,371.74399 L191.110157,368.735877 C190.96893,368.481669 190.997175,368.283955 191.194892,368.142728 L193.101443,366.702224 C193.101443,366.617488 193.094382,366.476263 193.080259,366.278546 C193.066136,366.080828 193.059075,365.925481 193.059075,365.8125 C193.059075,365.699519 193.066136,365.544172 193.080259,365.346454 C193.094382,365.148737 193.101443,365.007512 193.101443,364.922776 L191.152525,363.482272 C190.983053,363.3128 190.954808,363.115085 191.067789,362.889123 L192.889604,359.88101 C193.002585,359.655047 193.172055,359.584435 193.398017,359.669171 L195.685878,360.558894 C196.392011,360.078724 196.90042,359.782152 197.211118,359.669171 L197.550061,357.338942 C197.606551,357.11298 197.761898,357 198.016106,357 L201.617368,357 C201.871576,357 202.026923,357.11298 202.083414,357.338942 L202.379988,359.669171 C202.803668,359.838643 203.312077,360.135214 203.905229,360.558894 L206.150722,359.669171 C206.376684,359.556189 206.560276,359.626802 206.701503,359.88101 L208.523318,362.889123 C208.664544,363.143331 208.6363,363.341045 208.438582,363.482272 L206.532032,364.922776 C206.532032,365.007512 206.539093,365.148737 206.553216,365.346454 C206.567338,365.544172 206.5744,365.699519 206.5744,365.8125 C206.5744,366.23618 206.560277,366.532752 206.532032,366.702224 Z M199.795553,368.905349 C200.671159,368.905349 201.419649,368.608777 202.041046,368.015625 C202.662443,367.422473 202.973138,366.688105 202.973138,365.8125 C202.973138,364.936895 202.662443,364.202527 202.041046,363.609375 C201.419649,363.016223 200.671159,362.719651 199.795553,362.719651 C198.919948,362.719651 198.178519,363.016223 197.571244,363.609375 C196.96397,364.202527 196.660337,364.936895 196.660337,365.8125 C196.660337,366.688105 196.96397,367.422473 197.571244,368.015625 C198.178519,368.608777 198.919948,368.905349 199.795553,368.905349 Z" transform="translate(-191 -357)"/>
|
<path
|
||||||
|
fill="#fff"
|
||||||
|
fillRule="evenodd"
|
||||||
|
d="M206.532032,366.702224 L208.523318,368.142728 C208.69279,368.3122 208.721035,368.509915 208.608053,368.735877 L206.786238,371.74399 C206.673257,371.969953 206.503788,372.040565 206.277825,371.955829 L203.989964,371.066106 C203.283831,371.546276 202.775423,371.842848 202.464724,371.955829 L202.125782,374.286058 C202.069291,374.51202 201.913944,374.625 201.659736,374.625 L198.058474,374.625 C197.804266,374.625 197.648919,374.51202 197.592428,374.286058 L197.253486,371.955829 C196.829806,371.786357 196.321398,371.489786 195.728246,371.066106 L193.440385,371.955829 C193.214422,372.068811 193.044953,371.998198 192.931972,371.74399 L191.110157,368.735877 C190.96893,368.481669 190.997175,368.283955 191.194892,368.142728 L193.101443,366.702224 C193.101443,366.617488 193.094382,366.476263 193.080259,366.278546 C193.066136,366.080828 193.059075,365.925481 193.059075,365.8125 C193.059075,365.699519 193.066136,365.544172 193.080259,365.346454 C193.094382,365.148737 193.101443,365.007512 193.101443,364.922776 L191.152525,363.482272 C190.983053,363.3128 190.954808,363.115085 191.067789,362.889123 L192.889604,359.88101 C193.002585,359.655047 193.172055,359.584435 193.398017,359.669171 L195.685878,360.558894 C196.392011,360.078724 196.90042,359.782152 197.211118,359.669171 L197.550061,357.338942 C197.606551,357.11298 197.761898,357 198.016106,357 L201.617368,357 C201.871576,357 202.026923,357.11298 202.083414,357.338942 L202.379988,359.669171 C202.803668,359.838643 203.312077,360.135214 203.905229,360.558894 L206.150722,359.669171 C206.376684,359.556189 206.560276,359.626802 206.701503,359.88101 L208.523318,362.889123 C208.664544,363.143331 208.6363,363.341045 208.438582,363.482272 L206.532032,364.922776 C206.532032,365.007512 206.539093,365.148737 206.553216,365.346454 C206.567338,365.544172 206.5744,365.699519 206.5744,365.8125 C206.5744,366.23618 206.560277,366.532752 206.532032,366.702224 Z M199.795553,368.905349 C200.671159,368.905349 201.419649,368.608777 202.041046,368.015625 C202.662443,367.422473 202.973138,366.688105 202.973138,365.8125 C202.973138,364.936895 202.662443,364.202527 202.041046,363.609375 C201.419649,363.016223 200.671159,362.719651 199.795553,362.719651 C198.919948,362.719651 198.178519,363.016223 197.571244,363.609375 C196.96397,364.202527 196.660337,364.936895 196.660337,365.8125 C196.660337,366.688105 196.96397,367.422473 197.571244,368.015625 C198.178519,368.608777 198.919948,368.905349 199.795553,368.905349 Z"
|
||||||
|
transform="translate(-191 -357)"
|
||||||
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
)
|
);
|
||||||
|
@ -1,64 +1,113 @@
|
|||||||
import React from 'react'
|
import React from 'react';
|
||||||
|
|
||||||
export const Sharp = () => (
|
export const Sharp = () => (
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 81 81" xmlnsXlink="http://www.w3.org/1999/xlink">
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="50"
|
||||||
|
height="50"
|
||||||
|
viewBox="0 0 81 81"
|
||||||
|
xmlnsXlink="http://www.w3.org/1999/xlink"
|
||||||
|
>
|
||||||
<defs>
|
<defs>
|
||||||
<rect id="a" width="81" height="81" rx="3"/>
|
<rect id="a" width="81" height="81" rx="3" />
|
||||||
</defs>
|
</defs>
|
||||||
<g fill="none" fillRule="evenodd">
|
<g fill="none" fillRule="evenodd">
|
||||||
<mask id="b" fill="white">
|
<mask id="b" fill="white">
|
||||||
<use xlinkHref="#a"/>
|
<use xlinkHref="#a" />
|
||||||
</mask>
|
</mask>
|
||||||
<use fill="#616161" xlinkHref="#a"/>
|
<use fill="#616161" xlinkHref="#a" />
|
||||||
<g transform="translate(16 32)" mask="url(#b)">
|
<g transform="translate(16 32)" mask="url(#b)">
|
||||||
<path fill="#000000" fillRule="nonzero" d="M66.0458013,46.1092762 C66.0458013,48.3193105 64.2622787,50.1077029 62.050805,50.1077029 L0.174089069,50.1077029 L0.174089069,6.16868499 C0.174089069,0.174657534 0.174089069,0.174657534 0.174089069,0.174657534 L66.0458013,0.174657534 L66.0458013,46.1092762 Z"/>
|
<path
|
||||||
|
fill="#000000"
|
||||||
|
fillRule="nonzero"
|
||||||
|
d="M66.0458013,46.1092762 C66.0458013,48.3193105 64.2622787,50.1077029 62.050805,50.1077029 L0.174089069,50.1077029 L0.174089069,6.16868499 C0.174089069,0.174657534 0.174089069,0.174657534 0.174089069,0.174657534 L66.0458013,0.174657534 L66.0458013,46.1092762 Z"
|
||||||
|
/>
|
||||||
<g transform="translate(19.96 15.27)">
|
<g transform="translate(19.96 15.27)">
|
||||||
<ellipse cx="7.045" cy="7.048" fill="#FF5E55" fillRule="nonzero" stroke="#E0443E" strokeWidth=".5" rx="7.045" ry="7.048"/>
|
<ellipse
|
||||||
<ellipse cx="30.526" cy="7.048" fill="#FFC02C" fillRule="nonzero" stroke="#DEA123" strokeWidth=".5" rx="7.045" ry="7.048"/>
|
cx="7.045"
|
||||||
|
cy="7.048"
|
||||||
|
fill="#FF5E55"
|
||||||
|
fillRule="nonzero"
|
||||||
|
stroke="#E0443E"
|
||||||
|
strokeWidth=".5"
|
||||||
|
rx="7.045"
|
||||||
|
ry="7.048"
|
||||||
|
/>
|
||||||
|
<ellipse
|
||||||
|
cx="30.526"
|
||||||
|
cy="7.048"
|
||||||
|
fill="#FFC02C"
|
||||||
|
fillRule="nonzero"
|
||||||
|
stroke="#DEA123"
|
||||||
|
strokeWidth=".5"
|
||||||
|
rx="7.045"
|
||||||
|
ry="7.048"
|
||||||
|
/>
|
||||||
</g>
|
</g>
|
||||||
</g>
|
</g>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
)
|
);
|
||||||
|
|
||||||
export const BW = () => (
|
export const BW = () => (
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 81 81" xmlnsXlink="http://www.w3.org/1999/xlink">
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="50"
|
||||||
|
height="50"
|
||||||
|
viewBox="0 0 81 81"
|
||||||
|
xmlnsXlink="http://www.w3.org/1999/xlink"
|
||||||
|
>
|
||||||
<defs>
|
<defs>
|
||||||
<rect id="a" width="81" height="81" rx="3"/>
|
<rect id="a" width="81" height="81" rx="3" />
|
||||||
</defs>
|
</defs>
|
||||||
<g fill="none" fillRule="evenodd">
|
<g fill="none" fillRule="evenodd">
|
||||||
<mask id="b" fill="white">
|
<mask id="b" fill="white">
|
||||||
<use xlinkHref="#a"/>
|
<use xlinkHref="#a" />
|
||||||
</mask>
|
</mask>
|
||||||
<use fill="#616161" xlinkHref="#a"/>
|
<use fill="#616161" xlinkHref="#a" />
|
||||||
<g transform="translate(17 33)" mask="url(#b)">
|
<g transform="translate(17 33)" mask="url(#b)">
|
||||||
<path fill="#000000" stroke="#FFFFFF" strokeWidth="2" d="M65.0458013,49.1077029 C66.0458013,49.1077029 0.174089069,49.1077029 0.174089069,49.1077029 L0.174089069,5.16868499 C0.174089069,2.41055979 2.40986586,0.174657534 5.17268563,0.174657534 L65.0458013,0.174657534 L65.0458013,49.1077029 Z"/>
|
<path
|
||||||
|
fill="#000000"
|
||||||
|
stroke="#FFFFFF"
|
||||||
|
strokeWidth="2"
|
||||||
|
d="M65.0458013,49.1077029 C66.0458013,49.1077029 0.174089069,49.1077029 0.174089069,49.1077029 L0.174089069,5.16868499 C0.174089069,2.41055979 2.40986586,0.174657534 5.17268563,0.174657534 L65.0458013,0.174657534 L65.0458013,49.1077029 Z"
|
||||||
|
/>
|
||||||
<g fillRule="nonzero" stroke="#878787" transform="translate(18.96 14.27)">
|
<g fillRule="nonzero" stroke="#878787" transform="translate(18.96 14.27)">
|
||||||
<ellipse cx="7.045" cy="7.048" rx="7.045" ry="7.048"/>
|
<ellipse cx="7.045" cy="7.048" rx="7.045" ry="7.048" />
|
||||||
<ellipse cx="30.526" cy="7.048" rx="7.045" ry="7.048"/>
|
<ellipse cx="30.526" cy="7.048" rx="7.045" ry="7.048" />
|
||||||
</g>
|
</g>
|
||||||
</g>
|
</g>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
)
|
);
|
||||||
|
|
||||||
export const None = () => (
|
export const None = () => (
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 81 81" xmlnsXlink="http://www.w3.org/1999/xlink">
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="50"
|
||||||
|
height="50"
|
||||||
|
viewBox="0 0 81 81"
|
||||||
|
xmlnsXlink="http://www.w3.org/1999/xlink"
|
||||||
|
>
|
||||||
<defs>
|
<defs>
|
||||||
<rect id="a" width="81" height="81" rx="3"/>
|
<rect id="a" width="81" height="81" rx="3" />
|
||||||
</defs>
|
</defs>
|
||||||
<g fill="none" fillRule="evenodd">
|
<g fill="none" fillRule="evenodd">
|
||||||
<mask id="b" fill="white">
|
<mask id="b" fill="white">
|
||||||
<use xlinkHref="#a"/>
|
<use xlinkHref="#a" />
|
||||||
</mask>
|
</mask>
|
||||||
<use fill="#616161" xlinkHref="#a"/>
|
<use fill="#616161" xlinkHref="#a" />
|
||||||
<g transform="translate(16 32)" mask="url(#b)">
|
<g transform="translate(16 32)" mask="url(#b)">
|
||||||
<path fill="#000000" fillRule="nonzero" d="M66.0458013,46.1092762 C66.0458013,48.3193105 64.2622787,50.1077029 62.050805,50.1077029 L0.174089069,50.1077029 L0.174089069,6.16868499 C0.174089069,2.85738806 2.85846845,0.174657534 6.17268563,0.174657534 L66.0458013,0.174657534 L66.0458013,46.1092762 Z"/>
|
<path
|
||||||
|
fill="#000000"
|
||||||
|
fillRule="nonzero"
|
||||||
|
d="M66.0458013,46.1092762 C66.0458013,48.3193105 64.2622787,50.1077029 62.050805,50.1077029 L0.174089069,50.1077029 L0.174089069,6.16868499 C0.174089069,2.85738806 2.85846845,0.174657534 6.17268563,0.174657534 L66.0458013,0.174657534 L66.0458013,46.1092762 Z"
|
||||||
|
/>
|
||||||
<g fillRule="nonzero" strokeWidth=".5" transform="translate(19.96 15.27)">
|
<g fillRule="nonzero" strokeWidth=".5" transform="translate(19.96 15.27)">
|
||||||
<ellipse cx="7.045" cy="7.048" fill="#FF5E55" stroke="#E0443E" rx="7.045" ry="7.048"/>
|
<ellipse cx="7.045" cy="7.048" fill="#FF5E55" stroke="#E0443E" rx="7.045" ry="7.048" />
|
||||||
<ellipse cx="30.526" cy="7.048" fill="#FFC02C" stroke="#DEA123" rx="7.045" ry="7.048"/>
|
<ellipse cx="30.526" cy="7.048" fill="#FFC02C" stroke="#DEA123" rx="7.045" ry="7.048" />
|
||||||
</g>
|
</g>
|
||||||
</g>
|
</g>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
)
|
);
|
||||||
|
@ -1,46 +1,46 @@
|
|||||||
const Twitter = require('twitter')
|
const Twitter = require('twitter');
|
||||||
const morph = require('morphmorph')
|
const morph = require('morphmorph');
|
||||||
|
|
||||||
const RATE_LIMIT_CODE = 420
|
const RATE_LIMIT_CODE = 420;
|
||||||
|
|
||||||
const client = new Twitter({
|
const client = new Twitter({
|
||||||
consumer_key: process.env.TWITTER_CONSUMER_KEY,
|
consumer_key: process.env.TWITTER_CONSUMER_KEY,
|
||||||
consumer_secret: process.env.TWITTER_CONSUMER_SECRET,
|
consumer_secret: process.env.TWITTER_CONSUMER_SECRET,
|
||||||
access_token_key: process.env.TWITTER_ACCESS_TOKEN_KEY,
|
access_token_key: process.env.TWITTER_ACCESS_TOKEN_KEY,
|
||||||
access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET
|
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 = {}) =>
|
const uploadTweet = (media = {}) =>
|
||||||
client.post('statuses/update', {
|
client.post('statuses/update', {
|
||||||
status: `Carbon Copy #${media.media_id_string.slice(0, 8)}`,
|
status: `Carbon Copy #${media.media_id_string.slice(0, 8)}`,
|
||||||
media_ids: media.media_id_string
|
media_ids: media.media_id_string
|
||||||
})
|
});
|
||||||
|
|
||||||
const extractImageUrl = morph.get('entities.media.0.display_url')
|
const extractImageUrl = morph.get('entities.media.0.display_url');
|
||||||
const extractErrorCode = morph.get('0.code')
|
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 respondFail = (res, err) => {
|
||||||
const errorCode = extractErrorCode(err)
|
const errorCode = extractErrorCode(err);
|
||||||
|
|
||||||
// check for rate limit
|
// check for rate limit
|
||||||
if (errorCode === RATE_LIMIT_CODE) {
|
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)}`)
|
console.error(`Error: ${err.message || JSON.stringify(err, null, 2)}`);
|
||||||
res.status(500).send()
|
res.status(500).send();
|
||||||
}
|
};
|
||||||
|
|
||||||
module.exports = (req, res) => {
|
module.exports = (req, res) => {
|
||||||
if (!req.body.data) {
|
if (!req.body.data) {
|
||||||
return res.status(400).send()
|
return res.status(400).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadImage(req.body.data)
|
uploadImage(req.body.data)
|
||||||
.then(uploadTweet)
|
.then(uploadTweet)
|
||||||
.then(extractImageUrl)
|
.then(extractImageUrl)
|
||||||
.then(respondSuccess.bind(null, res))
|
.then(respondSuccess.bind(null, res))
|
||||||
.catch(respondFail.bind(null, res))
|
.catch(respondFail.bind(null, res));
|
||||||
}
|
};
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
import Editor from './editor'
|
import Editor from './editor';
|
||||||
export default Editor
|
export default Editor;
|
||||||
|
@ -1,40 +1,38 @@
|
|||||||
const express = require('express')
|
const express = require('express');
|
||||||
const morgan = require('morgan')
|
const morgan = require('morgan');
|
||||||
const bodyParser = require('body-parser')
|
const bodyParser = require('body-parser');
|
||||||
const next = require('next')
|
const next = require('next');
|
||||||
|
|
||||||
const port = parseInt(process.env.PORT, 10) || 3000
|
const port = parseInt(process.env.PORT, 10) || 3000;
|
||||||
const dev = process.env.NODE_ENV !== 'production' && !process.env.NOW
|
const dev = process.env.NODE_ENV !== 'production' && !process.env.NOW;
|
||||||
const app = next({ dev })
|
const app = next({ dev });
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler();
|
||||||
|
|
||||||
function wrap (handler) {
|
function wrap(handler) {
|
||||||
return (req, res) => handler(req, res).catch((err) => {
|
return (req, res) =>
|
||||||
console.log('ERR:', err)
|
handler(req, res).catch(err => {
|
||||||
})
|
console.log('ERR:', err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
app.prepare()
|
app.prepare().then(() => {
|
||||||
.then(() => {
|
const server = express();
|
||||||
const server = express()
|
|
||||||
|
|
||||||
server.use(morgan('tiny'))
|
server.use(morgan('tiny'));
|
||||||
|
|
||||||
server.get('/about', (req, res) =>
|
server.get('/about', (req, res) => app.render(req, res, '/about'));
|
||||||
app.render(req, res, '/about'))
|
|
||||||
|
|
||||||
// if root, render webpage from next
|
// if root, render webpage from next
|
||||||
server.get('/*', (req, res) =>
|
server.get('/*', (req, res) => app.render(req, res, '/', req.query));
|
||||||
app.render(req, res, '/', req.query))
|
|
||||||
|
|
||||||
// otherwise, try and get gist
|
// otherwise, try and get gist
|
||||||
server.get('*', handle)
|
server.get('*', handle);
|
||||||
|
|
||||||
// api endpoints
|
// 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) => {
|
server.listen(port, err => {
|
||||||
if (err) throw err
|
if (err) throw err;
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`);
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue