diff options
-rwxr-xr-x | app.js | 7 | ||||
-rw-r--r-- | app/welcome.html | 2 | ||||
-rw-r--r-- | src/files.js | 5 |
3 files changed, 6 insertions, 8 deletions
@@ -7,6 +7,8 @@ var express = require('express'), | |||
7 | morgan = require('morgan'), | 7 | morgan = require('morgan'), |
8 | passport = require('passport'), | 8 | passport = require('passport'), |
9 | path = require('path'), | 9 | path = require('path'), |
10 | ejs = require('ejs'), | ||
11 | fs = require('fs'), | ||
10 | compression = require('compression'), | 12 | compression = require('compression'), |
11 | session = require('express-session'), | 13 | session = require('express-session'), |
12 | bodyParser = require('body-parser'), | 14 | bodyParser = require('body-parser'), |
@@ -25,8 +27,9 @@ router.get('/api/files/*', auth.ldap, files.get); | |||
25 | router.put('/api/files/*', auth.ldap, multipart, files.put); | 27 | router.put('/api/files/*', auth.ldap, multipart, files.put); |
26 | router.delete('/api/files/*', auth.ldap, files.del); | 28 | router.delete('/api/files/*', auth.ldap, files.del); |
27 | 29 | ||
28 | // healthcheck in case / does not serve up any file yet | 30 | // welcome screen in case / does not serve up any file yet |
29 | router.get('/', function (req, res) { res.sendFile(path.join(__dirname, '/app/welcome.html')); }); | 31 | var appUrl = process.env.HOSTNAME ? 'https://' + process.env.HOSTNAME : 'http://localhost:3000'; |
32 | router.get('/', function (req, res) { res.status(200).send(ejs.render(fs.readFileSync(path.join(__dirname, '/app/welcome.html'), 'utf8'), { appUrl: appUrl })); }); | ||
30 | 33 | ||
31 | app.use(morgan('dev')); | 34 | app.use(morgan('dev')); |
32 | app.use(compression()); | 35 | app.use(compression()); |
diff --git a/app/welcome.html b/app/welcome.html index 3fd2ed8..9d3fa25 100644 --- a/app/welcome.html +++ b/app/welcome.html | |||
@@ -17,7 +17,7 @@ | |||
17 | </p> | 17 | </p> |
18 | <pre> | 18 | <pre> |
19 | npm -g install cloudron-surfer | 19 | npm -g install cloudron-surfer |
20 | surfer login http://test-foobar | 20 | surfer login <%= appUrl %> |
21 | surfer put [file]</pre> | 21 | surfer put [file]</pre> |
22 | <br/> | 22 | <br/> |
23 | <br/> | 23 | <br/> |
diff --git a/src/files.js b/src/files.js index c725e4b..3b28d3f 100644 --- a/src/files.js +++ b/src/files.js | |||
@@ -2,7 +2,6 @@ | |||
2 | 2 | ||
3 | var fs = require('fs'), | 3 | var fs = require('fs'), |
4 | path = require('path'), | 4 | path = require('path'), |
5 | ejs = require('ejs'), | ||
6 | rm = require('del'), | 5 | rm = require('del'), |
7 | debug = require('debug')('files'), | 6 | debug = require('debug')('files'), |
8 | mkdirp = require('mkdirp'), | 7 | mkdirp = require('mkdirp'), |
@@ -54,10 +53,6 @@ function copyFile(source, target, cb) { | |||
54 | }); | 53 | }); |
55 | } | 54 | } |
56 | 55 | ||
57 | function render(view, options) { | ||
58 | return ejs.render(fs.readFileSync(view, 'utf8'), options); | ||
59 | } | ||
60 | |||
61 | function getAbsolutePath(filePath) { | 56 | function getAbsolutePath(filePath) { |
62 | var absoluteFilePath = path.resolve(gBasePath, filePath); | 57 | var absoluteFilePath = path.resolve(gBasePath, filePath); |
63 | 58 | ||