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'), ...@@ -7,6 +7,8 @@ var express = require('express'),
morgan = require('morgan'), morgan = require('morgan'),
passport = require('passport'), passport = require('passport'),
path = require('path'), path = require('path'),
ejs = require('ejs'),
fs = require('fs'),
compression = require('compression'), compression = require('compression'),
session = require('express-session'), session = require('express-session'),
bodyParser = require('body-parser'), bodyParser = require('body-parser'),
...@@ -25,8 +27,9 @@ router.get('/api/files/*', auth.ldap, files.get); ...@@ -25,8 +27,9 @@ router.get('/api/files/*', auth.ldap, files.get);
router.put('/api/files/*', auth.ldap, multipart, files.put); router.put('/api/files/*', auth.ldap, multipart, files.put);
router.delete('/api/files/*', auth.ldap, files.del); router.delete('/api/files/*', auth.ldap, files.del);
// healthcheck in case / does not serve up any file yet // welcome screen in case / does not serve up any file yet
router.get('/', function (req, res) { res.sendFile(path.join(__dirname, '/app/welcome.html')); }); 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(morgan('dev'));
app.use(compression()); app.use(compression());
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</p> </p>
<pre> <pre>
npm -g install cloudron-surfer npm -g install cloudron-surfer
surfer login http://test-foobar surfer login <%= appUrl %>
surfer put [file]</pre> surfer put [file]</pre>
<br/> <br/>
<br/> <br/>
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
var fs = require('fs'), var fs = require('fs'),
path = require('path'), path = require('path'),
ejs = require('ejs'),
rm = require('del'), rm = require('del'),
debug = require('debug')('files'), debug = require('debug')('files'),
mkdirp = require('mkdirp'), mkdirp = require('mkdirp'),
...@@ -54,10 +53,6 @@ function copyFile(source, target, cb) { ...@@ -54,10 +53,6 @@ function copyFile(source, target, cb) {
}); });
} }
function render(view, options) {
return ejs.render(fs.readFileSync(view, 'utf8'), options);
}
function getAbsolutePath(filePath) { function getAbsolutePath(filePath) {
var absoluteFilePath = path.resolve(gBasePath, 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!