mirror of
https://github.com/turt2live/matrix-dimension.git
synced 2024-10-01 05:05:53 +00:00
Unpack Etherpad widgets from scalar correctly
Fixes https://github.com/turt2live/matrix-dimension/issues/142
This commit is contained in:
parent
f10abf95e5
commit
4e414d8236
@ -4,6 +4,7 @@ import { Component } from "@angular/core";
|
||||
import { FE_EtherpadWidget } from "../../../shared/models/integration";
|
||||
import { SessionStorage } from "../../../shared/SessionStorage";
|
||||
import { NameService } from "../../../shared/services/name.service";
|
||||
import * as url from "url";
|
||||
|
||||
@Component({
|
||||
templateUrl: "etherpad.widget.component.html",
|
||||
@ -14,7 +15,20 @@ export class EtherpadWidgetConfigComponent extends WidgetComponent {
|
||||
private etherpadWidget: FE_EtherpadWidget = <FE_EtherpadWidget>SessionStorage.editIntegration;
|
||||
|
||||
constructor(private nameService: NameService) {
|
||||
super(WIDGET_ETHERPAD, "Etherpad", "generic", "etherpad");
|
||||
super(WIDGET_ETHERPAD, "Etherpad", "generic", "etherpad", "padName");
|
||||
}
|
||||
|
||||
protected OnWidgetsDiscovered(widgets: EditableWidget[]): void {
|
||||
console.log(widgets);
|
||||
for (const widget of widgets) {
|
||||
if (!widget.dimension.newUrl.startsWith("http://") && !widget.dimension.newUrl.startsWith("https://")) {
|
||||
const parsedUrl = url.parse(widget.url, true);
|
||||
const padName = parsedUrl.query["padName"];
|
||||
|
||||
// Set the new URL so that it unpacks correctly
|
||||
widget.url = `https://demo.riot.im/etherpad/p/${padName}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected OnNewWidgetPrepared(widget: EditableWidget): void {
|
||||
|
@ -6,10 +6,10 @@ import { SessionStorage } from "../../shared/SessionStorage";
|
||||
import { OnInit } from "@angular/core";
|
||||
|
||||
const SCALAR_WIDGET_LINKS = [
|
||||
"https://scalar-staging.riot.im/scalar/api/widgets/__TYPE__.html?url=",
|
||||
"https://scalar-staging.vector.im/scalar/api/widgets/__TYPE__.html?url=",
|
||||
"https://scalar-develop.riot.im/scalar/api/widgets/__TYPE__.html?url=",
|
||||
"https://demo.riot.im/scalar/api/widgets/__TYPE__.html?url=",
|
||||
"https://scalar-staging.riot.im/scalar/api/widgets/__TYPE__.html?__PNAME__=",
|
||||
"https://scalar-staging.vector.im/scalar/api/widgets/__TYPE__.html?__PNAME__=",
|
||||
"https://scalar-develop.riot.im/scalar/api/widgets/__TYPE__.html?__PNAME__=",
|
||||
"https://demo.riot.im/scalar/api/widgets/__TYPE__.html?__PNAME__=",
|
||||
];
|
||||
|
||||
export const DISABLE_AUTOMATIC_WRAPPING = "";
|
||||
@ -32,7 +32,8 @@ export class WidgetComponent implements OnInit {
|
||||
constructor(private widgetTypes: string[],
|
||||
public defaultName: string,
|
||||
private wrapperId = "generic",
|
||||
private scalarWrapperId = null) {
|
||||
private scalarWrapperId = null,
|
||||
private scalarWrapperUrlParamName = "url") {
|
||||
this.isLoading = true;
|
||||
this.isUpdating = false;
|
||||
}
|
||||
@ -43,7 +44,10 @@ export class WidgetComponent implements OnInit {
|
||||
|
||||
if (!this.scalarWrapperId) this.scalarWrapperId = this.wrapperId;
|
||||
for (let widgetLink of SCALAR_WIDGET_LINKS) {
|
||||
this.scalarWrapperUrls.push(widgetLink.replace("__TYPE__", this.scalarWrapperId));
|
||||
const wrapperLink = widgetLink
|
||||
.replace("__TYPE__", this.scalarWrapperId)
|
||||
.replace("__PNAME__", this.scalarWrapperUrlParamName);
|
||||
this.scalarWrapperUrls.push(wrapperLink);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user