Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

config for default server #195

Closed
wants to merge 3 commits into from

4 participants

@hoxca

Add configuration for

  • default server
  • default channel

Add fixed font for motd

@SpenserJ

Hoxca, you're going to want to make commits that you'd like pulled on a separate branch. Otherwise every commit you make will appear in this pull request, and hoxca@8d9346d is a duplicate of thedjpetersen@b6ce807, while hoxca@37ee050 looks like more of a personal change. The first and second commit, I can see being accepted with only a few minor tweaks:

  • Using === instead of == in lib/socket.js,
  • Setting the default server and channel to something more generic (irc.freenode.net #subway)
assets/js/views/overview.js
@@ -62,7 +62,7 @@ var OverviewView = Backbone.View.extend({
if (!server) {
$('#connect-server').closest('.control-group').addClass('error');
- }
+ }
@thedjpetersen Owner

Don't add whitespace here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@thedjpetersen thedjpetersen commented on the diff
assets/js/views/overview.js
@@ -48,7 +48,7 @@ var OverviewView = Backbone.View.extend({
event.preventDefault();
$('.error').removeClass('error');
- var server = $('#connect-server').val(),
+ var server = $('#connect-server').val() || "default",
@thedjpetersen Owner

We should stil require a server here, if there is a default specified maybe use a checkbox or something to indicate it.

@hoxca
hoxca added a note

In fact, "default" is the trick i use to overcome the form validation, but we can make overloading of server with a different server value.
This will work until we have a mandatory default_ircserver in config.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
lib/socket.js
@@ -56,6 +57,9 @@ module.exports = function(socket, connections) {
if(current_user){
connection = connections[current_user.username];
}
+ if ( data.server === undefined || data.server == 'default' ) {
+ data.server = app.set('default_ircserver');
@thedjpetersen Owner

Indentation here and on the next line.

@thedjpetersen Owner

=== coding style

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@kaihendry

Hi, I'm looking for a default server / channel setup for our hackerspace. Wondering when you are going to this on. :)

@thedjpetersen

I'll take another pass on this.

@thedjpetersen

Pulled this down and am re-architecting it a bit.

@thedjpetersen

So I feel bad for leaving this open for so long. After taking a long look at it I don't think this is the approach that most people have requested. The idea would be for a server to connect to as soon as the client is opened and then drop the person in a room. So I am closing this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
1  assets/css/subway.css
@@ -383,6 +383,7 @@ html { overflow: hidden; }
.chat-message.motd {
white-space: pre;
+ font: 12px monospace;
}
div.embed-toggle {
View
2  assets/js/views/overview.js
@@ -48,7 +48,7 @@ var OverviewView = Backbone.View.extend({
event.preventDefault();
$('.error').removeClass('error');
- var server = $('#connect-server').val(),
+ var server = $('#connect-server').val() || "default",
@thedjpetersen Owner

We should stil require a server here, if there is a default specified maybe use a checkbox or something to indicate it.

@hoxca
hoxca added a note

In fact, "default" is the trick i use to overcome the form validation, but we can make overloading of server with a different server value.
This will work until we have a mandatory default_ircserver in config.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
nick = $('#connect-nick').val(),
port = $('#connect-port').val(),
away = $('#connect-away').val(),
View
10 config.js
@@ -1,15 +1,19 @@
exports.dev = {
port: 3000,
client_port: 3000,
- mongoose_auth: 'mongodb://mongodb@localhost/subway'
+ mongoose_auth: 'mongodb://mongodb@localhost/subway',
+ default_ircserver: '192.168.56.54',
+ default_ircchannel: '#powerline'
}
exports.prod = {
port: 14858, // Nodester port
client_port: 80, // Websockets talk on port 80 on Nodester, regardless of listen port
- mongoose_auth: 'mongodb://mongodb@localhost/subway'
+ mongoose_auth: 'mongodb://mongodb@localhost/subway',
+ default_ircserver: '192.168.56.54',
+ default_ircchannel: '#powerline'
}
exports.misc = {
max_log_size: 32000
-}
+}
View
2  lib/irclink.js
@@ -1,4 +1,5 @@
var irc = require('irc'),
+ app = require('./webserver').app,
mongoose = require('mongoose'),
config = require('../config');
@@ -23,6 +24,7 @@ var IRCLink = function(hostname, port, ssl, selfSigned, nick, realName, password
if (channels === undefined || !rejoin)
var channels = new Array();
+ channels[0] = app.set('default_ircchannel');
this.client = new irc.Client(hostname, nick, {
userName: nick,
View
4 lib/socket.js
@@ -1,4 +1,5 @@
var bcrypt = require('bcrypt'),
+ app = require('./webserver').app,
mongoose = require('mongoose'),
IRCLink = require('./irclink');
@@ -56,6 +57,9 @@ module.exports = function(socket, connections) {
if(current_user){
connection = connections[current_user.username];
}
+ if ( data.server === undefined || data.server == 'default' ) {
+ data.server = app.set('default_ircserver');
+ }
if(connection === undefined) {
connection = new IRCLink(data.server, data.port, data.secure, data.selfSigned, data.nick, data.realName, data.password, data.rejoin, data.away, data.encoding, data.keepAlive);
View
4 lib/webserver.js
@@ -19,6 +19,8 @@ function configureApp(app, envConfig) {
app.set('port', process.env.PORT || envConfig.port);
app.set('client_port', process.env.PORT || envConfig.client_port);
app.set('mongoose_auth', envConfig.mongoose_auth);
+ app.set('default_ircchannel', envConfig.default_ircchannel);
+ app.set('default_ircserver', envConfig.default_ircserver);
}
app.configure('development', function() {
@@ -36,4 +38,4 @@ server.listen(port);
app.get('/', function(req, res) {
res.render('index.jade', {port: app.set('client_port'), env: process.env.NODE_ENV || null});
-});
+});
View
2  views/templates.jade
@@ -41,7 +41,7 @@ script(id="overview_connection", type="text/html")
input#connect-nick(type="text")
.control-group
label(for="connect-server") Server
- input#connect-server(type="text")
+ input#connect-server(type="text", placeholder='default')
.control-group
label(for="connect-password") Password (optional)
input#connect-password(type="password")
Something went wrong with that request. Please try again.