[openstreetmap/openstreetmap-website] Add social sharing functionality (PR #4985)
Emin Kocan
notifications at github.com
Thu Aug 22 07:22:43 UTC 2024
@kcne commented on this pull request.
> +
+ def self.generate_share_url(site, params)
+ site = site.to_sym
+ case site
+ when :email
+ "mailto:?subject=#{URI.encode_www_form_component(params[:title])}&body=#{URI.encode_www_form_component(params[:url])}"
+ when :x
+ via_str = params[:via] ? "&via=#{URI.encode_www_form_component(params[:via])}" : ""
+ hashtags_str = params[:hashtags] ? "&hashtags=#{URI.encode_www_form_component(params[:hashtags].join(','))}" : ""
+ "https://x.com/intent/tweet?url=#{URI.encode_www_form_component(params[:url])}&text=#{URI.encode_www_form_component(params[:title])}#{hashtags_str}#{via_str}"
+ when :linkedin
+ "https://www.linkedin.com/shareArticle?mini=true&url=#{URI.encode_www_form_component(params[:url])}"
+ when :facebook
+ "https://www.facebook.com/sharer/sharer.php?url=#{URI.encode_www_form_component(params[:url])}"
+ when :mastodon
+ "https://mastodon.social/share?text=#{URI.encode_www_form_component(params[:title])}&url=#{URI.encode_www_form_component(params[:url])}"
Good catch but I'm a little stuck here, there is n numbers of mastodon instances. Do you have some recommendation on how to approach this?
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/4985#discussion_r1726493665
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/4985/review/2253697184 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20240822/89d034bd/attachment.htm>
More information about the rails-dev
mailing list