diff --git a/README.md b/README.md index 180098a..3c770f4 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/app/config.js b/app/config.js new file mode 100644 index 0000000..edd30d7 --- /dev/null +++ b/app/config.js @@ -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' + } +} diff --git a/app/config.local.js b/app/config.local.js new file mode 100644 index 0000000..aea8519 --- /dev/null +++ b/app/config.local.js @@ -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' diff --git a/app/index.html b/app/index.html index 6a7545f..94321be 100644 --- a/app/index.html +++ b/app/index.html @@ -13,8 +13,9 @@ + + - diff --git a/app/index.js b/app/index.js index f9aa729..a3dd75b 100644 --- a/app/index.js +++ b/app/index.js @@ -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 diff --git a/app/theme.js b/app/theme.js index bc28652..62da032 100644 --- a/app/theme.js +++ b/app/theme.js @@ -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] = { diff --git a/package.json b/package.json index 5097a01..6c65364 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/webpack.config.js b/webpack.config.js index 7404156..44d4087 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -8,6 +8,7 @@ module.exports = { './app/index.js', './app/index.html' ], + config: './app/config.js', theme: './app/theme.js', matrix: './app/matrix.js' },