Skip to content

Commit

Permalink
trying to implement mastodon sharing button
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas2511 committed Dec 29, 2024
1 parent 657880e commit 2c9d51b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/helpers/frontend/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ def oembed_api_event_url(event)
(public_oembed_url(url: event_url(slug: event.slug))).freeze
end

def twitter_url(title, url)
'https://twitter.com/home?status='.freeze + URI.encode_www_form_component(title + ': ' + url)
def mastodon_url(title, url)
'javascript:self.location.href("https://" + prompt("Please enter the domain of your mastodon instance, e.g. chaos.social") + "/share?url='.freeze + URI.encode_www_form_component(url) + '&text='.freeze + URI.encode_www_form_component(title)
end

def facebook_url(title, url)
Expand Down
4 changes: 2 additions & 2 deletions app/views/frontend/shared/_embedshare.haml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

%ul.share
%li
%a.popup{:href => twitter_url(event.title, event_url(slug: event.slug)), :title => 'via Twitter'}
%i{:class => "icon-twitter"}
%a.popup{:href => mastodon_url(event.title, event_url(slug: event.slug)), :title => 'via Mastodon'}
%i{:class => "icon-mastodon"}

%li
%a.popup{:href => facebook_url(event.title, event_url(slug: event.slug)), :title => 'via Facebook'}
Expand Down

0 comments on commit 2c9d51b

Please sign in to comment.