Merge branch 'text_themes' of https://github.com/CoryChaplin/KiwiIRC into CoryChaplin...
authorDarren <darren@darrenwhitlen.com>
Mon, 14 Apr 2014 08:49:35 +0000 (09:49 +0100)
committerDarren <darren@darrenwhitlen.com>
Mon, 14 Apr 2014 08:49:35 +0000 (09:49 +0100)
client/src/app.js
client/src/models/application.js
client/src/models/newconnection.js
client/src/views/channel.js
client/src/views/tabs.js
package.json
server/irc/commands.js
server/irc/user.js
server_modules/example.js

index 094fbcdad36ae89d2a6952915c559a7e50aec4ed..68993a5e65ff0080e9c47e6abb29684c7cc99d44 100644 (file)
@@ -175,7 +175,168 @@ _kiwi.global = {
      */\r
     newIrcConnection: function(connection_details, callback) {\r
         _kiwi.gateway.newConnection(connection_details, callback);\r
-    }\r
+    },\r
+\r
+\r
+    /**\r
+     * Taking settings from the server and URL, extract the default server/channel/nick settings\r
+     */\r
+    defaultServerSettings: function () {\r
+        var parts;\r
+        var defaults = {\r
+            nick: '',\r
+            server: '',\r
+            port: 6667,\r
+            ssl: false,\r
+            channel: '',\r
+            channel_key: ''\r
+        };\r
+        var uricheck;\r
+\r
+\r
+        /**\r
+         * Get any settings set by the server\r
+         * These settings may be changed in the server selection dialog or via URL parameters\r
+         */\r
+        if (_kiwi.app.server_settings.client) {\r
+            if (_kiwi.app.server_settings.client.nick)\r
+                defaults.nick = _kiwi.app.server_settings.client.nick;\r
+\r
+            if (_kiwi.app.server_settings.client.server)\r
+                defaults.server = _kiwi.app.server_settings.client.server;\r
+\r
+            if (_kiwi.app.server_settings.client.port)\r
+                defaults.port = _kiwi.app.server_settings.client.port;\r
+\r
+            if (_kiwi.app.server_settings.client.ssl)\r
+                defaults.ssl = _kiwi.app.server_settings.client.ssl;\r
+\r
+            if (_kiwi.app.server_settings.client.channel)\r
+                defaults.channel = _kiwi.app.server_settings.client.channel;\r
+\r
+            if (_kiwi.app.server_settings.client.channel_key)\r
+                defaults.channel_key = _kiwi.app.server_settings.client.channel_key;\r
+        }\r
+\r
+\r
+\r
+        /**\r
+         * Get any settings passed in the URL\r
+         * These settings may be changed in the server selection dialog\r
+         */\r
+\r
+        // Any query parameters first\r
+        if (getQueryVariable('nick'))\r
+            defaults.nick = getQueryVariable('nick');\r
+\r
+        if (window.location.hash)\r
+            defaults.channel = window.location.hash;\r
+\r
+\r
+        // Process the URL part by part, extracting as we go\r
+        parts = window.location.pathname.toString().replace(_kiwi.app.get('base_path'), '').split('/');\r
+\r
+        if (parts.length > 0) {\r
+            parts.shift();\r
+\r
+            if (parts.length > 0 && parts[0]) {\r
+                // Check to see if we're dealing with an irc: uri, or whether we need to extract the server/channel info from the HTTP URL path.\r
+                uricheck = parts[0].substr(0, 7).toLowerCase();\r
+                if ((uricheck === 'ircs%3a') || (uricheck.substr(0,6) === 'irc%3a')) {\r
+                    parts[0] = decodeURIComponent(parts[0]);\r
+                    // irc[s]://<host>[:<port>]/[<channel>[?<password>]]\r
+                    uricheck = /^irc(s)?:(?:\/\/?)?([^:\/]+)(?::([0-9]+))?(?:(?:\/)([^\?]*)(?:(?:\?)(.*))?)?$/.exec(parts[0]);\r
+                    /*\r
+                        uricheck[1] = ssl (optional)\r
+                        uricheck[2] = host\r
+                        uricheck[3] = port (optional)\r
+                        uricheck[4] = channel (optional)\r
+                        uricheck[5] = channel key (optional, channel must also be set)\r
+                    */\r
+                    if (uricheck) {\r
+                        if (typeof uricheck[1] !== 'undefined') {\r
+                            defaults.ssl = true;\r
+                            if (defaults.port === 6667) {\r
+                                defaults.port = 6697;\r
+                            }\r
+                        }\r
+                        defaults.server = uricheck[2];\r
+                        if (typeof uricheck[3] !== 'undefined') {\r
+                            defaults.port = uricheck[3];\r
+                        }\r
+                        if (typeof uricheck[4] !== 'undefined') {\r
+                            defaults.channel = '#' + uricheck[4];\r
+                            if (typeof uricheck[5] !== 'undefined') {\r
+                                defaults.channel_key = uricheck[5];\r
+                            }\r
+                        }\r
+                    }\r
+                    parts = [];\r
+                } else {\r
+                    // Extract the port+ssl if we find one\r
+                    if (parts[0].search(/:/) > 0) {\r
+                        defaults.port = parts[0].substring(parts[0].search(/:/) + 1);\r
+                        defaults.server = parts[0].substring(0, parts[0].search(/:/));\r
+                        if (defaults.port[0] === '+') {\r
+                            defaults.port = parseInt(defaults.port.substring(1), 10);\r
+                            defaults.ssl = true;\r
+                        } else {\r
+                            defaults.ssl = false;\r
+                        }\r
+\r
+                    } else {\r
+                        defaults.server = parts[0];\r
+                    }\r
+\r
+                    parts.shift();\r
+                }\r
+            }\r
+\r
+            if (parts.length > 0 && parts[0]) {\r
+                defaults.channel = '#' + parts[0];\r
+                parts.shift();\r
+            }\r
+        }\r
+\r
+        // If any settings have been given by the server.. override any auto detected settings\r
+        /**\r
+         * Get any server restrictions as set in the server config\r
+         * These settings can not be changed in the server selection dialog\r
+         */\r
+        if (_kiwi.app.server_settings && _kiwi.app.server_settings.connection) {\r
+            if (_kiwi.app.server_settings.connection.server) {\r
+                defaults.server = _kiwi.app.server_settings.connection.server;\r
+            }\r
+\r
+            if (_kiwi.app.server_settings.connection.port) {\r
+                defaults.port = _kiwi.app.server_settings.connection.port;\r
+            }\r
+\r
+            if (_kiwi.app.server_settings.connection.ssl) {\r
+                defaults.ssl = _kiwi.app.server_settings.connection.ssl;\r
+            }\r
+\r
+            if (_kiwi.app.server_settings.connection.channel) {\r
+                defaults.channel = _kiwi.app.server_settings.connection.channel;\r
+            }\r
+\r
+            if (_kiwi.app.server_settings.connection.channel_key) {\r
+                defaults.channel_key = _kiwi.app.server_settings.connection.channel_key;\r
+            }\r
+\r
+            if (_kiwi.app.server_settings.connection.nick) {\r
+                defaults.nick = _kiwi.app.server_settings.connection.nick;\r
+            }\r
+        }\r
+\r
+        // Set any random numbers if needed\r
+        defaults.nick = defaults.nick.replace('?', Math.floor(Math.random() * 100000).toString());\r
+\r
+        if (getQueryVariable('encoding'))\r
+            defaults.encoding = getQueryVariable('encoding');\r
+\r
+        return defaults;\r
+    },\r
 };\r
 \r
 \r
index 08678b76d82c50d81c4f757d8c908ef0890be6f2..feb251ef25f9a9ddaa756aab94b00def7572f01d 100644 (file)
         })(),\r
 \r
 \r
-        defaultServerSettings: function () {\r
-            var parts;\r
-            var defaults = {\r
-                nick: '',\r
-                server: '',\r
-                port: 6667,\r
-                ssl: false,\r
-                channel: '',\r
-                channel_key: ''\r
-            };\r
-            var uricheck;\r
-\r
-\r
-            /**\r
-             * Get any settings set by the server\r
-             * These settings may be changed in the server selection dialog or via URL parameters\r
-             */\r
-            if (this.server_settings.client) {\r
-                if (this.server_settings.client.nick)\r
-                    defaults.nick = this.server_settings.client.nick;\r
-\r
-                if (this.server_settings.client.server)\r
-                    defaults.server = this.server_settings.client.server;\r
-\r
-                if (this.server_settings.client.port)\r
-                    defaults.port = this.server_settings.client.port;\r
-\r
-                if (this.server_settings.client.ssl)\r
-                    defaults.ssl = this.server_settings.client.ssl;\r
-\r
-                if (this.server_settings.client.channel)\r
-                    defaults.channel = this.server_settings.client.channel;\r
-\r
-                if (this.server_settings.client.channel_key)\r
-                    defaults.channel_key = this.server_settings.client.channel_key;\r
-            }\r
-\r
-\r
-\r
-            /**\r
-             * Get any settings passed in the URL\r
-             * These settings may be changed in the server selection dialog\r
-             */\r
-\r
-            // Any query parameters first\r
-            if (getQueryVariable('nick'))\r
-                defaults.nick = getQueryVariable('nick');\r
-\r
-            if (window.location.hash)\r
-                defaults.channel = window.location.hash;\r
-\r
-\r
-            // Process the URL part by part, extracting as we go\r
-            parts = window.location.pathname.toString().replace(this.get('base_path'), '').split('/');\r
-\r
-            if (parts.length > 0) {\r
-                parts.shift();\r
-\r
-                if (parts.length > 0 && parts[0]) {\r
-                    // Check to see if we're dealing with an irc: uri, or whether we need to extract the server/channel info from the HTTP URL path.\r
-                    uricheck = parts[0].substr(0, 7).toLowerCase();\r
-                    if ((uricheck === 'ircs%3a') || (uricheck.substr(0,6) === 'irc%3a')) {\r
-                        parts[0] = decodeURIComponent(parts[0]);\r
-                        // irc[s]://<host>[:<port>]/[<channel>[?<password>]]\r
-                        uricheck = /^irc(s)?:(?:\/\/?)?([^:\/]+)(?::([0-9]+))?(?:(?:\/)([^\?]*)(?:(?:\?)(.*))?)?$/.exec(parts[0]);\r
-                        /*\r
-                            uricheck[1] = ssl (optional)\r
-                            uricheck[2] = host\r
-                            uricheck[3] = port (optional)\r
-                            uricheck[4] = channel (optional)\r
-                            uricheck[5] = channel key (optional, channel must also be set)\r
-                        */\r
-                        if (uricheck) {\r
-                            if (typeof uricheck[1] !== 'undefined') {\r
-                                defaults.ssl = true;\r
-                                if (defaults.port === 6667) {\r
-                                    defaults.port = 6697;\r
-                                }\r
-                            }\r
-                            defaults.server = uricheck[2];\r
-                            if (typeof uricheck[3] !== 'undefined') {\r
-                                defaults.port = uricheck[3];\r
-                            }\r
-                            if (typeof uricheck[4] !== 'undefined') {\r
-                                defaults.channel = '#' + uricheck[4];\r
-                                if (typeof uricheck[5] !== 'undefined') {\r
-                                    defaults.channel_key = uricheck[5];\r
-                                }\r
-                            }\r
-                        }\r
-                        parts = [];\r
-                    } else {\r
-                        // Extract the port+ssl if we find one\r
-                        if (parts[0].search(/:/) > 0) {\r
-                            defaults.port = parts[0].substring(parts[0].search(/:/) + 1);\r
-                            defaults.server = parts[0].substring(0, parts[0].search(/:/));\r
-                            if (defaults.port[0] === '+') {\r
-                                defaults.port = parseInt(defaults.port.substring(1), 10);\r
-                                defaults.ssl = true;\r
-                            } else {\r
-                                defaults.ssl = false;\r
-                            }\r
-\r
-                        } else {\r
-                            defaults.server = parts[0];\r
-                        }\r
-\r
-                        parts.shift();\r
-                    }\r
-                }\r
-\r
-                if (parts.length > 0 && parts[0]) {\r
-                    defaults.channel = '#' + parts[0];\r
-                    parts.shift();\r
-                }\r
-            }\r
-\r
-            // If any settings have been given by the server.. override any auto detected settings\r
-            /**\r
-             * Get any server restrictions as set in the server config\r
-             * These settings can not be changed in the server selection dialog\r
-             */\r
-            if (this.server_settings && this.server_settings.connection) {\r
-                if (this.server_settings.connection.server) {\r
-                    defaults.server = this.server_settings.connection.server;\r
-                }\r
-\r
-                if (this.server_settings.connection.port) {\r
-                    defaults.port = this.server_settings.connection.port;\r
-                }\r
-\r
-                if (this.server_settings.connection.ssl) {\r
-                    defaults.ssl = this.server_settings.connection.ssl;\r
-                }\r
-\r
-                if (this.server_settings.connection.channel) {\r
-                    defaults.channel = this.server_settings.connection.channel;\r
-                }\r
-\r
-                if (this.server_settings.connection.channel_key) {\r
-                    defaults.channel_key = this.server_settings.connection.channel_key;\r
-                }\r
-\r
-                if (this.server_settings.connection.nick) {\r
-                    defaults.nick = this.server_settings.connection.nick;\r
-                }\r
-            }\r
-\r
-            // Set any random numbers if needed\r
-            defaults.nick = defaults.nick.replace('?', Math.floor(Math.random() * 100000).toString());\r
-\r
-            if (getQueryVariable('encoding'))\r
-                defaults.encoding = getQueryVariable('encoding');\r
-\r
-            return defaults;\r
-        },\r
-\r
-\r
         bindGatewayCommands: function (gw) {\r
             var that = this;\r
 \r
index c3c4095e58b2eebf81315d656066bcc9ba073d30..6df5b97bfd1c55a9ad42704bee784d5f3f5f7290 100644 (file)
@@ -8,7 +8,7 @@ _kiwi.model.NewConnection = Backbone.Collection.extend({
 
 
     populateDefaultServerSettings: function() {
-        var defaults = _kiwi.app.defaultServerSettings();
+        var defaults = _kiwi.global.defaultServerSettings();
         this.view.populateFields(defaults);
     },
 
index d1e4ef86324239528346e6f126fb73a798241017..5f819f610f840ca54f080f44d9161d92c4ad77aa 100644 (file)
@@ -74,7 +74,7 @@ _kiwi.view.Channel = _kiwi.view.Panel.extend({
         if ((network = this.model.get('network'))) {
             re = new RegExp('(?:^|\\s)([' + escapeRegex(network.get('channel_prefix')) + '][^ ,\\007]+)', 'g');
             msg.msg = msg.msg.replace(re, function (match) {
-                return '<a class="chan" data-channel="' + match.trim() + '">' + match + '</a>';
+                return '<a class="chan" data-channel="' + _.escape(match.trim()) + '">' + _.escape(match.trim()) + '</a>';
             });
         }
 
index 527592e9139ba16f2ddcd492d4dcd6783e8a3d06..1508e10b3dfa654afbc1d3e3494b21589013f9a6 100644 (file)
@@ -110,7 +110,7 @@ _kiwi.view.Tabs = Backbone.View.extend({
     },
 
     panelActive: function (panel, previously_active_panel) {
-        var panel_index = this.panel_access.indexOf(panel.cid);
+        var panel_index = _.indexOf(this.panel_access, panel.cid);
 
         // Remove any existing tabs or part images
         _kiwi.app.view.$el.find('.panellist .part').remove();
index 74989f167ef24e62bbe5a9dc82cecd7f3cd781e3..b44c7f587d514478909d3ebe6c3e4f410261e5da 100644 (file)
@@ -1,6 +1,6 @@
 {
   "name": "kiwiirc",
-  "version": "0.8.3-dev",
+  "version": "0.8.4-dev",
   "description": "A hand-crafted webirc client",
   "homepage": "https://www.kiwiirc.com/",
   "preferGlobal": "true",
@@ -27,5 +27,8 @@
     "spdy": "1.19.1",
     "po2json": "0.2.3",
     "winston": "~0.7.2"
+  },
+  "engines": {
+    "node": ">=0.10"
   }
 }
index 96927dcbb72bba62820e9e197d54f6c0ffb91862..bdf2038661a6901f139592b54cf9e673af83e6b9 100644 (file)
@@ -20,6 +20,7 @@ irc_numerics = {
     '266': 'RPL_GLOBALUSERS',
     '301': 'RPL_AWAY',
     '307': 'RPL_WHOISREGNICK',
+    '310': 'RPL_WHOIHELPOP',
     '311': 'RPL_WHOISUSER',
     '312': 'RPL_WHOISSERVER',
     '313': 'RPL_WHOISOPERATOR',
@@ -38,6 +39,7 @@ irc_numerics = {
     '331': 'RPL_NOTOPIC',
     '332': 'RPL_TOPIC',
     '333': 'RPL_TOPICWHOTIME',
+    '335': 'RPL_WHOISBOT',
     '341': 'RPL_INVITING',
     '352': 'RPL_WHOREPLY',
     '353': 'RPL_NAMEREPLY',
@@ -184,6 +186,20 @@ handlers = {
         });
     },
 
+    'RPL_WHOISHELPOP': function (command) {
+        this.irc_connection.emit('user ' + command.params[1] + ' whoishelpop', {
+            nick: command.params[1],
+            msg: command.params[command.params.length - 1]
+        });
+    },
+
+    'RPL_WHOISBOT': function (command) {
+        this.irc_connection.emit('user ' + command.params[1] + ' whoisbot', {
+            nick: command.params[1],
+            msg: command.params[command.params.length - 1]
+        });
+    },
+
     'RPL_WHOISSERVER': function (command) {
         this.irc_connection.emit('user ' + command.params[1] + ' whoisserver', {
             nick: command.params[1],
index 67303e6cd5913369b28a2c1eb2b7baa3d84dab58..021d1bb9ffd179dc60d2bb1e5f0885b1e3a1e66a 100755 (executable)
@@ -20,6 +20,8 @@ var IrcUser = function (irc_connection, nick) {
         whoishost:      onWhoisHost,\r
         whoissecure:    onWhoisSecure,\r
         whoisaccount:   onWhoisAccount,\r
+        whoishelpop:    onWhoisHelpOp,\r
+        whoisbot:       onWhoisBot,\r
         endofwhois:     onWhoisEnd,\r
         whowas:         onWhoWas,\r
         endofwhowas:    onWhoWasEnd,\r
@@ -168,6 +170,22 @@ function onWhoisAccount(event) {
     });\r
 }\r
 \r
+function onWhoisHelpOp(event) {\r
+    this.irc_connection.clientEvent('whois', {\r
+        nick: event.nick,\r
+        msg: event.msg,\r
+        end: false\r
+    });\r
+}\r
+\r
+function onWhoisBot(event) {\r
+    this.irc_connection.clientEvent('whois', {\r
+        nick: event.nick,\r
+        msg: event.msg,\r
+        end: false\r
+    });\r
+}\r
+\r
 function onWhoisEnd(event) {\r
     this.irc_connection.clientEvent('whois', {\r
         nick: event.nick,\r
@@ -201,14 +219,21 @@ function onWhoWasEnd(event) {
 }\r
 \r
 function onNotice(event) {\r
-    this.irc_connection.clientEvent('notice', {\r
-        from_server: event.from_server,\r
-        nick: event.nick,\r
-        ident: event.ident,\r
-        hostname: event.hostname,\r
-        target: event.target,\r
-        msg: event.msg,\r
-        time: event.time\r
+   var that = this;\r
+   global.modules.emit('irc user notice', {\r
+       connection: this.irc_connection,\r
+       irc_event: event\r
+    })\r
+    .done(function() {\r
+        that.irc_connection.clientEvent('notice', {\r
+            from_server: event.from_server,\r
+            nick: event.nick,\r
+            ident: event.ident,\r
+            hostname: event.hostname,\r
+            target: event.target,\r
+            msg: event.msg,\r
+            time: event.time\r
+        });\r
     });\r
 }\r
 \r
index 7bce5e77a717b02bab22a05ad269968b2025e1a6..d880c1914423709e6d9dbcb469d2eeae5e328ce6 100644 (file)
@@ -14,6 +14,10 @@ module.on('irc message', function(event, data) {
        console.log('[MESSAGE]', data.irc_event);
 });
 
+// The Client recieves a IRC USER NOTICE command
+module.on('irc user notice', function(event, data) {
+       console.log('[NOTICE]', data.irc_event);
+});
 
 // The client recieves an IRC JOIN command
 module.on('irc channel join', function(event, data) {