From 76ccf0f20472e8e8e17bb3bf39ac3eaf1b2d0d97 Mon Sep 17 00:00:00 2001 From: Mattias Erming Date: Fri, 18 Jul 2014 07:40:08 -0700 Subject: [PATCH] Added default connection values --- client/index.html | 10 +++++----- client/js/chat.js | 1 + config.js | 9 ++++++++- lib/client.js | 25 +++++++++++++------------ lib/server.js | 2 +- package.json | 4 ++-- 6 files changed, 30 insertions(+), 21 deletions(-) diff --git a/client/index.html b/client/index.html index 2a46e75b..41c7ad6f 100644 --- a/client/index.html +++ b/client/index.html @@ -76,31 +76,31 @@
diff --git a/client/js/chat.js b/client/js/chat.js index d37cdd1a..48a50790 100644 --- a/client/js/chat.js +++ b/client/js/chat.js @@ -376,6 +376,7 @@ $(function() { } }); + console.log(post); socket.emit("conn", post); }); diff --git a/config.js b/config.js index 6c1e1b52..69020dec 100644 --- a/config.js +++ b/config.js @@ -1,5 +1,12 @@ module.exports = { port: 9000, + theme: "themes/example.css", public: true, - theme: "themes/example.css" + defaults: { + host: "irc.freenode.net", + port: 6667, + nick: "shout-user", + realname: "Shout User", + join: "#shout-irc" + } }; diff --git a/lib/client.js b/lib/client.js index 5886ae0f..05569661 100644 --- a/lib/client.js +++ b/lib/client.js @@ -1,4 +1,5 @@ var _ = require("lodash"); +var config = require("../config"); var net = require("net"); var Network = require("./models/network"); var slate = require("slate-irc"); @@ -62,41 +63,41 @@ Client.prototype.find = function(id) { Client.prototype.connect = function(args) { var client = this; var options = { - host: args.host || "irc.freenode.org", - port: args.port || 6667 + host: args.host || config.defaults.host, + port: args.port || config.defaults.port }; - + var stream = args.tls ? tls.connect(options) : net.connect(options); stream.on("error", function(e) { console.log(e); }); - - var nick = args.nick || "shout"; - var realname = args.realname || "Shout User"; - + + var nick = args.nick || config.defaults.nick; + var realname = args.realname || config.defaults.realname; + var irc = slate(stream); irc.me = nick; irc.nick(nick); irc.user(nick, realname); - + var network = new Network({ host: options.host, irc: irc }); - + client.networks.push(network); client.emit("network", { network: network }); - + events.forEach(function(plugin) { require("./plugins/irc-events/" + plugin).apply(client, [ irc, network ]); }); - - var join = (args.join || "#shout-irc").replace(/\,/g, " ").split(/\s+/g); + + var join = (args.join || config.defaults.join).replace(/\,/g, " ").split(/\s+/g); irc.on("welcome", function() { irc.join(join); }); diff --git a/lib/server.js b/lib/server.js index 17616cb0..23d67b7c 100644 --- a/lib/server.js +++ b/lib/server.js @@ -1,6 +1,6 @@ var _ = require("lodash"); var Client = require("./client"); -var config = require("../config") || {}; +var config = require("../config"); var fs = require("fs"); var http = require("connect"); var indicator = require("indicator"); diff --git a/package.json b/package.json index a67447ce..bceb3ec5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "shout", "description": "The modern IRC client", - "version": "0.8.0", + "version": "0.8.1", "homepage": "http://github.com/erming/shout", "author": { "name": "Mattias Erming", @@ -33,7 +33,7 @@ }, "dependencies": { "connect": "~2.19.6", - "indicator": "~0.1.0", + "indicator": "^0.1.2", "lodash": "~2.4.1", "moment": "~2.7.0", "slate-irc": "~0.6.0",