logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe
commit: 9004151e340f1d8080b415afc3668437de32ebc2
parent: 6884dd79ba8909e17cc6d48e658775fcf7f87890
Author: Sorin Davidoi <sorin.davidoi@gmail.com>
Date:   Fri, 28 Jul 2017 00:55:15 +0200

feat: Web Share for detailed status and account (#4402)

* feat: Web Share for detailed status and account

* fix(account/action_bar): Move share under mention

Diffstat:

Mapp/javascript/mastodon/features/account/components/action_bar.js10++++++++++
Mapp/javascript/mastodon/features/status/components/action_bar.js13+++++++++++++
Mapp/javascript/mastodon/locales/ar.json1+
Mapp/javascript/mastodon/locales/bg.json1+
Mapp/javascript/mastodon/locales/ca.json1+
Mapp/javascript/mastodon/locales/de.json1+
Mapp/javascript/mastodon/locales/defaultMessages.json8++++++++
Mapp/javascript/mastodon/locales/en.json1+
Mapp/javascript/mastodon/locales/eo.json1+
Mapp/javascript/mastodon/locales/es.json1+
Mapp/javascript/mastodon/locales/fa.json1+
Mapp/javascript/mastodon/locales/fi.json1+
Mapp/javascript/mastodon/locales/fr.json1+
Mapp/javascript/mastodon/locales/he.json1+
Mapp/javascript/mastodon/locales/hr.json1+
Mapp/javascript/mastodon/locales/hu.json1+
Mapp/javascript/mastodon/locales/id.json1+
Mapp/javascript/mastodon/locales/io.json1+
Mapp/javascript/mastodon/locales/it.json1+
Mapp/javascript/mastodon/locales/ja.json1+
Mapp/javascript/mastodon/locales/ko.json1+
Mapp/javascript/mastodon/locales/nl.json1+
Mapp/javascript/mastodon/locales/no.json1+
Mapp/javascript/mastodon/locales/oc.json1+
Mapp/javascript/mastodon/locales/pl.json1+
Mapp/javascript/mastodon/locales/pt-BR.json1+
Mapp/javascript/mastodon/locales/pt.json1+
Mapp/javascript/mastodon/locales/ru.json1+
Mapp/javascript/mastodon/locales/th.json1+
Mapp/javascript/mastodon/locales/tr.json1+
Mapp/javascript/mastodon/locales/uk.json1+
Mapp/javascript/mastodon/locales/zh-CN.json1+
Mapp/javascript/mastodon/locales/zh-HK.json1+
Mapp/javascript/mastodon/locales/zh-TW.json1+
34 files changed, 62 insertions(+), 0 deletions(-)

diff --git a/app/javascript/mastodon/features/account/components/action_bar.js b/app/javascript/mastodon/features/account/components/action_bar.js @@ -15,6 +15,7 @@ const messages = defineMessages({ mute: { id: 'account.mute', defaultMessage: 'Mute @{name}' }, follow: { id: 'account.follow', defaultMessage: 'Follow' }, report: { id: 'account.report', defaultMessage: 'Report @{name}' }, + share: { id: 'account.share', defaultMessage: 'Share @{name}\'s profile' }, media: { id: 'account.media', defaultMessage: 'Media' }, blockDomain: { id: 'account.block_domain', defaultMessage: 'Hide everything from {domain}' }, unblockDomain: { id: 'account.unblock_domain', defaultMessage: 'Unhide {domain}' }, @@ -36,6 +37,12 @@ export default class ActionBar extends React.PureComponent { intl: PropTypes.object.isRequired, }; + handleShare = () => { + navigator.share({ + url: this.props.account.get('url'), + }); + } + render () { const { account, me, intl } = this.props; @@ -43,6 +50,9 @@ export default class ActionBar extends React.PureComponent { let extraInfo = ''; menu.push({ text: intl.formatMessage(messages.mention, { name: account.get('username') }), action: this.props.onMention }); + if ('share' in navigator) { + menu.push({ text: intl.formatMessage(messages.share, { name: account.get('username') }), action: this.handleShare }); + } menu.push(null); menu.push({ text: intl.formatMessage(messages.media), to: `/accounts/${account.get('id')}/media` }); menu.push(null); diff --git a/app/javascript/mastodon/features/status/components/action_bar.js b/app/javascript/mastodon/features/status/components/action_bar.js @@ -13,6 +13,7 @@ const messages = defineMessages({ cannot_reblog: { id: 'status.cannot_reblog', defaultMessage: 'This post cannot be boosted' }, favourite: { id: 'status.favourite', defaultMessage: 'Favourite' }, report: { id: 'status.report', defaultMessage: 'Report @{name}' }, + share: { id: 'status.share', defaultMessage: 'Share' }, }); @injectIntl @@ -58,6 +59,13 @@ export default class ActionBar extends React.PureComponent { this.props.onReport(this.props.status); } + handleShare = () => { + navigator.share({ + text: this.props.status.get('search_index'), + url: this.props.status.get('url'), + }); + } + render () { const { status, me, intl } = this.props; @@ -71,6 +79,10 @@ export default class ActionBar extends React.PureComponent { menu.push({ text: intl.formatMessage(messages.report, { name: status.getIn(['account', 'username']) }), action: this.handleReport }); } + const shareButton = ('share' in navigator) && status.get('visibility') === 'public' && ( + <div className='detailed-status__button'><IconButton title={intl.formatMessage(messages.share)} icon='share-alt' onClick={this.handleShare} /></div> + ); + let reblogIcon = 'retweet'; if (status.get('visibility') === 'direct') reblogIcon = 'envelope'; else if (status.get('visibility') === 'private') reblogIcon = 'lock'; @@ -82,6 +94,7 @@ export default class ActionBar extends React.PureComponent { <div className='detailed-status__button'><IconButton title={intl.formatMessage(messages.reply)} icon={status.get('in_reply_to_id', null) === null ? 'reply' : 'reply-all'} onClick={this.handleReplyClick} /></div> <div className='detailed-status__button'><IconButton disabled={reblog_disabled} active={status.get('reblogged')} title={reblog_disabled ? intl.formatMessage(messages.cannot_reblog) : intl.formatMessage(messages.reblog)} icon={reblogIcon} onClick={this.handleReblogClick} /></div> <div className='detailed-status__button'><IconButton animate active={status.get('favourited')} title={intl.formatMessage(messages.favourite)} icon='star' onClick={this.handleFavouriteClick} activeStyle={{ color: '#ca8f04' }} /></div> + {shareButton} <div className='detailed-status__action-bar-dropdown'> <DropdownMenuContainer size={18} icon='ellipsis-h' items={menu} direction='left' ariaLabel='More' /> diff --git a/app/javascript/mastodon/locales/ar.json b/app/javascript/mastodon/locales/ar.json @@ -13,6 +13,7 @@ "account.posts": "المشاركات", "account.report": "أبلغ عن @{name}", "account.requested": "في انتظار الموافقة", + "account.share": "Share @{name}'s profile", "account.unblock": "إلغاء الحظر عن @{name}", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "إلغاء المتابعة", diff --git a/app/javascript/mastodon/locales/bg.json b/app/javascript/mastodon/locales/bg.json @@ -13,6 +13,7 @@ "account.posts": "Публикации", "account.report": "Report @{name}", "account.requested": "В очакване на одобрение", + "account.share": "Share @{name}'s profile", "account.unblock": "Не блокирай", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Не следвай", diff --git a/app/javascript/mastodon/locales/ca.json b/app/javascript/mastodon/locales/ca.json @@ -13,6 +13,7 @@ "account.posts": "Publicacions", "account.report": "Informe @{name}", "account.requested": "Esperant aprovació", + "account.share": "Share @{name}'s profile", "account.unblock": "Desbloquejar @{name}", "account.unblock_domain": "Mostra {domain}", "account.unfollow": "Deixar de seguir", diff --git a/app/javascript/mastodon/locales/de.json b/app/javascript/mastodon/locales/de.json @@ -13,6 +13,7 @@ "account.posts": "Beiträge", "account.report": "@{name} melden", "account.requested": "Warte auf Erlaubnis", + "account.share": "Share @{name}'s profile", "account.unblock": "@{name} entblocken", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Entfolgen", diff --git a/app/javascript/mastodon/locales/defaultMessages.json b/app/javascript/mastodon/locales/defaultMessages.json @@ -375,6 +375,10 @@ "id": "account.report" }, { + "defaultMessage": "Share @{name}'s profile", + "id": "account.share" + }, + { "defaultMessage": "Media", "id": "account.media" }, @@ -1027,6 +1031,10 @@ { "defaultMessage": "Report @{name}", "id": "status.report" + }, + { + "defaultMessage": "Share", + "id": "status.share" } ], "path": "app/javascript/mastodon/features/status/components/action_bar.json" diff --git a/app/javascript/mastodon/locales/en.json b/app/javascript/mastodon/locales/en.json @@ -13,6 +13,7 @@ "account.posts": "Posts", "account.report": "Report @{name}", "account.requested": "Awaiting approval", + "account.share": "Share @{name}'s profile", "account.unblock": "Unblock @{name}", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Unfollow", diff --git a/app/javascript/mastodon/locales/eo.json b/app/javascript/mastodon/locales/eo.json @@ -13,6 +13,7 @@ "account.posts": "Mesaĝoj", "account.report": "Report @{name}", "account.requested": "Atendas aprobon", + "account.share": "Share @{name}'s profile", "account.unblock": "Malbloki @{name}", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Malsekvi", diff --git a/app/javascript/mastodon/locales/es.json b/app/javascript/mastodon/locales/es.json @@ -13,6 +13,7 @@ "account.posts": "Publicaciones", "account.report": "Report @{name}", "account.requested": "Esperando aprobación", + "account.share": "Share @{name}'s profile", "account.unblock": "Desbloquear", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Dejar de seguir", diff --git a/app/javascript/mastodon/locales/fa.json b/app/javascript/mastodon/locales/fa.json @@ -13,6 +13,7 @@ "account.posts": "نوشته‌ها", "account.report": "گزارش @{name}", "account.requested": "در انتظار پذیرش", + "account.share": "Share @{name}'s profile", "account.unblock": "رفع انسداد @{name}", "account.unblock_domain": "رفع پنهان‌سازی از {domain}", "account.unfollow": "پایان پیگیری", diff --git a/app/javascript/mastodon/locales/fi.json b/app/javascript/mastodon/locales/fi.json @@ -13,6 +13,7 @@ "account.posts": "Postit", "account.report": "Report @{name}", "account.requested": "Odottaa hyväksyntää", + "account.share": "Share @{name}'s profile", "account.unblock": "Salli @{name}", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Lopeta seuraaminen", diff --git a/app/javascript/mastodon/locales/fr.json b/app/javascript/mastodon/locales/fr.json @@ -13,6 +13,7 @@ "account.posts": "Statuts", "account.report": "Signaler", "account.requested": "Invitation envoyée", + "account.share": "Share @{name}'s profile", "account.unblock": "Débloquer", "account.unblock_domain": "Ne plus masquer {domain}", "account.unfollow": "Ne plus suivre", diff --git a/app/javascript/mastodon/locales/he.json b/app/javascript/mastodon/locales/he.json @@ -13,6 +13,7 @@ "account.posts": "הודעות", "account.report": "לדווח על @{name}", "account.requested": "בהמתנה לאישור", + "account.share": "Share @{name}'s profile", "account.unblock": "הסרת חסימה מעל @{name}", "account.unblock_domain": "הסר חסימה מקהילת {domain}", "account.unfollow": "הפסקת מעקב", diff --git a/app/javascript/mastodon/locales/hr.json b/app/javascript/mastodon/locales/hr.json @@ -13,6 +13,7 @@ "account.posts": "Postovi", "account.report": "Prijavi @{name}", "account.requested": "Čeka pristanak", + "account.share": "Share @{name}'s profile", "account.unblock": "Deblokiraj @{name}", "account.unblock_domain": "Otkrij {domain}", "account.unfollow": "Prestani slijediti", diff --git a/app/javascript/mastodon/locales/hu.json b/app/javascript/mastodon/locales/hu.json @@ -13,6 +13,7 @@ "account.posts": "Posts", "account.report": "Report @{name}", "account.requested": "Awaiting approval", + "account.share": "Share @{name}'s profile", "account.unblock": "Blokkolás levétele", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Követés abbahagyása", diff --git a/app/javascript/mastodon/locales/id.json b/app/javascript/mastodon/locales/id.json @@ -13,6 +13,7 @@ "account.posts": "Postingan", "account.report": "Laporkan @{name}", "account.requested": "Menunggu persetujuan", + "account.share": "Share @{name}'s profile", "account.unblock": "Hapus blokir @{name}", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Berhenti mengikuti", diff --git a/app/javascript/mastodon/locales/io.json b/app/javascript/mastodon/locales/io.json @@ -13,6 +13,7 @@ "account.posts": "Mesaji", "account.report": "Denuncar @{name}", "account.requested": "Vartante aprobo", + "account.share": "Share @{name}'s profile", "account.unblock": "Desblokusar @{name}", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Ne plus sequar", diff --git a/app/javascript/mastodon/locales/it.json b/app/javascript/mastodon/locales/it.json @@ -13,6 +13,7 @@ "account.posts": "Posts", "account.report": "Segnala @{name}", "account.requested": "In attesa di approvazione", + "account.share": "Share @{name}'s profile", "account.unblock": "Sblocca @{name}", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Non seguire", diff --git a/app/javascript/mastodon/locales/ja.json b/app/javascript/mastodon/locales/ja.json @@ -13,6 +13,7 @@ "account.posts": "投稿", "account.report": "通報", "account.requested": "承認待ち", + "account.share": "Share @{name}'s profile", "account.unblock": "ブロック解除", "account.unblock_domain": "{domain}を表示", "account.unfollow": "フォロー解除", diff --git a/app/javascript/mastodon/locales/ko.json b/app/javascript/mastodon/locales/ko.json @@ -13,6 +13,7 @@ "account.posts": "포스트", "account.report": "신고", "account.requested": "승인 대기 중", + "account.share": "Share @{name}'s profile", "account.unblock": "차단 해제", "account.unblock_domain": "{domain} 숨김 해제", "account.unfollow": "팔로우 해제", diff --git a/app/javascript/mastodon/locales/nl.json b/app/javascript/mastodon/locales/nl.json @@ -13,6 +13,7 @@ "account.posts": "Toots", "account.report": "Rapporteer @{name}", "account.requested": "Wacht op goedkeuring", + "account.share": "Share @{name}'s profile", "account.unblock": "Deblokkeer @{name}", "account.unblock_domain": "{domain} niet meer negeren", "account.unfollow": "Ontvolgen", diff --git a/app/javascript/mastodon/locales/no.json b/app/javascript/mastodon/locales/no.json @@ -13,6 +13,7 @@ "account.posts": "Innlegg", "account.report": "Rapportér @{name}", "account.requested": "Venter på godkjennelse", + "account.share": "Share @{name}'s profile", "account.unblock": "Avblokker @{name}", "account.unblock_domain": "Vis {domain}", "account.unfollow": "Avfølg", diff --git a/app/javascript/mastodon/locales/oc.json b/app/javascript/mastodon/locales/oc.json @@ -13,6 +13,7 @@ "account.posts": "Estatuts", "account.report": "Senhalar @{name}", "account.requested": "Invitacion mandada", + "account.share": "Share @{name}'s profile", "account.unblock": "Desblocar @{name}", "account.unblock_domain": "Desblocar {domain}", "account.unfollow": "Quitar de sègre", diff --git a/app/javascript/mastodon/locales/pl.json b/app/javascript/mastodon/locales/pl.json @@ -13,6 +13,7 @@ "account.posts": "Posty", "account.report": "Zgłoś @{name}", "account.requested": "Oczekująca prośba", + "account.share": "Share @{name}'s profile", "account.unblock": "Odblokuj @{name}", "account.unblock_domain": "Odblokuj domenę {domain}", "account.unfollow": "Przestań śledzić", diff --git a/app/javascript/mastodon/locales/pt-BR.json b/app/javascript/mastodon/locales/pt-BR.json @@ -13,6 +13,7 @@ "account.posts": "Posts", "account.report": "Denunciar @{name}", "account.requested": "A aguardar aprovação", + "account.share": "Share @{name}'s profile", "account.unblock": "Não bloquear @{name}", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Deixar de seguir", diff --git a/app/javascript/mastodon/locales/pt.json b/app/javascript/mastodon/locales/pt.json @@ -13,6 +13,7 @@ "account.posts": "Posts", "account.report": "Denunciar @{name}", "account.requested": "A aguardar aprovação", + "account.share": "Share @{name}'s profile", "account.unblock": "Não bloquear @{name}", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Deixar de seguir", diff --git a/app/javascript/mastodon/locales/ru.json b/app/javascript/mastodon/locales/ru.json @@ -13,6 +13,7 @@ "account.posts": "Посты", "account.report": "Пожаловаться", "account.requested": "Ожидает подтверждения", + "account.share": "Share @{name}'s profile", "account.unblock": "Разблокировать", "account.unblock_domain": "Разблокировать {domain}", "account.unfollow": "Отписаться", diff --git a/app/javascript/mastodon/locales/th.json b/app/javascript/mastodon/locales/th.json @@ -13,6 +13,7 @@ "account.posts": "Posts", "account.report": "Report @{name}", "account.requested": "Awaiting approval", + "account.share": "Share @{name}'s profile", "account.unblock": "Unblock @{name}", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Unfollow", diff --git a/app/javascript/mastodon/locales/tr.json b/app/javascript/mastodon/locales/tr.json @@ -13,6 +13,7 @@ "account.posts": "Gönderiler", "account.report": "Rapor et @{name}", "account.requested": "Onay bekleniyor", + "account.share": "Share @{name}'s profile", "account.unblock": "Engeli kaldır @{name}", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Takipten vazgeç", diff --git a/app/javascript/mastodon/locales/uk.json b/app/javascript/mastodon/locales/uk.json @@ -13,6 +13,7 @@ "account.posts": "Пости", "account.report": "Поскаржитися", "account.requested": "Очікує підтвердження", + "account.share": "Share @{name}'s profile", "account.unblock": "Розблокувати", "account.unblock_domain": "Розблокувати {domain}", "account.unfollow": "Відписатися", diff --git a/app/javascript/mastodon/locales/zh-CN.json b/app/javascript/mastodon/locales/zh-CN.json @@ -13,6 +13,7 @@ "account.posts": "嘟文", "account.report": "举报 @{name}", "account.requested": "等待审批", + "account.share": "Share @{name}'s profile", "account.unblock": "解除对 @{name} 的屏蔽", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "取消关注", diff --git a/app/javascript/mastodon/locales/zh-HK.json b/app/javascript/mastodon/locales/zh-HK.json @@ -13,6 +13,7 @@ "account.posts": "文章", "account.report": "舉報 @{name}", "account.requested": "等候審批", + "account.share": "Share @{name}'s profile", "account.unblock": "解除對 @{name} 的封鎖", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "取消關注", diff --git a/app/javascript/mastodon/locales/zh-TW.json b/app/javascript/mastodon/locales/zh-TW.json @@ -13,6 +13,7 @@ "account.posts": "貼文", "account.report": "檢舉 @{name}", "account.requested": "正在等待許可", + "account.share": "Share @{name}'s profile", "account.unblock": "取消封鎖 @{name}", "account.unblock_domain": "不再隱藏 {domain}", "account.unfollow": "取消關注",