Commit 9f18a84b by Johannes Zellner

Dynamically use HOSTNAME in welcome screen

1 parent a46d643e
Showing with 6 additions and 8 deletions
......@@ -7,6 +7,8 @@ var express = require('express'),
morgan = require('morgan'),
passport = require('passport'),
path = require('path'),
ejs = require('ejs'),
fs = require('fs'),
compression = require('compression'),
session = require('express-session'),
bodyParser = require('body-parser'),
......@@ -25,8 +27,9 @@ router.get('/api/files/*', auth.ldap, files.get);
router.put('/api/files/*', auth.ldap, multipart, files.put);
router.delete('/api/files/*', auth.ldap, files.del);
// healthcheck in case / does not serve up any file yet
router.get('/', function (req, res) { res.sendFile(path.join(__dirname, '/app/welcome.html')); });
// welcome screen in case / does not serve up any file yet
var appUrl = process.env.HOSTNAME ? 'https://' + process.env.HOSTNAME : 'http://localhost:3000';
router.get('/', function (req, res) { res.status(200).send(ejs.render(fs.readFileSync(path.join(__dirname, '/app/welcome.html'), 'utf8'), { appUrl: appUrl })); });
app.use(morgan('dev'));
app.use(compression());
......
......@@ -17,7 +17,7 @@
</p>
<pre>
npm -g install cloudron-surfer
surfer login http://test-foobar
surfer login <%= appUrl %>
surfer put [file]</pre>
<br/>
<br/>
......
......@@ -2,7 +2,6 @@
var fs = require('fs'),
path = require('path'),
ejs = require('ejs'),
rm = require('del'),
debug = require('debug')('files'),
mkdirp = require('mkdirp'),
......@@ -54,10 +53,6 @@ function copyFile(source, target, cb) {
});
}
function render(view, options) {
return ejs.render(fs.readFileSync(view, 'utf8'), options);
}
function getAbsolutePath(filePath) {
var absoluteFilePath = path.resolve(gBasePath, filePath);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!