From a7ddcc9c0fc3c4723c23618316955f1b3941ad70 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sat, 15 Nov 2014 01:29:15 +0000 Subject: [PATCH 1/8] do not use captcha by default --- syweb/webclient/login/register-controller.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/syweb/webclient/login/register-controller.js b/syweb/webclient/login/register-controller.js index b23a72b18..ec48def48 100644 --- a/syweb/webclient/login/register-controller.js +++ b/syweb/webclient/login/register-controller.js @@ -20,7 +20,7 @@ angular.module('RegisterController', ['matrixService']) 'use strict'; var config = window.webClientConfig; - var useCaptcha = true; + var useCaptcha = false; // default to no captcha to make it easier to get a homeserver up and running... if (config !== undefined) { useCaptcha = config.useCaptcha; } @@ -167,16 +167,10 @@ angular.module('RegisterController', ['matrixService']) var setupCaptcha = function() { console.log("Setting up ReCaptcha") - var config = window.webClientConfig; - var public_key = undefined; - if (config === undefined) { - console.error("Couldn't find webClientConfig. Cannot get public key for captcha."); - } - else { - public_key = webClientConfig.recaptcha_public_key; - if (public_key === undefined) { - console.error("No public key defined for captcha!") - } + var public_key = window.webClientConfig.recaptcha_public_key; + if (public_key === undefined) { + console.error("No public key defined for captcha!") + return; } Recaptcha.create(public_key, "regcaptcha", From 1f70929e53649a24f4cf4093f0fbad99a053c78d Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sat, 15 Nov 2014 01:29:34 +0000 Subject: [PATCH 2/8] spell useCaptcha right... --- syweb/webclient/test/unit/register-controller.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syweb/webclient/test/unit/register-controller.spec.js b/syweb/webclient/test/unit/register-controller.spec.js index b5c784235..62d7a4aa3 100644 --- a/syweb/webclient/test/unit/register-controller.spec.js +++ b/syweb/webclient/test/unit/register-controller.spec.js @@ -5,7 +5,7 @@ describe("RegisterController ", function() { var avatarUrl = "avatar.url"; window.webClientConfig = { - useCapatcha: false + useCaptcha: false }; // test vars From 921d95357d141bbd15111cac5a831835d8dbb4c6 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sat, 15 Nov 2014 01:30:02 +0000 Subject: [PATCH 3/8] improve notif setting text --- syweb/webclient/settings/settings.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syweb/webclient/settings/settings.html b/syweb/webclient/settings/settings.html index 094c846f8..4c20634a7 100644 --- a/syweb/webclient/settings/settings.html +++ b/syweb/webclient/settings/settings.html @@ -54,7 +54,7 @@ Notifications are enabled.

Specific words to alert on:

-

Leave blank to alert on all messages. Your username & display name always alerts.

+

If blank, all messages will trigger an alert. Your username & display name always alerts.

    From adf582dba785f0f40fc68d7b1f079fabd210cabe Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sat, 15 Nov 2014 01:34:33 +0000 Subject: [PATCH 4/8] merge in msg.__room_member usage to new message display template --- synctl | 1 + syweb/webclient/app.css | 4 +- .../fileInput/file-input-directive.js | 3 +- .../fileUpload/file-upload-service.js | 222 ++++++++++-------- syweb/webclient/recents/recents.html | 2 +- syweb/webclient/room/room-controller.js | 23 +- syweb/webclient/room/room.html | 58 +++-- 7 files changed, 180 insertions(+), 133 deletions(-) create mode 120000 synctl diff --git a/synctl b/synctl new file mode 120000 index 000000000..1bdceda20 --- /dev/null +++ b/synctl @@ -0,0 +1 @@ +./synapse/app/synctl.py \ No newline at end of file diff --git a/syweb/webclient/app.css b/syweb/webclient/app.css index 25f7208a1..1264ac787 100755 --- a/syweb/webclient/app.css +++ b/syweb/webclient/app.css @@ -699,7 +699,7 @@ textarea, input { vertical-align: middle; */ display: inline-block; - max-width: 90%; + max-width: 80%; padding-left: 1em; padding-right: 1em; padding-top: 2px; @@ -721,6 +721,7 @@ textarea, input { text-align: right; } +/* .text.emote .bubble, .text.membership .bubble, .mine .text.emote .bubble, @@ -729,6 +730,7 @@ textarea, input { background-color: transparent ! important; border: 0px ! important; } +*/ .mine .text .bubble { /* diff --git a/syweb/webclient/components/fileInput/file-input-directive.js b/syweb/webclient/components/fileInput/file-input-directive.js index 9c849a140..e530c0608 100644 --- a/syweb/webclient/components/fileInput/file-input-directive.js +++ b/syweb/webclient/components/fileInput/file-input-directive.js @@ -25,7 +25,8 @@ angular.module('mFileInput', []) return { restrict: 'A', transclude: 'true', - template: '
    ', + // FIXME: add back in accept="image/*" when needed - e.g. for avatars + template: '
    ', scope: { selectedFile: '=mFileInput' }, diff --git a/syweb/webclient/components/fileUpload/file-upload-service.js b/syweb/webclient/components/fileUpload/file-upload-service.js index b544e2950..28e3f0ff5 100644 --- a/syweb/webclient/components/fileUpload/file-upload-service.js +++ b/syweb/webclient/components/fileUpload/file-upload-service.js @@ -47,30 +47,31 @@ angular.module('mFileUpload', ['matrixService', 'mUtilities']) }; /* - * Upload an image file plus generate a thumbnail of it and upload it so that + * Upload an filmessagee plus generate a thumbnail of it (if possible) and upload it so that * we will have all information to fulfill an image message request data. - * @param {File} imageFile the imageFile to send + * @param {File} file the file to send * @param {Integer} thumbnailSize the max side size of the thumbnail to create * @returns {promise} A promise that will be resolved by a image message object * ready to be send with the Matrix API */ - this.uploadImageAndThumbnail = function(imageFile, thumbnailSize) { + this.uploadFileAndThumbnail = function(file, thumbnailSize) { var self = this; var deferred = $q.defer(); - console.log("uploadImageAndThumbnail " + imageFile.name + " - thumbnailSize: " + thumbnailSize); + console.log("uploadFileAndThumbnail " + file.name + " - thumbnailSize: " + thumbnailSize); - // The message structure that will be returned in the promise - var imageMessage = { + // The message structure that will be returned in the promise will look something like: + var message = { +/* msgtype: "m.image", url: undefined, body: "Image", info: { size: undefined, - w: undefined, - h: undefined, + w: undefined, + h: undefined, mimetype: undefined - }, + }, thumbnail_url: undefined, thumbnail_info: { size: undefined, @@ -78,101 +79,128 @@ angular.module('mFileUpload', ['matrixService', 'mUtilities']) h: undefined, mimetype: undefined } +*/ }; - // First, get the image size - mUtilities.getImageSize(imageFile).then( - function(size) { - console.log("image size: " + JSON.stringify(size)); + if (file.type.indexOf("image/") === 0) { + // it's an image - try to do clientside thumbnailing. + mUtilities.getImageSize(file).then( + function(size) { + console.log("image size: " + JSON.stringify(size)); - // The final operation: send imageFile - var uploadImage = function() { - self.uploadFile(imageFile).then( - function(url) { - // Update message metadata - imageMessage.url = url; - imageMessage.info = { - size: imageFile.size, - w: size.width, - h: size.height, - mimetype: imageFile.type - }; + // The final operation: send file + var uploadImage = function() { + self.uploadFile(file).then( + function(url) { + // Update message metadata + message.url = url; + message.msgtype = "m.image"; + message.body = file.name; + message.info = { + size: file.size, + w: size.width, + h: size.height, + mimetype: file.type + }; - // If there is no thumbnail (because the original image is smaller than thumbnailSize), - // reuse the original image info for thumbnail data - if (!imageMessage.thumbnail_url) { - imageMessage.thumbnail_url = imageMessage.url; - imageMessage.thumbnail_info = imageMessage.info; - } - - // We are done - deferred.resolve(imageMessage); - }, - function(error) { - console.log(" -> Can't upload image"); - deferred.reject(error); - } - ); - }; - - // Create a thumbnail if the image size exceeds thumbnailSize - if (Math.max(size.width, size.height) > thumbnailSize) { - console.log(" Creating thumbnail..."); - mUtilities.resizeImage(imageFile, thumbnailSize).then( - function(thumbnailBlob) { - - // Get its size - mUtilities.getImageSize(thumbnailBlob).then( - function(thumbnailSize) { - console.log(" -> Thumbnail size: " + JSON.stringify(thumbnailSize)); - - // Upload it to the server - self.uploadFile(thumbnailBlob).then( - function(thumbnailUrl) { - - // Update image message data - imageMessage.thumbnail_url = thumbnailUrl; - imageMessage.thumbnail_info = { - size: thumbnailBlob.size, - w: thumbnailSize.width, - h: thumbnailSize.height, - mimetype: thumbnailBlob.type - }; - - // Then, upload the original image - uploadImage(); - }, - function(error) { - console.log(" -> Can't upload thumbnail"); - deferred.reject(error); - } - ); - }, - function(error) { - console.log(" -> Failed to get thumbnail size"); - deferred.reject(error); + // If there is no thumbnail (because the original image is smaller than thumbnailSize), + // reuse the original image info for thumbnail data + if (!message.thumbnail_url) { + message.thumbnail_url = message.url; + message.thumbnail_info = message.info; } - ); - }, - function(error) { - console.log(" -> Failed to create thumbnail: " + error); - deferred.reject(error); - } - ); - } - else { - // No need of thumbnail - console.log(" Thumbnail is not required"); - uploadImage(); - } + // We are done + deferred.resolve(message); + }, + function(error) { + console.log(" -> Can't upload image"); + deferred.reject(error); + } + ); + }; - }, - function(error) { - console.log(" -> Failed to get image size"); - deferred.reject(error); - } - ); + // Create a thumbnail if the image size exceeds thumbnailSize + if (Math.max(size.width, size.height) > thumbnailSize) { + console.log(" Creating thumbnail..."); + mUtilities.resizeImage(file, thumbnailSize).then( + function(thumbnailBlob) { + + // Get its size + mUtilities.getImageSize(thumbnailBlob).then( + function(thumbnailSize) { + console.log(" -> Thumbnail size: " + JSON.stringify(thumbnailSize)); + + // Upload it to the server + self.uploadFile(thumbnailBlob).then( + function(thumbnailUrl) { + + // Update image message data + message.thumbnail_url = thumbnailUrl; + message.thumbnail_info = { + size: thumbnailBlob.size, + w: thumbnailSize.width, + h: thumbnailSize.height, + mimetype: thumbnailBlob.type + }; + + // Then, upload the original image + uploadImage(); + }, + function(error) { + console.log(" -> Can't upload thumbnail"); + deferred.reject(error); + } + ); + }, + function(error) { + console.log(" -> Failed to get thumbnail size"); + deferred.reject(error); + } + ); + + }, + function(error) { + console.log(" -> Failed to create thumbnail: " + error); + deferred.reject(error); + } + ); + } + else { + // No need of thumbnail + console.log(" Thumbnail is not required"); + uploadImage(); + } + + }, + function(error) { + console.log(" -> Failed to get image size"); + deferred.reject(error); + } + ); + } + else { + // it's a random file - just upload it. + self.uploadFile(file).then( + function(url) { + // Update message metadata + message.url = url; + message.msgtype = "m.file"; + message.body = file.name; + message.info = { + size: file.size, + mimetype: file.type + }; + + // We are done + deferred.resolve(message); + }, + function(error) { + console.log(" -> Can't upload file"); + deferred.reject(error); + } + ); + } return deferred.promise; }; diff --git a/syweb/webclient/recents/recents.html b/syweb/webclient/recents/recents.html index 0b3a77ca1..600e1f9c1 100644 --- a/syweb/webclient/recents/recents.html +++ b/syweb/webclient/recents/recents.html @@ -84,7 +84,7 @@
- {{ lastMsg.content }} + {{ lastMsg.content.body | linky:'_blank' }}
diff --git a/syweb/webclient/room/room-controller.js b/syweb/webclient/room/room-controller.js index cf9bc1fcd..fdd10d7c9 100644 --- a/syweb/webclient/room/room-controller.js +++ b/syweb/webclient/room/room-controller.js @@ -495,6 +495,7 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput', 'a }); }; + // used to send an image based on just a URL, rather than uploading one $scope.sendImage = function(url, body) { scrollToBottom(true); @@ -507,23 +508,23 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput', 'a }); }; - $scope.imageFileToSend; - $scope.$watch("imageFileToSend", function(newValue, oldValue) { - if ($scope.imageFileToSend) { - // Upload this image with its thumbnail to Internet - mFileUpload.uploadImageAndThumbnail($scope.imageFileToSend, THUMBNAIL_SIZE).then( - function(imageMessage) { - // imageMessage is complete message structure, send it as is - matrixService.sendMessage($scope.room_id, undefined, imageMessage).then( + $scope.fileToSend; + $scope.$watch("fileToSend", function(newValue, oldValue) { + if ($scope.fileToSend) { + // Upload this file + mFileUpload.uploadFileAndThumbnail($scope.fileToSend, THUMBNAIL_SIZE).then( + function(fileMessage) { + // fileMessage is complete message structure, send it as is + matrixService.sendMessage($scope.room_id, undefined, fileMessage).then( function() { - console.log("Image message sent"); + console.log("File message sent"); }, function(error) { - $scope.feedback = "Failed to send image message: " + error.data.error; + $scope.feedback = "Failed to send file message: " + error.data.error; }); }, function(error) { - $scope.feedback = "Can't upload image"; + $scope.feedback = "Can't upload file"; } ); } diff --git a/syweb/webclient/room/room.html b/syweb/webclient/room/room.html index 955f5ff11..8baf9eda7 100644 --- a/syweb/webclient/room/room.html +++ b/syweb/webclient/room/room.html @@ -198,31 +198,45 @@ {{ msg.user_id }} changed their display name from {{ msg.prev_content.displayname }} to {{ msg.content.displayname }} - - - + + + + + +
+
+ +
+
+ +
+
+ + + {{ msg.content.body }} +
+ + + +
+
+ + + Outgoing Call{{ isWebRTCSupported() ? '' : ' (But your browser does not support VoIP)' }} Incoming Call{{ isWebRTCSupported() ? '' : ' (But your browser does not support VoIP)' }} -
-
- -
-
- -
-
- {{ msg.__room_member.cnt.displayname || msg.user_id }} changed the topic to: {{ msg.content.topic }} @@ -250,7 +264,7 @@
- +