MediaWiki
master
|
Helper for getting output of a given wikitext page rendered by parsoid. More...
Public Member Functions | |||||||
__construct (ParsoidOutputStash $parsoidOutputStash, StatsdDataFactoryInterface $statsDataFactory, ParsoidOutputAccess $parsoidOutputAccess, HtmlTransformFactory $htmlTransformFactory, IContentHandlerFactory $contentHandlerFactory, LanguageFactory $languageFactory) | |||||||
getETag (string $suffix='') | |||||||
Returns an ETag uniquely identifying the HTML output.
| |||||||
getFlavor () | |||||||
Returns the flavor of HTML that will be generated. More... | |||||||
getHtml () | |||||||
Fetch the HTML for rendering of a given page.If the rendering is available in parsoid parser cache, return that. Otherwise, perform a parse and return the result while caching it in the parser cache.NOTE: Caching can be explicitly disabled or a force parse action can be issued. Stashing and rate limiting on stashing also applies here if specified.
| |||||||
getHtmlOutputContentLanguage () | |||||||
The content language of the HTML output after parsing. More... | |||||||
getLastModified () | |||||||
Returns the time at which the HTML was rendered.
| |||||||
getPageBundle () | |||||||
Returns the rendered HTML as a PageBundle object. More... | |||||||
getParamSettings () | |||||||
Gets the request parameters of this request.
| |||||||
getRevisionId () | |||||||
Returns the ID of the revision that is being rendered. More... | |||||||
init (PageIdentity $page, array $parameters, User $user, $revision=null, ?Bcp47Code $pageLanguage=null) | |||||||
Initializes the helper with the given parameters like the page we're dealing with, parameters gotten from the request inputs, and the revision if any is available. More... | |||||||
putHeaders (ResponseInterface $response, bool $forHtml=true) | |||||||
Set the HTTP headers based on the response generated.
| |||||||
setContent (Content $content) | |||||||
Set the content to render. More... | |||||||
setContentSource (string $source, string $model) | |||||||
Set the content to render. More... | |||||||
setFlavor (string $flavor) | |||||||
Sets the given flavor to use for Wikitext -> HTML transformations. More... | |||||||
setOffsetType ( $offsetType) | |||||||
Set the desired offset type for data-parsoid attributes. More... | |||||||
setOutputProfileVersion ( $version) | |||||||
Set the desired Parsoid profile version for the output. More... | |||||||
setPageLanguage ( $pageLanguage) | |||||||
This is equivalent of 'pageLanguageOverride' in PageConfigFactory For example, when clients call the REST API with the 'content-language' header to effect language variant conversion. More... | |||||||
setRevision ( $revisionOrId) | |||||||
Set the revision to render. More... | |||||||
setStashingEnabled (bool $stash) | |||||||
Determine whether stashing should be applied. More... | |||||||
setUseParserCache (bool $read, bool $write) | |||||||
Controls how the parser cache is used. More... | |||||||
setVariantConversionLanguage ( $targetLanguage, $sourceLanguage=null) | |||||||
Set the language to be used for variant conversion.
| |||||||
Helper for getting output of a given wikitext page rendered by parsoid.
Definition at line 69 of file HtmlOutputRendererHelper.php.
MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::__construct | ( | ParsoidOutputStash | $parsoidOutputStash, |
StatsdDataFactoryInterface | $statsDataFactory, | ||
ParsoidOutputAccess | $parsoidOutputAccess, | ||
HtmlTransformFactory | $htmlTransformFactory, | ||
IContentHandlerFactory | $contentHandlerFactory, | ||
LanguageFactory | $languageFactory | ||
) |
ParsoidOutputStash | $parsoidOutputStash | |
StatsdDataFactoryInterface | $statsDataFactory | |
ParsoidOutputAccess | $parsoidOutputAccess | |
HtmlTransformFactory | $htmlTransformFactory | |
IContentHandlerFactory | $contentHandlerFactory | |
LanguageFactory | $languageFactory |
Definition at line 159 of file HtmlOutputRendererHelper.php.
MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::getETag | ( | string | $suffix = '' | ) |
Returns an ETag uniquely identifying the HTML output.
string | $suffix | A suffix to attach to the etag. |
Implements MediaWiki\Rest\Handler\Helper\HtmlOutputHelper.
Definition at line 498 of file HtmlOutputRendererHelper.php.
MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::getFlavor | ( | ) |
Returns the flavor of HTML that will be generated.
Definition at line 207 of file HtmlOutputRendererHelper.php.
MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::getHtml | ( | ) |
Fetch the HTML for rendering of a given page.If the rendering is available in parsoid parser cache, return that. Otherwise, perform a parse and return the result while caching it in the parser cache.NOTE: Caching can be explicitly disabled or a force parse action can be issued. Stashing and rate limiting on stashing also applies here if specified.
LocalizedHttpException | |
ClientError |
Implements MediaWiki\Rest\Handler\Helper\HtmlOutputHelper.
Definition at line 430 of file HtmlOutputRendererHelper.php.
MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::getHtmlOutputContentLanguage | ( | ) |
The content language of the HTML output after parsing.
Definition at line 616 of file HtmlOutputRendererHelper.php.
MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::getLastModified | ( | ) |
Returns the time at which the HTML was rendered.
Implements MediaWiki\Rest\Handler\Helper\HtmlOutputHelper.
Definition at line 519 of file HtmlOutputRendererHelper.php.
MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::getPageBundle | ( | ) |
Returns the rendered HTML as a PageBundle object.
Definition at line 668 of file HtmlOutputRendererHelper.php.
MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::getParamSettings | ( | ) |
Gets the request parameters of this request.
Implements MediaWiki\Rest\Handler\Helper\HtmlOutputHelper.
Definition at line 526 of file HtmlOutputRendererHelper.php.
MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::getRevisionId | ( | ) |
Returns the ID of the revision that is being rendered.
This will return 0 if no revision has been specified, so the current revision will be rendered.
This wil return null if RevisionRecord has been set but that RevisionRecord does not have a revision ID, e.g. when rendering a preview.
Definition at line 698 of file HtmlOutputRendererHelper.php.
MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::init | ( | PageIdentity | $page, |
array | $parameters, | ||
User | $user, | ||
$revision = null , |
|||
?Bcp47Code | $pageLanguage = null |
||
) |
Initializes the helper with the given parameters like the page we're dealing with, parameters gotten from the request inputs, and the revision if any is available.
PageIdentity | $page | |
array | $parameters | |
User | $user | |
RevisionRecord | int | null | $revision | |
?Bcp47Code | $pageLanguage |
Definition at line 378 of file HtmlOutputRendererHelper.php.
MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::putHeaders | ( | ResponseInterface | $response, |
bool | $forHtml = true |
||
) |
Set the HTTP headers based on the response generated.
ResponseInterface | $response | |
bool | $forHtml | Whether the response will be HTML (rather than JSON) |
Implements MediaWiki\Rest\Handler\Helper\HtmlOutputHelper.
Definition at line 637 of file HtmlOutputRendererHelper.php.
References MediaWiki\Rest\ResponseInterface\setHeader().
MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::setContent | ( | Content | $content | ) |
Set the content to render.
Useful when rendering for previews or when switching the editor from source mode to visual mode.
This will create a fake revision for rendering, the revision ID will be 0.
Content | $content |
Definition at line 322 of file HtmlOutputRendererHelper.php.
MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::setContentSource | ( | string | $source, |
string | $model | ||
) |
Set the content to render.
Useful when rendering for previews or when switching the editor from source mode to visual mode.
This will create a fake revision for rendering, the revision ID will be 0.
string | $source | The source data, e.g. wikitext |
string | $model | The content model indicating how to interpret $source, e.g. CONTENT_MODEL_WIKITEXT |
Definition at line 342 of file HtmlOutputRendererHelper.php.
MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::setFlavor | ( | string | $flavor | ) |
Sets the given flavor to use for Wikitext -> HTML transformations.
Flavors may influence parser options, parsoid options, and DOM transformations. They will be reflected by the ETag returned by getETag().
string | $flavor |
Definition at line 189 of file HtmlOutputRendererHelper.php.
MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::setOffsetType | ( | $offsetType | ) |
Set the desired offset type for data-parsoid attributes.
string | $offsetType | One of the offset types accepted by Parsoid::wikitext2html. |
Definition at line 244 of file HtmlOutputRendererHelper.php.
MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::setOutputProfileVersion | ( | $version | ) |
Set the desired Parsoid profile version for the output.
The actual output version is selected to be compatible with the one given here, per the rules of semantic versioning.
string | $version |
HttpException | If the given version is not supported (status 406) |
Definition at line 222 of file HtmlOutputRendererHelper.php.
MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::setPageLanguage | ( | $pageLanguage | ) |
This is equivalent of 'pageLanguageOverride' in PageConfigFactory For example, when clients call the REST API with the 'content-language' header to effect language variant conversion.
Bcp47Code | string | $pageLanguage | the page language, as a Bcp47Code or a BCP-47 string. |
Definition at line 360 of file HtmlOutputRendererHelper.php.
MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::setRevision | ( | $revisionOrId | ) |
Set the revision to render.
This can take a fake RevisionRecord when rendering for previews or when switching the editor from source mode to visual mode.
In that case, $revisionOrId->getId() must return 0 to indicate that the ParserCache should be bypassed. Stashing may still apply.
RevisionRecord | int | $revisionOrId |
Definition at line 293 of file HtmlOutputRendererHelper.php.
MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::setStashingEnabled | ( | bool | $stash | ) |
Determine whether stashing should be applied.
bool | $stash |
Definition at line 272 of file HtmlOutputRendererHelper.php.
MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::setUseParserCache | ( | bool | $read, |
bool | $write | ||
) |
Controls how the parser cache is used.
bool | $read | Whether we should look for cached output before parsing |
bool | $write | Whether we should cache output after parsing |
Definition at line 259 of file HtmlOutputRendererHelper.php.
MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::setVariantConversionLanguage | ( | $targetLanguage, | |
$sourceLanguage = null |
|||
) |
Set the language to be used for variant conversion.
Bcp47Code | string | $targetLanguage | |
Bcp47Code | string | null | $sourceLanguage |
Implements MediaWiki\Rest\Handler\Helper\HtmlOutputHelper.
Definition at line 409 of file HtmlOutputRendererHelper.php.
References LanguageCode\normalizeNonstandardCodeAndWarn().