From fbe7756da6e817c3de633f624f5a28bc133e78c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8A=E3=82=93=E3=81=99=E3=81=8D?= <428rinsuki+git@gmail.com> Date: Thu, 18 Jan 2018 01:08:10 +0900 Subject: [PATCH] implement web share target (#6278) * web share target * fix * fix --- app/controllers/shares_controller.rb | 3 ++- app/serializers/manifest_serializer.rb | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/controllers/shares_controller.rb b/app/controllers/shares_controller.rb index fc2469deaa..3ec831a72d 100644 --- a/app/controllers/shares_controller.rb +++ b/app/controllers/shares_controller.rb @@ -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 diff --git a/app/serializers/manifest_serializer.rb b/app/serializers/manifest_serializer.rb index 95bcc21bb2..859ef0d149 100644 --- a/app/serializers/manifest_serializer.rb +++ b/app/serializers/manifest_serializer.rb @@ -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