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)
@@ -123,18 +123,26 @@
Save password in your browser
+
+
+
-
+ One time password
+
@@ -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.
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 @@
- 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.
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)
+
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
+
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 ~username
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
+ 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.
-