Created
August 10, 2016 10:58
-
-
Save codeincontext/5b48bce37c093cc74a4f9fcc6c976849 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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