Add way to set default values short of forking the whole project

This commit is contained in:
Jonas Herzig 2018-10-08 18:10:56 +02:00
parent ae1479368c
commit f739ff9345
8 changed files with 40 additions and 4 deletions

View File

@ -86,6 +86,10 @@ map $http_upgrade $connection_upgrade {
}
```
### Configuration
The `app/config.js` file contains default values and descriptions for all configuration options.
You can overwrite those by editing the `config.local.js` file within your `dist` folder. Make sure to back up and restore the file whenever you update to a new version.
### Themes
The default theme of mumble-web tries to mimic the excellent [MetroMumble]Light theme.
mumble-web also includes a dark version, named MetroMumbleDark, which is heavily inspired by [MetroMumble]'s dark version.

20
app/config.js Normal file
View File

@ -0,0 +1,20 @@
// Note: You probably do not want to change any values in here because this
// file might need to be updated with new default values for new
// configuration options. Use the [config.local.js] file instead!
window.mumbleWebConfig = {
// Default values (can be changed by passing a query parameter of the same name)
'defaults': {
// Connect Dialog
'address': '',
'port': '443',
'token': '',
'username': '',
'password': '',
'joinDialog': false, // replace whole dialog with single "Join Conference" button
'matrix': false, // enable Matrix Widget support (mostly auto-detected; implies 'joinDialog')
'avatarurl': '', // download and set the user's Mumble avatar to the image at this URL
// General
'theme': 'MetroMumbleLight'
}
}

9
app/config.local.js Normal file
View File

@ -0,0 +1,9 @@
// You can overwrite the default configuration values set in [config.js] here.
// There should never be any required changes to this file and you can always
// simply copy it over when updating to a new version.
let config = window.mumbleWebConfig // eslint-disable-line no-unused-vars
// E.g. changing default address and theme:
// config.defaults.address = 'voice.example.com'
// config.defaults.theme = 'MetroMumbleDark'

View File

@ -13,8 +13,9 @@
<meta name="msapplication-config" content="${require('./favicon/browserconfig.xml')}">
<meta name="theme-color" content="#ffffff">
<script src="config.js"></script>
<script src="config.local.js"></script>
<script src="theme.js"></script>
<script src="matrix.js"></script>
</head>
<body>

View File

@ -51,7 +51,7 @@ function ContextMenu () {
function ConnectDialog () {
var self = this
self.address = ko.observable('')
self.port = ko.observable('443')
self.port = ko.observable('')
self.token = ko.observable('')
self.username = ko.observable('')
self.password = ko.observable('')
@ -867,6 +867,7 @@ window.mumbleUi = ui
window.onload = function () {
var queryParams = url.parse(document.location.href, true).query
queryParams = Object.assign({}, window.mumbleWebConfig.defaults, queryParams)
var useJoinDialog = queryParams.joinDialog
if (queryParams.matrix) {
useJoinDialog = true

View File

@ -8,7 +8,7 @@ var themes = {
'light': 'MetroMumbleLight',
'dark': 'MetroMumbleDark'
}
theme = themes[theme] || 'MetroMumbleLight'
theme = themes[theme] || window.mumbleWebConfig.defaults.theme
window.theme = theme
var [loadingTheme, mainTheme] = {

View File

@ -3,7 +3,7 @@
"version": "0.4.1",
"description": "An HTML5 Mumble client.",
"scripts": {
"build": "webpack",
"build": "webpack && [ -f dist/config.local.js ] || cp app/config.local.js dist/",
"prepublish": "rm -rf dist && npm run build",
"test": "echo \"Error: no test specified\" && exit 1"
},

View File

@ -8,6 +8,7 @@ module.exports = {
'./app/index.js',
'./app/index.html'
],
config: './app/config.js',
theme: './app/theme.js',
matrix: './app/matrix.js'
},