mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/17363] Add web app manifest
PHPBB-17363 Signed-off-by: Matt Friedman <maf675@gmail.com>
This commit is contained in:
parent
1dacbf6bde
commit
d651cccc76
8 changed files with 119 additions and 0 deletions
|
@ -157,6 +157,15 @@ services:
|
|||
- '%core.php_ext%'
|
||||
- '%tables.log%'
|
||||
|
||||
manifest.controller:
|
||||
class: phpbb\manifest
|
||||
arguments:
|
||||
- '@config'
|
||||
- '@language'
|
||||
- '@path_helper'
|
||||
- '@event_dispatcher'
|
||||
- '@user'
|
||||
|
||||
path_helper:
|
||||
class: phpbb\path_helper
|
||||
arguments:
|
||||
|
|
|
@ -24,6 +24,10 @@ phpbb_help_routing:
|
|||
resource: help.yml
|
||||
prefix: /help
|
||||
|
||||
phpbb_manifest_controller:
|
||||
path: /manifest
|
||||
defaults: { _controller: manifest.controller:handle }
|
||||
|
||||
phpbb_mention_controller:
|
||||
path: /mention
|
||||
methods: [GET, POST]
|
||||
|
|
|
@ -78,6 +78,7 @@ class acp_board
|
|||
'site_home_url' => array('lang' => 'SITE_HOME_URL', 'validate' => 'url', 'type' => 'url:40:255', 'explain' => true),
|
||||
'site_home_text' => array('lang' => 'SITE_HOME_TEXT', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => true),
|
||||
'board_index_text' => array('lang' => 'BOARD_INDEX_TEXT', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => true),
|
||||
'sitename_short' => array('lang' => 'SITE_NAME_SHORT', 'validate' => 'string', 'type' => 'text:40:12', 'explain' => true),
|
||||
'board_disable' => array('lang' => 'DISABLE_BOARD', 'validate' => 'bool', 'type' => 'custom', 'method' => 'board_disable', 'explain' => true),
|
||||
'board_disable_msg' => false,
|
||||
'board_disable_access' => array('lang' => 'DISABLE_BOARD_ACCESS', 'validate' => 'int', 'type' => 'select', 'method' => 'board_disable_access', 'explain' => true),
|
||||
|
@ -593,6 +594,7 @@ class acp_board
|
|||
// Array of emoji-enabled configurations
|
||||
$config_name_ary = [
|
||||
'sitename',
|
||||
'sitename_short',
|
||||
'site_desc',
|
||||
'site_home_text',
|
||||
'board_index_text',
|
||||
|
|
|
@ -3855,6 +3855,7 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
|
|||
'UA_PRIVACY' => addslashes(append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy')),
|
||||
'U_RESTORE_PERMISSIONS' => ($user->data['user_perm_from'] && $auth->acl_get('a_switchperm')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=restore_perm') : '',
|
||||
'U_FEED' => $controller_helper->route('phpbb_feed_index'),
|
||||
'U_MANIFEST' => $controller_helper->route('phpbb_manifest_controller'),
|
||||
|
||||
'S_ALLOW_MENTIONS' => ($config['allow_mentions'] && $auth->acl_get('u_mention') && (empty($forum_id) || $auth->acl_get('f_mention', $forum_id))) ? true : false,
|
||||
'S_MENTION_NAMES_LIMIT' => $config['mention_names_limit'],
|
||||
|
|
|
@ -284,6 +284,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('site_desc', '{L_CO
|
|||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('site_home_text', '');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('site_home_url', '');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('sitename', '{L_CONFIG_SITENAME}');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('sitename_short', '');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('smilies_path', 'images/smilies');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('smilies_per_page', '50');
|
||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_allow_self_signed', '0');
|
||||
|
|
|
@ -69,6 +69,8 @@ $lang = array_merge($lang, array(
|
|||
'SITE_HOME_URL' => 'Main website URL',
|
||||
'SITE_HOME_URL_EXPLAIN' => 'If specified, a link to this URL will be prepended to your board’s breadcrumbs and the board logo will link to this URL instead of the forum index. An absolute URL is required, e.g. <samp>http://www.phpbb.com</samp>.',
|
||||
'SITE_NAME' => 'Site name',
|
||||
'SITE_NAME_SHORT' => 'Short site name',
|
||||
'SITE_NAME_SHORT_EXPLAIN' => 'Short name will be used if your site is added to a mobile device’s home screen. It can not exceed 12 characters (Emoji is supported).',
|
||||
'SYSTEM_TIMEZONE' => 'Guest timezone',
|
||||
'SYSTEM_TIMEZONE_EXPLAIN' => 'Timezone to use for displaying times to users who are not logged in (guests, bots). Logged in users set their timezone during registration and can change it in their user control panel.',
|
||||
'WARNINGS_EXPIRE' => 'Warning duration',
|
||||
|
|
95
phpBB/phpbb/manifest.php
Normal file
95
phpBB/phpbb/manifest.php
Normal file
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb;
|
||||
|
||||
use phpbb\config\config;
|
||||
use phpbb\event\dispatcher_interface;
|
||||
use phpbb\exception\http_exception;
|
||||
use phpbb\language\language;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class manifest
|
||||
{
|
||||
/** @var config */
|
||||
protected $config;
|
||||
|
||||
/** @var language */
|
||||
protected $language;
|
||||
|
||||
/** @var path_helper */
|
||||
protected $path_helper;
|
||||
|
||||
/** @var dispatcher_interface */
|
||||
protected $phpbb_dispatcher;
|
||||
|
||||
/** @var user */
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* Constructor for manifest controller
|
||||
*
|
||||
* @param config $config
|
||||
* @param language $language
|
||||
* @param path_helper $path_helper
|
||||
* @param dispatcher_interface $phpbb_dispatcher
|
||||
* @param user $user
|
||||
*/
|
||||
public function __construct(config $config, language $language, path_helper $path_helper, dispatcher_interface $phpbb_dispatcher, user $user)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->path_helper = $path_helper;
|
||||
$this->phpbb_dispatcher = $phpbb_dispatcher;
|
||||
$this->language = $language;
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle creation of a manifest json file for progressive web-app support
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function handle(): JsonResponse
|
||||
{
|
||||
if ($this->user->data['is_bot'] || $this->user->data['user_type'] == USER_INACTIVE)
|
||||
{
|
||||
throw new http_exception(Response::HTTP_FORBIDDEN, 'NO_AUTH_OPERATION');
|
||||
}
|
||||
|
||||
$board_path = $this->config['force_server_vars'] ? $this->config['script_path'] : $this->path_helper->get_web_root_path();
|
||||
|
||||
$manifest = [
|
||||
'name' => $this->config['sitename'],
|
||||
'short_name' => $this->config['sitename_short'] ?: substr($this->config['sitename'], 0, 12),
|
||||
'display' => 'standalone',
|
||||
'orientation' => 'portrait',
|
||||
'dir' => $this->language->lang('DIRECTION'),
|
||||
'start_url' => $board_path,
|
||||
'scope' => $board_path,
|
||||
];
|
||||
|
||||
/**
|
||||
* Event to modify manifest data before it is outputted
|
||||
*
|
||||
* @event core.modify_manifest
|
||||
* @var array manifest Array of config values to display and process
|
||||
* @var string board_path Mode of the config page we are displaying
|
||||
* @since 4.0.0-a1
|
||||
*/
|
||||
$vars = array('manifest', 'board_path');
|
||||
extract($this->phpbb_dispatcher->trigger_event('core.modify_manifest', compact($vars)));
|
||||
|
||||
return new JsonResponse($manifest);
|
||||
}
|
||||
}
|
|
@ -4,6 +4,9 @@
|
|||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
<meta name="apple-mobile-web-app-title" content="{{ SITENAME }}">
|
||||
{META}
|
||||
<title><!-- IF UNREAD_NOTIFICATIONS_COUNT -->({UNREAD_NOTIFICATIONS_COUNT}) <!-- ENDIF --><!-- IF not S_VIEWTOPIC and not S_VIEWFORUM -->{SITENAME} - <!-- ENDIF --><!-- IF S_IN_MCP -->{L_MCP} - <!-- ELSEIF S_IN_UCP -->{L_UCP} - <!-- ENDIF -->{PAGE_TITLE}<!-- IF S_VIEWTOPIC or S_VIEWFORUM --> - {SITENAME}<!-- ENDIF --></title>
|
||||
|
||||
|
@ -57,6 +60,8 @@
|
|||
<link href="{T_ASSETS_PATH}/cookieconsent/cookieconsent.min.css?assets_version={T_ASSETS_VERSION}" rel="stylesheet">
|
||||
<!-- ENDIF -->
|
||||
|
||||
<link rel="manifest" href="{{ U_MANIFEST }}">
|
||||
|
||||
<!-- EVENT overall_header_head_append -->
|
||||
|
||||
{$STYLESHEETS}
|
||||
|
|
Loading…
Add table
Reference in a new issue