Module: preview/model

Members

(inner, constant) previewTypes :Object

Page Preview types as defined in Schema:Popups https://meta.wikimedia.org/wiki/Schema:Popups

Type:
  • Object
Source:

Methods

(static) createModel(title, url, languageCode, languageDirection, extract, type, thumbnailopt, pageIdopt) → {PreviewModel}

Creates a preview model.

Parameters:
Name Type Attributes Description
title string
url string

The canonical URL of the page being previewed

languageCode string
languageDirection string

Either "ltr" or "rtl"

extract Array | undefined | null
type string
thumbnail Object <optional>
pageId number <optional>
Source:
Returns:
Type
PreviewModel

(static) createNullModel(title, url) → {PreviewModel}

Creates an empty preview model.

Parameters:
Name Type Description
title string
url string
Source:
Returns:
Type
PreviewModel

(inner) getPreviewType(type, processedExtractopt) → {string}

Determines the preview type based on whether or not: a. Is the preview empty. b. The preview type matches one of previewTypes. c. Assume standard page preview if both above are false

Parameters:
Name Type Attributes Description
type string
processedExtract string <optional>
Source:
Returns:

One of the previewTypes.TYPE_… constants.

Type
string

(inner) processExtract(extract) → {Array|undefined}

Processes the extract returned by the TextExtracts MediaWiki API query module.

If the extract is undefined, null, or empty, then undefined is returned.

Parameters:
Name Type Description
extract Array | undefined | null
Source:
Returns:

Array when extract is an not empty array, undefined otherwise

Type
Array | undefined