Skip to content

Instantly share code, notes, and snippets.

@codeincontext
Created August 10, 2016 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeincontext/5b48bce37c093cc74a4f9fcc6c976849 to your computer and use it in GitHub Desktop.
Save codeincontext/5b48bce37c093cc74a4f9fcc6c976849 to your computer and use it in GitHub Desktop.
function renderSVG() {
services.fetchAll()
.done(function(results) {
const data = {};
results.forEach(r => data[r.name] = r);
const lastSeenDates = results.map(r => r.lastSeenDate);
data.lastSeenDate = Math.max.apply(Math, lastSeenDates);
// console.log(data)
let svg = ReactDOMServer.renderToStaticMarkup(React.createElement(Board, data));
svg = svg.replace('<svg', '<svg xmlns="http://www.w3.org/2000/svg"');
console.log(svg);
fs.writeFileSync(SVG_FILENAME, svg)
execSync(`rsvg-convert ${SVG_FILENAME} --background-color=white -o ${PNG_FILENAME}`)
execSync(`pngcrush -c 0 -ow ${PNG_FILENAME}`)
var body = fs.createReadStream(PNG_FILENAME);
var s3obj = new AWS.S3({params: {
Region: 'eu-west-1',
Bucket: 'cantseethis',
Key: 'latest-600x800.png'
}});
s3obj.upload({Body: body}).
on('httpUploadProgress', function(evt) { console.log(evt); }).
send(function(err, data) { console.log(err, data) });
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment