From c5b9a9833454c92a988e5084d9af5ac8f51e1c94 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 29 Jun 2021 10:26:12 +0200 Subject: [PATCH] Add Mastodon as a sharing provider Closes #227 Signed-off-by: Thomas Citharel --- js/src/components/Event/ShareEventModal.vue | 28 ++++++++++++++++++--- js/src/components/Group/ShareGroupModal.vue | 28 ++++++++++++++++++--- js/src/components/Share/MastodonLogo.vue | 25 ++++++++++++++++++ 3 files changed, 75 insertions(+), 6 deletions(-) create mode 100644 js/src/components/Share/MastodonLogo.vue diff --git a/js/src/components/Event/ShareEventModal.vue b/js/src/components/Event/ShareEventModal.vue index 1095300d..d21f3ce3 100644 --- a/js/src/components/Event/ShareEventModal.vue +++ b/js/src/components/Event/ShareEventModal.vue @@ -53,6 +53,14 @@ + + + @@ -81,10 +89,12 @@ import { Component, Prop, Vue, Ref } from "vue-property-decorator"; import { EventStatus, EventVisibility } from "@/types/enums"; import { IEvent } from "../../types/event.model"; import DiasporaLogo from "../Share/DiasporaLogo.vue"; +import MastodonLogo from "../Share/MastodonLogo.vue"; @Component({ components: { DiasporaLogo, + MastodonLogo, }, }) export default class ShareEventModal extends Vue { @@ -129,6 +139,16 @@ export default class ShareEventModal extends Vue { )}&url=${encodeURIComponent(this.event.url)}`; } + get mastodonShareUrl(): string { + return `https://toot.karamoff.dev/?text=${encodeURIComponent( + this.basicTextToEncode + )}`; + } + + get basicTextToEncode(): string { + return `${this.event.title}\r\n${this.event.url}`; + } + copyURL(): void { this.eventURLInput.$refs.input.select(); document.execCommand("copy"); @@ -140,8 +160,10 @@ export default class ShareEventModal extends Vue { } diff --git a/js/src/components/Group/ShareGroupModal.vue b/js/src/components/Group/ShareGroupModal.vue index b394659c..bb4b43ac 100644 --- a/js/src/components/Group/ShareGroupModal.vue +++ b/js/src/components/Group/ShareGroupModal.vue @@ -43,6 +43,14 @@ + + + @@ -70,11 +78,13 @@ import { Component, Prop, Vue, Ref } from "vue-property-decorator"; import { GroupVisibility } from "@/types/enums"; import DiasporaLogo from "../Share/DiasporaLogo.vue"; +import MastodonLogo from "../Share/MastodonLogo.vue"; import { displayName, IGroup } from "@/types/actor"; @Component({ components: { DiasporaLogo, + MastodonLogo, }, }) export default class ShareGroupModal extends Vue { @@ -116,6 +126,16 @@ export default class ShareGroupModal extends Vue { )}&url=${encodeURIComponent(this.group.url)}`; } + get mastodonShareUrl(): string { + return `https://toot.karamoff.dev/?text=${encodeURIComponent( + this.basicTextToEncode + )}`; + } + + get basicTextToEncode(): string { + return `${displayName(this.group)}\r\n${this.group.url}`; + } + copyURL(): void { this.groupURLInput.$refs.input.select(); document.execCommand("copy"); @@ -127,8 +147,10 @@ export default class ShareGroupModal extends Vue { } diff --git a/js/src/components/Share/MastodonLogo.vue b/js/src/components/Share/MastodonLogo.vue new file mode 100644 index 00000000..c35ace26 --- /dev/null +++ b/js/src/components/Share/MastodonLogo.vue @@ -0,0 +1,25 @@ + +