Created
September 21, 2019 10:46
-
-
Save frauzufall/f343031a992536eb7208db482679085b to your computer and use it in GitHub Desktop.
Exporting gitter to HTML
This file contains 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
'use strict'; | |
const fs = require('fs'); | |
var http = require('http'); | |
http.createServer(function (req, res) { | |
res.setHeader("Content-Type", "text/html"); | |
let rawdata = fs.readFileSync('imagej-imagej.json'); | |
let room = JSON.parse(rawdata); | |
room.sort(function(a,b) { | |
if ( a.sent < b.sent ) | |
return -1; | |
if ( a.sent > b.sent ) | |
return 1; | |
return 0; | |
} ); | |
res.end(buildHTML(room)); | |
}).listen(8080); | |
var buildHTML = function(room) { | |
var result = "<style>.msg {margin: 20px;max-width: 900px;background:#f2f2f4; padding:5px;} .meta{font-size:90%;margin-bottom:7px;}</style>"; | |
room.forEach(function(msg) { | |
console.log(msg); | |
var author = "<div class='meta'>" + msg["sent"] + " " + msg["fromUser"]["displayName"] + " (" + msg["fromUser"]["username"] + ")</div>"; | |
var text = msg["html"]; | |
result += "<div class='msg'>" | |
result += author; | |
result += text; | |
result += "</div>"; | |
}); | |
return result; | |
} |
This file contains 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
npm install --global gitter-export-room | |
# get YOURTOKEN by opening https://developer.gitter.im and sign in | |
gitter-export-room list --token YOURTOKEN | |
# copy ROOMID of the room you want to export, e.g. 5503522515522ed4b3dd3b5a for imagej/imagej | |
gitter-export-room 5503522515522ed4b3dd3b5a --token YOURTOKEN > imagej-imagej.json | |
node app.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment