Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
PUBLIC
/
surfer-okd
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 9f18a84b
authored
Jun 27, 2015
by
Johannes Zellner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dynamically use HOSTNAME in welcome screen
1 parent
a46d643e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
8 deletions
app.js
app/welcome.html
src/files.js
app.js
View file @
9f18a84
...
...
@@ -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
());
...
...
app/welcome.html
View file @
9f18a84
...
...
@@ -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/>
...
...
src/files.js
View file @
9f18a84
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment