]> git.mxchange.org Git - friendica.git/commitdiff
Web app manifest (fixes #3317)
authorPierre Rudloff <contact@rudloff.pro>
Thu, 13 Apr 2017 00:24:27 +0000 (02:24 +0200)
committerPierre Rudloff <contact@rudloff.pro>
Thu, 13 Apr 2017 14:46:36 +0000 (16:46 +0200)
mod/manifest.php [new file with mode: 0644]
view/templates/head.tpl
view/templates/manifest.tpl [new file with mode: 0644]
view/theme/frio/templates/head.tpl

diff --git a/mod/manifest.php b/mod/manifest.php
new file mode 100644 (file)
index 0000000..6dc0d10
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+    use Friendica\Core\Config;
+
+    function manifest_content(App $a) {
+
+               $tpl = get_markup_template('manifest.tpl');
+
+               header('Content-type: application/manifest+json');
+
+               $touch_icon = Config::get('system', 'touch_icon', 'images/friendica-128.png');
+               if ($touch_icon == '') {
+                       $touch_icon = 'images/friendica-128.png';
+               }
+
+               $o = replace_macros($tpl, array(
+                       '$baseurl' => App::get_baseurl(),
+                       '$touch_icon' => $touch_icon,
+                       '$title' => Config::get('config', 'sitename', 'Friendica'),
+               ));
+
+               echo $o;
+
+               killme();
+
+       }
+?>
index bfc5728ed267e6641db596388e30a0b7923ad351..e7df8a18cde05c16b15cc43ceff67801ecbe30ca 100644 (file)
@@ -19,6 +19,7 @@
 <link rel="apple-touch-icon" href="{{$touch_icon}}"/>
 
 <meta name="apple-mobile-web-app-capable" content="yes" />
+<link rel="manifest" href="{{$baseurl}}/manifest" />
 <script>
 // Prevents links to switch to Safari in a home screen app - see https://gist.github.com/irae/1042167
 (function(a,b,c){if(c in b&&b[c]){var d,e=a.location,f=/^(a|html)$/i;a.addEventListener("click",function(a){d=a.target;while(!f.test(d.nodeName))d=d.parentNode;"href"in d&&(chref=d.href).replace(e.href,"").indexOf("#")&&(!/^[a-z\+\.\-]+:/i.test(chref)||chref.indexOf(e.protocol+"//"+e.host)===0)&&(a.preventDefault(),e.href=d.href)},!1)}})(document,window.navigator,"standalone");
diff --git a/view/templates/manifest.tpl b/view/templates/manifest.tpl
new file mode 100644 (file)
index 0000000..6f92947
--- /dev/null
@@ -0,0 +1,9 @@
+{
+  "name": "{{$title}}",
+  "start_url": "{{$baseurl}}",
+  "display": "standalone",
+  "description": "A Decentralized Social Network",
+  "icons": [{
+    "src": "{{$baseurl}}/{{$touch_icon}}"
+  }]
+}
index 32005417c82b7e1916172ac6c939aceac700b88c..882d2215cfe58396913d0fb40ec5aa026be46eef 100644 (file)
@@ -41,6 +41,7 @@
 <link rel="apple-touch-icon" href="{{$touch_icon}}"/>
 
 <meta name="apple-mobile-web-app-capable" content="yes" />
+<link rel="manifest" href="{{$baseurl}}/manifest" />
 <script>
 // Prevents links to switch to Safari in a home screen app - see https://gist.github.com/irae/1042167
 (function(a,b,c){if(c in b&&b[c]){var d,e=a.location,f=/^(a|html)$/i;a.addEventListener("click",function(a){d=a.target;while(!f.test(d.nodeName))d=d.parentNode;"href"in d&&(chref=d.href).replace(e.href,"").indexOf("#")&&(!/^[a-z\+\.\-]+:/i.test(chref)||chref.indexOf(e.protocol+"//"+e.host)===0)&&(a.preventDefault(),e.href=d.href)},!1)}})(document,window.navigator,"standalone");