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

Anton Khorev notifications at github.com
Thu Aug 15 14:05:39 UTC 2024


@AntonKhorev commented on this pull request.



> +    [valid_sites, invalid_sites]
+  end
+
+  def self.icon_path(site)
+    SOCIAL_SHARE_CONFIG[site.to_sym] || ""
+  end
+
+  def self.valid_site?(site)
+    SOCIAL_SHARE_CONFIG.key?(site.to_sym)
+  end
+
+  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])}"

`URI.encode_www_form_component` is a bit different from javascript's `encodeURIComponent`. It encodes spaces as `+`. But [mailto rfc](https://datatracker.ietf.org/doc/html/rfc6068#section-5) says spaces should be encoded as `%20`.

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

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


More information about the rails-dev mailing list