Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F2752266
page.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
page.js
View Options
import
constants
from
'../constants'
;
import
createMediaWikiApiGateway
from
'./mediawiki'
;
import
createRESTBaseGateway
from
'./rest'
;
import
*
as
formatters
from
'./restFormatters'
;
import
{
abortablePromise
}
from
'./index.js'
;
/**
* @module gateway/page
* @private
*/
/**
* @param {Object} options
* @return {Promise}
*/
function
ajax
(
options
)
{
const
controller
=
new
AbortController
();
const
signal
=
controller
.
signal
;
return
abortablePromise
(
fetch
(
options
.
url
,
{
headers
:
options
.
headers
,
signal
}
).
then
(
(
resp
)
=>
resp
.
json
()
),
()
=>
{
controller
.
abort
();
}
);
}
/**
* Creates a page preview gateway with sensible values for the dependencies.
*
* @param {mw.Map} config
* @return {Gateway}
*/
export
default
function
createPagePreviewGateway
(
config
)
{
const
gatewayConfig
=
Object
.
assign
(
{},
constants
,
{
acceptLanguage
:
config
.
get
(
'wgPageContentLanguage'
)
}
);
const
restConfig
=
Object
.
assign
(
{},
gatewayConfig
,
{
endpoint
:
config
.
get
(
'wgPopupsRestGatewayEndpoint'
)
}
);
switch
(
config
.
get
(
'wgPopupsGateway'
)
)
{
case
'mwApiPlain'
:
return
createMediaWikiApiGateway
(
new
mw
.
Api
(),
gatewayConfig
);
case
'restbasePlain'
:
return
createRESTBaseGateway
(
ajax
,
restConfig
,
formatters
.
parsePlainTextResponse
);
case
'restbaseHTML'
:
return
createRESTBaseGateway
(
ajax
,
restConfig
,
formatters
.
parseHTMLResponse
);
default
:
throw
new
Error
(
'Unknown gateway'
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Fri, Jul 3, 19:48 (1 d, 3 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
37/e8/0722ccfacb2f87a20b0e720a1a01
Default Alt Text
page.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment