From: Darren Date: Sat, 1 Dec 2012 16:51:09 +0000 (+0000) Subject: Client default settings taken from config.js X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=763917845aa23405dbce18a31162f6f6b6ec0e92;p=KiwiIRC.git Client default settings taken from config.js --- diff --git a/client/assets/dev/build.js b/client/assets/dev/build.js index 2f0c5b8..9db3895 100644 --- a/client/assets/dev/build.js +++ b/client/assets/dev/build.js @@ -85,13 +85,13 @@ var index_src = fs.readFileSync(__dirname + '/index.html.tmpl', FILE_ENCODING); var vars = { base_path: config.get().http_base_path || '/kiwi', cache_buster: Math.ceil(Math.random() * 9000).toString(), - server_settings: '{}', - client_plugins: '[]' + server_settings: {}, + client_plugins: [] }; // Any restricted server mode set? if (config.get().restrict_server) { - vars.server_settings = JSON.stringify({ + vars.server_settings = { connection: { server: config.get().restrict_server, port: config.get().restrict_server_port || 6667, @@ -100,15 +100,21 @@ if (config.get().restrict_server) { nick: config.get().restrict_server_nick, allow_change: false } - }); + }; +} + +// Any client default settings? +if (config.get().client) { + vars.server_settings.client = config.get().client; } // Any client plugins? if (config.get().client_plugins && config.get().client_plugins.length > 0) { - vars.client_plugins = JSON.stringify(config.get().client_plugins); + vars.client_plugins = config.get().client_plugins; } _.each(vars, function(value, key) { + if (typeof value === 'object') value = JSON.stringify(value); index_src = index_src.replace(new RegExp('<%' + key + '%>', 'g'), value); }); diff --git a/client/assets/dev/model_application.js b/client/assets/dev/model_application.js index 6610a46..ef7deac 100644 --- a/client/assets/dev/model_application.js +++ b/client/assets/dev/model_application.js @@ -146,7 +146,7 @@ _kiwi.model.Application = function () { this.populateDefaultServerSettings = function () { var parts; var defaults = { - nick: getQueryVariable('nick') || 'kiwi_' + Math.ceil(Math.random() * 10000).toString(), + nick: getQueryVariable('nick') || 'kiwi_?', server: 'irc.kiwiirc.com', port: 6667, ssl: false, @@ -155,6 +155,35 @@ _kiwi.model.Application = function () { }; var uricheck; + + /** + * Get any settings set by the server + * These settings may be changed in the server selection dialog + */ + if (this.server_settings.client) { + if (this.server_settings.client.nick) + defaults.nick = this.server_settings.client.nick; + + if (this.server_settings.client.server) + defaults.server = this.server_settings.client.server; + + if (this.server_settings.client.port) + defaults.port = this.server_settings.client.port; + + if (this.server_settings.client.ssl) + defaults.ssl = this.server_settings.client.ssl; + + if (this.server_settings.client.channel) + defaults.channel = this.server_settings.client.channel; + } + + + + /** + * Get any settings passed in the URL + * These settings may be changed in the server selection dialog + */ + // Process the URL part by part, extracting as we go parts = window.location.pathname.toString().replace(this.get('base_path'), '').split('/'); @@ -221,6 +250,10 @@ _kiwi.model.Application = function () { } // If any settings have been given by the server.. override any auto detected settings + /** + * Get any server restrictions as set in the server config + * These settings can not changed in the server selection dialog + */ if (this.server_settings && this.server_settings.connection) { if (this.server_settings.connection.server) { defaults.server = this.server_settings.connection.server; diff --git a/config.example.js b/config.example.js index 08d4877..286ee21 100644 --- a/config.example.js +++ b/config.example.js @@ -93,6 +93,7 @@ conf.reject_unauthorised_certificates = false; * Reverse proxies that have been reported to work can be found at: * http://github.com/prawnsalad/KiwiIRC/wiki/Running-behind-a-proxy */ + // Whitelisted HTTP proxies in CIDR format conf.http_proxies = ["127.0.0.1/32"]; @@ -120,6 +121,16 @@ conf.transports = [ conf.quit_message = "http://www.kiwiirc.com/ - A hand-crafted IRC client"; +// Default settings for the client. These may be changed in the browser +conf.client = { + server: 'irc.kiwiirc.com', + port: 6697, + ssl: true, + channel: '#kiwiirc', + nick: 'kiwi_?' +}; + + // If not empty, the client may only connect to this 1 IRC server //conf.restrict_server = "irc.kiwiirc.com"; //conf.restrict_server_port = 6667; @@ -129,6 +140,8 @@ conf.quit_message = "http://www.kiwiirc.com/ - A hand-crafted IRC client"; //conf.restrict_server_nick = "kiwi_"; + + /* * Do not ammend the below lines unless you understand the changes! */