[openstreetmap/openstreetmap-website] Add social sharing functionality (PR #4985)
Emin Kocan
notifications at github.com
Tue Aug 27 19:44:59 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])}"
Found out there is [mastodonshare.com](https://mastodonshare.com) that takes text and url query parameters and let's you choose the mastodon instance you want to share on. Updated the code accordingly. Can you please test this and let me know if this solution is okay. @mmd-osm @tomhughes
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/4985#discussion_r1733428865
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/4985/review/2264311808 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20240827/e97b6de7/attachment.htm>
More information about the rails-dev
mailing list