Browse Source

Add share_target support in the Manifest and Share widget

master
Timothée Jaussoin 2 days ago
parent
commit
f1da95a324
  1. 2
      CHANGELOG.md
  2. 50
      app/Widgets/Manifest/Manifest.php
  3. 31
      app/Widgets/Share/share.js
  4. BIN
      public/theme/img/app/shortcuts/chat.png
  5. BIN
      public/theme/img/app/shortcuts/news.png
  6. BIN
      public/theme/img/app/shortcuts/publish.png

2
CHANGELOG.md

@ -5,6 +5,8 @@ v0.33 (master)
---------------------------
* Add a Shortcuts widget to quickly access the 3 most recent notified chats and chatrooms
* Implement XEP-0317: Hats and display it in the MUC navigation bar and in a new MUC participant card
* Jingle and Video-conference fixes
* Add share_target support in the Manifest and Share widget
v0.32.1
---------------------------

50
app/Widgets/Manifest/Manifest.php

@ -45,44 +45,6 @@ class Manifest extends Base
'purpose' => 'any'
]
],
'shortcuts' => [
[
'name' => $this->__('page.chats'),
'url' => $this->route('chat'),
'icons' => [
[
'src' => BASE_URI . 'theme/img/app/shortcuts/chat.png',
'sizes' => '96x96',
'type' => 'image/png',
'purpose' => 'any'
]
]
],
[
'name' => $this->__('page.publish'),
'url' => $this->route('publish'),
'icons' => [
[
'src' => BASE_URI . 'theme/img/app/shortcuts/publish.png',
'sizes' => '96x96',
'type' => 'image/png',
'purpose' => 'any'
]
]
],
[
'name' => $this->__('page.news'),
'url' => $this->route('news'),
'icons' => [
[
'src' => BASE_URI . 'theme/img/app/shortcuts/news.png',
'sizes' => '96x96',
'type' => 'image/png',
'purpose' => 'any'
]
]
]
],
'display_override' => ['window-controls-overlay'],
'display' => 'standalone',
'orientation' => 'portrait-primary',
@ -90,7 +52,7 @@ class Manifest extends Base
'theme_color' => '#10151A',
'id' => '/login',
'start_url' => '/login',
'launch_handler'=> [
'launch_handler' => [
'client_mode' => 'navigate-new',
],
'categories' => ['news', 'photo', 'social', 'entertainment'],
@ -102,6 +64,16 @@ class Manifest extends Base
'name' => 'Movim',
'url' => '/share/%s'
]],
'share_target' => [
'action' => "/share/",
'method' => 'GET',
'params' => [
'title' => 'title',
'description' => 'description',
'url' => 'url'
]
],
'handle_links' => 'preferred',
'edge_side_panel' => ['preferred_width' => 375],
];

31
app/Widgets/Share/share.js

@ -1,17 +1,40 @@
var Share = {
get: function() {
get: function () {
// https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Manifest/Reference/share_target
if (window.location.search) {
params = new URLSearchParams(window.location.search);
url = null;
if (url = params.get('url')) {
Share.openUri(url);
return;
} else if (params.get('description')) {
try {
url = new URL(params.get('description'));
Share.openUri(url);
return;
} catch (error) { }
}
}
var parts = MovimUtils.urlParts();
if (parts.params[0]) {
uri = parts.params[0].substr(0, 5) == 'xmpp:'
? parts.params[0]
: atob(parts.params[0]);
document.querySelector('h4').innerHTML = uri;
Share_ajaxGet(uri);
Share.openUri(uri);
}
},
openUri: function (uri) {
document.querySelector('h4').innerHTML = uri;
Share_ajaxGet(uri);
}
};
MovimWebsocket.attach(function() {
MovimWebsocket.attach(function () {
Share.get();
});

BIN
public/theme/img/app/shortcuts/chat.png

Before

Width: 96  |  Height: 96  |  Size: 710 B

BIN
public/theme/img/app/shortcuts/news.png

Before

Width: 96  |  Height: 96  |  Size: 846 B

BIN
public/theme/img/app/shortcuts/publish.png

Before

Width: 96  |  Height: 96  |  Size: 738 B

Loading…
Cancel
Save