Remove separate file converse-http-file-upload
It contained only `overrides` and some HTTP upload code was in other modules. Current thinking concerning overrides: Usage of `overrides`, while useful in certain cases, should in general be discouraged, since it's in essence "monkey patching" which makes it more difficult to know whats executing at runtime and more difficult to refactor. Splitting modules up between XEPs is not always that useful. Some XEPs, like HTTP Upload (and MAM comes to mind) have their functionality spread out over single and group chats (and pubsub) and might for practical purposes be considered "core" enough to not try and keep them in separate modules (which inevitably requires overrides or a fundamentally rethinking the architecture). Where splitting code between modules makes a lot of sense is in keeping Backbone Models and Views separate (so that alternative view libraries like Vue could be used) and probably in keeping Single chats, MUC, PubSub and MIX separate. updates #161
This commit is contained in:
parent
de6ecbf07a
commit
dad8eb2f48
@ -75,7 +75,6 @@ require.config({
|
|||||||
"converse-dragresize": "src/converse-dragresize",
|
"converse-dragresize": "src/converse-dragresize",
|
||||||
"converse-fullscreen": "src/converse-fullscreen",
|
"converse-fullscreen": "src/converse-fullscreen",
|
||||||
"converse-headline": "src/converse-headline",
|
"converse-headline": "src/converse-headline",
|
||||||
"converse-http-file-upload":"src/converse-http-file-upload",
|
|
||||||
"converse-mam": "src/converse-mam",
|
"converse-mam": "src/converse-mam",
|
||||||
"converse-message-view": "src/converse-message-view",
|
"converse-message-view": "src/converse-message-view",
|
||||||
"converse-minimize": "src/converse-minimize",
|
"converse-minimize": "src/converse-minimize",
|
||||||
|
@ -20,11 +20,11 @@
|
|||||||
"tpl!help_message",
|
"tpl!help_message",
|
||||||
"tpl!info",
|
"tpl!info",
|
||||||
"tpl!new_day",
|
"tpl!new_day",
|
||||||
|
"tpl!toolbar_fileupload",
|
||||||
"tpl!spinner",
|
"tpl!spinner",
|
||||||
"tpl!spoiler_button",
|
"tpl!spoiler_button",
|
||||||
"tpl!status_message",
|
"tpl!status_message",
|
||||||
"tpl!toolbar",
|
"tpl!toolbar",
|
||||||
"converse-http-file-upload",
|
|
||||||
"converse-chatboxes",
|
"converse-chatboxes",
|
||||||
"converse-message-view"
|
"converse-message-view"
|
||||||
], factory);
|
], factory);
|
||||||
@ -43,6 +43,7 @@
|
|||||||
tpl_help_message,
|
tpl_help_message,
|
||||||
tpl_info,
|
tpl_info,
|
||||||
tpl_new_day,
|
tpl_new_day,
|
||||||
|
tpl_toolbar_fileupload,
|
||||||
tpl_spinner,
|
tpl_spinner,
|
||||||
tpl_spoiler_button,
|
tpl_spoiler_button,
|
||||||
tpl_status_message,
|
tpl_status_message,
|
||||||
@ -240,15 +241,17 @@
|
|||||||
is_chatroom: false, // Leaky abstraction from MUC
|
is_chatroom: false, // Leaky abstraction from MUC
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
|
'change input.fileupload': 'onFileSelection',
|
||||||
'click .close-chatbox-button': 'close',
|
'click .close-chatbox-button': 'close',
|
||||||
'click .new-msgs-indicator': 'viewUnreadMessages',
|
'click .new-msgs-indicator': 'viewUnreadMessages',
|
||||||
'click .send-button': 'onFormSubmitted',
|
'click .send-button': 'onFormSubmitted',
|
||||||
'click .toggle-call': 'toggleCall',
|
'click .toggle-call': 'toggleCall',
|
||||||
'click .toggle-clear': 'clearMessages',
|
'click .toggle-clear': 'clearMessages',
|
||||||
|
'click .toggle-compose-spoiler': 'toggleComposeSpoilerMessage',
|
||||||
'click .toggle-smiley ul.emoji-picker li': 'insertEmoji',
|
'click .toggle-smiley ul.emoji-picker li': 'insertEmoji',
|
||||||
'click .toggle-smiley': 'toggleEmojiMenu',
|
'click .toggle-smiley': 'toggleEmojiMenu',
|
||||||
'click .toggle-spoiler': 'toggleSpoilerMessage',
|
'click .toggle-spoiler': 'toggleSpoilerMessage',
|
||||||
'click .toggle-compose-spoiler': 'toggleComposeSpoilerMessage',
|
'click .upload-file': 'toggleFileUpload',
|
||||||
'keypress .chat-textarea': 'keyPressed'
|
'keypress .chat-textarea': 'keyPressed'
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -296,6 +299,7 @@
|
|||||||
);
|
);
|
||||||
this.el.querySelector('.chat-toolbar').innerHTML = toolbar(options);
|
this.el.querySelector('.chat-toolbar').innerHTML = toolbar(options);
|
||||||
this.addSpoilerButton(options);
|
this.addSpoilerButton(options);
|
||||||
|
this.addFileUploadButton();
|
||||||
this.insertEmojiPicker();
|
this.insertEmojiPicker();
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
@ -322,6 +326,22 @@
|
|||||||
this.renderToolbar();
|
this.renderToolbar();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
toggleFileUpload (ev) {
|
||||||
|
this.el.querySelector('input.fileupload').click();
|
||||||
|
},
|
||||||
|
|
||||||
|
onFileSelection (evt) {
|
||||||
|
this.model.sendFiles(evt.target.files);
|
||||||
|
},
|
||||||
|
|
||||||
|
addFileUploadButton (options) {
|
||||||
|
_converse.api.disco.supports(Strophe.NS.HTTPUPLOAD, _converse.domain).then((result) => {
|
||||||
|
this.el.querySelector('.chat-toolbar').insertAdjacentHTML(
|
||||||
|
'beforeend',
|
||||||
|
tpl_toolbar_fileupload({'tooltip_upload_file': __('Choose a file to send')}));
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
addSpoilerButton (options) {
|
addSpoilerButton (options) {
|
||||||
/* Asynchronously adds a button for writing spoiler
|
/* Asynchronously adds a button for writing spoiler
|
||||||
* messages, based on whether the contact's client supports
|
* messages, based on whether the contact's client supports
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
Strophe.addNamespace('DELAY', 'urn:xmpp:delay');
|
Strophe.addNamespace('DELAY', 'urn:xmpp:delay');
|
||||||
Strophe.addNamespace('FORWARD', 'urn:xmpp:forward:0');
|
Strophe.addNamespace('FORWARD', 'urn:xmpp:forward:0');
|
||||||
Strophe.addNamespace('HINTS', 'urn:xmpp:hints');
|
Strophe.addNamespace('HINTS', 'urn:xmpp:hints');
|
||||||
|
Strophe.addNamespace('HTTPUPLOAD', 'urn:xmpp:http:upload:0');
|
||||||
Strophe.addNamespace('MAM', 'urn:xmpp:mam:2');
|
Strophe.addNamespace('MAM', 'urn:xmpp:mam:2');
|
||||||
Strophe.addNamespace('NICK', 'http://jabber.org/protocol/nick');
|
Strophe.addNamespace('NICK', 'http://jabber.org/protocol/nick');
|
||||||
Strophe.addNamespace('PUBSUB', 'http://jabber.org/protocol/pubsub');
|
Strophe.addNamespace('PUBSUB', 'http://jabber.org/protocol/pubsub');
|
||||||
|
@ -1,74 +0,0 @@
|
|||||||
/**
|
|
||||||
* Adds Support for Http File Upload (XEP-0363)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
(function (root, factory) {
|
|
||||||
define([
|
|
||||||
"converse-core",
|
|
||||||
"tpl!toolbar_fileupload"
|
|
||||||
], factory);
|
|
||||||
}(this, function (converse, tpl_toolbar_fileupload) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
const { Promise, Strophe, _ } = converse.env;
|
|
||||||
const u = converse.env.utils;
|
|
||||||
|
|
||||||
Strophe.addNamespace('HTTPUPLOAD', 'urn:xmpp:http:upload:0');
|
|
||||||
|
|
||||||
converse.plugins.add('converse-http-file-upload', {
|
|
||||||
/* Plugin dependencies are other plugins which might be
|
|
||||||
* overridden or relied upon, and therefore need to be loaded before
|
|
||||||
* this plugin.
|
|
||||||
*
|
|
||||||
* If the setting "strict_plugin_dependencies" is set to true,
|
|
||||||
* an error will be raised if the plugin is not found. By default it's
|
|
||||||
* false, which means these plugins are only loaded opportunistically.
|
|
||||||
*
|
|
||||||
* NB: These plugins need to have already been loaded via require.js.
|
|
||||||
*/
|
|
||||||
dependencies: ["converse-chatboxes", "converse-chatview", "converse-muc-views"],
|
|
||||||
|
|
||||||
overrides: {
|
|
||||||
ChatBoxView: {
|
|
||||||
events: {
|
|
||||||
'click .upload-file': 'toggleFileUpload',
|
|
||||||
'change input.fileupload': 'onFileSelection'
|
|
||||||
},
|
|
||||||
|
|
||||||
toggleFileUpload (ev) {
|
|
||||||
this.el.querySelector('input.fileupload').click();
|
|
||||||
},
|
|
||||||
|
|
||||||
onFileSelection (evt) {
|
|
||||||
this.model.sendFiles(evt.target.files);
|
|
||||||
},
|
|
||||||
|
|
||||||
addFileUploadButton (options) {
|
|
||||||
const { __ } = this.__super__._converse;
|
|
||||||
this.el.querySelector('.chat-toolbar').insertAdjacentHTML(
|
|
||||||
'beforeend',
|
|
||||||
tpl_toolbar_fileupload({'tooltip_upload_file': __('Choose a file to send')}));
|
|
||||||
},
|
|
||||||
|
|
||||||
renderToolbar (toolbar, options) {
|
|
||||||
const { _converse } = this.__super__;
|
|
||||||
const result = this.__super__.renderToolbar.apply(this, arguments);
|
|
||||||
_converse.api.disco.supports(Strophe.NS.HTTPUPLOAD, _converse.domain).then((result) => {
|
|
||||||
if (result.length) {
|
|
||||||
this.addFileUploadButton();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
ChatRoomView: {
|
|
||||||
events: {
|
|
||||||
'click .upload-file': 'toggleFileUpload',
|
|
||||||
'change .input.fileupload': 'onFileSelection'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return converse;
|
|
||||||
}));
|
|
@ -3,7 +3,7 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2012-2018, the Converse.js developers
|
// Copyright (c) 2012-2018, the Converse.js developers
|
||||||
// Licensed under the Mozilla Public License (MPLv2)
|
// Licensed under the Mozilla Public License (MPLv2)
|
||||||
//
|
|
||||||
(function (root, factory) {
|
(function (root, factory) {
|
||||||
define([
|
define([
|
||||||
"converse-core",
|
"converse-core",
|
||||||
|
@ -497,17 +497,19 @@
|
|||||||
className: 'chatbox chatroom hidden',
|
className: 'chatbox chatroom hidden',
|
||||||
is_chatroom: true,
|
is_chatroom: true,
|
||||||
events: {
|
events: {
|
||||||
|
'change .input.fileupload': 'onFileSelection',
|
||||||
'click .close-chatbox-button': 'close',
|
'click .close-chatbox-button': 'close',
|
||||||
'click .configure-chatroom-button': 'getAndRenderConfigurationForm',
|
'click .configure-chatroom-button': 'getAndRenderConfigurationForm',
|
||||||
'click .toggle-smiley': 'toggleEmojiMenu',
|
|
||||||
'click .toggle-smiley ul.emoji-picker li': 'insertEmoji',
|
|
||||||
'click .toggle-clear': 'clearChatRoomMessages',
|
|
||||||
'click .toggle-call': 'toggleCall',
|
|
||||||
'click .toggle-occupants': 'toggleOccupants',
|
|
||||||
'click .new-msgs-indicator': 'viewUnreadMessages',
|
'click .new-msgs-indicator': 'viewUnreadMessages',
|
||||||
'click .occupant': 'onOccupantClicked',
|
'click .occupant': 'onOccupantClicked',
|
||||||
'keypress .chat-textarea': 'keyPressed',
|
'click .send-button': 'onFormSubmitted',
|
||||||
'click .send-button': 'onFormSubmitted'
|
'click .toggle-call': 'toggleCall',
|
||||||
|
'click .toggle-clear': 'clearChatRoomMessages',
|
||||||
|
'click .toggle-occupants': 'toggleOccupants',
|
||||||
|
'click .toggle-smiley ul.emoji-picker li': 'insertEmoji',
|
||||||
|
'click .toggle-smiley': 'toggleEmojiMenu',
|
||||||
|
'click .upload-file': 'toggleFileUpload',
|
||||||
|
'keypress .chat-textarea': 'keyPressed'
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize () {
|
initialize () {
|
||||||
|
@ -10,7 +10,8 @@
|
|||||||
* encryption of one-on-one chat messages.
|
* encryption of one-on-one chat messages.
|
||||||
*/
|
*/
|
||||||
(function (root, factory) {
|
(function (root, factory) {
|
||||||
define([ "converse-chatview",
|
define([
|
||||||
|
"converse-chatview",
|
||||||
"bootstrap",
|
"bootstrap",
|
||||||
"tpl!toolbar_otr",
|
"tpl!toolbar_otr",
|
||||||
'otr'
|
'otr'
|
||||||
|
@ -13,7 +13,6 @@ if (typeof define !== 'undefined') {
|
|||||||
"converse-dragresize", // Allows chat boxes to be resized by dragging them
|
"converse-dragresize", // Allows chat boxes to be resized by dragging them
|
||||||
"converse-fullscreen",
|
"converse-fullscreen",
|
||||||
"converse-headline", // Support for headline messages
|
"converse-headline", // Support for headline messages
|
||||||
"converse-http-file-upload",// Support for XEP-0363
|
|
||||||
"converse-mam", // XEP-0313 Message Archive Management
|
"converse-mam", // XEP-0313 Message Archive Management
|
||||||
"converse-minimize", // Allows chat boxes to be minimized
|
"converse-minimize", // Allows chat boxes to be minimized
|
||||||
"converse-muc", // XEP-0045 Multi-user chat
|
"converse-muc", // XEP-0045 Multi-user chat
|
||||||
|
Loading…
Reference in New Issue
Block a user