Pepperminty Wiki Module API

page_renderer
in package

Renders the HTML page that is sent to the client.

Table of Contents

$html_template  : string
The root HTML template that all pages are built from.
$main_content_template  : string
The main content template that is used to render normal wiki pages.
$minimal_content_template  : string
A specially minified content template that doesn't include the navbar and other elements not suitable for printing.
$nav_divider  : string
The navigation bar divider.
add_header_html()  : mixed
Adds a string of HTML to the header of the rendered page.
add_js_link()  : mixed
Adds the specified url to a javascript file as a reference to the page.
add_js_snippet()  : mixed
Adds a javascript snippet to the page.
add_server_push_indicator()  : mixed
Adds a resource to the list of items to indicate that the web server should send via HTTP/2.0 Server Push.
generate_all_pages_datalist()  : string
Renders the datalist for the search box as HTML.
get_css_as_html()  : string
Renders all the CSS as HTML.
get_header_html()  : string
Renders the header HTML.
is_css_url()  : bool
Figures out whether $settings->css is a url, or a string of css.
register_part_preprocessor()  : mixed
Registers a function as a part post processor.
render()  : string
Renders a HTML page with the content specified.
render_main()  : string
Renders a normal HTML page.
render_minimal()  : string
Renders a minimal HTML page. Useful for printable pages.
render_navigation_bar()  : mixed
Renders a navigation bar from an array of links. See $settings->nav_links for format information.
render_username()  : string
Renders a username for inclusion in a page.
send_server_push_indicators()  : int|false
Sends the currently registered HTTP2 server push items to the client.

Properties

$html_template

The root HTML template that all pages are built from.

public static string $html_template = "<!DOCTYPE html>\n<html>\n\t<head>\n\t\t<meta charset='utf-8' />\n\t\t<title>{title}</title>\n\t\t<meta name='viewport' content='width=device-width, initial-scale=1' />\n\t\t<meta name='generator' content='Pepperminty Wiki {version}' />\n\t\t<meta name='application-name' content='Pepperminty Wiki {version}' />\n\t\t<link rel='shortcut-icon' href='{favicon-url}' />\n\t\t<link rel='icon' href='{favicon-url}' />\n\t\t{header-html}\n\t</head>\n\t<body>\n\t\t{body}\n\t\t<!-- Took {generation-time-taken}ms to generate -->\n\t</body>\n</html>\n"

$main_content_template

The main content template that is used to render normal wiki pages.

public static string $main_content_template = "{navigation-bar}\n\t\t<h1 class='sitename'>{sitename}</h1>\n\t\t<main>\n\t\t{content}\n\t\t</main>\n\t\t{extra}\n\t\t<footer>\n\t\t\t<p>{footer-message}</p>\n\t\t\t<p>Powered by Pepperminty Wiki {version}, which was built by <a href='//starbeamrainbowlabs.com/'>Starbeamrainbowlabs</a>. Send bugs to 'bugs at starbeamrainbowlabs dot com' or <a href='//github.com/sbrl/Pepperminty-Wiki' title='Github Issue Tracker'>open an issue</a>.</p>\n\t\t\t<p>Your local friendly moderators are {admins-name-list}.</p>\n\t\t\t<p>This wiki is managed by {admin-details}.</p>\n\t\t</footer>\n\t\t{navigation-bar-bottom}\n\t\t{all-pages-datalist}"

$minimal_content_template

A specially minified content template that doesn't include the navbar and other elements not suitable for printing.

public static string $minimal_content_template = "<main class='printable'>{content}</main>\n\t\t<footer class='printable'>\n\t\t\t<hr class='footerdivider' />\n\t\t\t<p><em>From {sitename}, which is managed by {admin-details-name}.</em></p>\n\t\t\t<p>{footer-message}</p>\n\t\t\t<p><em>Timed at {generation-date}</em></p>\n\t\t\t<p><em>Powered by Pepperminty Wiki {version}.</em></p>\n\t\t</footer>"

$nav_divider

The navigation bar divider.

public static string $nav_divider = "<span class='nav-divider inflexible'> | </span>"

Methods

add_header_html()

Adds a string of HTML to the header of the rendered page.

public static add_header_html(string $html) : mixed
Parameters
$html : string

The string of HTML to add.

Return values
mixed

Adds the specified url to a javascript file as a reference to the page.

public static add_js_link(string $scriptUrl) : mixed
Parameters
$scriptUrl : string

The url of the javascript file to reference.

Return values
mixed

add_js_snippet()

Adds a javascript snippet to the page.

public static add_js_snippet(string $script) : mixed
Parameters
$script : string

The snippet of javascript to add.

Return values
mixed

add_server_push_indicator()

Adds a resource to the list of items to indicate that the web server should send via HTTP/2.0 Server Push.

public static add_server_push_indicator(string $type, string $path) : mixed

Note: Only specify static files here, as you might end up with strange (and possibly dangerous) results!

Parameters
$type : string

The resource type. See https://fetch.spec.whatwg.org/#concept-request-destination for more information.

$path : string

The relative url path to the resource.

Return values
mixed

generate_all_pages_datalist()

Renders the datalist for the search box as HTML.

public static generate_all_pages_datalist() : string
Return values
string

The search box datalist as HTML.

get_css_as_html()

Renders all the CSS as HTML.

public static get_css_as_html() : string
Return values
string

The css as HTML, ready to be included in the HTML header.

get_header_html()

Renders the header HTML.

public static get_header_html() : string
Return values
string

The rendered HTML that goes in the header.

is_css_url()

Figures out whether $settings->css is a url, or a string of css.

public static is_css_url(string $str) : bool

A url is something starting with "protocol://" or simply a "/". Before v0.20, this method took no arguments and checked $settings->css directly.

Parameters
$str : string

The CSS string to check.

Tags
since
0.20.0
Return values
bool

True if it's a url - false if we assume it's a string of css.

register_part_preprocessor()

Registers a function as a part post processor.

public static register_part_preprocessor(callable $function) : mixed

This function's use is more complicated to explain. Pepperminty Wiki renders pages with a very simple templating system. For example, in the template a page's content is denoted by {content}. A function registered here will be passed all the components of a page just before they are dropped into the template. Note that the function you pass in here should take a reference to the components, as the return value of the function passed is discarded.

Parameters
$function : callable

The part preprocessor to register.

Return values
mixed

render()

Renders a HTML page with the content specified.

public static render(string $title, string $content[, bool $body_template = false ]) : string
Parameters
$title : string

The title of the page.

$content : string

The (HTML) content of the page.

$body_template : bool = false

The HTML content template to use.

Return values
string

The rendered HTML, ready to send to the client :-)

render_main()

Renders a normal HTML page.

public static render_main(string $title, string $content) : string
Parameters
$title : string

The title of the page.

$content : string

The content of the page.

Return values
string

The rendered page.

render_minimal()

Renders a minimal HTML page. Useful for printable pages.

public static render_minimal(string $title, string $content) : string
Parameters
$title : string

The title of the page.

$content : string

The content of the page.

Return values
string

The rendered page.

render_navigation_bar()

Renders a navigation bar from an array of links. See $settings->nav_links for format information.

public static render_navigation_bar(array<string|int, mixed> $nav_links, array<string|int, mixed> $nav_links_extra[, string $class = "" ]) : mixed
Parameters
$nav_links : array<string|int, mixed>

The links to add to the navigation bar.

$nav_links_extra : array<string|int, mixed>

The extra nav links to add to the "More..." menu.

$class : string = ""

The class(es) to assign to the rendered navigation bar.

Return values
mixed

render_username()

Renders a username for inclusion in a page.

public static render_username(string $name) : string
Parameters
$name : string

The username to render.

Return values
string

The username rendered in HTML.

send_server_push_indicators()

Sends the currently registered HTTP2 server push items to the client.

public static send_server_push_indicators() : int|false
Return values
int|false

The number of resource hints included in the link: header, or false if server pushing is disabled.

Search results