FEATURE: Web Share Target Support

FEATURE: Web Share Target Support

This adds a very basic support for share to Discourse.

Currently, this is only supported in Android + Chrome 71+.

After installing a Discourse site to the Home Screen, you will be
able to share from anywhere in the OS to the Discourse site.

Discourse will use the title and text from the share event.

From efec2db859c803e180f143b26ed439d810cb8764 Mon Sep 17 00:00:00 2001
From: Rafael dos Santos Silva <xfalcox@gmail.com>
Date: Fri, 7 Dec 2018 13:48:09 -0200
Subject: [PATCH] FEATURE: Web Share Target Support

This adds a **very basic** support for share to Discourse.

Currently, this is only supported in Android + Chrome 71+.

After installing a Discourse site to the Home Screen, you will be
able to share from anywhere in the OS to the Discourse site.

Discourse will use the title and text from the share event.

diff --git a/app/controllers/metadata_controller.rb b/app/controllers/metadata_controller.rb
index dacba4d..bbe977b 100644
--- a/app/controllers/metadata_controller.rb
+++ b/app/controllers/metadata_controller.rb
@@ -37,7 +37,14 @@ class MetadataController < ApplicationController
           sizes: file_info[:size],
           type: file_info[:type]
         }
-      ]
+      ],
+      share_target: {
+        action: "/new-topic",
+        params: {
+          title: "title",
+          text: "body"
+        }
+      }
     }
 
     manifest[:short_name] = SiteSetting.short_title if SiteSetting.short_title.present?

GitHub

1 Like