ADD: website

This commit is contained in:
Overtorment 2018-12-08 15:47:48 +00:00
parent bf2c01a88c
commit 17140e4f23
5 changed files with 567 additions and 21 deletions

23
controllers/website.js Normal file
View File

@ -0,0 +1,23 @@
let express = require('express');
let router = express.Router();
let fs = require('fs');
let mustache = require('mustache');
let lightning = require('../lightning');
router.get('/', function(req, res) {
let html = fs.readFileSync('./templates/index.html').toString('utf8');
lightning.getInfo({}, function(err, info) {
if (err) {
console.error('lnd failure');
process.exit(3);
}
res.setHeader('Content-Type', 'text/html');
return res.status(200).send(mustache.render(html, info));
});
});
router.use(function(req, res) {
res.status(404).send('404');
});
module.exports = router;

View File

@ -30,6 +30,7 @@ app.use(bodyParser.urlencoded({ extended: false })); // parse application/x-www-
app.use(bodyParser.json(null)); // parse application/json app.use(bodyParser.json(null)); // parse application/json
app.use(require('./controllers/api')); app.use(require('./controllers/api'));
app.use(require('./controllers/website'));
let server = app.listen(process.env.PORT || 3000, function() { let server = app.listen(process.env.PORT || 3000, function() {
logger.log('BOOTING UP', 'Listening on port ' + (process.env.PORT || 3000)); logger.log('BOOTING UP', 'Listening on port ' + (process.env.PORT || 3000));

33
package-lock.json generated
View File

@ -2265,13 +2265,11 @@
}, },
"balanced-match": { "balanced-match": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true
"optional": true
}, },
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
@ -2284,18 +2282,15 @@
}, },
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true
"optional": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"bundled": true, "bundled": true
"optional": true
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@ -2398,8 +2393,7 @@
}, },
"inherits": { "inherits": {
"version": "2.0.3", "version": "2.0.3",
"bundled": true, "bundled": true
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
@ -2409,7 +2403,6 @@
"is-fullwidth-code-point": { "is-fullwidth-code-point": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
@ -2422,20 +2415,17 @@
"minimatch": { "minimatch": {
"version": "3.0.4", "version": "3.0.4",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
}, },
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"bundled": true, "bundled": true
"optional": true
}, },
"minipass": { "minipass": {
"version": "2.2.4", "version": "2.2.4",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"safe-buffer": "^5.1.1", "safe-buffer": "^5.1.1",
"yallist": "^3.0.0" "yallist": "^3.0.0"
@ -2452,7 +2442,6 @@
"mkdirp": { "mkdirp": {
"version": "0.5.1", "version": "0.5.1",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }
@ -2525,8 +2514,7 @@
}, },
"number-is-nan": { "number-is-nan": {
"version": "1.0.1", "version": "1.0.1",
"bundled": true, "bundled": true
"optional": true
}, },
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
@ -2536,7 +2524,6 @@
"once": { "once": {
"version": "1.4.0", "version": "1.4.0",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
@ -2642,7 +2629,6 @@
"string-width": { "string-width": {
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",
@ -3956,6 +3942,11 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
}, },
"mustache": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/mustache/-/mustache-3.0.1.tgz",
"integrity": "sha512-jFI/4UVRsRYdUbuDTKT7KzfOp7FiD5WzYmmwNwXyUVypC0xjoTL78Fqc0jHUPIvvGD+6DQSPHIt1NE7D1ArsqA=="
},
"mute-stream": { "mute-stream": {
"version": "0.0.7", "version": "0.0.7",
"resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz",

View File

@ -29,6 +29,7 @@
"ioredis": "^4.2.0", "ioredis": "^4.2.0",
"jayson": "^2.1.0", "jayson": "^2.1.0",
"morgan": "^1.9.1", "morgan": "^1.9.1",
"mustache": "^3.0.1",
"node-uuid": "^1.4.8", "node-uuid": "^1.4.8",
"prettier": "^1.15.3", "prettier": "^1.15.3",
"request": "^2.88.0", "request": "^2.88.0",

530
templates/index.html Normal file
View File

@ -0,0 +1,530 @@
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<style type="text/css">
@charset "UTF-8";
</style>
<meta content="width=640, maximum-scale=1.0" name="viewport">
<meta content="http://lndhub.io" property="og:url">
<meta content="lndhub.io" property="og:title">
<meta content="lndhub" property="og:description">
<meta content="http://url.here/logo.png" property="og:image">
<meta content="800" property="og:image:width">
<meta content="800" property="og:image:height">
<title>LndHub</title>
<meta content="command line, lndhub" name="keywords">
<meta content="command-line lndhub" name="description">
</head>
<body class="theme-dark" style="background: none;">
<div class="holder">
<div class="container">
<div class="terminal-output">
<pre class="line"> _________________________</pre>
<pre class="line">/ Hi! How are you? \</pre>
<pre class="line">| |</pre>
<pre class="line">\ Welcome to LNDHUB! /</pre>
<pre class="line"> -------------------------</pre>
<pre class="line"> \ ^__^</pre>
<pre class="line"> \ (oo)\_______</pre>
<pre class="line"> (__)\ )\/\</pre>
<pre class="line"> ||----w |</pre>
<pre class="line"> || ||</pre>
<pre class="line"> </pre>
<pre class="line"> </pre>
<pre class="line"> </pre>
<pre class="line"><span class="dyer-white">Hello world!</span></pre>
<pre class="line"><span class="dyer-orange">Welcome to LndHub, opensource wrapper for Lightning Network Daemon</span></pre>
<pre class="line"><span class="dyer-orange">It provides separate accounts and trust minimization for end users</span></pre>
<pre class="line"> </pre>
<pre class="line"><span class="dyer-white">LND uris:</span></pre>
{{#uris}}
<pre class="line">{{.}}</pre>
{{/uris}}
<pre class="line"> </pre>
<pre class="line"><span class="dyer-white">num_active_channels:</span></pre>
<pre class="line">{{num_active_channels}}</pre>
<pre class="line"> </pre>
<pre class="line"><span class="dyer-white">num_peers:</span></pre>
<pre class="line">{{num_peers}}</pre>
<pre class="line"> </pre>
<pre class="line"><span class="dyer-white">version:</span></pre>
<pre class="line">{{version}}</pre>
<pre class="line"> </pre>
<pre class="line"><span class="dyer-white">Fork me on GitHub!</span></pre>
<pre class="line"><a href="https://github.com/BlueWallet/LndHub" target="_blank">https://github.com/BlueWallet/LndHub</a></pre>
<pre class="line"> </pre>
<pre class="line"><span class="dyer-white">Start using it on MainNet (zero configuration required):</span></pre>
<pre class="line"><a href="https://bluewallet.io" target="_blank">https://bluewallet.io</a></pre>
<pre class="line"> </pre>
<pre class="line"> </pre>
<pre class="line"> </pre>
</div>
</div>
<div class="terminal-input-holder">
<div class="pre-query">
$
</div>
<input autocomplete="off" class="terminal-input " eb-caret="caretPosition" style="width: 967px;" type="text">
</div>
</div>
<style>
html, body {
height: 100%;
background: #000;
overflow-y: scroll!important
}
html {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box
}
*, :before, :after {
box-sizing: inherit
}
body {
margin: 0;
font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
word-wrap: break-word;
font-weight: 400;
height: 100%;
width: 100%;
float: left
}
body.theme-dark {
background-color: #000;
color: #f7f7f7
}
body.theme-light {
background-color: #f7f7f7;
color: #191919
}
a {
color: inherit;
text-decoration: none
}
body.theme-dark a {
color: #f7f7f7
}
body.theme-light a {
color: #191919
}
.line a {
cursor: pointer
}
body.theme-dark cmd, body.theme-dark .line a {
color: #f7f7f7;
border-bottom: 1px dotted #f7f7f7
}
body.theme-light cmd, body.theme-light .line a {
color: #191919;
border-bottom: 1px dotted #191919
}
body.theme-dark a:hover, body.theme-dark cmd:hover {
color: #0ff
}
body.theme-light a:hover, body.theme-light cmd:hover {
color: #ff00ff
}
textarea {
resize: none;
min-height: 0;
font-family: inherit;
font-size: inherit;
font-weight: inherit;
vertical-align: middle;
overflow: none;
letter-spacing: inherit
}
.container {
padding: 10px;
width: 100%
}
.holder {
position: fixed;
width: 100%;
height: 100%;
overflow: auto;
bottom: 0;
padding-top: 30px;
padding-bottom: 0
}
.terminal-input {
font-family: inherit;
font-size: 16px;
width: 100%;
float: left;
text-align: inherit;
border: 0;
padding: 0 10px;
border-radius: 0;
margin-top: 10px;
margin-bottom: 10px;
background: 0 0
}
.prompt-input {
background-color: transparent;
font-family: inherit;
font-size: 16px;
width: 100%;
float: left;
text-align: inherit;
border: 0;
padding: 0 10px;
border-radius: 0;
margin-top: 10px;
margin-bottom: 10px
}
.terminal-input-sml {
width: 50%;
float: left
}
.prompt-input-sml {
width: 50%;
float: left
}
.pre-query {
font-size: 16px;
padding-top: 10px;
float: left;
color: #01DD06
}
.pre-prompt {
font-size: 16px;
padding-top: 10px;
float: left;
color: #01DD06
}
body.theme-dark .terminal-input {
color: #fff
}
body.theme-light .terminal-input {
color: #f7f7f7
}
body.theme-dark .prompt-input {
color: #fff
}
body.theme-light .prompt-input {
color: #f7f7f7
}
#tabs {
display: none!important;
list-style: none;
margin: 0!important;
width: 100%;
float: left;
position: fixed;
z-index: 3;
padding-left: 25px;
font-size: 14px
}
#tabs li {
float: left;
margin: 0;
margin-right: 10px;
background: #252525;
padding: 5px;
padding-right: 14px;
padding-left: 14px;
color: gray;
cursor: pointer
}
.noselect {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none
}
.close_tab_btn {
color: #b4b4b4!important;
margin-top: -2px;
float: right;
margin-left: 10px;
padding: 1px
}
.close_tab_btn:hover {
color: #2d2d2d!important
}
#tabs li:hover {
background: #fff
}
.pull-right {
float: right!important
}
#tabs li.active {
font-weight: 700;
background: #fff
}
.terminal-input:focus {
outline: 0
}
.prompt-input:focus {
outline: 0
}
.terminal-output {
padding: 0 16px;
margin-bottom: 50px
}
.divider {
width: 100%;
overflow: hidden;
white-space: nowrap;
margin-top: 5px;
margin-bottom: 5px
}
.line {
font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
display: block;
float: left;
width: 100%;
font-size: 12px;
color: #C3C3C3;
margin: 0;
font-smooth: never!important;
white-space: pre-wrap;
white-space: -moz-pre-wrap;
white-space: -pre-wrap;
white-space: -o-pre-wrap;
word-wrap: break-word
}
.darkIframeBg {
background: #000!important
}
.cmdfmWidgetHolder {
position: fixed!important;
left: -1000px!important;
top: -500px!important;
width: 0!important;
height: 0!important
}
.iframeHolder iframe {
width: 100%;
height: 100%;
padding: 3%;
position: fixed;
border: none!important;
overflow: hidden!important
}
.dyer-runcmd-green {
color: #01DD06;
margin-left: -5px;
font-size: 14px
}
.dyer-runcmd-green span {
color: #d4d4d4;
font-size: 14px
}
.dyer-runcmd-green .qry {
color: #fff!important
}
.dyer-green {
color: #01DD06
}
.dyer-tomato {
color: tomato
}
.dyer-orange {
color: orange
}
.dyer-white {
color: #fff
}
.dyer-red {
color: #e74c3c
}
.dyer-darkgray {
color: #666
}
.dyer-blue {
color: #1DBAFE
}
.dyer-yellow {
color: #fff01c
}
.dyer-gr-yellow-1 {
color: #fff8e3
}
.dyer-gr-yellow-2 {
color: #fffeab
}
.dyer-gr-yellow-3 {
color: #fff85f
}
.dyer-gr-yellow-4 {
color: #ffe454
}
.dyer-gr-yellow-5 {
color: #ffb50e
}
.dyer-gr-green-1 {
color: #bdffbc
}
.dyer-gr-green-2 {
color: #78ff75
}
.dyer-gr-green-3 {
color: #35ff2a
}
.dyer-gr-green-4 {
color: #27ce21
}
.dyer-gr-green-5 {
color: #008e03
}
.dyer-gr-blue-1 {
color: #f1f6ff
}
.dyer-gr-blue-2 {
color: #e7e0ff
}
.dyer-gr-blue-3 {
color: #84cbff
}
.dyer-gr-blue-4 {
color: #38acff
}
.dyer-gr-blue-5 {
color: #0f72ff
}
span {
line-height: 15px
}
.no-animation * {
-o-transition-property: none!important;
-moz-transition-property: none!important;
-ms-transition-property: none!important;
-webkit-transition-property: none!important;
transition-property: none!important;
-o-transform: none!important;
-moz-transform: none!important;
-ms-transform: none!important;
-webkit-transform: none!important;
transform: none!important;
-webkit-animation: none!important;
-moz-animation: none!important;
-o-animation: none!important;
-ms-animation: none!important;
animation: none!important
}
.container * {
-webkit-animation: fadein .2s ease;
-moz-animation: fadein .2s ease;
-ms-animation: fadein .2s ease;
-o-animation: fadein .2s ease;
animation: fadein .2s ease
}
@keyframes fadein {
from {
transform: translateY(4px)
}
to {
transform: translateY(0px)
}
}
@-moz-keyframes fadein {
from {
-moz-transform: translateY(4px)
}
to {
-moz-transform: translateY(0px)
}
}
@-webkit-keyframes fadein {
from {
-webkit-transform: translateY(4px)
}
to {
-webkit-transform: translateY(0px)
}
}
@-ms-keyframes fadein {
from {
-ms-transform: translateY(4px)
}
to {
-ms-transform: translateY(0px)
}
}
@-o-keyframes fadein {
from {
-o-transform: translateY(4px)
}
to {
-o-transform: translateY(0px)
}
}
::-webkit-scrollbar {
width: 4px;
height: 4px
}
::-webkit-scrollbar-track {
background-color: transparent;
-webkit-border-radius: 0
}
body.theme-dark ::-webkit-scrollbar-thumb:vertical, body.theme-dark ::-webkit-scrollbar-thumb:horizontal {
background-color: orange;
-webkit-border-radius: 0
}
body.theme-light ::-webkit-scrollbar-thumb:vertical, body.theme-light ::-webkit-scrollbar-thumb:horizontal {
background-color: #191919;
-webkit-border-radius: 0
}
body.theme-dark ::-webkit-scrollbar-thumb:vertical:hover, body.theme-dark ::-webkit-scrollbar-thumb:horizontal:hover {
background-color: #0ff
}
body.theme-light ::-webkit-scrollbar-thumb:vertical:hover, body.theme-light ::-webkit-scrollbar-thumb:horizontal:hover {
background-color: #ff00ff
}
.nobot {
margin: none!important;
padding: none!important;
line-height: 1em
}
.mini-player-indicator {
background: #FF3900!important;
color: #fff!important
}
.mini-player-indicator:hover {
background: #fff!important;
color: #FF3900!important
}
.terminal-input-holder-fixed {
position: fixed;
bottom: 0;
width: 100%;
background: rgba(0, 0, 0, .7)
}
.terminal-input-holder {
float: left;
width: 100%;
display: block
}
.curtain {
width: 100%;
height: 100%;
position: fixed;
z-index: 1;
top: 0;
left: 0;
display: none;
background: #000;
opacity: .5
}
.curtain.active {
display: block
}
</style>
</body>
</html>