From e9bcbf40c5d0172aa3a03b9f7d0ed7a02ff46c43 Mon Sep 17 00:00:00 2001 From: Fmstrat Date: Wed, 20 Nov 2019 13:40:54 -0500 Subject: [PATCH 01/55] Check suffix for whitespace on tab completion --- js/irc-utils.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/js/irc-utils.js b/js/irc-utils.js index ffab2b5..78c207f 100644 --- a/js/irc-utils.js +++ b/js/irc-utils.js @@ -144,7 +144,11 @@ IrcUtils.service('IrcUtils', [function() { if (doIterate) { // try iterating newNick = _nextNick(iterCandidate, m[1], searchNickList); - beforeCaret = newNick + suf + ' '; + if (suf.endsWith(' ')) { + beforeCaret = newNick + suf; + } else { + beforeCaret = newNick + suf + ' '; + } return { text: beforeCaret + afterCaret, caretPos: beforeCaret.length, @@ -166,7 +170,11 @@ IrcUtils.service('IrcUtils', [function() { // no match return ret; } - beforeCaret = newNick + suf + ' '; + if (suf.endsWith(' ')) { + beforeCaret = newNick + suf; + } else { + beforeCaret = newNick + suf + ' '; + } if (afterCaret[0] === ' ') { // swallow first space after caret if any afterCaret = afterCaret.substring(1); From 14851e4aa143a55764e5da21c8cee1a2b4aa6682 Mon Sep 17 00:00:00 2001 From: Fmstrat Date: Thu, 21 Nov 2019 09:37:55 -0500 Subject: [PATCH 02/55] Show badeges for mobile (Revert of #581). --- css/glowingbear.css | 5 ----- 1 file changed, 5 deletions(-) diff --git a/css/glowingbear.css b/css/glowingbear.css index ca11870..53a68cc 100644 --- a/css/glowingbear.css +++ b/css/glowingbear.css @@ -817,11 +817,6 @@ img.emojione { height: 28px; } - #topbar .badge { - display: none; - } - - #bufferlines, #nicklist { position: relative; min-height: 0; From fbbc4b0fabca7ede7a37b1ee4af157ba8e5d892f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Fri, 22 Nov 2019 09:38:35 +0100 Subject: [PATCH 03/55] Fix background colour parsing to recognise WeeChat 2.6+ format Fixes #1071 --- js/weechat.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/weechat.js b/js/weechat.js index 640ccbd..4d06ff5 100644 --- a/js/weechat.js +++ b/js/weechat.js @@ -363,7 +363,8 @@ // "*" + (A)STD + "," + EXT // "*" + (A)EXT + "," + STD // "*" + (A)EXT + "," + EXT - regex: /^\*(?:([\x01\x02\x03\x04*!\/_|]*)(\d{2})|@([\x01\x02\x03\x04*!\/_|]*)(\d{5})),(\d{2}|@\d{5})/, + // WeeChat 2.6+ use a tilde (~) instead of a comma (,) so recognise both + regex: /^\*(?:([\x01\x02\x03\x04*!\/_|]*)(\d{2})|@([\x01\x02\x03\x04*!\/_|]*)(\d{5}))[,~](\d{2}|@\d{5})/, fn: function(m) { var ret = {}; From fbb382e835479a135bea12139d72fbe0cc46c67b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Fri, 22 Nov 2019 09:47:44 +0100 Subject: [PATCH 04/55] Make badge on mobile clickable and move it closer to the bear icon --- css/glowingbear.css | 5 +++++ index.html | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/css/glowingbear.css b/css/glowingbear.css index 53a68cc..6dc1524 100644 --- a/css/glowingbear.css +++ b/css/glowingbear.css @@ -811,6 +811,11 @@ img.emojione { text-align: center; font-size: 18px; width: initial; + z-index: -1; + } + + #topbar .brand a { + padding: 0 2px 0 10px; } #topbar .brand img { diff --git a/index.html b/index.html index 3e6ba8f..09eaa07 100644 --- a/index.html +++ b/index.html @@ -255,8 +255,8 @@ npm run build-electron-{windows, darwin, linux}
-
- +
+ brand {{unread}} From 7de6bbd0156b7daea7b0831813c59a53a4a49192 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Fri, 22 Nov 2019 12:23:23 +0100 Subject: [PATCH 05/55] Update to latest electron --- electron-main.js | 354 ++++++++++++++------------------------------ electron-start.html | 41 ----- electron.makefile | 6 +- 3 files changed, 112 insertions(+), 289 deletions(-) mode change 100755 => 100644 electron-main.js delete mode 100644 electron-start.html diff --git a/electron-main.js b/electron-main.js old mode 100755 new mode 100644 index 36ef9dc..6b62abf --- a/electron-main.js +++ b/electron-main.js @@ -1,258 +1,122 @@ -(function() { - 'use strict'; - const electron = require('electron'); - const app = electron.app; // Module to control application life. - const BrowserWindow = electron.BrowserWindow; // Module to create native browser window. +// Modules to control application life and create native browser window +const {app, BrowserWindow, shell, ipcMain} = require('electron') +const path = require('path') +const fs = require('fs') - const ipcMain = require('electron').ipcMain; - const nativeImage = require('electron').nativeImage; - const Menu = require('electron').Menu; - // Node fs module - const fs = require("fs"); - var template; +// Keep a global reference of the window object, if you don't, the window will +// be closed automatically when the JavaScript object is garbage collected. +let mainWindow - template = [ - { - label: 'Edit', - submenu: [ - { - label: 'Undo', - accelerator: 'CmdOrCtrl+Z', - role: 'undo' - }, - { - label: 'Redo', - accelerator: 'Shift+CmdOrCtrl+Z', - role: 'redo' - }, - { - type: 'separator' - }, - { - label: 'Cut', - accelerator: 'CmdOrCtrl+X', - role: 'cut' - }, - { - label: 'Copy', - accelerator: 'CmdOrCtrl+C', - role: 'copy' - }, - { - label: 'Paste', - accelerator: 'CmdOrCtrl+V', - role: 'paste' - }, - { - label: 'Select All', - accelerator: 'CmdOrCtrl+A', - role: 'selectall' - }, - ] - }, - { - label: 'View', - submenu: [ - { - label: 'Reload', - accelerator: 'CmdOrCtrl+R', - click: function(item, focusedWindow) { - if (focusedWindow) - focusedWindow.reload(); - } - }, - { - label: 'Toggle Full Screen', - accelerator: (function() { - if (process.platform == 'darwin') - return 'Ctrl+Command+F'; - else - return 'F11'; - })(), - click: function(item, focusedWindow) { - if (focusedWindow) - focusedWindow.setFullScreen(!focusedWindow.isFullScreen()); - } - }, - { - label: 'Electron Developer Tools', - accelerator: (function() { - if (process.platform == 'darwin') - return 'Alt+Command+E'; - else - return 'Ctrl+Shift+E'; - })(), - click: function(item, focusedWindow) { - if (focusedWindow) - focusedWindow.toggleDevTools(); - } - }, - { - label: 'Web Developer Tools', - accelerator: (function() { - if (process.platform == 'darwin') - return 'Alt+Command+I'; - else - return 'Ctrl+Shift+I'; - })(), - click: function(item, focusedWindow) { - if ( focusedWindow ) { - focusedWindow.webContents.send( 'openDevTools' ); - } - } - } - ] - }, - { - label: 'Window', - role: 'window', - submenu: [ - { - label: 'Minimize', - accelerator: 'CmdOrCtrl+M', - role: 'minimize' - }, - { - label: 'Close', - accelerator: 'CmdOrCtrl+Q', - role: 'close' - }, - ] - }, - { - label: 'Help', - role: 'help', - submenu: [ - { - label: 'Learn More', - click: function() { require('electron').shell.openExternal('https://github.com/glowing-bear/glowing-bear'); } - }, - ] - }, - ]; +// We use this to store some tiny amount of preferences specific to electron +// things like window bounds and location +const initPath = "init.json" - if (process.platform == 'darwin') { - var name = app.getName(); - template.unshift({ - label: name, - submenu: [ - { - label: 'About ' + name, - role: 'about' - }, - { - type: 'separator' - }, - { - label: 'Services', - role: 'services', - submenu: [] - }, - { - type: 'separator' - }, - { - label: 'Hide ' + name, - accelerator: 'Command+H', - role: 'hide' - }, - { - label: 'Hide Others', - accelerator: 'Command+Alt+H', - role: 'hideothers' - }, - { - label: 'Show All', - role: 'unhide' - }, - { - type: 'separator' - }, - { - label: 'Quit', - accelerator: 'Command+Q', - click: function() { app.quit(); } - }, - ] - }); - // Window menu. - template[3].submenu.push( - { - type: 'separator' - }, - { - label: 'Bring All to Front', - role: 'front' - } - ); +function createWindow () { + let data + // read saved state from file (e.g. window bounds) + try { + data = JSON.parse(fs.readFileSync(initPath, 'utf8')) + } + catch(e) { + console.log('Unable to read init.json: ', e) + } + // Create the browser window. + const bounds = (data && data.bounds) ? data.bounds : {width: 1280, height:800 } + mainWindow = new BrowserWindow({ + width: bounds.width, + height: bounds.height, + webPreferences: { + preload: path.join(__dirname, 'electron-globals.js') } + }) - // Keep a global reference of the window object, if you don't, the window will - // be closed automatically when the JavaScript object is garbage collected. - var mainWindow = null; + // Remember window position + if (data && data.bounds.x && data.bounds.y) { + mainWindow.x = data.bounds.x; + mainWindow.y = data.bounds.y; + } - app.on('browser-window-focus', function(e, w) { - w.webContents.send('browser-window-focus'); - }); + mainWindow.setMenu(null) + mainWindow.setMenuBarVisibility(false) + mainWindow.setAutoHideMenuBar(true) - app.on('ready', function() { - var menu = Menu.buildFromTemplate(template); - Menu.setApplicationMenu(menu); - const initPath = __dirname + "/init.json"; - var data; + // and load the index.html of the app. + mainWindow.loadFile('index.html') - // read saved state from file (e.g. window bounds) - try { - data = JSON.parse(fs.readFileSync(initPath, 'utf8')); - } - catch(e) { - console.log('Unable to read init.json: ', e); - } - const bounds = (data && data.bounds) ? data.bounds : {width: 1280, height:800 }; - var bwdata = {width: bounds.width, height: bounds.height, 'min-width': 1024, 'min-height': 600, 'autoHideMenuBar': true, 'web-security': true, 'java': false, 'accept-first-mouse': true, defaultEncoding: 'UTF-8', 'icon':'file://'+__dirname + '/assets/img/favicon.png'}; - // Remembe window position - if (data && data.bounds.x && data.bounds.y) { - bwdata.x = data.bounds.x; - bwdata.y = data.bounds.y; - } + // Open the DevTools. + // mainWindow.webContents.openDevTools() + + var handleLink = (e, url) => { + if(url != mainWindow.webContents.getURL()) { + e.preventDefault() + shell.openExternal(url) + } + } + + mainWindow.webContents.on('will-navigate', handleLink) + mainWindow.webContents.on('new-window', handleLink) + + // Emitted when the window is closing. + mainWindow.on('close', function () { + let data = { + bounds: mainWindow.getBounds() + } + fs.writeFileSync(initPath, JSON.stringify(data)) + }) + + // Emitted when the window is closed. + mainWindow.on('closed', function () { + // Dereference the window object, usually you would store windows + // in an array if your app supports multi windows, this is the time + // when you should delete the corresponding element. + mainWindow = null + }) + + app.on('browser-window-focus', function() { + setTimeout(function() { mainWindow.webContents.focus() }, 0) + setTimeout(function() { mainWindow.webContents.executeJavaScript("document.getElementById(\"sendMessage\").focus()") }, 0) + }) +} + +// This method will be called when Electron has finished +// initialization and is ready to create browser windows. +// Some APIs can only be used after this event occurs. +app.on('ready', function() { + createWindow() +}) - mainWindow = new BrowserWindow(bwdata); - mainWindow.loadURL('file://' + __dirname + '/electron-start.html'); - mainWindow.focus(); - // Listen for badge changes - ipcMain.on('badge', function(event, arg) { - if (process.platform === "darwin") { - app.dock.setBadge(String(arg)); - } - else if (process.platform === "win32") { - let n = parseInt(arg, 10); - // Only show notifications with number - if (isNaN(n)) { - return; - } - if (n > 0) { - mainWindow.setOverlayIcon(__dirname + '/assets/img/favicon.ico', String(arg)); - } else { - mainWindow.setOverlayIcon(null, ''); - } - } - }); +// Listen for badge changes +ipcMain.on('badge', function(event, arg) { + if (process.platform === "darwin") { + app.dock.setBadge(String(arg)) + } + else if (process.platform === "win32") { + let n = parseInt(arg, 10) + // Only show notifications with number + if (isNaN(n)) { + return + } + if (n > 0) { + mainWindow.setOverlayIcon(__dirname + '/assets/img/favicon.ico', String(arg)) + } else { + mainWindow.setOverlayIcon(null, '') + } + } +}) - mainWindow.on('devtools-opened', function() { - mainWindow.webContents.executeJavaScript("document.getElementById('glowingbear').openDevTools();"); - }); +// Quit when all windows are closed. +app.on('window-all-closed', function () { + // On macOS it is common for applications and their menu bar + // to stay active until the user quits explicitly with Cmd + Q + if (process.platform !== 'darwin') app.quit() +}) - mainWindow.on('close', function() { - // Save window bounds to disk - var data = { - bounds: mainWindow.getBounds() - }; - fs.writeFileSync(initPath, JSON.stringify(data)); - }); +app.on('activate', function () { + // On macOS it's common to re-create a window in the app when the + // dock icon is clicked and there are no other windows open. + if (mainWindow === null) createWindow() +}) - mainWindow.on('closed', function() { - app.quit(); - }); - }); -})(); +// In this file you can include the rest of your app's specific main process +// code. You can also put them in separate files and require them here. diff --git a/electron-start.html b/electron-start.html deleted file mode 100644 index 2844bfa..0000000 --- a/electron-start.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - diff --git a/electron.makefile b/electron.makefile index bb0b721..69a69d1 100644 --- a/electron.makefile +++ b/electron.makefile @@ -18,10 +18,10 @@ uselocal: copylocal # build the electron app for various platforms build-electron-windows: uselocal - electron-packager ${ELECTRON_COMMON} --platform=win32 --arch=ia32 --electron-version=3.0.6 --icon=assets/img/favicon.ico --asar=true + electron-packager ${ELECTRON_COMMON} --platform=win32 --arch=ia32 --electron-version=7.1.2 --icon=assets/img/favicon.ico --asar=true build-electron-darwin: uselocal - electron-packager ${ELECTRON_COMMON} --platform=darwin --arch=x64 --electron-version=3.0.6 --icon=assets/img/glowing-bear.icns + electron-packager ${ELECTRON_COMMON} --platform=darwin --arch=x64 --electron-version=7.1.2 --icon=assets/img/glowing-bear.icns build-electron-linux: uselocal - electron-packager ${ELECTRON_COMMON} --platform=linux --arch=x64 --electron-version=3.0.6 --icon=assets/img/favicon.ico + electron-packager ${ELECTRON_COMMON} --platform=linux --arch=x64 --electron-version=7.1.2 --icon=assets/img/favicon.ico From 93d02c9bcca62c2f684aeda63869079740510f58 Mon Sep 17 00:00:00 2001 From: Michael Hazell Date: Thu, 28 Nov 2019 04:24:13 -0500 Subject: [PATCH 06/55] Fix highlights in notify_private buffers with notify level is 0 --- js/handlers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/handlers.js b/js/handlers.js index 2e749cf..77c5e91 100644 --- a/js/handlers.js +++ b/js/handlers.js @@ -168,7 +168,7 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific $rootScope.$emit('notificationChanged'); } - if ((buffer.notify !== 0 && message.highlight) || _.contains(message.tags, 'notify_private')) { + if ((buffer.notify !== 0) && (message.highlight || _.contains(message.tags, 'notify_private'))) { buffer.notification++; server.unread++; notifications.createHighlight(buffer, message); From b78952cd3bdc130f2c50b225f0dc8a1ae9f8a251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Sat, 7 Dec 2019 23:59:04 -0500 Subject: [PATCH 07/55] Don't show a TLS warning when loading locally --- js/glowingbear.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index f8bc47b..98c246e 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -104,8 +104,8 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', })(); // Show a TLS warning if GB was loaded over an unencrypted connection, - // except for local instances (testing, cordova, or electron) - $scope.show_tls_warning = (window.location.protocol !== "https:") && + // except for local instances (local files, testing, cordova, or electron) + $scope.show_tls_warning = (["https:", "file:"].indexOf(window.location.protocol) === -1) && (["localhost", "127.0.0.1", "::1"].indexOf(window.location.hostname) === -1) && !window.is_electron && !utils.isCordova(); From 9c78472f5ab8bc4833dd22028c8386a2c382299a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Sun, 8 Dec 2019 01:52:37 -0500 Subject: [PATCH 08/55] Purge the Vine plugin, that platform died a while ago --- js/plugins.js | 20 +------------------- test/unit/plugins.js | 9 --------- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/js/plugins.js b/js/plugins.js index 32c8fa3..b05ebe3 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -534,24 +534,6 @@ plugins.factory('userPlugins', function() { } }); - /* - * Vine plugin - */ - var vinePlugin = new UrlPlugin('Vine', function (url) { - var regexp = /^https?:\/\/(www\.)?vine\.co\/v\/([a-zA-Z0-9]+)(\/.*)?/i, - match = url.match(regexp); - if (match) { - var id = match[2], embedurl = "https://vine.co/v/" + id + "/embed/simple?audio=1"; - var element = angular.element('') - .addClass('vine-embed') - .attr('src', embedurl) - .attr('width', '600') - .attr('height', '600') - .attr('frameborder', '0'); - return element.prop('outerHTML') + ''; - } - }); - /* * Streamable Embedded Player */ @@ -570,7 +552,7 @@ plugins.factory('userPlugins', function() { }); return { - plugins: [youtubePlugin, dailymotionPlugin, allocinePlugin, imagePlugin, videoPlugin, audioPlugin, spotifyPlugin, cloudmusicPlugin, googlemapPlugin, asciinemaPlugin, yrPlugin, gistPlugin, pastebinPlugin, giphyPlugin, tweetPlugin, vinePlugin, streamablePlugin] + plugins: [youtubePlugin, dailymotionPlugin, allocinePlugin, imagePlugin, videoPlugin, audioPlugin, spotifyPlugin, cloudmusicPlugin, googlemapPlugin, asciinemaPlugin, yrPlugin, gistPlugin, pastebinPlugin, giphyPlugin, tweetPlugin, streamablePlugin] }; diff --git a/test/unit/plugins.js b/test/unit/plugins.js index eaec98b..10a7e53 100644 --- a/test/unit/plugins.js +++ b/test/unit/plugins.js @@ -169,14 +169,5 @@ describe('filter', function() { plugins); })); - it('should recognize vines', inject(function(plugins) { - expectTheseMessagesToContain([ - 'https://vine.co/v/hWh262H9HM5', - 'https://vine.co/v/hWh262H9HM5/embed', - ], - 'Vine', - plugins); - })); - }); }); From 4b6eff57784e031955d709dc87a4ce79d8a06f9f Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Sun, 8 Dec 2019 23:50:59 +0100 Subject: [PATCH 09/55] Update http-server to mitigate INVALID_REDIRECT bug --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 77c3099..ad1d7aa 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "devDependencies": { "bower": "^1.8.8", "electron-packager": "^12.2.0", - "http-server": "^0.11", + "http-server": "^0.12.0", "jasmine-core": "^3.1", "jshint": "^2.9.6", "karma": "^4.2.0", From 62b12dd836b24ad5b88819ede09af49c0e945789 Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Mon, 9 Dec 2019 01:07:03 +0100 Subject: [PATCH 10/55] Correctly interpret value for addSpace It's a string 'on' not a boolean --- js/irc-utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/irc-utils.js b/js/irc-utils.js index 78c207f..8acde89 100644 --- a/js/irc-utils.js +++ b/js/irc-utils.js @@ -119,7 +119,7 @@ IrcUtils.service('IrcUtils', [function() { suf = ':'; } // addSpace defaults to true - var addSpaceChar = (addSpace === undefined || addSpace === true) ? ' ' : ''; + var addSpaceChar = (addSpace === undefined || addSpace === 'on') ? ' ' : ''; // new nick list to search in var searchNickList = _ciNickList(nickList); From 60f834882a6d498912377a7be4f1f884d335f550 Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Thu, 12 Dec 2019 00:39:17 +0100 Subject: [PATCH 11/55] Remove nicklist when weechat clears it and bring is back if it's filled again --- js/glowingbear.js | 5 ++++- js/handlers.js | 15 +++++++++++++++ js/models.js | 13 +++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index f8bc47b..6b46756 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -149,6 +149,9 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', }, false); } + $rootScope.$on('nickListChanged', function() { + $scope.updateShowNicklist(); + }); $rootScope.$on('activeBufferChanged', function(event, unreadSum) { var ab = models.getActiveBuffer(); @@ -776,7 +779,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', $scope.updateShowNicklist = function() { var ab = models.getActiveBuffer(); // Check whether buffer exists and nicklist is non-empty - if (!ab || ab.isNicklistEmpty()) { + if (!ab || !ab.nicklistRequested() || ab.isNicklistEmpty()) { $scope.showNicklist = false; return false; } diff --git a/js/handlers.js b/js/handlers.js index 77c5e91..9891e8f 100644 --- a/js/handlers.js +++ b/js/handlers.js @@ -431,12 +431,24 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific /* * Handle nicklist event + * + * This event can either fill or clear a nicklist. It is always a complete nicklist. */ var handleNicklist = function(message) { var nicklist = message.objects[0].content; var group = 'root'; + + //clear the nicklists in case we are clearing + if (nicklist.length==1) + { + models.getBuffer(nicklist[0].pointers[0]).clearNicklist(); + } + + //fill the nicklist nicklist.forEach(function(n) { var buffer = models.getBuffer(n.pointers[0]); + + //buffer nicklist if (n.group === 1) { var g = new models.NickGroup(n); group = g.name; @@ -446,6 +458,9 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific buffer.addNick(group, nick); } }); + + //check if nicklist should be hidden or not + $rootScope.$emit('nickListChanged'); }; /* * Handle nicklist diff event diff --git a/js/models.js b/js/models.js index ed3e6f1..b19c0f1 100644 --- a/js/models.js +++ b/js/models.js @@ -154,6 +154,18 @@ models.service('models', ['$rootScope', '$filter', 'bufferResume', function($roo } */ }; + /* + * Clear the nicklist + */ + var clearNicklist = function() { + //only keep the root node + for (var obj in nicklist) { + if (obj !== 'root') { + delete nicklist[obj] + } + } + }; + /* * Updates a nick in nicklist */ @@ -325,6 +337,7 @@ models.service('models', ['$rootScope', '$filter', 'bufferResume', function($roo nicklist: nicklist, addNick: addNick, delNick: delNick, + clearNicklist: clearNicklist, updateNick: updateNick, getNicklistByTime: getNicklistByTime, serverSortKey: serverSortKey, From fdb24447c42b29f57749c4e0bbabf17da9243d67 Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Thu, 12 Dec 2019 00:52:52 +0100 Subject: [PATCH 12/55] Missing semicolon --- js/models.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/models.js b/js/models.js index b19c0f1..469bdaf 100644 --- a/js/models.js +++ b/js/models.js @@ -161,7 +161,7 @@ models.service('models', ['$rootScope', '$filter', 'bufferResume', function($roo //only keep the root node for (var obj in nicklist) { if (obj !== 'root') { - delete nicklist[obj] + delete nicklist[obj]; } } }; From 05a40e0a3bc072fa2c396d34de3761d2d3f413b3 Mon Sep 17 00:00:00 2001 From: rio- Date: Mon, 17 Sep 2018 11:58:52 +0200 Subject: [PATCH 13/55] Add input field for WebSocket path, resolves #1008 --- index.html | 2 ++ js/bufferResume.js | 2 +- js/connection.js | 6 +++--- js/glowingbear.js | 6 ++++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index 09eaa07..374ef52 100644 --- a/index.html +++ b/index.html @@ -111,6 +111,8 @@
+ +
diff --git a/js/bufferResume.js b/js/bufferResume.js index 1af4f4e..536e715 100644 --- a/js/bufferResume.js +++ b/js/bufferResume.js @@ -11,7 +11,7 @@ var bufferResume = angular.module('bufferResume', []); bufferResume.service('bufferResume', ['settings', function(settings) { var resumer = {}; - var key = settings.host + ":" + settings.port; + var key = settings.host + ":" + settings.port + "/" + settings.path; // Hold the status that we were able to find the previously accessed buffer // and reload it. If we cannot, we'll need to know so we can load the default diff --git a/js/connection.js b/js/connection.js index 3f0933d..1347551 100644 --- a/js/connection.js +++ b/js/connection.js @@ -20,15 +20,15 @@ weechat.factory('connection', var locked = false; // Takes care of the connection and websocket hooks - var connect = function (host, port, passwd, ssl, noCompression, successCallback, failCallback) { + var connect = function (host, port, path, passwd, ssl, noCompression, successCallback, failCallback) { $rootScope.passwordError = false; - connectionData = [host, port, passwd, ssl, noCompression]; + connectionData = [host, port, path, passwd, ssl, noCompression]; var proto = ssl ? 'wss' : 'ws'; // If host is an IPv6 literal wrap it in brackets if (host.indexOf(":") !== -1 && host[0] !== "[" && host[host.length-1] !== "]") { host = "[" + host + "]"; } - var url = proto + "://" + host + ":" + port + "/weechat"; + var url = proto + "://" + host + ":" + port + "/" + path; $log.debug('Connecting to URL: ', url); var onopen = function () { diff --git a/js/glowingbear.js b/js/glowingbear.js index 717831f..a0073be 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -43,6 +43,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', 'theme': 'dark', 'host': 'localhost', 'port': 9001, + 'path': 'weechat', 'ssl': (window.location.protocol === "https:"), 'savepassword': false, 'autoconnect': false, @@ -665,7 +666,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', $rootScope.bufferBottom = true; $scope.connectbutton = 'Connecting'; $scope.connectbuttonicon = 'glyphicon-refresh glyphicon-spin'; - connection.connect(settings.host, settings.port, $scope.password, settings.ssl); + connection.connect(settings.host, settings.port, settings.path, $scope.password, settings.ssl); }; $scope.disconnect = function() { $scope.connectbutton = 'Connect'; @@ -933,6 +934,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', var spl = rawStr.split(":"); var host = spl[0]; var port = parseInt(spl[1]); + var path = 'weechat'; var password = spl[2]; var ssl = spl.length > 3; notifications.requestNotificationPermission(); @@ -942,7 +944,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', $rootScope.bufferBottom = true; $scope.connectbutton = 'Connecting'; $scope.connectbuttonicon = 'glyphicon-chevron-right'; - connection.connect(host, port, password, ssl); + connection.connect(host, port, path, password, ssl); } }; From 3fe1b0fdfb5510d920fe54fd6bdcd3df05977f0e Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Sun, 15 Dec 2019 02:47:55 +0100 Subject: [PATCH 14/55] Add feature to set port and path in the host field --- css/glowingbear.css | 4 ++++ index.html | 10 ++++++---- js/glowingbear.js | 44 +++++++++++++++++++++++++++++++++++++++----- 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/css/glowingbear.css b/css/glowingbear.css index 6dc1524..7b1651d 100644 --- a/css/glowingbear.css +++ b/css/glowingbear.css @@ -931,4 +931,8 @@ code { padding: 0px 2px; color: #444; border: 1pt solid #444; +} + +.form-control[disabled] { + background-color: #555; } \ No newline at end of file diff --git a/index.html b/index.html index 374ef52..df97f76 100644 --- a/index.html +++ b/index.html @@ -104,15 +104,13 @@
- +
- +
- -
@@ -209,6 +207,10 @@ chown -R username:username ~username Helpful trigger to automatically repin a buffer (in this instance, irc.freenode.#weechat):
/trigger add autopin signal "buffer_opened" "${buffer[${tg_signal_data}].full_name} =~ irc.freenode.#weechat" "" "/command -buffer ${buffer[${tg_signal_data}].full_name} * /buffer set localvar_set_pinned true"

+

Setting path

+

+ The path is by default 'weechat'. In case a proxy is used the path can be changed by entering it in the host field. For example your.domain.com:8000/otherpath. +

diff --git a/js/glowingbear.js b/js/glowingbear.js index a0073be..eb80eb5 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -657,6 +657,39 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', window.requestAnimationFrame(scroll); }; + $scope.parseHost = function() { + //The host field is multi purpose for advanced users + //There can be a combination of host, port and path + //If host is specified here the dedicated port field is disabled + + let parts; + + //host + const regexHost = /^([^:\/]*|\[.*\])$/; + const regexHostPort = /^([^:]*|\[.*\]):(\d+)$/; + const regexHostPortPath = /^([^:]*|\[.*\]):(\d*)\/(.+)$/; + if(parts = regexHost.exec(settings.host)) + { + settings.hostOnly = parts[1]; + $rootScope.portDisabled = false; + } + //host:port + else if(parts = regexHostPort.exec(settings.host)) + { + settings.hostOnly = parts[1]; + settings.port = parts[2]; + $rootScope.portDisabled = true; + } + //host:port/path + else if(parts = regexHostPortPath.exec(settings.host)) + { + settings.hostOnly = parts[1]; + settings.port = parts[2]; + settings.path = parts[3]; + $rootScope.portDisabled = true; + } + + }; $scope.connect = function() { notifications.requestNotificationPermission(); @@ -666,7 +699,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', $rootScope.bufferBottom = true; $scope.connectbutton = 'Connecting'; $scope.connectbuttonicon = 'glyphicon-refresh glyphicon-spin'; - connection.connect(settings.host, settings.port, settings.path, $scope.password, settings.ssl); + connection.connect(settings.hostOnly, settings.port, settings.path, $scope.password, settings.ssl); }; $scope.disconnect = function() { $scope.connectbutton = 'Connect'; @@ -928,13 +961,13 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', }; $scope.init = function() { + $scope.parseHost(); if (window.location.hash) { var rawStr = atob(window.location.hash.substring(1)); window.location.hash = ""; var spl = rawStr.split(":"); - var host = spl[0]; - var port = parseInt(spl[1]); - var path = 'weechat'; + settings.host = spl[0]; + settings.port = parseInt(spl[1]); var password = spl[2]; var ssl = spl.length > 3; notifications.requestNotificationPermission(); @@ -944,7 +977,8 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', $rootScope.bufferBottom = true; $scope.connectbutton = 'Connecting'; $scope.connectbuttonicon = 'glyphicon-chevron-right'; - connection.connect(host, port, path, password, ssl); + $scope.parseHost(); + connection.connect(settings.host, settings.port, settings.path, password, ssl); } }; From f20f442b43c66fc88145fdf176acb5756f950b24 Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Sun, 15 Dec 2019 03:31:46 +0100 Subject: [PATCH 15/55] Make js ES5 compliant so it would pass tests --- js/glowingbear.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index eb80eb5..58f6d14 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -662,26 +662,26 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', //There can be a combination of host, port and path //If host is specified here the dedicated port field is disabled - let parts; + var parts; //host - const regexHost = /^([^:\/]*|\[.*\])$/; - const regexHostPort = /^([^:]*|\[.*\]):(\d+)$/; - const regexHostPortPath = /^([^:]*|\[.*\]):(\d*)\/(.+)$/; - if(parts = regexHost.exec(settings.host)) + var regexHost = /^([^:\/]*|\[.*\])$/; + var regexHostPort = /^([^:]*|\[.*\]):(\d+)$/; + var regexHostPortPath = /^([^:]*|\[.*\]):(\d*)\/(.+)$/; + if((parts = regexHost.exec(settings.host)) !== null) { settings.hostOnly = parts[1]; $rootScope.portDisabled = false; } //host:port - else if(parts = regexHostPort.exec(settings.host)) + else if((parts = regexHostPort.exec(settings.host)) !== null) { settings.hostOnly = parts[1]; settings.port = parts[2]; $rootScope.portDisabled = true; } //host:port/path - else if(parts = regexHostPortPath.exec(settings.host)) + else if((parts = regexHostPortPath.exec(settings.host)) !== null) { settings.hostOnly = parts[1]; settings.port = parts[2]; From 279b3870c6ac7ca78314a90ccbe4e054f05313a3 Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Sun, 15 Dec 2019 03:41:53 +0100 Subject: [PATCH 16/55] Revert CSS change for disabled fields --- css/glowingbear.css | 4 ---- 1 file changed, 4 deletions(-) diff --git a/css/glowingbear.css b/css/glowingbear.css index 7b1651d..6dc1524 100644 --- a/css/glowingbear.css +++ b/css/glowingbear.css @@ -931,8 +931,4 @@ code { padding: 0px 2px; color: #444; border: 1pt solid #444; -} - -.form-control[disabled] { - background-color: #555; } \ No newline at end of file From 47c0a5a0931965f579a0e6766fb803b297d28f73 Mon Sep 17 00:00:00 2001 From: AStove Date: Mon, 16 Dec 2019 11:08:06 +0100 Subject: [PATCH 17/55] Don't remove whole head when appending a stylesheet for a plugin (#1092) --- js/plugins.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/plugins.js b/js/plugins.js index b05ebe3..2dcabc4 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -463,8 +463,10 @@ plugins.factory('userPlugins', function() { 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; + var stylesheet = document.createElement("link"); + stylesheet.href = data.stylesheet; + stylesheet.setAttribute('rel', 'stylesheet'); + document.head.appendChild(stylesheet); } element.innerHTML = '
' + data.div + '
'; }); From 81148545e0de334f1d5115e59ac5df37a46377c0 Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Mon, 16 Dec 2019 12:32:34 +0100 Subject: [PATCH 18/55] Fleshed out the instructions for setting a custom path --- css/glowingbear.css | 1 - index.html | 37 ++++++++++++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/css/glowingbear.css b/css/glowingbear.css index 6dc1524..ca71b9f 100644 --- a/css/glowingbear.css +++ b/css/glowingbear.css @@ -610,7 +610,6 @@ h2 span, h2 small { .panel[data-state=active] .panel-collapse { transition: max-height 0.5s; - max-height: 60em; height: auto; display: block; } diff --git a/index.html b/index.html index df97f76..3505dc3 100644 --- a/index.html +++ b/index.html @@ -207,10 +207,41 @@ chown -R username:username ~username Helpful trigger to automatically repin a buffer (in this instance, irc.freenode.#weechat):
/trigger add autopin signal "buffer_opened" "${buffer[${tg_signal_data}].full_name} =~ irc.freenode.#weechat" "" "/command -buffer ${buffer[${tg_signal_data}].full_name} * /buffer set localvar_set_pinned true"

-

Setting path

-

- The path is by default 'weechat'. In case a proxy is used the path can be changed by entering it in the host field. For example your.domain.com:8000/otherpath. +

Setting a custom path

+

+ To connect to the weechat relay service we connect using a URL. A typical URL consists of 4 parts. {scheme}://{host}:{port}/{path}. The path can be changed by enterying the relay's full URL (except the scheme). +

+
    +
  • scheme: The scheme must never be input. The scheme is "ws" if TLS isn't used and it is "wss" if TLS is used.
  • +
  • host: Can be an IPv4, IPv6 or a FQDN. IPv6 addresses must be wrapped in square brackets.
  • +
  • port: can be specified in the host field or the seperate port field. However if the path is specified in the host field the port must also be specified.
  • +
  • path: by defautl this is "weechat". In case a proxy is used the path can be changed by entering it in the host field.
  • +
+

+ Examples of correct input for the host field are:

+
    +
  • 192.168.0.1
  • +
  • 192.168.0.1:8000
  • +
  • 192.168.0.1:8000/weechat2
  • +
  • [2001:db8:85a3::8a2e:370:7334]
  • +
  • [2001:db8:85a3::8a2e:370:7334]:8000
  • +
  • [2001:db8:85a3::8a2e:370:7334]:8000/weechat2
  • +
  • yourhost.yourdomain.com
  • +
  • yourhost.yourdomain.com:8000
  • +
  • yourhost.yourdomain.com:8000/weechat2
  • +
+

+ Incorrect input for the host field: +

+
    +
  • ws://192.168.0.1 (do not specify the scheme)
  • +
  • 192.168.0.1/weechat2 (must specify port when specifying path)
  • +
  • [2001:db8:85a3::8a2e:370:7334]/weechat2 (must specify port when specifying path)
  • +
  • yourhost.yourdomain.com/weechat2 (must specify port when specifying path)
  • +
  • 2001:db8:85a3::8a2e:370:7334 (must wrap IPv6 address in square brackets)
  • +
  • 2001:db8:85a3::8a2e:370:7334:8000 (must wrap IPv6 address in square brackets)
  • +
From 38862453758fceb71da5d2d262d6acd50d12c772 Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Mon, 16 Dec 2019 13:51:53 +0100 Subject: [PATCH 19/55] Add validation for the host field --- css/themes/base16-default.css | 3 +++ css/themes/dark.css | 3 +++ css/themes/light.css | 3 +++ index.html | 4 ++-- js/glowingbear.js | 13 +++++++------ 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/css/themes/base16-default.css b/css/themes/base16-default.css index ec40fcb..dea026f 100644 --- a/css/themes/base16-default.css +++ b/css/themes/base16-default.css @@ -301,6 +301,9 @@ tr.bufferline:hover { input[type=text], input[type=password], #sendMessage, .badge { box-shadow: 0px 1px 0px rgba(255, 255, 255, 0.1), 0px 1px 7px 0px rgba(0, 0, 0, 0.2) inset; } +input[type=text].is-invalid{ + box-shadow: 0px 1px 0px rgba(255, 255, 255, 0.1), 0px 1px 7px 0px rgba(255, 0, 0, 0.6) inset; +} input[type=text], input[type=password], #sendMessage, .btn-send, .btn-send-image, .btn-complete-nick { color: var(--base05); diff --git a/css/themes/dark.css b/css/themes/dark.css index da260c8..7e79db3 100644 --- a/css/themes/dark.css +++ b/css/themes/dark.css @@ -86,6 +86,9 @@ input[type=text], input[type=password], #sendMessage, .badge, .btn-send, .btn-se color: #ccc; background: none repeat scroll 0% 0% rgba(0, 0, 0, 0.3); } +input[type=text].is-invalid{ + box-shadow: 0px 1px 0px rgba(255, 255, 255, 0.1), 0px 1px 7px 0px rgba(255, 0, 0, 0.8) inset; +} .btn-complete-nick:hover, .btn-complete-nick:focus, .btn-send:hover, .btn-send:focus, diff --git a/css/themes/light.css b/css/themes/light.css index be8012e..323e6c8 100644 --- a/css/themes/light.css +++ b/css/themes/light.css @@ -68,6 +68,9 @@ select.form-control, select option, input[type=text], input[type=password], #sen box-shadow: 0px 1px 0px rgba(0, 0, 0, 0.1), 0px 1px 7px 0px rgba(255, 255, 255, 0.8) inset; background: none repeat scroll 0% 0% rgba(255, 255, 255, 0.3); } +input[type=text].is-invalid{ + box-shadow: 0px 1px 0px rgba(0, 0, 0, 0.1), 0px 1px 7px 0px rgba(255, 0, 0, 0.8) inset; +} #connection-infos { color: #aaa; diff --git a/index.html b/index.html index 3505dc3..8491b70 100644 --- a/index.html +++ b/index.html @@ -104,7 +104,7 @@
- +
@@ -136,7 +136,7 @@
- +
diff --git a/js/glowingbear.js b/js/glowingbear.js index 58f6d14..fe9e075 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -663,31 +663,32 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', //If host is specified here the dedicated port field is disabled var parts; + $rootScope.hostInvalid = false; //host var regexHost = /^([^:\/]*|\[.*\])$/; var regexHostPort = /^([^:]*|\[.*\]):(\d+)$/; var regexHostPortPath = /^([^:]*|\[.*\]):(\d*)\/(.+)$/; - if((parts = regexHost.exec(settings.host)) !== null) - { + if((parts = regexHost.exec(settings.host)) !== null) { settings.hostOnly = parts[1]; $rootScope.portDisabled = false; } //host:port - else if((parts = regexHostPort.exec(settings.host)) !== null) - { + else if((parts = regexHostPort.exec(settings.host)) !== null) { settings.hostOnly = parts[1]; settings.port = parts[2]; $rootScope.portDisabled = true; } //host:port/path - else if((parts = regexHostPortPath.exec(settings.host)) !== null) - { + else if((parts = regexHostPortPath.exec(settings.host)) !== null) { settings.hostOnly = parts[1]; settings.port = parts[2]; settings.path = parts[3]; $rootScope.portDisabled = true; } + else { + $rootScope.hostInvalid = true; + } }; From 9dbd55443a97c0dccba079fcba42b2fed977cc95 Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Mon, 16 Dec 2019 14:21:11 +0100 Subject: [PATCH 20/55] Changed hostOnly to host and host to hostField --- index.html | 2 +- js/glowingbear.js | 25 ++++++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index 8491b70..e30e596 100644 --- a/index.html +++ b/index.html @@ -104,7 +104,7 @@
- +
diff --git a/js/glowingbear.js b/js/glowingbear.js index fe9e075..cd01531 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -41,7 +41,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', // or else they won't be saved to the localStorage. settings.setDefaults({ 'theme': 'dark', - 'host': 'localhost', + 'hostField': 'localhost', 'port': 9001, 'path': 'weechat', 'ssl': (window.location.protocol === "https:"), @@ -66,6 +66,12 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', }); $scope.settings = settings; + //For upgrade reasons because we changed the name of host to hostField + //check if the value might still be in the host key instead of the hostField key + if (!settings.hostFieldv && settings.host) { + settings.hostField = settings.host; + } + $rootScope.countWatchers = function () { $log.debug($rootScope.$$watchersCount); }; @@ -658,30 +664,31 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', }; $scope.parseHost = function() { + //The host field is multi purpose for advanced users //There can be a combination of host, port and path //If host is specified here the dedicated port field is disabled - var parts; + $rootScope.hostInvalid = false; //host var regexHost = /^([^:\/]*|\[.*\])$/; var regexHostPort = /^([^:]*|\[.*\]):(\d+)$/; var regexHostPortPath = /^([^:]*|\[.*\]):(\d*)\/(.+)$/; - if((parts = regexHost.exec(settings.host)) !== null) { - settings.hostOnly = parts[1]; + if((parts = regexHost.exec(settings.hostField)) !== null) { + settings.host = parts[1]; $rootScope.portDisabled = false; } //host:port - else if((parts = regexHostPort.exec(settings.host)) !== null) { - settings.hostOnly = parts[1]; + else if((parts = regexHostPort.exec(settings.hostField)) !== null) { + settings.host = parts[1]; settings.port = parts[2]; $rootScope.portDisabled = true; } //host:port/path - else if((parts = regexHostPortPath.exec(settings.host)) !== null) { - settings.hostOnly = parts[1]; + else if((parts = regexHostPortPath.exec(settings.hostField)) !== null) { + settings.host = parts[1]; settings.port = parts[2]; settings.path = parts[3]; $rootScope.portDisabled = true; @@ -700,7 +707,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', $rootScope.bufferBottom = true; $scope.connectbutton = 'Connecting'; $scope.connectbuttonicon = 'glyphicon-refresh glyphicon-spin'; - connection.connect(settings.hostOnly, settings.port, settings.path, $scope.password, settings.ssl); + connection.connect(settings.host, settings.port, settings.path, $scope.password, settings.ssl); }; $scope.disconnect = function() { $scope.connectbutton = 'Connect'; From 8779e66900880c0c41bc03b4d2e1227d20548e6a Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Mon, 16 Dec 2019 14:39:46 +0100 Subject: [PATCH 21/55] Have different gb colors for disabled inputs --- css/themes/base16-default.css | 4 ++++ css/themes/dark.css | 4 ++++ css/themes/light.css | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/css/themes/base16-default.css b/css/themes/base16-default.css index dea026f..b30a08a 100644 --- a/css/themes/base16-default.css +++ b/css/themes/base16-default.css @@ -65,6 +65,10 @@ a:visited:hover, a:visited:active, a:visited:focus { border: 0px none; } +.form-control[disabled] { + background: var(--base03); +} + .form-control:focus { color: var(--base06); box-shadow: 0px 1px 0px rgba(255, 255, 255, 0.1), 0px 1px 7px 0px rgba(0, 0, 0, 0.2) inset; diff --git a/css/themes/dark.css b/css/themes/dark.css index 7e79db3..b6d1a08 100644 --- a/css/themes/dark.css +++ b/css/themes/dark.css @@ -10,6 +10,10 @@ body { border: 0px none; } +.form-control[disabled] { + background: none repeat scroll 0% 0% rgba(63, 63, 63, 0.3); +} + .form-control option { color: #eee; background: #282828; diff --git a/css/themes/light.css b/css/themes/light.css index 323e6c8..31a2368 100644 --- a/css/themes/light.css +++ b/css/themes/light.css @@ -68,6 +68,11 @@ select.form-control, select option, input[type=text], input[type=password], #sen box-shadow: 0px 1px 0px rgba(0, 0, 0, 0.1), 0px 1px 7px 0px rgba(255, 255, 255, 0.8) inset; background: none repeat scroll 0% 0% rgba(255, 255, 255, 0.3); } + +.form-control[disabled] { + background: none repeat scroll 0% 0% rgba(134, 134, 134, 0.3); +} + input[type=text].is-invalid{ box-shadow: 0px 1px 0px rgba(0, 0, 0, 0.1), 0px 1px 7px 0px rgba(255, 0, 0, 0.8) inset; } From 5a5927104de634d3d82595d72a294369cd96bbd4 Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Mon, 16 Dec 2019 15:26:17 +0100 Subject: [PATCH 22/55] Code style --- js/glowingbear.js | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index cd01531..48b9301 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -610,7 +610,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', } return connection.fetchMoreLines(numLines); }; - + $scope.infiniteScroll = function() { // Check if we are already fetching if ($rootScope.loadingLines) { @@ -630,6 +630,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', } $rootScope.bufferBottom = eob.offsetTop <= bl.scrollTop + bl.clientHeight; }; + $rootScope.scrollWithBuffer = function(scrollToReadmarker, moreLines) { // First, get scrolling status *before* modification // This is required to determine where we were in the buffer pre-change @@ -664,39 +665,31 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', }; $scope.parseHost = function() { - //The host field is multi purpose for advanced users //There can be a combination of host, port and path //If host is specified here the dedicated port field is disabled - var parts; - $rootScope.hostInvalid = false; - //host + var parts; var regexHost = /^([^:\/]*|\[.*\])$/; var regexHostPort = /^([^:]*|\[.*\]):(\d+)$/; var regexHostPortPath = /^([^:]*|\[.*\]):(\d*)\/(.+)$/; - if((parts = regexHost.exec(settings.hostField)) !== null) { + + if ((parts = regexHost.exec(settings.hostField)) !== null) { //host only settings.host = parts[1]; $rootScope.portDisabled = false; - } - //host:port - else if((parts = regexHostPort.exec(settings.hostField)) !== null) { + } else if ((parts = regexHostPort.exec(settings.hostField)) !== null) { //host:port settings.host = parts[1]; settings.port = parts[2]; $rootScope.portDisabled = true; - } - //host:port/path - else if((parts = regexHostPortPath.exec(settings.hostField)) !== null) { + } else if ((parts = regexHostPortPath.exec(settings.hostField)) !== null) { //host:port/path settings.host = parts[1]; settings.port = parts[2]; settings.path = parts[3]; $rootScope.portDisabled = true; - } - else { + } else { $rootScope.hostInvalid = true; } - }; $scope.connect = function() { @@ -709,12 +702,14 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', $scope.connectbuttonicon = 'glyphicon-refresh glyphicon-spin'; connection.connect(settings.host, settings.port, settings.path, $scope.password, settings.ssl); }; + $scope.disconnect = function() { $scope.connectbutton = 'Connect'; $scope.connectbuttonicon = 'glyphicon-chevron-right'; bufferResume.reset(); connection.disconnect(); }; + $scope.reconnect = function() { var bufferId = models.getActiveBuffer().id; connection.attemptReconnect(bufferId, 3000); @@ -723,6 +718,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', $scope.showModal = function(elementId) { document.getElementById(elementId).setAttribute('data-state', 'visible'); }; + $scope.closeModal = function($event) { function closest(elem, selector) { var matchesSelector = elem.matches || elem.webkitMatchesSelector || elem.mozMatchesSelector || elem.msMatchesSelector; From 0823a417f2b26d698c8bea2e4f4260d95cf89e10 Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Mon, 16 Dec 2019 17:22:20 +0100 Subject: [PATCH 23/55] Reset path to weechat if not filled in. --- js/glowingbear.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index 48b9301..b216d1b 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -610,7 +610,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', } return connection.fetchMoreLines(numLines); }; - + $scope.infiniteScroll = function() { // Check if we are already fetching if ($rootScope.loadingLines) { @@ -677,10 +677,12 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', if ((parts = regexHost.exec(settings.hostField)) !== null) { //host only settings.host = parts[1]; + settings.path = "weechat"; $rootScope.portDisabled = false; } else if ((parts = regexHostPort.exec(settings.hostField)) !== null) { //host:port settings.host = parts[1]; settings.port = parts[2]; + settings.path = "weechat"; $rootScope.portDisabled = true; } else if ((parts = regexHostPortPath.exec(settings.hostField)) !== null) { //host:port/path settings.host = parts[1]; From 4bc77a294dc35a8a41f0dbdc8a723322b9eebafc Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Mon, 16 Dec 2019 21:22:48 +0100 Subject: [PATCH 24/55] Hide sidebar for all widths accoring to state. And always check if mobile to hide it or not --- css/glowingbear.css | 11 ++++++----- js/glowingbear.js | 4 +--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/css/glowingbear.css b/css/glowingbear.css index 6dc1524..4cd92f7 100644 --- a/css/glowingbear.css +++ b/css/glowingbear.css @@ -263,6 +263,11 @@ input[type=text], input[type=password], #sendMessage { #sidebar.ng-hide { width: 0; } + +#sidebar[data-state=hidden] { + transform: translate(-200px,0); + -webkit-transform: translate(-200px,0); +} #nicklist { position: fixed; @@ -400,6 +405,7 @@ td.time { margin-left: 0; padding-left: 145px; } + .footer.withnicklist { padding-right: 100px; } @@ -794,11 +800,6 @@ img.emojione { -webkit-transform: translate(0,0); /* Safari */ } - #sidebar[data-state=hidden] { - transform: translate(-200px,0); - -webkit-transform: translate(-200px,0); - } - .content[sidebar-state=visible] #bufferlines, .content[sidebar-state=visible] .footer { margin-left: 0px; transform: translate(200px,0); diff --git a/js/glowingbear.js b/js/glowingbear.js index 717831f..e32587f 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -576,12 +576,10 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', // Recalculation fails when not connected if ($rootScope.connected) { // Show the sidebar if switching away from mobile view, hide it when switching to mobile - // Wrap in a condition so we save ourselves the $apply if nothing changes (50ms or more) - if ($scope.wasMobileUi && !utils.isMobileUi()) { + if (!utils.isMobileUi()) { $scope.showSidebar(); $scope.updateShowNicklist(); } - $scope.wasMobileUi = utils.isMobileUi(); $scope.calculateNumLines(); // if we're scrolled to the bottom, scroll down to the same position after the resize From 7982f46e6c045d47e7ad6f8cc7e1ee8e92c36478 Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Mon, 16 Dec 2019 23:25:04 +0100 Subject: [PATCH 25/55] Delete unused references to wasMobileUi --- js/glowingbear.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index e32587f..40d7971 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -319,11 +319,6 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', } }); - $rootScope.wasMobileUi = false; - if (utils.isMobileUi()) { - $rootScope.wasMobileUi = true; - } - if (!settings.fontfamily) { if (utils.isMobileUi()) { settings.fontfamily = 'sans-serif'; From 75114a455c5de01c81a7079ae26cf62cb04122c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Tue, 17 Dec 2019 10:52:34 +0100 Subject: [PATCH 26/55] Fix typo --- js/glowingbear.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index b216d1b..e706815 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -68,7 +68,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', //For upgrade reasons because we changed the name of host to hostField //check if the value might still be in the host key instead of the hostField key - if (!settings.hostFieldv && settings.host) { + if (!settings.hostField && settings.host) { settings.hostField = settings.host; } From 68e2df24fdac15d2328555f31d44de627ec8b3f4 Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Wed, 18 Dec 2019 22:08:16 +0100 Subject: [PATCH 27/55] Support TOTP --- index.html | 24 +++++++++++++++++++----- js/connection.js | 9 ++++++--- js/glowingbear.js | 11 ++++++++++- js/weechat.js | 3 +++ 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index e30e596..3da29a8 100644 --- a/index.html +++ b/index.html @@ -114,7 +114,7 @@
- Error: wrong password + Error: wrong password or one-time password
@@ -123,18 +123,26 @@ Save password in your browser
+
+ +
-
+ +
@@ -151,6 +159,7 @@
+

Use TLS encryption

WeeChat version 0.4.2 or higher is required—we recommend at least 1.0.

To start using Glowing Bear, follow the instructions below to set up an encrypted relay. All communication goes directly between your browser and your WeeChat relay! This means that your server must be accessible. We never see any of your data or your password, and you don't need to trust a "cloud". All settings, including your password, are saved locally in your own browser between sessions.

You're using Glowing Bear over an unencrypted connection (http://). This is not recommended! We recommend using our secure hosted version at https://www.glowing-bear.org/, or https://latest.glowing-bear.org for the latest and greatest development version. You can still follow the instructions below to set up an encrypted relay, though.
@@ -168,6 +177,11 @@ chown -R username:username ~username

Your certificate needs to be renewed every couple of months. Either follow the instructions for automatic renewal at https://certbot.eff.org, or run certbot renew manually when renewal is due. Important: You'll need to follow the instructions for copying the certificate to the right place again, and re-run /relay sslcertkey in WeeChat.

+

Use TOTP (Time-based One-Time Password)

+

Configure WeeChat for TOTP. The secret key has to be a base 32 string.

+
/secure set relay_totp_secret xxxxx
+/set relay.network.totp_secret "${sec.data.relay_totp_secret}"
+

Open an authenticator app and create an entry with the same secret. In Glowing Bear check the checkbox for "use Time-based One-Time Password" and fill in the one time password as you see it in the authenticator app.

diff --git a/js/connection.js b/js/connection.js index 1347551..242fcae 100644 --- a/js/connection.js +++ b/js/connection.js @@ -20,7 +20,7 @@ weechat.factory('connection', var locked = false; // Takes care of the connection and websocket hooks - var connect = function (host, port, path, passwd, ssl, noCompression, successCallback, failCallback) { + var connect = function (host, port, path, passwd, ssl, useTotp, totp, noCompression, successCallback, failCallback) { $rootScope.passwordError = false; connectionData = [host, port, path, passwd, ssl, noCompression]; var proto = ssl ? 'wss' : 'ws'; @@ -45,7 +45,9 @@ weechat.factory('connection', ngWebsockets.send( weeChat.Protocol.formatInit({ password: passwd, - compression: noCompression ? 'off' : 'zlib' + compression: noCompression ? 'off' : 'zlib', + useTotp: useTotp, + totp: totp }) ); @@ -328,7 +330,8 @@ weechat.factory('connection', var attemptReconnect = function (bufferId, timeout) { $log.info('Attempting to reconnect...'); var d = connectionData; - connect(d[0], d[1], d[2], d[3], d[4], function() { + // won't work if totp is mandetory + connect(d[0], d[1], d[2], d[3], d[4], false, "", function() { $rootScope.reconnecting = false; // on success, update active buffer models.setActiveBuffer(bufferId); diff --git a/js/glowingbear.js b/js/glowingbear.js index 1dd2291..32c83ae 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -45,6 +45,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', 'port': 9001, 'path': 'weechat', 'ssl': (window.location.protocol === "https:"), + 'useTotp': false, 'savepassword': false, 'autoconnect': false, 'nonicklist': utils.isMobileUi(), @@ -687,6 +688,13 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', } }; + $scope.changeUseTOTP = function() { + if (settings.useTotp) { + settings.autoconnect = false; + } + } + + $scope.connect = function() { notifications.requestNotificationPermission(); $rootScope.sslError = false; @@ -695,7 +703,8 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', $rootScope.bufferBottom = true; $scope.connectbutton = 'Connecting'; $scope.connectbuttonicon = 'glyphicon-refresh glyphicon-spin'; - connection.connect(settings.host, settings.port, settings.path, $scope.password, settings.ssl); + connection.connect(settings.host, settings.port, settings.path, $scope.password, settings.ssl, settings.useTotp, $scope.totp); + $scope.totp = "";//clear for next time }; $scope.disconnect = function() { diff --git a/js/weechat.js b/js/weechat.js index 4d06ff5..f46e3ef 100644 --- a/js/weechat.js +++ b/js/weechat.js @@ -648,6 +648,9 @@ if (params.password !== null) { keys.push('password=' + params.password); } + if (params.useTotp) { + keys.push('totp=' + params.totp); + } parts.push(keys.join(',')); return WeeChatProtocol._formatCmd(null, 'init', parts); From 060a722a3f45fed583a9a18d3b4e16b9ef4b41e8 Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Wed, 18 Dec 2019 22:28:12 +0100 Subject: [PATCH 28/55] Missed semicolon --- js/glowingbear.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index 32c83ae..a139787 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -692,7 +692,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', if (settings.useTotp) { settings.autoconnect = false; } - } + }; $scope.connect = function() { From e87d74243fbb2c673edcf79b42a01bdcbe62344c Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Thu, 19 Dec 2019 08:25:17 +0100 Subject: [PATCH 29/55] Spelling in comment --- js/connection.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/connection.js b/js/connection.js index 242fcae..d84ac76 100644 --- a/js/connection.js +++ b/js/connection.js @@ -330,7 +330,7 @@ weechat.factory('connection', var attemptReconnect = function (bufferId, timeout) { $log.info('Attempting to reconnect...'); var d = connectionData; - // won't work if totp is mandetory + // won't work if totp is mandatory connect(d[0], d[1], d[2], d[3], d[4], false, "", function() { $rootScope.reconnecting = false; // on success, update active buffer From 012bd882587d6463b7138bb1cb1843d95b76fe5c Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Thu, 19 Dec 2019 22:16:01 +0100 Subject: [PATCH 30/55] Change layout and autoconnect behaviour. Add info next to topt function --- index.html | 24 ++++++++++++++++-------- js/connection.js | 8 +++++++- js/glowingbear.js | 5 ++--- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/index.html b/index.html index 3da29a8..e66f13c 100644 --- a/index.html +++ b/index.html @@ -100,21 +100,31 @@
diff --git a/js/connection.js b/js/connection.js index d84ac76..b521332 100644 --- a/js/connection.js +++ b/js/connection.js @@ -328,9 +328,15 @@ weechat.factory('connection', }; var attemptReconnect = function (bufferId, timeout) { + // won't work if totp is mandatory + if (settings.useTotp) + { + $log.info('Not reconnecting because totp will be expired.'); + return; + } + $log.info('Attempting to reconnect...'); var d = connectionData; - // won't work if totp is mandatory connect(d[0], d[1], d[2], d[3], d[4], false, "", function() { $rootScope.reconnecting = false; // on success, update active buffer diff --git a/js/glowingbear.js b/js/glowingbear.js index a139787..d85114c 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -688,12 +688,11 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', } }; - $scope.changeUseTOTP = function() { + settings.addCallback('useTotp', function() { if (settings.useTotp) { settings.autoconnect = false; } - }; - + }); $scope.connect = function() { notifications.requestNotificationPermission(); From 876a9351ac12543f21c81c7e6ea438572b0e28d9 Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Thu, 19 Dec 2019 22:37:32 +0100 Subject: [PATCH 31/55] Validate token field --- index.html | 4 ++-- js/glowingbear.js | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index e66f13c..b66a6ae 100644 --- a/index.html +++ b/index.html @@ -120,7 +120,7 @@
- +
@@ -152,7 +152,7 @@
- + diff --git a/js/glowingbear.js b/js/glowingbear.js index d85114c..ee8540e 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -694,6 +694,10 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', } }); + $scope.parseTotp = function() { + $scope.totpInvalid = !/^\d{6}$/.test($scope.totp); + }; + $scope.connect = function() { notifications.requestNotificationPermission(); $rootScope.sslError = false; From 4498312e14acae7ab8a026c7938eb12c51c9c5cf Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Sat, 21 Dec 2019 01:02:48 +0100 Subject: [PATCH 32/55] Layout of checkboxes, 4-10digits, look of info --- index.html | 13 ++++++------- js/glowingbear.js | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index b66a6ae..e031aa1 100644 --- a/index.html +++ b/index.html @@ -126,13 +126,18 @@
Error: wrong password or token
-
+
+ +
-
- -
diff --git a/js/glowingbear.js b/js/glowingbear.js index ee8540e..5111d52 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -695,7 +695,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', }); $scope.parseTotp = function() { - $scope.totpInvalid = !/^\d{6}$/.test($scope.totp); + $scope.totpInvalid = !/^\d{4,10}$/.test($scope.totp); }; $scope.connect = function() { From e35f2ab4d6d2f0695a2e21719ee31492a7faa69c Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Wed, 18 Dec 2019 01:06:03 +0100 Subject: [PATCH 33/55] Fix atob error, add url params --- index.html | 27 ++++++++++++++++++++++++++- js/glowingbear.js | 30 +++++++++++++++++++----------- 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/index.html b/index.html index e031aa1..22a0cb6 100644 --- a/index.html +++ b/index.html @@ -12,6 +12,7 @@ + @@ -230,7 +231,10 @@ chown -R username:username ~username

Setting a custom path

- To connect to the weechat relay service we connect using a URL. A typical URL consists of 4 parts. {scheme}://{host}:{port}/{path}. The path can be changed by enterying the relay's full URL (except the scheme). + The hostname field can be used to set a custom path. Or a URL parameter can be used see section 'URL Parameters'. +

+

+ To connect to the weechat relay service we connect using a URL. A typical URL consists of 4 parts. {scheme}://{host}:{port}/{path}. The path can be changed by entering the relay's full URL (except the scheme).

  • scheme: The scheme must never be input. The scheme is "ws" if TLS isn't used and it is "wss" if TLS is used.
  • @@ -263,6 +267,27 @@ chown -R username:username ~username2001:db8:85a3::8a2e:370:7334 (must wrap IPv6 address in square brackets)
  • 2001:db8:85a3::8a2e:370:7334:8000 (must wrap IPv6 address in square brackets)
+

URL Parameters

+

+ Parameters can be passed in the URL to prefill the fields. This can be useful when you have multiple relays and want to use bookmarks to manage them. + We do not recommend passing the password in this was as it will be visible in plain text and stored in the bookmark but it is possible. Special characters should be URL encoded. +

+

+ If we want just the path for example: https://glowing-bear.org/?path=weechat2 +

+

+ An example: https://glowing-bear.org/?host=my.domain.com&port=8000&password=hunter2&autoconnect=true +

+

+ Available parameters: +

    +
  • host
  • +
  • port
  • +
  • path
  • +
  • password
  • +
  • autoconnect
  • +
+

diff --git a/js/glowingbear.js b/js/glowingbear.js index 5111d52..a738361 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -8,9 +8,12 @@ document.addEventListener("deviceready", function () { } }, false); -var weechat = angular.module('weechat', ['ngRoute', 'localStorage', 'weechatModels', 'bufferResume', 'plugins', 'IrcUtils', 'ngSanitize', 'ngWebsockets', 'ngTouch'], ['$compileProvider', function($compileProvider) { +var weechat = angular.module('weechat', ['ngRoute', 'localStorage', 'weechatModels', 'bufferResume', 'plugins', 'IrcUtils', 'ngSanitize', 'ngWebsockets', 'ngTouch'], ['$compileProvider', '$locationProvider', function($compileProvider, $locationProvider) { // hacky way to be able to find out if we're in debug mode weechat.compileProvider = $compileProvider; + + //remove hashbang from url + $locationProvider.html5Mode(true).hashPrefix(''); }]); weechat.config(['$compileProvider', function ($compileProvider) { // hack to determine whether we're executing the tests @@ -19,8 +22,8 @@ weechat.config(['$compileProvider', function ($compileProvider) { } }]); -weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', '$log', 'models', 'bufferResume', 'connection', 'notifications', 'utils', 'settings', - function ($rootScope, $scope, $store, $timeout, $log, models, bufferResume, connection, notifications, utils, settings) +weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout','$location', '$log', 'models', 'bufferResume', 'connection', 'notifications', 'utils', 'settings', + function ($rootScope, $scope, $store, $timeout, $location, $log, models, bufferResume, connection, notifications, utils, settings) { window.openBuffer = function(channel) { @@ -699,6 +702,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', }; $scope.connect = function() { + notifications.requestNotificationPermission(); $rootScope.sslError = false; $rootScope.securityError = false; @@ -973,14 +977,15 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', $scope.init = function() { $scope.parseHost(); + + //Fill in url parameters, they take precedence over the stored settings, but store them + if($location.search().host) { $scope.settings.host = $location.search().host; $scope.settings.hostField = $location.search().host;} + if($location.search().port) { $scope.settings.port = parseInt($location.search().port);} + if($location.search().path) { $scope.settings.path = $location.search().path;} + if($location.search().password) { $scope.settings.password = $location.search().password;} + if($location.search().autoconnect) { $scope.settings.autoconnect = $location.search().autoconnect === 'true';} + if (window.location.hash) { - var rawStr = atob(window.location.hash.substring(1)); - window.location.hash = ""; - var spl = rawStr.split(":"); - settings.host = spl[0]; - settings.port = parseInt(spl[1]); - var password = spl[2]; - var ssl = spl.length > 3; notifications.requestNotificationPermission(); $rootScope.sslError = false; $rootScope.securityError = false; @@ -988,7 +993,6 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', $rootScope.bufferBottom = true; $scope.connectbutton = 'Connecting'; $scope.connectbuttonicon = 'glyphicon-chevron-right'; - $scope.parseHost(); connection.connect(settings.host, settings.port, settings.path, password, ssl); } }; @@ -1000,6 +1004,10 @@ weechat.config(['$routeProvider', $routeProvider.when('/', { templateUrl: 'index.html', controller: 'WeechatCtrl' + }) + //for legacy reasons redirect the /#! to / + .otherwise({ + redirectTo: '/' }); } ]); From 267bb207115eb170459b5bd67428e5e24dd194cc Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Wed, 18 Dec 2019 08:33:21 +0100 Subject: [PATCH 34/55] Typo --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 22a0cb6..1707de2 100644 --- a/index.html +++ b/index.html @@ -270,7 +270,7 @@ chown -R username:username ~usernameURL Parameters

Parameters can be passed in the URL to prefill the fields. This can be useful when you have multiple relays and want to use bookmarks to manage them. - We do not recommend passing the password in this was as it will be visible in plain text and stored in the bookmark but it is possible. Special characters should be URL encoded. + We do not recommend passing the password in this way as it will be visible in plain text and stored in history/bookmarks but it is possible. Special characters should be URL encoded.

If we want just the path for example: https://glowing-bear.org/?path=weechat2 From 6fcb54f7aad752a8e5f6bff2158307d761676186 Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Wed, 18 Dec 2019 18:40:51 +0100 Subject: [PATCH 35/55] Don't use base --- index.html | 1 - js/glowingbear.js | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 1707de2..4ce8573 100644 --- a/index.html +++ b/index.html @@ -12,7 +12,6 @@ - diff --git a/js/glowingbear.js b/js/glowingbear.js index a738361..164ce74 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -13,7 +13,10 @@ var weechat = angular.module('weechat', ['ngRoute', 'localStorage', 'weechatMode weechat.compileProvider = $compileProvider; //remove hashbang from url - $locationProvider.html5Mode(true).hashPrefix(''); + $locationProvider.html5Mode({ + enabled: true, + requireBase: false + }).hashPrefix(''); }]); weechat.config(['$compileProvider', function ($compileProvider) { // hack to determine whether we're executing the tests From 3bffb13930b740cf7ff61b3af7eb562965bede80 Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Wed, 18 Dec 2019 19:52:27 +0100 Subject: [PATCH 36/55] no redirecting, removeautoconnect on hash --- js/glowingbear.js | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index 164ce74..85b318c 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -11,12 +11,6 @@ document.addEventListener("deviceready", function () { var weechat = angular.module('weechat', ['ngRoute', 'localStorage', 'weechatModels', 'bufferResume', 'plugins', 'IrcUtils', 'ngSanitize', 'ngWebsockets', 'ngTouch'], ['$compileProvider', '$locationProvider', function($compileProvider, $locationProvider) { // hacky way to be able to find out if we're in debug mode weechat.compileProvider = $compileProvider; - - //remove hashbang from url - $locationProvider.html5Mode({ - enabled: true, - requireBase: false - }).hashPrefix(''); }]); weechat.config(['$compileProvider', function ($compileProvider) { // hack to determine whether we're executing the tests @@ -988,30 +982,22 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', if($location.search().password) { $scope.settings.password = $location.search().password;} if($location.search().autoconnect) { $scope.settings.autoconnect = $location.search().autoconnect === 'true';} - if (window.location.hash) { - notifications.requestNotificationPermission(); - $rootScope.sslError = false; - $rootScope.securityError = false; - $rootScope.errorMessage = false; - $rootScope.bufferBottom = true; - $scope.connectbutton = 'Connecting'; - $scope.connectbuttonicon = 'glyphicon-chevron-right'; - connection.connect(settings.host, settings.port, settings.path, password, ssl); - } }; }]); -weechat.config(['$routeProvider', - function($routeProvider) { +weechat.config(['$routeProvider', '$locationProvider', + function($routeProvider, $locationProvider) { $routeProvider.when('/', { templateUrl: 'index.html', controller: 'WeechatCtrl' - }) - //for legacy reasons redirect the /#! to / - .otherwise({ - redirectTo: '/' }); + + //remove hashbang from url + $locationProvider.html5Mode({ + enabled: true, + requireBase: false + }).hashPrefix(''); } ]); From 844810408d8c18dd658a5f06469b703ec47f08c1 Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Wed, 18 Dec 2019 20:05:19 +0100 Subject: [PATCH 37/55] Preserve pathname in location --- js/glowingbear.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index 85b318c..5fd941d 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -8,7 +8,7 @@ document.addEventListener("deviceready", function () { } }, false); -var weechat = angular.module('weechat', ['ngRoute', 'localStorage', 'weechatModels', 'bufferResume', 'plugins', 'IrcUtils', 'ngSanitize', 'ngWebsockets', 'ngTouch'], ['$compileProvider', '$locationProvider', function($compileProvider, $locationProvider) { +var weechat = angular.module('weechat', ['ngRoute', 'localStorage', 'weechatModels', 'bufferResume', 'plugins', 'IrcUtils', 'ngSanitize', 'ngWebsockets', 'ngTouch'], ['$compileProvider', function($compileProvider) { // hacky way to be able to find out if we're in debug mode weechat.compileProvider = $compileProvider; }]); @@ -23,6 +23,8 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', function ($rootScope, $scope, $store, $timeout, $location, $log, models, bufferResume, connection, notifications, utils, settings) { + $location.path(window.location.pathname); + window.openBuffer = function(channel) { $scope.openBuffer(channel); $scope.$apply(); From 0b0ab115a07fde15dea1dd1bcab399d1093e751d Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Wed, 18 Dec 2019 20:10:06 +0100 Subject: [PATCH 38/55] revert setthing pathname --- js/glowingbear.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index 5fd941d..33bf5f6 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -23,8 +23,6 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', function ($rootScope, $scope, $store, $timeout, $location, $log, models, bufferResume, connection, notifications, utils, settings) { - $location.path(window.location.pathname); - window.openBuffer = function(channel) { $scope.openBuffer(channel); $scope.$apply(); From d9509bafd0868ec3a585745bf82dd6b7eeee4181 Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Fri, 20 Dec 2019 00:39:43 +0100 Subject: [PATCH 39/55] Chang get parameters to hash parameters --- js/glowingbear.js | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index 33bf5f6..27fd73e 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -698,6 +698,22 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', $scope.totpInvalid = !/^\d{4,10}$/.test($scope.totp); }; + $scope.parseHash = function() { + + //Fill in url parameters, they take precedence over the stored settings, but store them + var params = $location.$$hash.split('&').map(function(val) {return {key: val.split('=')[0], value: val.split('=')[1]}}); + var hostParam = params.find(function(p) { return p.key === 'host'; }); + var portParam = params.find(function(p) { return p.key === 'port'; }); + var pathParam = params.find(function(p) { return p.key === 'path'; }); + var passwordParam = params.find(function(p) { return p.key === 'password'; }); + var autoconnectParam = params.find(function(p) { return p.key === 'autoconnect'; }); + if(hostParam) { $scope.settings.host = hostParam.value; $scope.settings.hostField = hostParam.value;} + if(portParam) { $scope.settings.port = parseInt(portParam.value);} + if(pathParam) { $scope.settings.path = pathParam.value;} + if(passwordParam) { $scope.settings.password = passwordParam.value;} + if(autoconnectParam) { $scope.settings.autoconnect = autoconnectParam.value === 'true';} + }; + $scope.connect = function() { notifications.requestNotificationPermission(); @@ -972,23 +988,21 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', } }; + window.onhashchange = function() { + console.log('hash has changed'); + $scope.parseHash(); + }; + $scope.init = function() { $scope.parseHost(); - - //Fill in url parameters, they take precedence over the stored settings, but store them - if($location.search().host) { $scope.settings.host = $location.search().host; $scope.settings.hostField = $location.search().host;} - if($location.search().port) { $scope.settings.port = parseInt($location.search().port);} - if($location.search().path) { $scope.settings.path = $location.search().path;} - if($location.search().password) { $scope.settings.password = $location.search().password;} - if($location.search().autoconnect) { $scope.settings.autoconnect = $location.search().autoconnect === 'true';} - + $scope.parseHash(); }; }]); weechat.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) { - $routeProvider.when('/', { + $routeProvider.when('', { templateUrl: 'index.html', controller: 'WeechatCtrl' }); @@ -997,7 +1011,7 @@ weechat.config(['$routeProvider', '$locationProvider', $locationProvider.html5Mode({ enabled: true, requireBase: false - }).hashPrefix(''); + }); } ]); From 0c45b402cfb31921ab366ada8a2216fb6e1f535d Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Fri, 20 Dec 2019 00:43:45 +0100 Subject: [PATCH 40/55] Update documentation for hash paramters --- index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 4ce8573..1c502a8 100644 --- a/index.html +++ b/index.html @@ -272,10 +272,10 @@ chown -R username:username ~usernameURL encoded.

- If we want just the path for example: https://glowing-bear.org/?path=weechat2 + If we want just the path for example: https://glowing-bear.org/#path=weechat2

- An example: https://glowing-bear.org/?host=my.domain.com&port=8000&password=hunter2&autoconnect=true + An example: https://glowing-bear.org/#host=my.domain.com&port=8000&password=hunter2&autoconnect=true

Available parameters: From 6dc8fab9dd9fb5dcb5828e40b2565aab46b57796 Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Fri, 20 Dec 2019 00:48:50 +0100 Subject: [PATCH 41/55] remove debug comment --- js/glowingbear.js | 1 - 1 file changed, 1 deletion(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index 27fd73e..1eccad5 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -989,7 +989,6 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', }; window.onhashchange = function() { - console.log('hash has changed'); $scope.parseHash(); }; From 47bcd8c5180dca58918e54798181018839d0f3f1 Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Fri, 20 Dec 2019 01:04:21 +0100 Subject: [PATCH 42/55] missing semi colon --- js/glowingbear.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index 1eccad5..d70f6dc 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -701,7 +701,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', $scope.parseHash = function() { //Fill in url parameters, they take precedence over the stored settings, but store them - var params = $location.$$hash.split('&').map(function(val) {return {key: val.split('=')[0], value: val.split('=')[1]}}); + var params = $location.$$hash.split('&').map(function(val) { return {key: val.split('=')[0], value: val.split('=')[1]}; }); var hostParam = params.find(function(p) { return p.key === 'host'; }); var portParam = params.find(function(p) { return p.key === 'port'; }); var pathParam = params.find(function(p) { return p.key === 'path'; }); From 85ef6d897fb0c9bbcc761381886681f9b0b7c570 Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Sat, 21 Dec 2019 00:18:06 +0100 Subject: [PATCH 43/55] Refactor and correct parseHash --- js/glowingbear.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index d70f6dc..be3ab09 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -701,17 +701,17 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', $scope.parseHash = function() { //Fill in url parameters, they take precedence over the stored settings, but store them - var params = $location.$$hash.split('&').map(function(val) { return {key: val.split('=')[0], value: val.split('=')[1]}; }); - var hostParam = params.find(function(p) { return p.key === 'host'; }); - var portParam = params.find(function(p) { return p.key === 'port'; }); - var pathParam = params.find(function(p) { return p.key === 'path'; }); - var passwordParam = params.find(function(p) { return p.key === 'password'; }); - var autoconnectParam = params.find(function(p) { return p.key === 'autoconnect'; }); - if(hostParam) { $scope.settings.host = hostParam.value; $scope.settings.hostField = hostParam.value;} - if(portParam) { $scope.settings.port = parseInt(portParam.value);} - if(pathParam) { $scope.settings.path = pathParam.value;} - if(passwordParam) { $scope.settings.password = passwordParam.value;} - if(autoconnectParam) { $scope.settings.autoconnect = autoconnectParam.value === 'true';} + var params = {}; + $location.$$hash.split('&').map(function(val) { + var segs = val.split('='); + params[segs[0]] = segs[1]; + }); + if(params.host) { $scope.settings.host = params.host; $scope.settings.hostField = params.host; } + if(params.port) { $scope.settings.port = parseInt(params.port); } + if(params.path) { $scope.settings.path = params.path; $scope.settings.hostField = $scope.settings.host + ":" + $scope.settings.port + "/" + $scope.settings.path; } + if(params.password) { $scope.password = params.password; } + if(params.autoconnect) { $scope.settings.autoconnect = params.autoconnect === 'true'; } + }; $scope.connect = function() { From f82d3484a631681b2ddf74c0cea0b9b74e944331 Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Sat, 21 Dec 2019 00:52:42 +0100 Subject: [PATCH 44/55] Show autoconnect checkbox if it's checked --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 1c502a8..f8ffbb5 100644 --- a/index.html +++ b/index.html @@ -144,7 +144,7 @@ Encryption. Strongly recommended! Need help? Check below. -

+