mirror of
https://github.com/turt2live/matrix-dimension.git
synced 2024-10-01 05:05:53 +00:00
rework etherpad wrapUrl() hack
This commit is contained in:
parent
6e342f1075
commit
2915f6df0a
@ -36,23 +36,21 @@ export class EtherpadWidgetConfigComponent extends WidgetComponent implements Mo
|
|||||||
}
|
}
|
||||||
|
|
||||||
getPadURL(widget?: Widget): string {
|
getPadURL(widget?: Widget): string {
|
||||||
|
let url: string;
|
||||||
if (widget) {
|
if (widget) {
|
||||||
if (this.editUseCustomServer) {
|
if (this.editUseCustomServer) {
|
||||||
const url = widget.data.newPadServer + this.roomId + "_" + widget.data.newPadName;
|
url = widget.data.newPadServer + this.roomId + "_" + widget.data.newPadName;
|
||||||
return url;
|
|
||||||
} else {
|
} else {
|
||||||
const url = "https://demo.riot.im/etherpad/p/" + this.roomId + "_" + widget.data.newPadName;
|
url = "https://demo.riot.im/etherpad/p/" + this.roomId + "_" + widget.data.newPadName;
|
||||||
return url;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.useCustomServer) {
|
if (this.useCustomServer) {
|
||||||
const url = this.newEtherpadServerUrl + this.roomId + "_" + this.newWidgetUrl;
|
url = this.newEtherpadServerUrl + this.roomId + "_" + this.newWidgetUrl;
|
||||||
return url;
|
|
||||||
} else {
|
} else {
|
||||||
const url = "https://demo.riot.im/etherpad/p/" + this.roomId + "_" + this.newWidgetUrl;
|
url = "https://demo.riot.im/etherpad/p/" + this.roomId + "_" + this.newWidgetUrl;
|
||||||
return url;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
private checkPadURL(url: string, widget?: Widget): boolean {
|
private checkPadURL(url: string, widget?: Widget): boolean {
|
||||||
@ -71,12 +69,8 @@ export class EtherpadWidgetConfigComponent extends WidgetComponent implements Mo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public wrapUrl(url: string): string {
|
|
||||||
return this.wrapperUrl + encodeURIComponent(url + "?userName=") + "$matrix_user_id";
|
|
||||||
}
|
|
||||||
|
|
||||||
public validateAndAddWidget() {
|
public validateAndAddWidget() {
|
||||||
const url = this.getPadURL();
|
const url = this.getPadURL() + "?userName=$matrix_user_id";
|
||||||
|
|
||||||
if (this.checkPadURL(url)) {
|
if (this.checkPadURL(url)) {
|
||||||
this.toaster.pop("warning", "Please enter a Pad Name");
|
this.toaster.pop("warning", "Please enter a Pad Name");
|
||||||
@ -94,7 +88,7 @@ export class EtherpadWidgetConfigComponent extends WidgetComponent implements Mo
|
|||||||
}
|
}
|
||||||
|
|
||||||
public validateAndSaveWidget(widget: Widget) {
|
public validateAndSaveWidget(widget: Widget) {
|
||||||
const url = this.getPadURL(widget);
|
const url = this.getPadURL(widget) + "?userName=$matrix_user_id";
|
||||||
|
|
||||||
if (this.checkPadURL(url, widget)) {
|
if (this.checkPadURL(url, widget)) {
|
||||||
this.toaster.pop("warning", "Please enter a Pad Name");
|
this.toaster.pop("warning", "Please enter a Pad Name");
|
||||||
|
@ -18,7 +18,7 @@ export class WidgetComponent {
|
|||||||
public newWidgetName: string = "";
|
public newWidgetName: string = "";
|
||||||
|
|
||||||
private toggledWidgetIds: string[] = [];
|
private toggledWidgetIds: string[] = [];
|
||||||
public wrapperUrl = "";
|
private wrapperUrl = "";
|
||||||
private scalarWrapperUrls: string[] = [];
|
private scalarWrapperUrls: string[] = [];
|
||||||
|
|
||||||
constructor(protected toaster: ToasterService,
|
constructor(protected toaster: ToasterService,
|
||||||
@ -87,8 +87,17 @@ export class WidgetComponent {
|
|||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public wrapUrl(url: string): string {
|
private wrapUrl(url: string): string {
|
||||||
return this.wrapperUrl + encodeURIComponent(url);
|
let encodedURL = this.wrapperUrl + encodeURIComponent(url);
|
||||||
|
|
||||||
|
//don't URL encode $vars of the widget Spec
|
||||||
|
//TODO do the same with vars from the data object
|
||||||
|
encodedURL = encodedURL.replace(encodeURIComponent("$matrix_user_id"), "$matrix_user_id");
|
||||||
|
encodedURL = encodedURL.replace(encodeURIComponent("$matrix_room_id"), "$matrix_room_id");
|
||||||
|
encodedURL = encodedURL.replace(encodeURIComponent("$matrix_display_name"), "$matrix_display_name");
|
||||||
|
encodedURL = encodedURL.replace(encodeURIComponent("$matrix_avatar_url"), "$matrix_avatar_url");
|
||||||
|
|
||||||
|
return encodedURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
private setWidgetUrl(widget: Widget) {
|
private setWidgetUrl(widget: Widget) {
|
||||||
|
Loading…
Reference in New Issue
Block a user