Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configurable realname and username #702

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion client/assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ html, body { height:100%; }
*/
#kiwi .server_select { position:relative; width:320px; margin:0 auto; overflow:hidden; }
#kiwi .server_select.initial { margin-top: 3em; }
#kiwi .server_select .more { display: none; }
#kiwi .server_select .more, .advanced { display: none; }
#kiwi .server_select button { }
#kiwi .server_select input { }
#kiwi .server_select label { }
Expand All @@ -283,6 +283,7 @@ html, body { height:100%; }
#kiwi .server_select .basic tr.key { display:none; }
#kiwi .server_select.single_server .basic { border:none; }
#kiwi .server_select .status { }
#kiwi .server_select .show_advanced { font-size: 0.8em; }

/* Channel key icon */
#kiwi .server_select .basic tr.channel td { position: relative; }
Expand Down
10 changes: 9 additions & 1 deletion client/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,9 @@ _kiwi.global = {
port: 6667,
ssl: false,
channel: '',
channel_key: ''
channel_key: '',
username: '',
realname: ''
};
var uricheck;

Expand All @@ -314,6 +316,12 @@ _kiwi.global = {

if (_kiwi.app.server_settings.client.channel_key)
defaults.channel_key = _kiwi.app.server_settings.client.channel_key;

if (_kiwi.app.server_settings.client.username)
defaults.username = _kiwi.app.server_settings.client.username;

if (_kiwi.app.server_settings.client.realname)
defaults.realname = _kiwi.app.server_settings.client.realname;
}


Expand Down
18 changes: 18 additions & 0 deletions client/src/index.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,24 @@
</tr>
</table>
</div>


<a href="" onclick="return false;" class="show_advanced"> <%= advanced %> <i class="fa fa-caret-down"></i></a>

<div class="advanced">
<table>
<tr class="username">
<td><label for="server_select_username"><%= username %></label></td>
<td><input type="text" class="username" id="server_select_username"></td>
<tr>

<tr class="realname">
<td><label for="server_select_realname"><%= realname %></label></td>
<td><input type="text" class="realname" id="server_select_realname"></td>
</tr>

</table>
</div>
</form>

<a class="kiwi_logo" href="https://kiwiirc.com/" target="_blank">
Expand Down
8 changes: 6 additions & 2 deletions client/src/models/gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ _kiwi.model.Gateway = Backbone.Model.extend({
address: connection_info.host,
port: connection_info.port,
ssl: connection_info.ssl,
password: connection_info.password
password: connection_info.password,
realname: connection_info.realname,
username: connection_info.username
};
connection = new _kiwi.model.Network(inf);
_kiwi.app.connections.add(connection);
Expand All @@ -171,7 +173,9 @@ _kiwi.model.Gateway = Backbone.Model.extend({
hostname: connection_info.host,
port: connection_info.port,
ssl: connection_info.ssl,
password: connection_info.password
password: connection_info.password,
realname: connection_info.realname,
username: connection_info.username
};

connection_info.options = connection_info.options || {};
Expand Down
4 changes: 3 additions & 1 deletion client/src/models/newconnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ _kiwi.model.NewConnection = Backbone.Collection.extend({
port: new_connection_event.port,
ssl: new_connection_event.ssl,
password: new_connection_event.password,
options: new_connection_event.options
options: new_connection_event.options,
realname: new_connection_event.realname,
username: new_connection_event.username
}, function(err, network) {
that.onNewNetwork(err, network);
});
Expand Down
12 changes: 12 additions & 0 deletions client/src/translations/en-gb.po
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,18 @@ msgstr "Port"
msgid "client_views_serverselect_poweredby"
msgstr "Powered by Kiwi IRC"

#:
msgid "client_views_serverselect_username"
msgstr "Username"

#:
msgid "client_views_serverselect_realname"
msgstr "Realname"

#:
msgid "client_views_serverselect_advanced"
msgstr "Advanced"

#:
msgid "client_views_serverselect_nickname_error_empty"
msgstr "Select a nickname first!"
Expand Down
12 changes: 12 additions & 0 deletions client/src/translations/es-419.po
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,18 @@ msgstr "Puerto"
msgid "client_views_serverselect_poweredby"
msgstr "Respaldado por KiwiIRC"

#:
msgid "client_views_serverselect_username"
msgstr "Nombre usaurio"

#:
msgid "client_views_serverselect_realname"
msgstr "Nombre real"

#:
msgid "client_views_serverselect_advanced"
msgstr "Avanzado"

#:
msgid "client_views_serverselect_nickname_error_empty"
msgstr "¡Debes seleccionar un nick!"
Expand Down
12 changes: 12 additions & 0 deletions client/src/translations/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,18 @@ msgstr "Puerto"
msgid "client_views_serverselect_poweredby"
msgstr "Potenciado por Kiwi IRC"

#:
msgid "client_views_serverselect_username"
msgstr "Nombre usaurio"

#:
msgid "client_views_serverselect_realname"
msgstr "Nombre real"

#:
msgid "client_views_serverselect_advanced"
msgstr "Avanzado"

#:
msgid "client_views_serverselect_nickname_error_empty"
msgstr "¡Selecciona un sobrenombre primero!"
Expand Down
37 changes: 34 additions & 3 deletions client/src/views/serverselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ _kiwi.view.ServerSelect = Backbone.View.extend({
events: {
'submit form': 'submitForm',
'click .show_more': 'showMore',
'click .show_advanced': 'showAdvanced',
'change .have_pass input': 'showPass',
'change .have_key input': 'showKey',
'click .fa-key': 'channelKeyIconClick',
Expand All @@ -23,7 +24,10 @@ _kiwi.view.ServerSelect = Backbone.View.extend({
server_network: _kiwi.global.i18n.translate('client_views_serverselect_server_and_network').fetch(),
server: _kiwi.global.i18n.translate('client_views_serverselect_server').fetch(),
port: _kiwi.global.i18n.translate('client_views_serverselect_port').fetch(),
powered_by: _kiwi.global.i18n.translate('client_views_serverselect_poweredby').fetch()
powered_by: _kiwi.global.i18n.translate('client_views_serverselect_poweredby').fetch(),
advanced: _kiwi.global.i18n.translate('client_views_serverselect_advanced').fetch(),
username: _kiwi.global.i18n.translate('client_views_serverselect_username').fetch(),
realname: _kiwi.global.i18n.translate('client_views_serverselect_realname').fetch()
};

this.$el = $(_.template($('#tmpl_server_select').html().trim(), text));
Expand All @@ -32,6 +36,7 @@ _kiwi.view.ServerSelect = Backbone.View.extend({
if (_kiwi.app.server_settings && _kiwi.app.server_settings.connection) {
if (!_kiwi.app.server_settings.connection.allow_change) {
this.$el.find('.show_more').remove();
this.$el.find('.show_advanced').remove();
this.$el.addClass('single_server');
}
}
Expand All @@ -40,6 +45,7 @@ _kiwi.view.ServerSelect = Backbone.View.extend({
this.state = 'all';

this.more_shown = false;
this.advanced_shown = false;

this.model.bind('new_network', this.newNetwork, this);

Expand Down Expand Up @@ -87,6 +93,8 @@ _kiwi.view.ServerSelect = Backbone.View.extend({
port: $('input.port', this.$el).val(),
ssl: $('input.ssl', this.$el).prop('checked'),
password: $('input.password', this.$el).val(),
realname: $('input.realname', this.$el).val(),
username: $('input.username', this.$el).val(),
channel: $('input.channel', this.$el).val(),
channel_key: $('input.channel_key', this.$el).val(),
options: this.server_options
Expand Down Expand Up @@ -140,9 +148,28 @@ _kiwi.view.ServerSelect = Backbone.View.extend({
}
},

populateFields: function (defaults) {
var nick, server, port, channel, channel_key, ssl, password;
showAdvanced: function (event) {
if (!this.advanced_shown) {
$('.advanced', this.$el).slideDown('fast');
$('.show_advanced', this.$el)
.children('.fa-caret-down')
.removeClass('fa-caret-down')
.addClass('fa-caret-up');
$('input.ident', this.$el).select();
this.advanced_shown = true;
} else {
$('.advanced', this.$el).slideUp('fast');
$('.show_advanced', this.$el)
.children('.fa-caret-up')
.removeClass('fa-caret-up')
.addClass('fa-caret-down');
$('input.nick', this.$el).select();
this.advanced_shown = false;
}
},

populateFields: function (defaults) {
var nick, server, port, channel, channel_key, ssl, password, username, realname;
defaults = defaults || {};

nick = defaults.nick || '';
Expand All @@ -152,9 +179,13 @@ _kiwi.view.ServerSelect = Backbone.View.extend({
password = defaults.password || '';
channel = defaults.channel || '';
channel_key = defaults.channel_key || '';
username = defaults.username || '';
realname = defaults.realname || '';

$('input.nick', this.$el).val(nick);
$('input.server', this.$el).val(server);
$('input.username', this.$el).val(username);
$('input.realname', this.$el).val(realname);
$('input.port', this.$el).val(port);
$('input.ssl', this.$el).prop('checked', ssl);
$('input#server_select_show_pass', this.$el).prop('checked', !(!password));
Expand Down
6 changes: 5 additions & 1 deletion config.example.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ conf.client = {
count_all_activity: false,
locale: null // null = use the browser locale settings
},
window_title: 'Kiwi IRC'
window_title: 'Kiwi IRC',
username: 'kiwiirc', //this value dont work if ip_as_username is defined
realname: '[[ kiwiirc.com ]]'
};

// List of themes available for the user to choose from
Expand All @@ -223,6 +225,8 @@ conf.client_themes = [
//conf.restrict_server_channel_key = "";
//conf.restrict_server_password = "";
//conf.restrict_server_nick = "kiwi_";
//conf.restrict_server_realname = "[[ kiwiirc.com ]]";
//conf.restrict_server_username = "kiwiirc";



Expand Down
2 changes: 2 additions & 0 deletions server/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ Client.prototype.attachKiwiCommands = function() {
options.encoding = command.encoding;

options.password = global.config.restrict_server_password || command.password;
options.realname = global.config.restrict_server_realname || command.realname;
options.username = global.config.restrict_server_username || command.username;

that.state.connect(
(global.config.restrict_server || command.hostname),
Expand Down
4 changes: 2 additions & 2 deletions server/irc/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ var IrcConnection = function (hostname, port, ssl, nick, user, options, state, c
// User information
this.nick = nick;
this.user = user; // Contains users real hostname and address
this.username = this.nick.replace(/[^0-9a-zA-Z\-_.\/]/, '');
this.gecos = ''; // Users real-name. Uses default from config if empty
this.username = options.username || this.nick.replace(/[^0-9a-zA-Z\-_.\/]/, '');
this.gecos = options.realname || ''; // Users real-name. Uses default from config if empty
this.password = options.password || '';
this.quit_message = ''; // Uses default from config if empty

Expand Down
2 changes: 2 additions & 0 deletions server/settingsgenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ function generateSettings(debug) {
ssl: config.get().restrict_server_ssl,
channel: config.get().restrict_server_channel,
nick: config.get().restrict_server_nick,
username: config.get().restrict_server_username,
realname: config.get().restrict_server_realname,
allow_change: false
}
};
Expand Down