diff --git a/css/glowingbear.css b/css/glowingbear.css index 700e26d..312ef04 100644 --- a/css/glowingbear.css +++ b/css/glowingbear.css @@ -146,7 +146,7 @@ input[type=text], input[type=password], #sendMessage { .col-sm-9 { padding-right: 5px !important; } -.glyphicon { +#topbar .glyphicon { top: 0; /* Fixes alignment issue in top bar */ } #topbar { @@ -681,6 +681,10 @@ li.buffer.indent.private a { font-size: small; } +.lessleftpad { + padding-left: 5px; +} + .unselectable { -webkit-user-select: none; -moz-user-select: none; @@ -931,4 +935,4 @@ code { padding: 0px 2px; color: #444; border: 1pt solid #444; -} \ No newline at end of file +} diff --git a/index.html b/index.html index f8ffbb5..4ae19fd 100644 --- a/index.html +++ b/index.html @@ -100,7 +100,6 @@
-
@@ -458,7 +457,7 @@ npm run build-electron-{windows, darwin, linux}
-
+
@@ -468,7 +467,7 @@ npm run build-electron-{windows, darwin, linux}
-
+
@@ -479,13 +478,28 @@ npm run build-electron-{windows, darwin, linux}
-
+
+
  • +
    +
    + +
    + +
    + +
    + +
    +
    +
    +
  • +
  • diff --git a/js/glowingbear.js b/js/glowingbear.js index 4b11a09..04519bb 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -64,6 +64,8 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', 'enableQuickKeys': true, 'customCSS': '', "currentlyViewedBuffers":{}, + 'iToken': '', + 'iAlb': '', }); $scope.settings = settings; diff --git a/js/imgur.js b/js/imgur.js index fdcacf6..0ec0f97 100644 --- a/js/imgur.js +++ b/js/imgur.js @@ -3,7 +3,7 @@ var weechat = angular.module('weechat'); -weechat.factory('imgur', ['$rootScope', function($rootScope) { +weechat.factory('imgur', ['$rootScope', 'settings', function($rootScope, settings) { var process = function(image, callback) { @@ -26,8 +26,18 @@ weechat.factory('imgur', ['$rootScope', function($rootScope) { // Upload image to imgur from base64 var upload = function( base64img, callback ) { - // Set client ID (Glowing Bear) - var clientId = "164efef8979cd4b"; + + // API authorization, either via Client ID (anonymous) or access token + // (add to user's imgur account), see also: + // https://github.com/glowing-bear/glowing-bear/wiki/Getting-an-imgur-token-&-album-hash + var accessToken = "164efef8979cd4b"; + var isClientID = true; + + // Check whether the user has provided an access token + if (settings.iToken.length > 37){ + accessToken = settings.iToken; + isClientID = false; + } // Progress bars container var progressBars = document.getElementById("imgur-upload-progress"), @@ -45,6 +55,11 @@ weechat.factory('imgur', ['$rootScope', function($rootScope) { fd.append("image", base64img); // Append the file fd.append("type", "base64"); // Set image type to base64 + // Add the image to the provided album if configured to do so + if (!isClientID && settings.iAlb.length >= 6) { + fd.append("album", settings.iAlb); + } + // Create new XMLHttpRequest var xhttp = new XMLHttpRequest(); @@ -52,7 +67,11 @@ weechat.factory('imgur', ['$rootScope', function($rootScope) { xhttp.open("POST", "https://api.imgur.com/3/image", true); // Set headers - xhttp.setRequestHeader("Authorization", "Client-ID " + clientId); + if (isClientID) { + xhttp.setRequestHeader("Authorization", "Client-ID " + accessToken); + } else { + xhttp.setRequestHeader("Authorization", "Bearer " + accessToken); + } xhttp.setRequestHeader("Accept", "application/json"); // Handler for response