Skip to content

Commit 1f249b0

Browse files
committed
Make manifest a static page
1 parent 4d5c5a1 commit 1f249b0

File tree

4 files changed

+61
-6
lines changed

4 files changed

+61
-6
lines changed

config/routing.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
phpbb_webpushnotifications_ucp_routing:
22
resource: wpn_ucp.yml
33
prefix: /user
4-
5-
phpbb_webpushnotifications_manifest_controller:
6-
path: /manifest
7-
defaults: { _controller: phpbb.wpn.controller.manifest:handle }

event/listener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public function compatibility_notice()
143143
public function pwa_manifest()
144144
{
145145
$this->template->assign_vars([
146-
'U_MANIFEST_URL' => $this->controller_helper->route('phpbb_webpushnotifications_manifest_controller'),
146+
'U_MANIFEST_URL' => 'ext/phpbb/webpushnotifications/manifest.php',
147147
'U_TOUCH_ICON' => $this->config['pwa_icon_small'] ? ext::PWA_ICON_DIR . '/' . $this->config['pwa_icon_small'] : null,
148148
'SHORT_SITE_NAME' => $this->config['pwa_short_name'] ?: $this->trim_shortname($this->config['sitename']),
149149
]);

manifest.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/**
3+
*
4+
* phpBB Browser Push Notifications. An extension for the phpBB Forum Software package.
5+
*
6+
* @copyright (c) 2024, phpBB Limited <https://www.phpbb.com>
7+
* @license GNU General Public License, version 2 (GPL-2.0)
8+
*
9+
*/
10+
11+
use Symfony\Component\HttpFoundation\JsonResponse;
12+
use phpbb\webpushnotifications\ext;
13+
14+
/**
15+
* @ignore
16+
**/
17+
define('IN_PHPBB', true);
18+
$phpbb_root_path = ((defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './') . '../../../';
19+
$phpEx = substr(strrchr(__FILE__, '.'), 1);
20+
include($phpbb_root_path . 'common.' . $phpEx);
21+
22+
/** @var \phpbb\path_helper $path_helper */
23+
$path_helper = $phpbb_container->get('path_helper');
24+
25+
$board_path = $config['force_server_vars'] ? $config['script_path'] : $path_helper->get_web_root_path();
26+
$board_url = generate_board_url();
27+
28+
// Emoji fixer-uppers
29+
$sitename = ext::decode_entities($config['sitename'], ENT_QUOTES);
30+
$pwa_short_name = ext::decode_entities($config['pwa_short_name'], ENT_QUOTES);
31+
32+
$manifest = [
33+
'name' => $sitename,
34+
'short_name' => $pwa_short_name ?: utf8_substr($sitename, 0, 12),
35+
'display' => 'standalone',
36+
'orientation' => 'portrait',
37+
'dir' => $language->lang('DIRECTION'),
38+
'start_url' => $board_path,
39+
'scope' => $board_path,
40+
];
41+
42+
if (!empty($config['pwa_icon_small']) && !empty($config['pwa_icon_large']))
43+
{
44+
$manifest['icons'] = [
45+
[
46+
'src' => $board_url . '/' . ext::PWA_ICON_DIR . '/' . $config['pwa_icon_small'],
47+
'sizes' => '192x192',
48+
'type' => 'image/png'
49+
],
50+
[
51+
'src' => $board_url . '/' . ext::PWA_ICON_DIR . '/' . $config['pwa_icon_large'],
52+
'sizes' => '512x512',
53+
'type' => 'image/png'
54+
]
55+
];
56+
}
57+
58+
$response = new JsonResponse($manifest);
59+
$response->send();

styles/all/template/event/overall_header_head_append.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<meta name="application-name" content="{{ SHORT_SITE_NAME }}">
1515

1616
<!-- Link to app's configuration manifest -->
17-
<link rel="manifest" href="{{ U_MANIFEST_URL }}">
17+
<link rel="manifest" href="{{ ROOT_PATH ~ U_MANIFEST_URL }}">
1818

1919
{% if U_TOUCH_ICON %}
2020
<!-- App icon for iOS, a fallback to icons defined in the manifest -->

0 commit comments

Comments
 (0)