Merge pull request #40 from neuroscr/master

Homepage read public_host from env (docker)/config.json
This commit is contained in:
Ryan Tharp 2020-06-03 16:31:09 -07:00 committed by GitHub
commit c4994bb8fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 30 deletions

View File

@ -7,7 +7,9 @@ module.exports = (app, prefix) => {
// set cache based on dispatcher object
cache = app.dispatcher.cache;
const utilties = overlay.setup(cache, app.dispatcher);
utilties.nconf = app.nconf;
handlers.setup(utilties);
const { storage, logic, config, dialect } = utilties;
app.use('/images', express.static('public/images') );

View File

@ -2,58 +2,46 @@ const pjson = require('../../package.json');
// all input / output filtering should happen here
let cache, dialect, config;
let cache, dialect, config, nconf;
const setup = (utilties) => {
// config are also available here
({ cache, dialect, logic, config } = utilties);
({ cache, dialect, logic, config, nconf } = utilties);
};
const homePageHandler = async (req, res) => {
const version = pjson.version;
/*
const disk_config = config.getDiskConfig()
if (!disk_config) disk_config = {}
if (!disk_config.api) disk_config.api = {}
if (!disk_config) {
disk_config = {};
}
if (!disk_config.api) {
disk_config.api = {};
}
*/
// no trailing slash is needed
let public_url = 'https://localhost';
if (nconf.get('web:public_host')) {
public_url = 'https://' + nconf.get('web:public_host')
}
// console.log('disk_config', disk_config);
cache.getAnnotations('channel', 1, function(note, err) {
if (err) console.error('error', err)
// console.log('note', JSON.stringify(note))
var value = JSON.parse(note[0].value)
var value = JSON.parse(note[0].value);
// console.log('avatar', value.avatar)
var whitelistMode = config.inWhiteListMode();
// console.log('whitelistMode', whitelistMode, disk_config)
res.render('index.ejs', {
version: version,
public_url: disk_config.api.public_url,
public_url: public_url,
c1_name: value.name,
c1_logo: value.avatar,
c1_desc: value.description,
whitelistMode: whitelistMode,
});
})
/*
res.end(`
<html>
<head>
<title>Loki Session Open Group Server</title>
</head>
<body>
<h1>Loki <a href="https://getsession.org/">Session</a> Open Group Server</h1>
<h2>Version ${version}</h2>
<div>
<a href="https://github.com/loki-project/session-open-group-server/wiki/How-to-join-an-open-group">How to join an open group</a>
</div>
<h6>Copyright <a href="https://loki.network">Loki Project</a> 2019-Current</h6>
<h6>
<a href="https://github.com/loki-project/session-open-group-server">GitHub</a>
<a href="https://lokinet.org">Lokinet.org</a>
<a href="https://loki.foundation">Loki Foundation</a>
<a href="https://coinstop.io/">Merch</a>
</h6>
</body>
</html>
`);
*/
});
};
module.exports = {