]> cat aescling's git repositories - mastodon.git/commitdiff
implement web share target (#6278)
authorりんすき <428rinsuki+git@gmail.com>
Wed, 17 Jan 2018 16:08:10 +0000 (01:08 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Wed, 17 Jan 2018 16:08:10 +0000 (17:08 +0100)
* web share target

* fix

* fix

app/controllers/shares_controller.rb
app/serializers/manifest_serializer.rb

index fc2469deaaf76babcf5e12b77d7df0b8eaca6be4..3ec831a72dafe06a1652275adf45b2afca40605b 100644 (file)
@@ -14,13 +14,14 @@ class SharesController < ApplicationController
   private
 
   def initial_state_params
+    text = [params[:title], params[:text], params[:url]].compact.join(' ')
     {
       settings: Web::Setting.find_by(user: current_user)&.data || {},
       push_subscription: current_account.user.web_push_subscription(current_session),
       current_account: current_account,
       token: current_session.token,
       admin: Account.find_local(Setting.site_contact_username),
-      text: params[:text],
+      text: text,
     }
   end
 
index 95bcc21bb29e36733bb5122b05a2b742bfc45fdd..859ef0d1495513158a1677223016c70f0b99436e 100644 (file)
@@ -6,7 +6,8 @@ class ManifestSerializer < ActiveModel::Serializer
 
   attributes :name, :short_name, :description,
              :icons, :theme_color, :background_color,
-             :display, :start_url, :scope
+             :display, :start_url, :scope,
+             :share_target
 
   def name
     object.site_title
@@ -49,4 +50,8 @@ class ManifestSerializer < ActiveModel::Serializer
   def scope
     root_url
   end
+
+  def share_target
+    { url_template: 'share?title={title}&text={text}&url={url}' }
+  end
 end