Skip to content

Commit

Permalink
client: add native sharer
Browse files Browse the repository at this point in the history
using Web Share API for browsers that support it

https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share

Closes: #719
  • Loading branch information
jtojnar committed Apr 23, 2018
1 parent 0d75b5c commit 2ca1e6e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### New features
- Thumbnails can be disabled ([#897](https://github.com/SSilence/selfoss/pull/897))
- Reddit spout replaced fragile imgur heuristics with previews provided by the JSON API ([#1033](https://github.com/SSilence/selfoss/pull/1033))
- [Native sharer](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share) is available in browsers that support it. You can enable it by adding `a` to `share` key in your config.

### Bug fixes
- Reddit spout allows wider range of URLs, including absolute URLs and searches ([#1033](https://github.com/SSilence/selfoss/pull/1033))
Expand Down
2 changes: 1 addition & 1 deletion _docs/website/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ <h2 id="configuration_params">Configuration</h2>
</tr>
<tr>
<td class="documentation-first-column">share</td>
<td>share defines which share buttons beneath the entry are visible. Default is share=gtfprde (g = google, f = facebook, t = twitter, p = pocket, d = delicious, w = wallabag, e = email). When you would like to show only facebook and twitter share button use share=ft.</td>
<td>share defines which share buttons beneath the entry are visible. Default is share=agtfprde (a = <a href="https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share">Web Share API</a> when available, g = google, f = facebook, t = twitter, p = pocket, d = delicious, w = wallabag, e = email). When you would like to show only facebook and twitter share button use share=ft.</td>
</tr>
<tr>
<td class="documentation-first-column">wallabag</td>
Expand Down
2 changes: 1 addition & 1 deletion defaults.ini
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ auto_collapse=0
auto_stream_more=1
anonymizer=
use_system_font=
share=gtfpde
share=agtfpde
wallabag=
wallabag_version=1
allow_public_update_access=
Expand Down
Binary file added public/images/share.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions public/js/selfoss-shares.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ selfoss.shares = {
this.register('mail', 'e', function(url, title) {
document.location.href = 'mailto:?body=' + encodeURIComponent(url) + '&subject=' + encodeURIComponent(title);
});

if (navigator.share) {
selfoss.shares.register('share', 'a', function(url, title) {
navigator.share({
title: title,
url: url
});
});
}
},

register: function(name, id, sharer) {
Expand Down

0 comments on commit 2ca1e6e

Please sign in to comment.