port latest pwa work from zap

This commit is contained in:
Mario
2021-08-26 18:03:17 +00:00
parent 3ff184f8bb
commit 6e4c9d684d
16 changed files with 254 additions and 0 deletions

10
ServiceWorker.js Normal file
View File

@@ -0,0 +1,10 @@
// This file should be served from the web root to avoid scope and cookie related issues with some browsers
self.addEventListener('install', function(e) {
console.log('install event');
});
self.addEventListener('fetch', function(e) {
// nothing here yet
return;
});

View File

@@ -0,0 +1,52 @@
<?php
namespace Zotlabs\Module;
use App;
use Zotlabs\Web\Controller;
use Zotlabs\Lib\System;
class Manifest extends Controller {
function init() {
$ret = [
'name' => ucfirst(System::get_platform_name()),
'short_name' => ucfirst(System::get_platform_name()),
'icons' => [
[ 'src' => '/images/app/hz-72.png', 'sizes' => '72x72', 'type' => 'image/png' ],
[ 'src' => '/images/app/hz-96.png', 'sizes' => '96x96', 'type' => 'image/png' ],
[ 'src' => '/images/app/hz-128.png', 'sizes' => '128x128', 'type' => 'image/png' ],
[ 'src' => '/images/app/hz-144.png', 'sizes' => '144x144', 'type' => 'image/png' ],
[ 'src' => '/images/app/hz-152.png', 'sizes' => '152x152', 'type' => 'image/png' ],
[ 'src' => '/images/app/hz-192.png', 'sizes' => '192x192', 'type' => 'image/png' ],
[ 'src' => '/images/app/hz-348.png', 'sizes' => '384x384', 'type' => 'image/png' ],
[ 'src' => '/images/app/hz-512.png', 'sizes' => '512x512', 'type' => 'image/png' ],
[ 'src' => '/images/app/hz.svg', 'sizes' => '64x64', 'type' => 'image/xml+svg' ]
],
'scope' => '/',
'start_url' => z_root(),
'display' => 'standalone',
'orientation' => 'any',
'theme_color' => '#343a40',
'background_color' => 'white',
'share_target' => [
'action' => '/rpost',
'method' => 'POST',
'enctype' => 'multipart/form-data',
'params' => [
'title' => 'title',
'text' => 'body',
'url' => 'url',
'files' => [
[ 'name' => 'userfile',
'accept' => [ 'image/*', 'audio/*', 'video/*', 'text/*', 'application/*' ]
]
]
]
]
];
json_return_and_die($ret,'application/manifest+json');
}
}

View File

@@ -66,6 +66,73 @@ class Rpost extends \Zotlabs\Web\Controller {
nav_set_selected('Post');
if (local_channel() && array_key_exists('userfile',$_FILES)) {
$channel = App::get_channel();
$observer = App::get_observer();
$def_album = get_pconfig($channel['channel_id'],'system','photo_path');
$def_attach = get_pconfig($channel['channel_id'],'system','attach_path');
$r = attach_store($channel, (($observer) ? $observer['xchan_hash'] : ''), '', [
'source' => 'editor',
'visible' => 0,
'album' => $def_album,
'directory' => $def_attach,
'flags' => 1, // indicates temporary permissions are created
'allow_cid' => '<' . $channel['channel_hash'] . '>'
]);
if (! $r['success']) {
notice( $r['message'] . EOL);
}
$s = EMPTY_STR;
if (intval($r['data']['is_photo'])) {
$s .= "\n\n" . $r['body'] . "\n\n";
}
$url = z_root() . '/cloud/' . $channel['channel_address'] . '/' . $r['data']['display_path'];
if (strpos($r['data']['filetype'],'video') === 0) {
$s .= "\n\n" . '[zvideo]' . $url . '[/zvideo]' . "\n\n";
}
if (strpos($r['data']['filetype'],'audio') === 0) {
$s .= "\n\n" . '[zaudio]' . $url . '[/zaudio]' . "\n\n";
}
if ($r['data']['filetype'] === 'image/svg+xml') {
$x = @file_get_contents('store/' . $channel['channel_address'] . '/' . $r['data']['os_path']);
if ($x) {
$bb = svg2bb($x);
if ($bb) {
$s .= "\n\n" . $bb;
}
else {
logger('empty return from svgbb');
}
}
else {
logger('unable to read svg data file: ' . 'store/' . $channel['channel_address'] . '/' . $r['data']['os_path']);
}
}
if ($r['data']['filetype'] === 'text/calendar') {
$content = @file_get_contents('store/' . $channel['channel_address'] . '/' . $r['data']['os_path']);
if ($content) {
$ev = ical_to_ev($content);
if ($ev) {
$s .= "\n\n" . format_event_bbcode($ev[0]) . "\n\n";
}
}
}
$s .= "\n\n" . '[attachment]' . $r['data']['hash'] . ',' . $r['data']['revision'] . '[/attachment]' . "\n";
$_REQUEST['body'] = ((array_key_exists('body',$_REQUEST)) ? $_REQUEST['body'] . $s : $s);
}
// If we have saved rpost session variables, but nothing in the current $_REQUEST, recover the saved variables
if((! array_key_exists('body',$_REQUEST)) && (array_key_exists('rpost',$_SESSION))) {

View File

@@ -1198,6 +1198,10 @@ class App {
}
}
// webmanifest
head_add_link(['rel' => 'manifest', 'href' => '/manifest.json']);
self::$meta->set('application-name', Zotlabs\Lib\System::get_platform_name());
self::$meta->set('generator', Zotlabs\Lib\System::get_platform_name());
head_add_link(['rel' => 'shortcut icon', 'href' => head_get_icon()]);

BIN
images/app/hz-120.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

BIN
images/app/hz-128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

BIN
images/app/hz-144.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

BIN
images/app/hz-152.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

BIN
images/app/hz-180.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

BIN
images/app/hz-192.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

BIN
images/app/hz-384.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
images/app/hz-512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
images/app/hz-72.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
images/app/hz-96.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

112
images/app/hz.svg Normal file
View File

@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="64.0px"
height="64.0px"
viewBox="0 0 64.0 64.0"
version="1.1"
id="SVGRoot"
sodipodi:docname="hz.svg"
inkscape:version="1.1 (c4e8f9ed74, 2021-05-24)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview61"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="px"
showgrid="true"
inkscape:zoom="6.0069951"
inkscape:cx="16.980204"
inkscape:cy="24.970888"
inkscape:window-width="1440"
inkscape:window-height="831"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="g141">
<inkscape:grid
type="xygrid"
id="grid67" />
</sodipodi:namedview>
<defs
id="defs56" />
<g
inkscape:label="Ebene 1"
inkscape:groupmode="layer"
id="layer1">
<g
id="g141"
transform="matrix(3.7795276,0,0,3.7795276,22.748366,-1063.1931)">
<circle
style="fill:#43488a;stroke-width:0.264583;stop-color:#000000;fill-opacity:1"
id="path3823"
cx="2.4478281"
cy="289.76984"
r="8.4666662"
inkscape:export-filename="/run/user/1000/gvfs/sftp:host=10.3.0.14,user=root/srv/http/hub.somaton.com/www/images/app/hz-180.png"
inkscape:export-xdpi="270.00003"
inkscape:export-ydpi="270.00003" />
<g
id="g141-7"
transform="matrix(2.1038824,0,0,2.1655785,0.49257199,-333.55376)"
style="fill:#ffffff;stroke-width:0.468493;fill-opacity:1"
inkscape:export-filename="/run/user/1000/gvfs/sftp:host=10.3.0.14,user=root/srv/http/hub.somaton.com/www/images/app/hz-144.png"
inkscape:export-xdpi="276.47998"
inkscape:export-ydpi="276.47998">
<g
id="g2037"
inkscape:export-filename="/home/mario/Downloads/hz-icons/hz-512.png"
inkscape:export-xdpi="983.03998"
inkscape:export-ydpi="983.03998"
style="fill:#ffffff;stroke-width:0.468493;fill-opacity:1"
transform="translate(-4.3232614,-4.7489871)">
<ellipse
ry="1.0883039"
rx="1.0802424"
cy="292.92801"
cx="3.5032701"
id="path828-53"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.0235165" />
<ellipse
ry="1.5397485"
rx="1.4994409"
cy="291.37213"
cx="6.5827665"
id="path828-5"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.0329556" />
<ellipse
ry="0.78196651"
rx="0.79002792"
cy="294.54837"
cx="5.9217243"
id="path828-5-6"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.0170471" />
<path
sodipodi:nodetypes="ccccc"
inkscape:connector-curvature="0"
id="path871"
d="m 4.0465627,292.41576 1.3137706,-0.7355 0.1162183,0.24151 -1.2935591,0.74648 z"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.0276335px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
inkscape:connector-curvature="0"
id="path873"
d="m 4.2605136,293.26434 1.2691295,0.89108 -0.141557,0.20603 -1.2642478,-0.86532 z"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.02631px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
inkscape:connector-curvature="0"
id="path875"
d="m 5.8411078,293.86314 0.361292,-1.12861 0.2956026,0.0605 -0.3886627,1.11652 z"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.0246474px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@@ -34,6 +34,7 @@ if(localStorage.getItem('uid') !== localUser.toString()) {
sessionStorage.clear();
localStorage.setItem('uid', localUser.toString());
}
window.onstorage = function(e) {
if(e.key === 'uid' && parseInt(e.newValue) !== localUser) {
if(window_needs_alert) {
@@ -45,6 +46,14 @@ window.onstorage = function(e) {
}
}
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/ServiceWorker.js', { scope: '/' }).then(function(registration) {
console.log('Service worker registered. scope is', registration.scope);
}).catch(function(error) {
console.log('Service worker registration failed because ' + error);
});
}
$.ajaxSetup({cache: false});
$(document).ready(function() {