From 0de5511544db899ba460cd0716dcb69294f9d023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Thu, 7 Aug 2014 18:02:39 +0100 Subject: [PATCH 01/41] Default to using SSL if the page is using it as well --- js/glowingbear.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index 805bebe..a1ac3d8 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -841,7 +841,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', $store.bind($scope, "host", "localhost"); $store.bind($scope, "port", "9001"); $store.bind($scope, "proto", "weechat"); - $store.bind($scope, "ssl", false); + $store.bind($scope, "ssl", (window.location.protocol === "https:")); $store.bind($scope, "savepassword", false); if ($scope.savepassword) { $store.bind($scope, "password", ""); From 6f5047fb688552a0551389a83711e7d09ffa360f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Thu, 7 Aug 2014 18:41:18 +0100 Subject: [PATCH 02/41] Add indicators to the accordion so people will notice it's actually there --- css/glowingbear.css | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/css/glowingbear.css b/css/glowingbear.css index f1ef251..7f803ee 100644 --- a/css/glowingbear.css +++ b/css/glowingbear.css @@ -481,6 +481,18 @@ h2 span, h2 small { .panel[data-state=collapsed] { border: 0px solid transparent; } +.panel .panel-title:before { + display: inline-block; + font-size: 22px; + line-height: 20px; + margin: -3px 5px -3px 0; +} +.panel[data-state=active] .panel-title:before { + content: "–"; +} +.panel[data-state=collapsed] .panel-title:before { + content: "+"; +} /* fix for firefox being stupid */ @-moz-document url-prefix() { From 703fcb16684ecfba00ab5d98734ca698c5252f1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Fri, 8 Aug 2014 14:39:50 +0100 Subject: [PATCH 03/41] Add support for asynchronous / lazy plugins Fixes #253 --- js/glowingbear.js | 6 ++++++ js/plugins.js | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index a1ac3d8..0efde02 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -1343,6 +1343,12 @@ weechat.directive('plugin', function($rootScope) { * Actual plugin content is only fetched when * content is shown. */ + + // If the plugin is asynchronous / lazy, execute it now and store + // the result. This ensures that the callback is executed only once + if ($scope.plugin.content instanceof Function) { + $scope.plugin.content = $scope.plugin.content(); + } $scope.displayedContent = $scope.plugin.content; $scope.plugin.visible = true; diff --git a/js/plugins.js b/js/plugins.js index afd31af..16a4545 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -60,8 +60,14 @@ plugins.service('plugins', ['userPlugins', '$sce', function(userPlugins, $sce) { if (num) { pluginName += " " + num; } + + // If content isn't a callback, it's HTML + if (!(content instanceof Function)) { + content = $sce.trustAsHtml(content); + } + message.metadata.push({ - 'content': $sce.trustAsHtml(content), + 'content': content, 'nsfw': nsfw, 'name': pluginName }); From 3d719f3671503e4e6b594e9e68b7ee0e1fc2bdb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Fri, 8 Aug 2014 15:59:35 +0100 Subject: [PATCH 04/41] Simplify plugins that detect URLs by eliminating redundancy --- js/plugins.js | 85 ++++++++++++++++++++++----------------------------- 1 file changed, 36 insertions(+), 49 deletions(-) diff --git a/js/plugins.js b/js/plugins.js index 16a4545..d795dbe 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -132,6 +132,21 @@ plugins.factory('userPlugins', function() { var urlRegexp = RegExp(/(?:ftp|https?):\/\/\S*[^\s.;,(){}<>]/g); + var urlPlugin = function(callback) { + return function(message) { + var urls = message.match(urlRegexp); + var content = []; + + for (var i = 0; urls && i < urls.length; i++) { + var result = callback(urls[i]); + if (result) { + content.push(result); + } + } + return content; + }; + }; + /* * Spotify Embedded Player * @@ -221,13 +236,8 @@ plugins.factory('userPlugins', function() { /* * Image Preview */ - var imagePlugin = new Plugin(function(message) { - - var urls = message.match(urlRegexp); - var content = []; - - for (var i = 0; urls && i < urls.length; i++) { - var url = urls[i]; + var imagePlugin = new Plugin( + urlPlugin(function(url) { if (url.match(/\.(png|gif|jpg|jpeg)$/i)) { /* A fukung.net URL may end by an image extension but is not a direct link. */ @@ -238,58 +248,40 @@ plugins.factory('userPlugins', function() { url = url.replace(/http:/, ""); } - content.push(''); + return ''; } - } - - return content; - }); + }) + ); imagePlugin.name = 'image'; /* * Cloud Music Embedded Players */ - var cloudmusicPlugin = new Plugin(function(message) { - - var urls = message.match(urlRegexp); - var content = []; - - for (var i = 0; urls && i < urls.length; i++) { - var url = urls[i]; - + var cloudmusicPlugin = new Plugin( + urlPlugin(function(url) { /* SoundCloud http://help.soundcloud.com/customer/portal/articles/247785-what-widgets-can-i-use-from-soundcloud- */ if (url.match(/^https?:\/\/soundcloud.com\//)) { - content.push(''); + return ''; } /* MixCloud */ if (url.match(/^https?:\/\/([a-z]+\.)?mixcloud.com\//)) { - content.push(''); + return ''; } - } - - return content; - }); + }) + ); cloudmusicPlugin.name = 'cloud music'; /* * Google Maps */ - var googlemapPlugin = new Plugin(function(message) { - - var urls = message.match(urlRegexp); - var content = []; - - for (var i = 0; urls && i < urls.length; i++) { - var url = urls[i]; - + var googlemapPlugin = new Plugin( + urlPlugin(function(url) { if (url.match(/^https?:\/\/maps\.google\./i) || url.match(/^https?:\/\/(?:[\w]+\.)?google\.[\w]+\/maps/i)) { - content.push(''); + return ''; } - } - - return content; - }); + }) + ); googlemapPlugin.name = 'Google Map'; /* @@ -306,12 +298,8 @@ plugins.factory('userPlugins', function() { }); asciinemaPlugin.name = "ascii cast"; - var yrPlugin = new Plugin(function(message) { - var urls = message.match(urlRegexp); - var content = []; - - for (var i = 0; urls && i < urls.length; i++) { - var url = urls[i]; + var yrPlugin = new Plugin( + urlPlugin(function(url) { var regexp = /^https?:\/\/(?:www\.)?yr\.no\/(place|stad|sted|sadji|paikka)\/(([^\s.;,(){}<>\/]+\/){3,})/; var match = url.match(regexp); if (match) { @@ -319,11 +307,10 @@ plugins.factory('userPlugins', function() { var location = match[2]; var city = match[match.length - 1].slice(0, -1); url = "http://www.yr.no/" + language + "/" + location + "avansert_meteogram.png"; - content.push("Meteogram for " + city + ""); + return "Meteogram for " + city + ""; } - } - return content; - }); + }) + ); yrPlugin.name = "meteogram"; return { From 6d988069c745a4b5ee0abc502597db4a8adb92f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Sat, 9 Aug 2014 14:17:36 +0100 Subject: [PATCH 05/41] Add asynchronous GitHub Gist embedding plugin requires a few selectors to be more precise in our CSS --- css/glowingbear.css | 27 ++++++++++++--------------- js/plugins.js | 40 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 16 deletions(-) diff --git a/css/glowingbear.css b/css/glowingbear.css index 7f803ee..108fa9d 100644 --- a/css/glowingbear.css +++ b/css/glowingbear.css @@ -38,20 +38,6 @@ a { cursor: pointer; } -table { - width: 100%; -} -tr { - line-height: 100%; -} -tr:hover { - background-color: #222222; -} -td.time { - padding: 1px 5px 1px 1px; - vertical-align: top; -} - .repeated-time { } .repeated-time .cof-chat_time, @@ -281,8 +267,19 @@ input[type=text], input[type=password], #sendMessage, .badge { -webkit-transition:0.35s ease all; transition:0.35s ease all; } -#bufferlines table { +#bufferlines > table { margin-top: 35px; + width: 100%; +} +tr.bufferline { + line-height: 100%; +} +tr.bufferline:hover { + background-color: #222222; +} +td.time { + padding: 1px 5px 1px 1px; + vertical-align: top; } .withnicklist { diff --git a/js/plugins.js b/js/plugins.js index d795dbe..4febfc3 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -129,6 +129,19 @@ plugins.service('plugins', ['userPlugins', '$sce', function(userPlugins, $sce) { * */ plugins.factory('userPlugins', function() { + // standard JSONp origin policy trick + var jsonp = function (url, callback) { + var callbackName = 'jsonp_callback_' + Math.round(100000 * Math.random()); + window[callbackName] = function(data) { + delete window[callbackName]; + document.body.removeChild(script); + callback(data); + }; + + var script = document.createElement('script'); + script.src = url + (url.indexOf('?') >= 0 ? '&' : '?') + 'callback=' + callbackName; + document.body.appendChild(script); + }; var urlRegexp = RegExp(/(?:ftp|https?):\/\/\S*[^\s.;,(){}<>]/g); @@ -313,8 +326,33 @@ plugins.factory('userPlugins', function() { ); yrPlugin.name = "meteogram"; + // Embed GitHub gists + var gistPlugin = new Plugin( + urlPlugin(function(url) { + var regexp = /^https:\/\/gist\.github.com\/[^.?]+/i; + var match = url.match(regexp); + if (match) { + // get the URL from the match to trim away pseudo file endings and request parameters + url = match[0] + '.json'; + // load gist asynchronously -- return a function here + return function() { + var element = document.querySelector('.embed_' + this.$$hashKey); + jsonp(url, function(data) { + // Add the gist stylesheet only once + if (document.querySelectorAll('link[rel=stylesheet][href="' + data.stylesheet + '"]').length < 1) { + var stylesheet = ''; + document.getElementsByTagName('head')[0].innerHTML += stylesheet; + } + element.innerHTML = '
' + data.div + '
'; + }); + }; + } + }) + ); + gistPlugin.name = 'Gist'; + return { - plugins: [youtubePlugin, dailymotionPlugin, allocinePlugin, imagePlugin, spotifyPlugin, cloudmusicPlugin, googlemapPlugin, asciinemaPlugin, yrPlugin] + plugins: [youtubePlugin, dailymotionPlugin, allocinePlugin, imagePlugin, spotifyPlugin, cloudmusicPlugin, googlemapPlugin, asciinemaPlugin, yrPlugin, gistPlugin] }; From 7d13f49dabd75be14676e27ec43ab8b297d738e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Fri, 8 Aug 2014 17:09:23 +0100 Subject: [PATCH 06/41] Add tweet embedding plugin --- js/plugins.js | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/js/plugins.js b/js/plugins.js index 4febfc3..0f356ce 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -351,8 +351,36 @@ plugins.factory('userPlugins', function() { ); gistPlugin.name = 'Gist'; + var tweetPlugin = new Plugin( + urlPlugin(function(url) { + var regexp = /^https?:\/\/twitter\.com\/(?:#!\/)?(\w+)\/status(?:es)?\/(\d+)/i; + var match = url.match(regexp); + if (match) { + url = 'https://api.twitter.com/1/statuses/oembed.json?id=' + match[2]; + return function() { + var element = document.querySelector('.embed_' + this.$$hashKey); + jsonp(url, function(data) { + // sepearate the HTML into content and script tag + var scriptIndex = data.html.indexOf(" - - - + + + + From ae5f0effcf9b725d046744cddd9e7475289fc58f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Wed, 13 Aug 2014 09:22:41 +0100 Subject: [PATCH 09/41] Auto-close keyboard when opening sidebar (bufferlist) This is for mobile --- js/glowingbear.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/js/glowingbear.js b/js/glowingbear.js index d31695a..ac4cd1e 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -907,6 +907,12 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', $scope.showSidebar = function() { document.getElementById('sidebar').setAttribute('data-state', 'visible'); document.getElementById('content').setAttribute('sidebar-state', 'visible'); + if ($rootScope.isMobileUi()) { + // de-focus the input bar when opening the sidebar on mobile, so that the keyboard goes down + _.each(document.getElementsByTagName('textarea'), function(elem) { + elem.blur(); + }); + } }; $rootScope.hideSidebar = function() { From 7baffb15e00f5cd63399cc794174762c9b89f571 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Thu, 14 Aug 2014 15:18:24 +0200 Subject: [PATCH 10/41] Fix word breaking Use break-all to force breaking in all browsers. --- css/glowingbear.css | 14 ++++++++++++-- index.html | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/css/glowingbear.css b/css/glowingbear.css index 108fa9d..337ffa7 100644 --- a/css/glowingbear.css +++ b/css/glowingbear.css @@ -56,11 +56,21 @@ td.prefix { border-right: 1px solid #444; } td.message { - word-wrap: break-word; - word-break: break-word; vertical-align: top; width: 100%; padding: 1px 1px 1px 5px; + +-ms-word-break: break-all; + word-break: break-all; + + /* Non standard for webkit */ + word-break: break-word; + +-webkit-hyphens: auto; + -moz-hyphens: auto; + -ms-hyphens: auto; + hyphens: auto; + } #readmarker { margin-top: 5px; diff --git a/index.html b/index.html index 6cae901..ad1a558 100644 --- a/index.html +++ b/index.html @@ -30,7 +30,7 @@ - +

logo From 1235a5e1482dec40fb7aaf68cfd5dda20cd3313d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Mon, 18 Aug 2014 16:37:45 +0100 Subject: [PATCH 11/41] Embed Dropbox images We need to pass a parameter, "?dl=1", to get the actual file --- js/plugins.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/js/plugins.js b/js/plugins.js index 0f356ce..4230365 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -259,6 +259,9 @@ plugins.factory('userPlugins', function() { } else if (url.match(/^http:\/\/(i\.)?imgur\.com\//i)) { // remove protocol specification to load over https if used by g-b url = url.replace(/http:/, ""); + } else if (url.match(/^https:\/\/www\.dropbox\.com\/s\/[a-z0-9]+\/[^?]+$/i)) { + // Dropbox requires a get parameter, dl=1 + url = url + "?dl=1"; } return ''; From b939bc7ca8d189af19efad90d38ff49479964ab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Mon, 18 Aug 2014 16:41:30 +0100 Subject: [PATCH 12/41] Check GET parameters in image embedding This is a great candidate for the tests! --- js/plugins.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/js/plugins.js b/js/plugins.js index 4230365..d5f1bc4 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -251,8 +251,14 @@ plugins.factory('userPlugins', function() { */ var imagePlugin = new Plugin( urlPlugin(function(url) { - if (url.match(/\.(png|gif|jpg|jpeg)$/i)) { - + var embed = false; + // Check the get parameters as well, they might contain an image to load + var segments = url.split(/[?&]/).forEach(function(param) { + if (param.match(/\.(png|gif|jpg|jpeg)$/i)) { + embed = true; + } + }); + if (embed) { /* A fukung.net URL may end by an image extension but is not a direct link. */ if (url.indexOf("^https?://fukung.net/v/") != -1) { url = url.replace(/.*\//, "http://media.fukung.net/imgs/"); From d3b8df8bb0c413c720093f889d84ccd93102722a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Sat, 23 Aug 2014 11:46:05 +0100 Subject: [PATCH 13/41] Don't watch for changes on existing lines How did we miss this angular 1.3 feature? It appears to be a bit similar to bindonce, but also works in ng-repeat! See https://docs.angularjs.org/guide/expression#one-time-binding --- index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 598da74..3ccfa8a 100644 --- a/index.html +++ b/index.html @@ -259,10 +259,10 @@ $ openssl req -nodes -newkey rsa:4096 -keyout relay.pem -x509 -days 365 -out rel :: - + -
- +
+ From 2cb6b054983758e86a22218764d45feb8babbac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Sat, 23 Aug 2014 12:03:13 +0100 Subject: [PATCH 14/41] Wrap inlinecolour filter in $sce.trustAsHtml This is required because bo-html is unsafe whereas ng-bind-html requires "safe" HTML (ng-bind-html-unsafe is deprecated since 1.2) --- js/glowingbear.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index ac4cd1e..f88e85d 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -49,7 +49,7 @@ weechat.filter('irclinky', ['$filter', function($filter) { }; }]); -weechat.filter('inlinecolour', function() { +weechat.filter('inlinecolour', ['$sce', function($sce) { 'use strict'; return function(text) { @@ -61,9 +61,9 @@ weechat.filter('inlinecolour', function() { var hexColourRegex = /(^|[^&])\#([0-9a-f]{6})($|[^\w'"])/gmi; var substitute = '$1#$2
$3'; - return text.replace(hexColourRegex, substitute); + return $sce.trustAsHtml(text.replace(hexColourRegex, substitute)); }; -}); +}]); weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', function($rootScope, $log, models, plugins) { From 4cdf86ed14824413d5917be8d2214ad072cd98b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Sat, 23 Aug 2014 12:23:47 +0100 Subject: [PATCH 15/41] Remove bindonce for Angular 1.3 One-Time Bindings --- directives/plugin.html | 8 ++++---- index.html | 15 +++++++-------- js/glowingbear.js | 2 +- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/directives/plugin.html b/directives/plugin.html index 657692a..67cb8fa 100644 --- a/directives/plugin.html +++ b/directives/plugin.html @@ -1,18 +1,18 @@
-
+
diff --git a/index.html b/index.html index 3ccfa8a..c187d30 100644 --- a/index.html +++ b/index.html @@ -27,7 +27,6 @@ - @@ -220,7 +219,7 @@ $ openssl req -nodes -newkey rsa:4096 -keyout relay.pem -x509 -days 365 -out rel

- From 6f1f84aa6225153e63f3c5a9ab04a105c1e75480 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Sun, 24 Aug 2014 18:13:24 +0100 Subject: [PATCH 20/41] Prevent triggering ng-focus on input during completion $apply during another $apply is not possible, and .focus() on the input node triggers the ng-focus on it (which hides the sidebar, if on mobile), so to prevent the exception from being thrown, move the input node focusing out of the $apply with a timeout of 0. --- js/glowingbear.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index a995baa..d7e6500 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -1428,8 +1428,10 @@ weechat.directive('inputBar', function() { $scope.command = nickComp.text; // update current caret position - inputNode.focus(); - inputNode.setSelectionRange(nickComp.caretPos, nickComp.caretPos); + setTimeout(function() { + inputNode.focus(); + inputNode.setSelectionRange(nickComp.caretPos, nickComp.caretPos); + }, 0); }; From 9c99eefb83d2933e8c6aa3be428a068c05265b06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Mon, 25 Aug 2014 12:40:49 +0100 Subject: [PATCH 21/41] update angularjs to 1.3 beta 19 to fix bug with quotes around URL --- index.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index c187d30..20a9140 100644 --- a/index.html +++ b/index.html @@ -14,10 +14,10 @@ - - - - + + + + From 64f412e047836dad36883bde53988bf1de816351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Sun, 10 Aug 2014 16:57:58 +0100 Subject: [PATCH 22/41] Handle keypress events as well keydown is not enough, because browsers. A (very very very) long explanation that I read in part is at http://unixpapa.com/js/key.html E.g. on my keyboard layout (neo2), I don't get a keydown event for alt+<, which in QWERTY keys is alt + caps lock + u (or the key above shift next to enter on the right side, which actually isn't present on QWERTY (not ' but to the right of it - it's not there on a US layout, but it is # on QWERTZ). I do get a keypress event though. --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index ebfc3c8..d4df8b6 100644 --- a/index.html +++ b/index.html @@ -29,7 +29,7 @@ - +

logo From 9501b9f3d3355aeef8964efbdb050221724ffbcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Sun, 10 Aug 2014 18:59:15 +0100 Subject: [PATCH 23/41] Fix history keybindings for keypress because ASCII != keydown code in JS m( --- js/glowingbear.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index d7e6500..98a96ae 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -1604,7 +1604,7 @@ weechat.directive('inputBar', function() { } // Arrow up -> go up in history - if (code === 38) { + if ($event.type === "keydown" && code === 38) { $scope.command = models.getActiveBuffer().getHistoryUp($scope.command); // Set cursor to last position. Need 0ms timeout because browser sets cursor // position to the beginning after this key handler returns. @@ -1617,7 +1617,7 @@ weechat.directive('inputBar', function() { } // Arrow down -> go down in history - if (code === 40) { + if ($event.type === "keydown" && code === 40) { $scope.command = models.getActiveBuffer().getHistoryDown($scope.command); // We don't need to set the cursor to the rightmost position here, the browser does that for us return true; From 583f5b0abed6ae6130c460b9f158dc02e02ac2be Mon Sep 17 00:00:00 2001 From: David Cormier Date: Tue, 26 Aug 2014 20:17:02 -0400 Subject: [PATCH 24/41] Add necessary files for unit tests setup --- bower.json | 15 +++++++++++++++ package.json | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 bower.json create mode 100644 package.json diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..8557a60 --- /dev/null +++ b/bower.json @@ -0,0 +1,15 @@ +{ + "name": "glowing-bear", + "description": "A webclient for WeeChat", + "version": "0.4.0", + "homepage": "https://github.com/glowing-bear/glowing-bear", + "license": "GPLv3", + "private": true, + "dependencies": { + "angular": "1.3.x", + "angular-route": "1.3.x", + "angular-loader": "1.3.x", + "angular-mocks": "~1.3.x", + "html5-boilerplate": "~4.3.0" + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..81d8608 --- /dev/null +++ b/package.json @@ -0,0 +1,32 @@ +{ + "name": "glowing-bear", + "private": true, + "version": "0.4.0", + "description": "A web client for Weechat", + "repository": "https://github.com/glowing-bear/glowing-bear", + "license": "GPLv3", + "devDependencies": { + "karma": "~0.10", + "protractor": "~0.20.1", + "http-server": "^0.6.1", + "bower": "^1.3.1", + "shelljs": "^0.2.6", + "jshint": "^2.5.2", + "karma-junit-reporter": "^0.2.2" + }, + "scripts": { + "postinstall": "bower install", + + "prestart": "npm install", + "start": "http-server -a localhost -p 8000", + + "pretest": "npm install", + "test": "karma start test/karma.conf.js", + "test-single-run": "karma start test/karma.conf.js --single-run", + + "preupdate-webdriver": "npm install", + "update-webdriver": "webdriver-manager update", + + "update-index-async": "node -e \"require('shelljs/global'); sed('-i', /\\/\\/@@NG_LOADER_START@@[\\s\\S]*\\/\\/@@NG_LOADER_END@@/, '//@@NG_LOADER_START@@\\n' + cat('app/bower_components/angular-loader/angular-loader.min.js') + '\\n//@@NG_LOADER_END@@', 'app/index-async.html');\"" + } +} From 341fa9f616a9e05cb64c09d9407b691d2610da47 Mon Sep 17 00:00:00 2001 From: David Cormier Date: Sat, 2 Aug 2014 11:46:19 -0400 Subject: [PATCH 25/41] Add unit test setup files and sample plugin unit test --- test/karma.conf.js | 34 ++++++++++++++++++++++++++++++++++ test/unit/plugins.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 test/karma.conf.js create mode 100644 test/unit/plugins.js diff --git a/test/karma.conf.js b/test/karma.conf.js new file mode 100644 index 0000000..379b976 --- /dev/null +++ b/test/karma.conf.js @@ -0,0 +1,34 @@ +module.exports = function(config){ + config.set({ + + basePath : '../', + + files : [ + 'bower_components/angular/angular.js', + 'bower_components/angular-route/angular-route.js', + 'bower_components/angular-mocks/angular-mocks.js', + 'js/**/*.js', + 'test/unit/**/*.js' + ], + + autoWatch : true, + + frameworks: ['jasmine'], + + browsers : ['PhantomJS'], + + singleRun: true, + + plugins : [ + 'karma-phantomjs-launcher', + 'karma-jasmine', + 'karma-junit-reporter' + ], + + junitReporter : { + outputFile: 'test_out/unit.xml', + suite: 'unit' + } + + }); +}; diff --git a/test/unit/plugins.js b/test/unit/plugins.js new file mode 100644 index 0000000..3f35d69 --- /dev/null +++ b/test/unit/plugins.js @@ -0,0 +1,29 @@ +/* plugins go here */ + +var msg = function(msg) { + return {'text': msg } +} + +var metadata_name = function(message) { + return message['metadata'][0]['name'] +} + +describe('filter', function() { + beforeEach(module('plugins')); + + + describe('Plugins', function() { + beforeEach(module(function($provide) { + $provide.value('version', 'TEST_VER'); + })); + + + it('should recognize youtube videos', inject(function(plugins) { + expect( + metadata_name( + plugins.PluginManager.contentForMessage(msg('https://www.youtube.com/watch?v=dQw4w9WgXcQ')) + ) + ).toEqual('YouTube video'); + })); + }); +}); From 9da4ece76d934eadc0f09cc5119c0f4c0744525b Mon Sep 17 00:00:00 2001 From: David Cormier Date: Sat, 2 Aug 2014 11:52:44 -0400 Subject: [PATCH 26/41] Add instructions on how to run the tests --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 9798c44..789b2a9 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,8 @@ FAQ Development ----------- +Setup +^^^^^ Getting started with the development of Glowing Bear is really simple, partly because we don't have a build process (pure client-side JS, remember). All you have to do is clone the repository, fire up a webserver to host the files, and start fiddling around. You can try out your changes by reloading the page. Here's a simple example using the python simple web server: @@ -58,6 +60,19 @@ If you'd prefer a version hosted with HTTPS, GitHub serves that as well with an You can also use the latest and greatest development version of Glowing Bear at [https://latest.glowing-bear.org/](https://latest.glowing-bear.org/). +Running the tests +^^^^^^^^^^^^^^^^^ +Glowing Bear uses Karma and Jasmine to run its unit tests. To run the tests locally, you will first need to install `npm` and `bower` on your machine. + +Once this is done, you will need to retrieve the necessary packages for testing Glowing-Bear: + +`$ npm install` + +Finally, you can run the tests: + +`$ npm test` + + Contributing ------------ From b16e9536f08cf8116ea56e3c0f40dc7b88f6d387 Mon Sep 17 00:00:00 2001 From: David Cormier Date: Tue, 26 Aug 2014 20:15:13 -0400 Subject: [PATCH 27/41] Make travis run the tests --- .travis.yml | 4 ++-- run_tests.sh | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 run_tests.sh diff --git a/.travis.yml b/.travis.yml index 4fee055..1f369fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: node_js node_js: - "0.10" -install: "npm -g install jshint" -script: "jshint js/*" +install: "npm install" +script: "sh -e run_tests.sh" notifications: email: false irc: diff --git a/run_tests.sh b/run_tests.sh new file mode 100644 index 0000000..da07a28 --- /dev/null +++ b/run_tests.sh @@ -0,0 +1,2 @@ +./node_modules/.bin/jshint js/* +npm test From 4c3d481447f55fa7446f91e65d081affb5ed00c2 Mon Sep 17 00:00:00 2001 From: David Cormier Date: Sat, 2 Aug 2014 23:48:09 -0400 Subject: [PATCH 28/41] Add tests for all plugins --- test/unit/plugins.js | 99 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 93 insertions(+), 6 deletions(-) diff --git a/test/unit/plugins.js b/test/unit/plugins.js index 3f35d69..c7533dc 100644 --- a/test/unit/plugins.js +++ b/test/unit/plugins.js @@ -8,22 +8,109 @@ var metadata_name = function(message) { return message['metadata'][0]['name'] } +var expectTheseMessagesToContain = function(urls, pluginType, plugins) { + for (var i = 0; i < urls.length; i++) { + expect( + metadata_name( + plugins.PluginManager.contentForMessage(msg(urls[i])) + ) + ).toEqual(pluginType); + } +} + describe('filter', function() { beforeEach(module('plugins')); - describe('Plugins', function() { beforeEach(module(function($provide) { $provide.value('version', 'TEST_VER'); })); + it('should recognize spotify tracks', inject(function(plugins) { + expectTheseMessagesToContain([ + 'https://spotify:track:3AAAAAAAAAAAAAAAAAAAAA', + 'https://open.spotify.com/track/3AAAAAAAAAAAAAAAAAAAAA' + ], + 'Spotify track', + plugins); + })); + it('should recognize youtube videos', inject(function(plugins) { - expect( - metadata_name( - plugins.PluginManager.contentForMessage(msg('https://www.youtube.com/watch?v=dQw4w9WgXcQ')) - ) - ).toEqual('YouTube video'); + expectTheseMessagesToContain([ + 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', + 'http://www.youtube.com/watch?v=dQw4w9WgXcQ', + 'http://youtu.be/J6vIS8jb6Fs', + 'https://youtu.be/J6vIS8jb6Fs', + 'http://www.youtube.com/embed?v=dQw4w9WgXcQ', + 'https://www.youtube.com/embed?v=dQw4w9WgXcQ' + ], + 'YouTube video', + plugins); + })); + + it('should recognize dailymotion videos', inject(function(plugins) { + expectTheseMessagesToContain([ + 'dailymotion.com/video/test', + 'dailymotion.com/video/#video=asdf', + 'dai.ly/sfg' + ], + 'Dailymotion video', + plugins); + })); + + it('should recognize allocine videos', inject(function(plugins) { + expectTheseMessagesToContain([ + 'allocine.fr/videokast/video-12', + 'allocine.fr/cmedia=234' + ], + 'AlloCine video', + plugins); + })); + + it('should recognize images', inject(function(plugins) { + expectTheseMessagesToContain([ + 'http://test.png', + 'https://test.jpg', + 'https://test.jpeg', + 'https://test.gif', + ], + 'image', + plugins); + })); + + it('should recognize cloud music', inject(function(plugins) { + expectTheseMessagesToContain([ + 'http://soundcloud.com/', + 'https://sadf.mixcloud.com/', + ], + 'cloud music', + plugins); + })); + + it('should recognize google map', inject(function(plugins) { + expectTheseMessagesToContain([ + 'https://www.google.com/maps/@48.0034139,-74.9129088,6z', + ], + 'Google Map', + plugins); })); + + it('should recognize google map', inject(function(plugins) { + expectTheseMessagesToContain([ + 'https://asciinema.org/a/10625', + ], + 'ascii cast', + plugins); + })); + + it('should recognize meteograms', inject(function(plugins) { + expectTheseMessagesToContain([ + 'http://www.yr.no/sted/Canada/Quebec/Montreal/', + ], + 'meteogram', + plugins); + })); + }); }); From f2bfb3444e78fd939698f230c801d38dcbb83d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Sat, 9 Aug 2014 13:54:11 +0100 Subject: [PATCH 29/41] Documentation; make test file executable, jshint tests, add a gitignore --- .gitignore | 2 ++ README.md | 4 ++-- run_tests.sh | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 .gitignore mode change 100644 => 100755 run_tests.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c346b13 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +bower_components/ +node_modules/ diff --git a/README.md b/README.md index 789b2a9..f19d5f5 100644 --- a/README.md +++ b/README.md @@ -62,9 +62,9 @@ You can also use the latest and greatest development version of Glowing Bear at Running the tests ^^^^^^^^^^^^^^^^^ -Glowing Bear uses Karma and Jasmine to run its unit tests. To run the tests locally, you will first need to install `npm` and `bower` on your machine. +Glowing Bear uses Karma and Jasmine to run its unit tests. To run the tests locally, you will first need to install `npm` on your machine. Check out the wonderful [nvm](https://github.com/creationix/nvm) if you don't know it already, it's highly recommended. -Once this is done, you will need to retrieve the necessary packages for testing Glowing-Bear: +Once this is done, you will need to retrieve the necessary packages for testing Glowing-Bear (first, you might want to use `npm link` on any packages you have already installed globally): `$ npm install` diff --git a/run_tests.sh b/run_tests.sh old mode 100644 new mode 100755 index da07a28..7ae7475 --- a/run_tests.sh +++ b/run_tests.sh @@ -1,2 +1,2 @@ -./node_modules/.bin/jshint js/* +./node_modules/.bin/jshint js/*.js test/unit/*.js npm test From 230e33136c6434292e7c5ca56c49fe55236f14cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Sat, 9 Aug 2014 13:54:18 +0100 Subject: [PATCH 30/41] Don't fail failed tests by accessing undefined members If a plugin didn't recognize something it should have recognized, don't fail in checking whether it failed. Also, semicolons. --- test/unit/plugins.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/unit/plugins.js b/test/unit/plugins.js index c7533dc..9ca41d0 100644 --- a/test/unit/plugins.js +++ b/test/unit/plugins.js @@ -1,12 +1,15 @@ /* plugins go here */ var msg = function(msg) { - return {'text': msg } -} + return {'text': msg }; +}; var metadata_name = function(message) { - return message['metadata'][0]['name'] -} + if (message.metadata && message.metadata[0] && message.metadata[0].name) { + return message.metadata[0].name; + } + return null; +}; var expectTheseMessagesToContain = function(urls, pluginType, plugins) { for (var i = 0; i < urls.length; i++) { @@ -16,7 +19,7 @@ var expectTheseMessagesToContain = function(urls, pluginType, plugins) { ) ).toEqual(pluginType); } -} +}; describe('filter', function() { beforeEach(module('plugins')); From a46df4baab7e6015395ac20798c326cca664810a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Sat, 9 Aug 2014 14:06:34 +0100 Subject: [PATCH 31/41] Use valid test URLs --- test/unit/plugins.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/test/unit/plugins.js b/test/unit/plugins.js index 9ca41d0..59e4364 100644 --- a/test/unit/plugins.js +++ b/test/unit/plugins.js @@ -31,8 +31,8 @@ describe('filter', function() { it('should recognize spotify tracks', inject(function(plugins) { expectTheseMessagesToContain([ - 'https://spotify:track:3AAAAAAAAAAAAAAAAAAAAA', - 'https://open.spotify.com/track/3AAAAAAAAAAAAAAAAAAAAA' + 'spotify:track:6JEK0CvvjDjjMUBFoXShNZ', + 'https://open.spotify.com/track/6JEK0CvvjDjjMUBFoXShNZ' ], 'Spotify track', plugins); @@ -45,8 +45,9 @@ describe('filter', function() { 'http://www.youtube.com/watch?v=dQw4w9WgXcQ', 'http://youtu.be/J6vIS8jb6Fs', 'https://youtu.be/J6vIS8jb6Fs', - 'http://www.youtube.com/embed?v=dQw4w9WgXcQ', - 'https://www.youtube.com/embed?v=dQw4w9WgXcQ' + 'http://www.youtube.com/embed/dQw4w9WgXcQ', + 'https://www.youtube.com/embed/dQw4w9WgXcQ', + 'youtu.be/dQw4w9WgXcQ' ], 'YouTube video', plugins); @@ -73,10 +74,11 @@ describe('filter', function() { it('should recognize images', inject(function(plugins) { expectTheseMessagesToContain([ - 'http://test.png', - 'https://test.jpg', - 'https://test.jpeg', - 'https://test.gif', + 'http://i.imgur.com/BTNIDBR.gif', + 'https://i.imgur.com/1LmDmct.jpg', + 'http://i.imgur.com/r4FKrnu.jpeg', + 'https://4z2.de/gb-mobile-new.png', + 'http://static.weechat.org/images/screenshots/relay/medium/glowing-bear.png', ], 'image', plugins); From 6d36bf1c829a331c29c7e244f1643d0a377210b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Sat, 9 Aug 2014 14:41:55 +0100 Subject: [PATCH 32/41] Add tests for Gist & Tweet plugins --- test/unit/plugins.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/unit/plugins.js b/test/unit/plugins.js index 59e4364..d515c18 100644 --- a/test/unit/plugins.js +++ b/test/unit/plugins.js @@ -117,5 +117,22 @@ describe('filter', function() { plugins); })); + it('should recognize gists', inject(function(plugins) { + expectTheseMessagesToContain([ + 'https://gist.github.com/lorenzhs/e8c1a7d56fa170320eb8', + 'https://gist.github.com/e8c1a7d56fa170320eb8', + ], + 'Gist', + plugins); + })); + + it('should recognize tweets', inject(function(plugins) { + expectTheseMessagesToContain([ + 'https://twitter.com/DFB_Team_EN/statuses/488436782959448065', + ], + 'Tweet', + plugins); + })); + }); }); From 92282e3a9315197bed41a96ff45fcce9dbf39c80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Mon, 18 Aug 2014 16:43:55 +0100 Subject: [PATCH 33/41] Test images with GET parameters as well (#414) --- test/unit/plugins.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/unit/plugins.js b/test/unit/plugins.js index d515c18..774e724 100644 --- a/test/unit/plugins.js +++ b/test/unit/plugins.js @@ -79,6 +79,8 @@ describe('filter', function() { 'http://i.imgur.com/r4FKrnu.jpeg', 'https://4z2.de/gb-mobile-new.png', 'http://static.weechat.org/images/screenshots/relay/medium/glowing-bear.png', + 'http://foo.bar/baz.php?img=trololo.png&dummy=yes', + 'https://tro.lo.lo/images/rick.png?size=123x45' ], 'image', plugins); From f1d36c1f9668d3a3fac0b44d544654af866c6e2e Mon Sep 17 00:00:00 2001 From: David Cormier Date: Tue, 26 Aug 2014 19:47:38 -0400 Subject: [PATCH 34/41] Setup end to end testing Add necessary targets in the package.json file and update test instructions --- README.md | 5 ++++- package.json | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f19d5f5..424f8d8 100644 --- a/README.md +++ b/README.md @@ -68,10 +68,13 @@ Once this is done, you will need to retrieve the necessary packages for testing `$ npm install` -Finally, you can run the tests: +Finally, you can run the unit tests: `$ npm test` +Or the end to end tests: +`$ npm run protractor` + Contributing ------------ diff --git a/package.json b/package.json index 81d8608..536fd28 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,9 @@ "preupdate-webdriver": "npm install", "update-webdriver": "webdriver-manager update", + "preprotractor": "npm run update-webdriver", + "protractor": "protractor test/protractor-conf.js", + "update-index-async": "node -e \"require('shelljs/global'); sed('-i', /\\/\\/@@NG_LOADER_START@@[\\s\\S]*\\/\\/@@NG_LOADER_END@@/, '//@@NG_LOADER_START@@\\n' + cat('app/bower_components/angular-loader/angular-loader.min.js') + '\\n//@@NG_LOADER_END@@', 'app/index-async.html');\"" } } From 9675909ab5612a6612b4ac70d010252c6b73c301 Mon Sep 17 00:00:00 2001 From: David Cormier Date: Tue, 26 Aug 2014 20:01:47 -0400 Subject: [PATCH 35/41] Add sample E2E test --- test/e2e/scenarios.js | 26 ++++++++++++++++++++++++++ test/protractor-conf.js | 19 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 test/e2e/scenarios.js create mode 100644 test/protractor-conf.js diff --git a/test/e2e/scenarios.js b/test/e2e/scenarios.js new file mode 100644 index 0000000..a1efb07 --- /dev/null +++ b/test/e2e/scenarios.js @@ -0,0 +1,26 @@ +'use strict'; + +/* https://github.com/angular/protractor/blob/master/docs/getting-started.md */ + +describe('Auth', function() { + + browser.get('index.html'); + var ptor = protractor.getInstance(); + it('auth should fail when trying to connect to an unused port', function() { + var host = ptor.findElement(protractor.By.model('host')); + var password = ptor.findElement(protractor.By.model('password')); + var port = ptor.findElement(protractor.By.model('port')); + var submit = ptor.findElement(protractor.By.tagName('button')); + // Fill out the form? + host.sendKeys('localhost'); + password.sendKeys('password'); + port.sendKeys(2462); + submit.click(); + + var error = ptor.findElement( + protractor.By.css('.alert.alert-danger > strong') + ) + + expect(error.getText()).toBeDefined(); + }); +}); diff --git a/test/protractor-conf.js b/test/protractor-conf.js new file mode 100644 index 0000000..d5bf372 --- /dev/null +++ b/test/protractor-conf.js @@ -0,0 +1,19 @@ +exports.config = { + allScriptsTimeout: 11000, + + specs: [ + 'e2e/*.js' + ], + + capabilities: { + 'browserName': 'firefox' + }, + + baseUrl: 'http://localhost:8000/', + + framework: 'jasmine', + + jasmineNodeOpts: { + defaultTimeoutInterval: 30000 + } +}; From 69e1e1907d7e598b3c3ed613586e5d9c3e7d8602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Mon, 11 Aug 2014 17:37:33 +0100 Subject: [PATCH 36/41] Use strict angular dependency injection Prerequisite for proper minification --- js/glowingbear.js | 13 +++++++------ js/localstorage.js | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index 98a96ae..717b16e 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -1320,7 +1320,7 @@ weechat.config(['$routeProvider', ]); -weechat.directive('plugin', function($rootScope) { +weechat.directive('plugin', ['$rootScope', function($rootScope) { /* * Plugin directive * Shows additional plugin content @@ -1373,10 +1373,10 @@ weechat.directive('plugin', function($rootScope) { } } }; -}); +}]); -weechat.directive('inputBar', function() { +weechat.directive('inputBar', ['$rootScope', function() { return { @@ -1386,7 +1386,8 @@ weechat.directive('inputBar', function() { inputId: '@inputId' }, - controller: function($rootScope, + controller: ['$rootScope', '$scope', '$log', 'connection', 'models', + function($rootScope, $scope, $element, $log, @@ -1666,6 +1667,6 @@ weechat.directive('inputBar', function() { return true; } }; - } + }] }; -}); +}]); diff --git a/js/localstorage.js b/js/localstorage.js index 7c3e3b2..5909bf8 100644 --- a/js/localstorage.js +++ b/js/localstorage.js @@ -3,7 +3,7 @@ var ls = angular.module('localStorage',[]); -ls.factory("$store",function($parse){ +ls.factory("$store", ["$parse", function($parse){ /** * Global Vars */ @@ -113,5 +113,5 @@ ls.factory("$store",function($parse){ } }; return publicMethods; -}); +}]); })(); From 33d43ee28d8de4bd43869de85f7b55f81f33e600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Wed, 27 Aug 2014 17:30:16 +0100 Subject: [PATCH 37/41] Add minification --- package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 536fd28..35a94d8 100644 --- a/package.json +++ b/package.json @@ -12,11 +12,14 @@ "bower": "^1.3.1", "shelljs": "^0.2.6", "jshint": "^2.5.2", - "karma-junit-reporter": "^0.2.2" + "karma-junit-reporter": "^0.2.2", + "uglify-js": "^2.4" }, "scripts": { "postinstall": "bower install", + "minify": " uglifyjs js/localstorage.js js/weechat.js js/irc-utils.js js/glowingbear.js js/websockets.js js/models.js js/plugins.js -c -m --screw-ie8 -o min.js --source-map min.map", + "prestart": "npm install", "start": "http-server -a localhost -p 8000", From 2599edec5aaec4cc7041cf14441b8012f4268ed3 Mon Sep 17 00:00:00 2001 From: David Cormier Date: Wed, 27 Aug 2014 12:36:34 -0400 Subject: [PATCH 38/41] Format README titles appropriately --- README.md | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 424f8d8..c5e9e30 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,9 @@ -A web client for WeeChat [![Build Status](https://api.travis-ci.org/glowing-bear/glowing-bear.png)](https://travis-ci.org/glowing-bear/glowing-bear?branch=master) -======================== +#A web client for WeeChat [![Build Status](https://api.travis-ci.org/glowing-bear/glowing-bear.png)](https://travis-ci.org/glowing-bear/glowing-bear?branch=master) Glowing Bear is a web frontend for the [WeeChat](http://weechat.org) IRC client and strives to be a modern interface. It relies on WeeChat to do all the heavy lifting and then provides some nice features on top of that, like embedding images, videos, and other content. The best part, however, is that you can use it from any modern internet device -- whether it's a computer, tablet, or smart phone -- and all your stuff is there, whereever you are. You don't have to deal with the messy technical details, and all you need to have installed is a browser or our app. -Getting Started ---------------- +##Getting Started + Glowing Bear connects to the WeeChat instance you're already running (version 0.4.2 or later is required), and you need to be able to establish a connection to the WeeChat host from your device. It makes use of the relay plugin, and therefore you need to set up a relay. If you want to get started as quickly as possible, use these commands in WeeChat: @@ -19,30 +18,26 @@ You can run Glowing Bear in many ways: use it like any other webpage, as an app Android app on Google PlayFirefox OS app in the Firefox Marketplace -Screenshots ------------ +##Screenshots + Running as Chrome application in a separate window on Windows and as Android app: ![Glowing bear screenshot](https://4z2.de/glowingbear.png) -How it Works ------------- +##How it Works What follows is a more technical explanation of how Glowing Bear works, and you don't need to understand it to use it. Glowing Bear uses WeeChat directly as its backend through the relay plugin. This means that we can connect to WeeChat directly from the browser using WebSockets. Therefore, the client does not need a special "backend service", and you don't have to install anything. A connection is made from your browser to your WeeChat, with no services in between. Thus, Glowing Bear is written purely in client-side JavaScript with a bit of HTML and CSS. -FAQ ---- +##FAQ - *Can I use Glowing Bear to access a machine or port not exposed to the internet by passing the connection through my server?* No, that's not what Glowing Bear does. You can use a websocket proxy module for your webserver to forward `/weechat` to your WeeChat instance though. Here are some pointers you might find helpful for setting this up with [nginx](http://nginx.com/blog/websocket-nginx/) or [apache](https://httpd.apache.org/docs/2.4/mod/mod_proxy_wstunnel.html). - *How does the encryption work?* TLS is used for securing the connection if you enable encryption. This is handled by your browser, and we have no influence on certificate handling, etc. You can find more detailed instructions on how to communicate securely in the "encryption instructions" tab on the [landing page](http://www.glowing-bear.org). A detailed guide on setting up a trusted secure relay is available [here](https://4z2.de/2014/07/06/weechat-trusted-relay). -Development ------------ +##Development -Setup -^^^^^ +###Setup Getting started with the development of Glowing Bear is really simple, partly because we don't have a build process (pure client-side JS, remember). All you have to do is clone the repository, fire up a webserver to host the files, and start fiddling around. You can try out your changes by reloading the page. Here's a simple example using the python simple web server: @@ -60,8 +55,7 @@ If you'd prefer a version hosted with HTTPS, GitHub serves that as well with an You can also use the latest and greatest development version of Glowing Bear at [https://latest.glowing-bear.org/](https://latest.glowing-bear.org/). -Running the tests -^^^^^^^^^^^^^^^^^ +###Running the tests Glowing Bear uses Karma and Jasmine to run its unit tests. To run the tests locally, you will first need to install `npm` on your machine. Check out the wonderful [nvm](https://github.com/creationix/nvm) if you don't know it already, it's highly recommended. Once this is done, you will need to retrieve the necessary packages for testing Glowing-Bear (first, you might want to use `npm link` on any packages you have already installed globally): @@ -76,8 +70,7 @@ Or the end to end tests: `$ npm run protractor` -Contributing ------------- +##Contributing Whether you are interested in contributing or simply want to talk about the project, join us at **#glowing-bear** on **freenode**! From 226068152f17ff415eb140ef3e6666af6fa751f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Wed, 27 Aug 2014 18:47:58 +0100 Subject: [PATCH 39/41] Hotfix strict injection to undo terrible breakage --- js/glowingbear.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index 717b16e..39e9f14 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -1332,7 +1332,7 @@ weechat.directive('plugin', ['$rootScope', function($rootScope) { plugin: '=data' }, - controller: function($scope) { + controller: ["$scope", function($scope) { $scope.displayedContent = ""; @@ -1371,12 +1371,12 @@ weechat.directive('plugin', ['$rootScope', function($rootScope) { if ($scope.plugin.visible) { $scope.showContent(); } - } + }] }; }]); -weechat.directive('inputBar', ['$rootScope', function() { +weechat.directive('inputBar', function() { return { @@ -1386,7 +1386,7 @@ weechat.directive('inputBar', ['$rootScope', function() { inputId: '@inputId' }, - controller: ['$rootScope', '$scope', '$log', 'connection', 'models', + controller: ['$rootScope', '$scope', '$element', '$log', 'connection', 'models', function($rootScope, $scope, $element, @@ -1669,4 +1669,4 @@ weechat.directive('inputBar', ['$rootScope', function() { }; }] }; -}]); +}); From 93e2d0d7b5d5d59a38079dfc0052f1278f7a1c5d Mon Sep 17 00:00:00 2001 From: David Cormier Date: Wed, 27 Aug 2014 14:30:38 -0400 Subject: [PATCH 40/41] Update README.md * Add precisions on the contribution process. * Add precisions on end to end testing. --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index c5e9e30..7e81b37 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ Finally, you can run the unit tests: Or the end to end tests: `$ npm run protractor` +**Note**: the end to end tests assume that a web server is hosting Glowing Bear on `localhost:8000` and that a WeeChat relay is configured on port 9001. ##Contributing @@ -76,4 +77,10 @@ Whether you are interested in contributing or simply want to talk about the proj We appreciate all forms of contributions -- whether you're a coder, designer, or user, we are always curious what you have to say. Whether you have suggestions or already implemented a solution, let us know and we'll try to help. We're also very keen to hear which devices and platforms Glowing Bear works on (or doesn't), as we're a small team and don't have access to the resources we would need to test it everywhere. +If you wish to submit code, we try to make the contribution process as simple as possible. Any pull request that is submitted has to go through automatic and manual testing. Please make sure that your changes pass the [Travis](https://travis-ci.org/glowing-bear/glowing-bear) tests before submitting a pull request. Here is how you can run the tests: + +`$ ./run_tests.sh` + + We'd also like to ask you to join our IRC channel, #glowing-bear on freenode, so we can discuss your ideas and changes. + If you're curious about the projects we're using, here's a list: [AngularJS](https://angularjs.org/), [Bootstrap](http://getbootstrap.com/), [Underscore](http://underscorejs.org/), [favico.js](http://lab.ejci.net/favico.js/), and [zlib.js](https://github.com/imaya/zlib.js). Technology-wise, [WebSockets](http://en.wikipedia.org/wiki/WebSocket) are the most important part, but we also use [local storage](https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Storage#localStorage), the [Notification Web API](https://developer.mozilla.org/en/docs/Web/API/notification), and last (but not least) [Apache Cordova](https://cordova.apache.org/) for our mobile app. From 9ee6dbb11b483e8c9d8ae1af36b79ce4ecd2b97b Mon Sep 17 00:00:00 2001 From: David Cormier Date: Fri, 29 Aug 2014 11:25:33 -0400 Subject: [PATCH 41/41] Bump version to 0.4.1 --- manifest.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index 026b134..237d267 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "Glowing Bear", "description": "WeeChat Web frontend", - "version": "0.4.0", + "version": "0.4.1", "manifest_version": 2, "icons": { "32": "assets/img/favicon.png", diff --git a/package.json b/package.json index 35a94d8..4fe93af 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "glowing-bear", "private": true, - "version": "0.4.0", + "version": "0.4.1", "description": "A web client for Weechat", "repository": "https://github.com/glowing-bear/glowing-bear", "license": "GPLv3",