mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
Configurable base url
This commit is contained in:
parent
7b6d0c6425
commit
20cbf50596
@ -42,6 +42,7 @@ Key | Description
|
||||
--- | ---
|
||||
game | Which game server to launch, see above
|
||||
path | Folder path to game server
|
||||
baseUrl | URL path used to serve the application, default is '/'. Must end with `/`
|
||||
port | Web port to use
|
||||
host | IP or Hostname to listen on
|
||||
type | Which kind of server to use, can be 'linux', 'windows' or 'wine'
|
||||
|
24
app.js
24
app.js
@ -17,7 +17,6 @@ var Settings = require('./lib/settings')
|
||||
|
||||
var app = express()
|
||||
var server = require('http').Server(app)
|
||||
var io = require('socket.io')(server)
|
||||
|
||||
setupBasicAuth(config, app)
|
||||
|
||||
@ -27,8 +26,6 @@ app.use(bodyParser.urlencoded({ extended: false }))
|
||||
morgan.token('user', function (req) { return req.auth ? req.auth.user : 'anon' })
|
||||
app.use(morgan(config.logFormat || 'dev'))
|
||||
|
||||
app.use(serveStatic(path.join(__dirname, 'public')))
|
||||
|
||||
var logs = new Logs(config)
|
||||
|
||||
var manager = new Manager(config, logs)
|
||||
@ -40,11 +37,22 @@ mods.updateMods()
|
||||
|
||||
var settings = new Settings(config)
|
||||
|
||||
app.use('/api/logs', require('./routes/logs')(logs))
|
||||
app.use('/api/missions', require('./routes/missions')(missions))
|
||||
app.use('/api/mods', require('./routes/mods')(mods))
|
||||
app.use('/api/servers', require('./routes/servers')(manager, mods))
|
||||
app.use('/api/settings', require('./routes/settings')(settings))
|
||||
var baseUrl = config.baseUrl || '/'
|
||||
var router = express.Router()
|
||||
|
||||
router.use('/api/logs', require('./routes/logs')(logs))
|
||||
router.use('/api/missions', require('./routes/missions')(missions))
|
||||
router.use('/api/mods', require('./routes/mods')(mods))
|
||||
router.use('/api/servers', require('./routes/servers')(manager, mods))
|
||||
router.use('/api/settings', require('./routes/settings')(settings))
|
||||
router.use('/', require('./routes/main')(baseUrl))
|
||||
router.use(serveStatic(path.join(__dirname, 'public')))
|
||||
|
||||
app.use(baseUrl, router)
|
||||
|
||||
var io = require('socket.io')(server, {
|
||||
path: baseUrl + 'socket.io'
|
||||
})
|
||||
|
||||
io.on('connection', function (socket) {
|
||||
socket.emit('missions', missions.missions)
|
||||
|
@ -1,6 +1,7 @@
|
||||
module.exports = {
|
||||
game: 'arma3', // arma3, arma2oa, arma2, arma1, cwa, ofpresistance, ofp
|
||||
path: 'path-to-arma3-directory',
|
||||
baseUrl: '/',
|
||||
port: 3000,
|
||||
host: '0.0.0.0', // Can be either an IP or a Hostname
|
||||
type: 'linux', // Can be either linux, windows or wine
|
||||
|
@ -1,17 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<base href="/" />
|
||||
<meta charset="utf-8">
|
||||
<title>Arma Server Admin</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="shortcut icon" href="/favicon.ico" />
|
||||
<link rel="shortcut icon" href="favicon.ico" />
|
||||
|
||||
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script src="/socket.io/socket.io.js"></script>
|
||||
<script src="socket.io/socket.io.js"></script>
|
||||
<script src="bundle.js"></script>
|
||||
</head>
|
||||
<body></body>
|
||||
|
@ -7,5 +7,5 @@ module.exports = Backbone.Collection.extend({
|
||||
return b.get('created').localeCompare(a.get('created')) // Descending order
|
||||
},
|
||||
model: Log,
|
||||
url: '/api/logs/'
|
||||
url: 'api/logs/'
|
||||
})
|
||||
|
@ -7,5 +7,5 @@ module.exports = Backbone.Collection.extend({
|
||||
return a.get('name').toLowerCase().localeCompare(b.get('name').toLowerCase())
|
||||
},
|
||||
model: Mission,
|
||||
url: '/api/missions/'
|
||||
url: 'api/missions/'
|
||||
})
|
||||
|
@ -7,5 +7,5 @@ module.exports = Backbone.Collection.extend({
|
||||
return a.get('name').toLowerCase().localeCompare(b.get('name').toLowerCase())
|
||||
},
|
||||
model: Mod,
|
||||
url: '/api/mods/'
|
||||
url: 'api/mods/'
|
||||
})
|
||||
|
@ -7,5 +7,5 @@ module.exports = Backbone.Collection.extend({
|
||||
return a.get('title').toLowerCase().localeCompare(b.get('title').toLowerCase())
|
||||
},
|
||||
model: Server,
|
||||
url: '/api/servers/'
|
||||
url: 'api/servers/'
|
||||
})
|
||||
|
@ -5,5 +5,5 @@ module.exports = Backbone.Model.extend({
|
||||
name: ''
|
||||
},
|
||||
idAttribute: 'name',
|
||||
urlRoot: '/api/missions/'
|
||||
urlRoot: 'api/missions/'
|
||||
})
|
||||
|
@ -5,5 +5,5 @@ module.exports = Backbone.Model.extend({
|
||||
name: ''
|
||||
},
|
||||
idAttribute: 'name',
|
||||
urlRoot: '/api/mods/'
|
||||
urlRoot: 'api/mods/'
|
||||
})
|
||||
|
@ -23,11 +23,11 @@ module.exports = Backbone.Model.extend({
|
||||
von: false,
|
||||
verify_signatures: false
|
||||
},
|
||||
urlRoot: '/api/servers/',
|
||||
urlRoot: 'api/servers/',
|
||||
start: function (cb) {
|
||||
var self = this
|
||||
$.ajax({
|
||||
url: '/api/servers/' + self.get('id') + '/start',
|
||||
url: 'api/servers/' + self.get('id') + '/start',
|
||||
type: 'POST',
|
||||
success: function (resp) {
|
||||
self.set('pid', resp.pid)
|
||||
@ -47,7 +47,7 @@ module.exports = Backbone.Model.extend({
|
||||
stop: function (cb) {
|
||||
var self = this
|
||||
$.ajax({
|
||||
url: '/api/servers/' + self.get('id') + '/stop',
|
||||
url: 'api/servers/' + self.get('id') + '/stop',
|
||||
type: 'POST',
|
||||
success: function (resp) {
|
||||
self.set('pid', resp.pid)
|
||||
|
@ -5,5 +5,5 @@ module.exports = Backbone.Model.extend({
|
||||
path: '',
|
||||
type: ''
|
||||
},
|
||||
urlRoot: '/api/settings'
|
||||
urlRoot: 'api/settings'
|
||||
})
|
||||
|
@ -37,7 +37,9 @@ module.exports = Backbone.Router.extend({
|
||||
var initialized = false
|
||||
|
||||
/* global io */
|
||||
var socket = io.connect()
|
||||
var socket = io({
|
||||
path: window.location.pathname + 'socket.io'
|
||||
})
|
||||
socket.on('missions', function (_missions) {
|
||||
missions.set(_missions)
|
||||
})
|
||||
|
@ -45,7 +45,7 @@ module.exports = Marionette.LayoutView.extend({
|
||||
refresh: function (event) {
|
||||
event.preventDefault()
|
||||
$.ajax({
|
||||
url: '/api/missions/refresh',
|
||||
url: 'api/missions/refresh',
|
||||
type: 'POST',
|
||||
success: function (resp) {
|
||||
|
||||
|
@ -21,7 +21,7 @@ module.exports = Marionette.ItemView.extend({
|
||||
var laddaBtn = Ladda.create($uploadBtn.get(0))
|
||||
laddaBtn.start()
|
||||
|
||||
$.ajax('/api/missions', {
|
||||
$.ajax('api/missions', {
|
||||
success: function (data) {
|
||||
laddaBtn.stop()
|
||||
self.render()
|
||||
|
@ -25,7 +25,7 @@ module.exports = Marionette.ItemView.extend({
|
||||
laddaBtn.start()
|
||||
|
||||
$.ajax({
|
||||
url: '/api/missions/workshop',
|
||||
url: 'api/missions/workshop',
|
||||
type: 'POST',
|
||||
data: {
|
||||
id: $form.find('input.workshop').val()
|
||||
|
@ -19,7 +19,7 @@ module.exports = Marionette.CompositeView.extend({
|
||||
refresh: function (event) {
|
||||
event.preventDefault()
|
||||
$.ajax({
|
||||
url: '/api/mods/refresh',
|
||||
url: 'api/mods/refresh',
|
||||
type: 'POST',
|
||||
success: function (resp) {
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<td>
|
||||
<% if (size < 100 * 1024 * 1024) { %>
|
||||
<!-- Only show files under 100 MB -->
|
||||
<a href='/api/logs/<%-name%>/view' target=_blank><%-name%></a>
|
||||
<a href='api/logs/<%-name%>/view' target=_blank><%-name%></a>
|
||||
<% } else { %>
|
||||
<%-name%>
|
||||
<% } %>
|
||||
@ -16,7 +16,7 @@
|
||||
<%-formattedSize%>
|
||||
</td>
|
||||
<td>
|
||||
<a class="btn btn-primary btn-xs" href="/api/logs/<%-name%>/download">
|
||||
<a class="btn btn-primary btn-xs" href="api/logs/<%-name%>/download">
|
||||
<span class="glyphicon glyphicon-download"></span>
|
||||
Download
|
||||
</a>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<td style="width: 100%;">
|
||||
<a href='/api/missions/<%-encodeURI(name)%>'><%-missionName%></a>
|
||||
<a href='api/missions/<%-encodeURI(name)%>'><%-missionName%></a>
|
||||
</td>
|
||||
<td><%-worldName%></td>
|
||||
<td class="text-nowrap"><%-sizeFormatted%></td>
|
||||
|
23
routes/main.js
Normal file
23
routes/main.js
Normal file
@ -0,0 +1,23 @@
|
||||
var express = require('express')
|
||||
var fs = require('fs')
|
||||
var path = require('path')
|
||||
|
||||
var indexPath = path.join(__dirname, '..', 'public', 'index.html')
|
||||
|
||||
module.exports = function (baseUrl) {
|
||||
var router = express.Router()
|
||||
|
||||
router.get('/', function (req, res) {
|
||||
fs.readFile(indexPath, 'utf-8', function (err, data) {
|
||||
if (err) {
|
||||
return res.status(404).send()
|
||||
}
|
||||
|
||||
data = data.replace('<base href="/" />', '<base href="' + baseUrl + '" />')
|
||||
|
||||
return res.send(data)
|
||||
})
|
||||
})
|
||||
|
||||
return router
|
||||
}
|
@ -1,6 +1,10 @@
|
||||
var path = require('path')
|
||||
var webpack = require('webpack')
|
||||
|
||||
var config = require('./config')
|
||||
|
||||
var baseUrl = config.baseUrl || '/'
|
||||
|
||||
module.exports = {
|
||||
// Entry point for static analyzer
|
||||
entry: path.join(__dirname, 'public', 'js', 'app.js'),
|
||||
@ -13,7 +17,7 @@ module.exports = {
|
||||
filename: 'bundle.js',
|
||||
|
||||
// Path to use in HTML
|
||||
publicPath: '/'
|
||||
publicPath: baseUrl
|
||||
},
|
||||
|
||||
resolve: {
|
||||
|
Loading…
Reference in New Issue
Block a user