1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-22 04:23:01 +00:00

Add new http2_server_push_items setting.

Still untested! I really need to do that.
This commit is contained in:
Starbeamrainbowlabs 2018-08-22 23:44:24 +01:00
parent 21cbd620d6
commit 4d65b3529e
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
3 changed files with 24 additions and 2 deletions

View file

@ -14,6 +14,10 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
- Added page restore system
- A previous page revision can be restored with a single click from the page history page
- Added a new `history_revert_require_moderator` setting to control whether moderator privileges are required to use the functionality (regardless of setting a user must be logged in)
- [HTTP/2.0 Server Push](https://www.smashingmagazine.com/2017/04/guide-http2-server-push/) support!
- You'll need to make sure your web server has support turned on
- The CSS file specified in the `css` setting (url path must begin with a forward-slash) and the favicon (must not be a `data:` url) are automatically pushed when rendering pages
- 2 new settings have been added: `http2_server_push` for turning it on and off (defaults to on), and `http2_server_push_items` for specifying custom resources to push (in case you design your own theme and want to push down the associated resources)
### Fixed
- Updated the search system to transliterate characters to better support searching pages that are written in other languages.

View file

@ -1214,8 +1214,8 @@ class page_renderer
$result = str_replace(array_keys($parts), array_values($parts), $result);
$result = str_replace("{generation-time-taken}", round((microtime(true) - $start_time)*1000, 2), $result);
// Send the HTTP/2.0 server push indicators if possible
if(!headers_sent()) self::send_server_push_indicators();
// Send the HTTP/2.0 server push indicators if possible - but not if we're sending a redirect page
if(!headers_sent() && http_response_code() < 300 && http_response_code() >= 400) self::send_server_push_indicators();
return $result;
}
/**
@ -1395,6 +1395,18 @@ class page_renderer
// ~
/**
* Adds a resource to the list of items to indicate that the web server should send via HTTP/2.0 Server Push.
* Note: Only specify static files here, as you might end up with strange (and possibly dangerous) results!
* @param string $type The resource type. See https://fetch.spec.whatwg.org/#concept-request-destination for more information.
* @param string $path The *relative url path* to the resource.
*/
public static function AddServerPushIndicator($type, $path) {
self::$http2_push_items[] = [ $type, $path ];
}
// ~
/**
* The navigation bar divider.
* @package core
@ -1528,6 +1540,11 @@ class page_renderer
}
}
// HTTP/2.0 Server Push static items
foreach($settings->http2_server_push_items as $push_item) {
page_renderer::AddServerPushIndicator($push_item[0], $push_item[1]);
}
// Math rendering support
if(!empty($settings->enable_math_rendering))
{

View file

@ -161,6 +161,7 @@
"updateurl": { "type": "url", "description": "The url from which to fetch updates. Defaults to the master (development) branch. MAKE SURE THAT THIS POINTS TO A *HTTPS* URL, OTHERWISE SOMEONE COULD INJECT A VIRUS INTO YOUR WIKI!", "default": "https://raw.githubusercontent.com/sbrl/pepperminty-wiki/master/index.php" },
"optimize_pages": { "type": "checkbox", "description": "Whether to optimise all webpages generated.", "default": true},
"http2_server_push": { "type": "checkbox", "description": "Whether HTTP/2.0 server should should be enabled. If true, then 'link' HTTP headers will be attached to rendered pages specifying files to push down. Note that web server support <em>also</em> has to be abled for this to work, as PHP can't push resources to the client on its own.", "default": true },
"http2_server_push_items": { "type": "server-push", "description": "An array of items to push to clients when rendering pages. Should be in the format <code>[ [type, path], [type, path], ....]</code>, where <code>type</code> is a <a href='https://fetch.spec.whatwg.org/#concept-request-destination'>resource type</a>, and <code>path</code> is a relative url path to a static file to send via <em>HTTP/2.0 Server Push</em>.<br />Note: These resources will only be pushed if your web server also has support for the link: HTTP/2.0 header, and it's a page that being rendered. If it's some other thing that being sent (e.g. an image, error message, event stream, redirect, etc.), then no server push is indicated by <em>Pepperminty Wiki</em>.", "default": [] },
"max_recent_changes": { "type": "number", "description": "The maximum number of recent changes to display on the recent changes page.", "default": 512},
"export_allow_only_admins": { "type": "checkbox", "description": "Whether to only allow adminstrators to export the your wiki as a zip using the page-export module.", "default": false},
"stats_update_interval": { "type": "number", "description": "The number of seconds which should elapse before a statistics update should be scheduled. Defaults to once a day.", "default": 86400},