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 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)
+
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..e706815 100644
--- a/js/glowingbear.js
+++ b/js/glowingbear.js
@@ -41,8 +41,9 @@ 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:"),
'savepassword': false,
'autoconnect': false,
@@ -65,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.hostField && settings.host) {
+ settings.hostField = settings.host;
+ }
+
$rootScope.countWatchers = function () {
$log.debug($rootScope.$$watchersCount);
};
@@ -623,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
@@ -656,6 +664,35 @@ 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
+ $rootScope.hostInvalid = false;
+
+ var parts;
+ var regexHost = /^([^:\/]*|\[.*\])$/;
+ var regexHostPort = /^([^:]*|\[.*\]):(\d+)$/;
+ var regexHostPortPath = /^([^:]*|\[.*\]):(\d*)\/(.+)$/;
+
+ 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];
+ settings.port = parts[2];
+ settings.path = parts[3];
+ $rootScope.portDisabled = true;
+ } else {
+ $rootScope.hostInvalid = true;
+ }
+ };
$scope.connect = function() {
notifications.requestNotificationPermission();
@@ -665,14 +702,16 @@ 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';
$scope.connectbuttonicon = 'glyphicon-chevron-right';
bufferResume.reset();
connection.disconnect();
};
+
$scope.reconnect = function() {
var bufferId = models.getActiveBuffer().id;
connection.attemptReconnect(bufferId, 3000);
@@ -681,6 +720,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;
@@ -927,12 +967,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]);
+ settings.host = spl[0];
+ settings.port = parseInt(spl[1]);
var password = spl[2];
var ssl = spl.length > 3;
notifications.requestNotificationPermission();
@@ -942,7 +983,8 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
$rootScope.bufferBottom = true;
$scope.connectbutton = 'Connecting';
$scope.connectbuttonicon = 'glyphicon-chevron-right';
- connection.connect(host, port, password, ssl);
+ $scope.parseHost();
+ connection.connect(settings.host, settings.port, settings.path, password, ssl);
}
};