[openstreetmap/openstreetmap-website] Add social sharing functionality (PR #4985)

mmd notifications at github.com
Thu Aug 22 07:33:39 UTC 2024


@mmd-osm 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])}"

A lot of folks hang out on en.osm.town. Maybe check out https://github.com/Juerd/tootpick?tab=readme-ov-file which offers a popup to enter the mastodon instance (might be include a few better known ones as preselect?).

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/4985#discussion_r1726509737
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/4985/review/2253718572 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20240822/22604e7d/attachment-0001.htm>


More information about the rails-dev mailing list