From 9f999189cd87eed3291efb24bd5ae3a543719a69 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Mon, 16 Oct 2023 15:20:04 +0200 Subject: [PATCH] Add Stimulus sharing feature to answerboxes --- app/helpers/social_helper.rb | 9 +++++++++ app/views/actions/_share.html.haml | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/helpers/social_helper.rb b/app/helpers/social_helper.rb index e1ffe35f..b8ce3b9d 100644 --- a/app/helpers/social_helper.rb +++ b/app/helpers/social_helper.rb @@ -4,4 +4,13 @@ module SocialHelper include SocialHelper::TwitterMethods include SocialHelper::TumblrMethods include SocialHelper::TelegramMethods + + def answer_share_url(answer) + answer_url( + id: answer.id, + username: answer.user.screen_name, + host: APP_CONFIG["hostname"], + protocol: (APP_CONFIG["https"] ? :https : :http) + ) + end end diff --git a/app/views/actions/_share.html.haml b/app/views/actions/_share.html.haml index 65daacc2..5fc3c26b 100644 --- a/app/views/actions/_share.html.haml +++ b/app/views/actions/_share.html.haml @@ -8,5 +8,5 @@ %a.dropdown-item{ href: telegram_share_url(answer), target: "_blank" } %i.fa.fa-fw.fa-telegram = t(".telegram") - %a.dropdown-item{ href: "#", name: "ab-share" } + %a.dropdown-item{ href: "#", data: { controller: :share, action: "share#share", share_url_value: answer_share_url(answer) } } = t(".other")