Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add support for server presets. #296

Closed
wants to merge 1 commit into from

3 participants

@jdve

To make it even easier for non-technical people to get started with IRC,
this change adds support for presets defined in config.js. In such a
deployment, instead of requiring users to type in all the server
configuration parameters, subway automatically connects to the preset
server and joins a predefined set of channels. After that, users may
join and leave channels as normal, but they cannot connect to other
servers.

@hermansc
Collaborator

A great idea and nice implementation! I love the focus on making subway more accessible to non-technical people.

I have a question though with regards to the presets.password variable and its meaning? I mean, it is obviously not referring to a channel password - since one can preset multiple channels? And we don't want to preset user-password either, now do we? :-)

Also, when we are talking about passwords. It is not possible to preset a channel with a password - or it is possible if one writes channels: ["#channelname password", "#anotherchannel foobar"], but perhaps a solution such as:

channels: [{ name: "#channelname", password: "password"}, {name: "#anotherchannel", password: ""}] 

is better?

@jdve

@hermansc, thanks for the feedback! Yes, I agree, presets.password really doesn't make any sense. I've removed that now. Also, AFAIK, the channels: ["#channelname password", "#anotherchannel foobar"] syntax will work, because under-the-hood it's just calling the same "join" method that we use when manually joining a channel.

@hermansc
Collaborator

Hey, no problem, nice to see people contributing to this project. As I said, I know it will work writing it #channel password, I just thought it would perhaps be more verbose and clearer if one separated them and did the join in the background. But, as you say there is perhaps not much point in it :-)

@jdve jdve Add support for server presets.
To make it even easier for non-technical people to get started with IRC,
this change adds support for presets defined in config.js.  In such a
deployment, instead of requiring users to type in all the server
configuration parameters, subway automatically connects to the preset
server and joins a predefined set of channels.  After that, users may
join and leave channels as normal, but they cannot connect to other
servers.
e3f25cd
@thedjpetersen

This is really neat. A quick note: I have worked on refactoring the client trying to make it more robust and easier to maintain the frontend code(using bower and grunt). If you would consider porting this work over to the refactor branch I would love to get it in here. Sorry that the work for this branch was lost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 17, 2014
  1. @jdve

    Add support for server presets.

    jdve authored
    To make it even easier for non-technical people to get started with IRC,
    this change adds support for presets defined in config.js.  In such a
    deployment, instead of requiring users to type in all the server
    configuration parameters, subway automatically connects to the preset
    server and joins a predefined set of channels.  After that, users may
    join and leave channels as normal, but they cannot connect to other
    servers.
This page is out of date. Refresh to see the latest.
View
38 assets/js/client.js
@@ -14,7 +14,8 @@ window.irc = {
socket: io.connect(null, {port: document.location.port}),
chatWindows: new WindowList(),
connected: false,
- loggedIn: false
+ loggedIn: false,
+ presets: false
};
window.unity = {
@@ -51,6 +52,11 @@ $(function() {
}
});
+ irc.socket.on('initialized', function(data) {
+ irc.presets = data.presets;
+ irc.appView.render();
+ });
+
// Registration (server joined)
irc.socket.on('registered', function(data) {
var window = irc.chatWindows.getByName('status');
@@ -65,11 +71,19 @@ $(function() {
// Will reflect modified nick, if chosen nick was taken already
irc.me.set('nick', data.message.args[0]);
+
+ // Join preset channels
+ $.each(irc.presets.channels, function(key, value){
+ irc.socket.emit('join', value);
+ });
});
irc.socket.on('login_success', function(data) {
window.irc.loggedIn = true;
+
if(data.exists){
+ irc.me = new User(data);
+ irc.me.on('change:nick', irc.appView.renderUserBox);
irc.socket.emit('connect', {});
} else {
irc.appView.overview.render({currentTarget: {id: "connection"}});
@@ -85,11 +99,31 @@ $(function() {
irc.socket.on('register_success', function(data) {
window.irc.loggedIn = true;
- irc.appView.overview.render({currentTarget: {id: "connection"}});
+
+ if(irc.presets){
+ var connectInfo = {
+ nick: data.username,
+ server: irc.presets.server,
+ port: irc.presets.port,
+ secure: irc.presets.secure,
+ selfSigned: irc.presets.selfSigned,
+ away: irc.presets.away,
+ encoding: irc.presets.encoding,
+ stripColors: irc.presets.stripColors,
+ keepAlive: irc.presets.keepAlive
+ };
+
+ irc.me = new User(connectInfo);
+ irc.me.on('change:nick', irc.appView.renderUserBox);
+ irc.socket.emit('connect', connectInfo);
+ } else {
+ irc.appView.overview.render({currentTarget: {id: "connection"}});
+ }
});
irc.socket.on('restore_connection', function(data) {
irc.me = new User({nick: data.nick, server: data.server});
+ irc.me.on('change:nick', irc.appView.renderUserBox);
irc.connected = true;
irc.appView.render();
irc.appView.renderUserBox();
View
2  assets/js/views/chat_application.js
@@ -37,8 +37,6 @@ var ChatApplicationView = Backbone.View.extend({
clearTimeout(blurTimer);
if(activeChat && activeChat.set) { activeChat.set('active', true); }
});
-
- this.render();
},
overview: null,
View
7 assets/js/views/overview.js
@@ -19,10 +19,13 @@ var OverviewView = Backbone.View.extend({
// Navigation to different overview panes
if (event === undefined) {
- $('#overview').html(ich.overview_home());
+ $('#overview').html(ich.overview_home({'presets': irc.presets}));
} else {
var func = ich['overview_' + event.currentTarget.id];
- $('#overview').html(func({'loggedIn': irc.loggedIn}));
+ $('#overview').html(func({
+ 'presets': irc.presets,
+ 'loggedIn': irc.loggedIn
+ }));
}
$('.overview_button').bind('click', $.proxy(this.render, this));
View
17 config.js
@@ -15,6 +15,23 @@ module.exports = {
// server_whitelist: ["irc.freenode.net"],
server_whitelist: false,
+ // If enabled, prevent creation of new accounts or editing settings. These presets
+ // are used for all new user accounts.
+ presets: false,
+ /*
+ presets: {
+ server: "chat.freenode.net",
+ port: 6667,
+ secure: false,
+ selfSigned: false,
+ away: "AKF",
+ encoding: null,
+ stripColors: false,
+ keepAlive: true,
+ channels: ["#subway"],
+ },
+ */
+
/* not implemented yet */
user_access: {
users_enabled: true, // show and allow logins
View
10 lib/socket.js
@@ -32,6 +32,10 @@ module.exports = function(socket, app) {
app.ircbridge.emit(connection, event, dict);
}
+ socket.emit('initialized', {
+ presets: app.config.presets
+ });
+
/* auth/setup commands */
// user registration
@@ -87,7 +91,11 @@ module.exports = function(socket, app) {
socket.connID = connections[0].id;
socket.conn = connections[0];
}
- socket.emit('login_success', {username: data.username, exists: exists});
+ socket.emit('login_success', {
+ username: data.username,
+ nick: data.username,
+ exists: exists
+ });
});
} else {
socket.emit('login_error', {message: 'Wrong password'});
View
2  views/templates.jade
@@ -16,12 +16,14 @@ script(id="load_image", type="text/html")
script(id="overview_home", type="text/html")
ul
+ {{^presets}}
li.overview_button#connection
img(src="/assets/images/connection.svg")
span New Connection
li.overview_button#settings
img(src="/assets/images/settings.svg")
span Settings
+ {{/presets}}
li.overview_button#login
img(src="/assets/images/login.svg")
span Login
Something went wrong with that request. Please try again.