Commit f658bcfb authored by Jared Pereira's avatar Jared Pereira

add markdown parsing to messages

parent e5be5073
......@@ -57,6 +57,14 @@
"readable-stream": "2.3.3"
}
},
"argparse": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.9.tgz",
"integrity": "sha1-c9g7wmP4bpf4zE9rrhsOkKfSLIY=",
"requires": {
"sprintf-js": "1.0.3"
}
},
"array-filter": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/array-filter/-/array-filter-0.0.1.tgz",
......@@ -1168,6 +1176,11 @@
"once": "1.4.0"
}
},
"entities": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz",
"integrity": "sha1-blwtClYhtdra7O+AuQ7ftc13cvA="
},
"escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
......@@ -1784,6 +1797,14 @@
"astw": "2.2.0"
}
},
"linkify-it": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.0.3.tgz",
"integrity": "sha1-2UpGSPmxwXnWT6lykSaL22zpQ08=",
"requires": {
"uc.micro": "1.0.3"
}
},
"lodash": {
"version": "4.17.4",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz",
......@@ -1802,6 +1823,18 @@
"js-tokens": "3.0.2"
}
},
"markdown-it": {
"version": "8.4.0",
"resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-8.4.0.tgz",
"integrity": "sha512-tNuOCCfunY5v5uhcO2AUMArvKAyKMygX8tfup/JrgnsDqcCATQsAExBq7o5Ml9iMmO82bk6jYNLj6khcrl0JGA==",
"requires": {
"argparse": "1.0.9",
"entities": "1.1.1",
"linkify-it": "2.0.3",
"mdurl": "1.0.1",
"uc.micro": "1.0.3"
}
},
"md5.js": {
"version": "1.3.4",
"resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.4.tgz",
......@@ -1822,6 +1855,11 @@
}
}
},
"mdurl": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz",
"integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4="
},
"media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
......@@ -2459,6 +2497,11 @@
"source-map": "0.5.7"
}
},
"sprintf-js": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw="
},
"static-eval": {
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/static-eval/-/static-eval-0.2.4.tgz",
......@@ -2817,6 +2860,11 @@
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
},
"uc.micro": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.3.tgz",
"integrity": "sha1-ftUNXg+an7ClczeSWfKndFjVAZI="
},
"ultron": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.0.tgz",
......
......@@ -13,6 +13,7 @@
"ethjs-query": "^0.2.9",
"express": "^4.15.4",
"express-ws": "^3.0.0",
"markdown-it": "^8.4.0",
"sha3": "^1.2.0",
"ws": "^3.1.0"
},
......
var fs = require('fs')
var path = require('path')
var config = JSON.parse(fs.readFileSync(path.join(__dirname, '../config.json')))
var MarkdownIt = require('markdown-it')
var md = new MarkdownIt()
var config = JSON.parse(fs.readFileSync(path.join(__dirname, '../config.json')))
var ethUtil = require('ethereumjs-util')
......@@ -90,7 +92,7 @@ function pushMessage(args){
var textEl = document.createElement('pre')
textEl.classList.add('text')
var text = args.text || ''
var text = md.renderInline(args.text)
if(args.class == 'message'){
var nickLinkEl = document.createElement('a')
......@@ -103,8 +105,7 @@ function pushMessage(args){
messageEl.appendChild(nickLinkEl)
}
textEl.textContent = text
textEl.innerHTML = textEl.innerHTML.replace(/(https?:\/\/)\S+?(?=[,.!?:)]?\s|$)/g, parseLinks)
textEl.innerHTML = text
if(typeof args.class != undefined) {
messageEl.classList.add(args.class)
......@@ -230,8 +231,10 @@ var room = window.location.search.replace(/^\?/, '')
var ABI = {"constant":true,"inputs":[{"name":"permissions","type":"address"}],"name":"getPermissions","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"}
if(room == ''){
var home = window.location
var roomLink = "[" + networkConfig.defaultRoom + "]" +"(" + home + "?" + networkConfig.defaultRoom + ")"
var message = [
"This is an interface for smart-contract based chat rooms",
"This is super low security. It's essentially just an arbitrary message relayer",
......@@ -240,7 +243,7 @@ if(room == ''){
"`" + JSON.stringify(ABI) + "'",
"\n",
"Go to an address and hit login, logout when you're done",
"If you want to try an room check out: " + home + "?" + network.defaultRoom,
"If you want to try an room check out: " + roomLink,
"\n",
"You can check out what commands are available with /help"
].join('\n')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment