mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-23 14:36:51 +00:00
Move Cite-specific settings from WikiEditor
The WikiEditor extension has a button and some help text that is only applicable if the Cite extension is enabled. Move that (with some modifications) to the Cite extension instead. Bug: T339973 Depends-On: I8256660f9c6886d6764b45735284e00308fc56e5 Change-Id: Ib3fdc897dd3330f69c5832003d4c3cb1e6dba2f3
This commit is contained in:
parent
bad83bbb21
commit
c66371b3d9
|
@ -34,6 +34,7 @@ Jackmcbarn
|
|||
James D. Forrester
|
||||
Jan Paul Posma
|
||||
Jens Frank
|
||||
Jon Harald Søby
|
||||
Jon Robson
|
||||
Kaity Hammerstein
|
||||
Kevin Brown
|
||||
|
|
|
@ -30,11 +30,15 @@
|
|||
"ParserClearState": "parser",
|
||||
"ParserCloned": "parser",
|
||||
"ParserFirstCallInit": "parser",
|
||||
"EditPage::showEditForm:initial": "main",
|
||||
"ResourceLoaderGetConfigVars": "main"
|
||||
},
|
||||
"HookHandlers": {
|
||||
"main": {
|
||||
"class": "Cite\\Hooks\\CiteHooks"
|
||||
"class": "Cite\\Hooks\\CiteHooks",
|
||||
"services": [
|
||||
"UserOptionsLookup"
|
||||
]
|
||||
},
|
||||
"parser": {
|
||||
"class": "Cite\\Hooks\\CiteParserHooks"
|
||||
|
@ -185,6 +189,40 @@
|
|||
"mobile"
|
||||
]
|
||||
},
|
||||
"ext.cite.wikiEditor": {
|
||||
"localBasePath": "modules",
|
||||
"remoteExtPath": "Cite/modules",
|
||||
"scripts": [
|
||||
"ext.cite.wikiEditor.js"
|
||||
],
|
||||
"dependencies": [
|
||||
"ext.wikiEditor",
|
||||
"mediawiki.jqueryMsg",
|
||||
"mediawiki.language"
|
||||
],
|
||||
"messages": [
|
||||
"cite-wikieditor-tool-reference",
|
||||
"cite-wikieditor-help-page-references",
|
||||
"cite-wikieditor-help-content-reference-example-text1",
|
||||
"cite-wikieditor-help-content-reference-example-text2",
|
||||
"cite-wikieditor-help-content-reference-example-text3",
|
||||
"cite-wikieditor-help-content-reference-example-ref-id",
|
||||
"cite-wikieditor-help-content-reference-example-ref-normal",
|
||||
"cite-wikieditor-help-content-reference-example-ref-named",
|
||||
"cite-wikieditor-help-content-reference-example-ref-reuse",
|
||||
"cite-wikieditor-help-content-reference-example-ref-result",
|
||||
"cite-wikieditor-help-content-reference-example-reflist",
|
||||
"cite-wikieditor-help-content-reference-description",
|
||||
"cite-wikieditor-help-content-named-reference-description",
|
||||
"cite-wikieditor-help-content-rereference-description",
|
||||
"cite-wikieditor-help-content-showreferences-description",
|
||||
"cite_reference_backlink_symbol"
|
||||
],
|
||||
"targets": [
|
||||
"desktop",
|
||||
"mobile"
|
||||
]
|
||||
},
|
||||
"ext.cite.ux-enhancements": {
|
||||
"localBasePath": "modules",
|
||||
"remoteExtPath": "Cite/modules",
|
||||
|
|
22
i18n/en.json
22
i18n/en.json
|
@ -43,10 +43,11 @@
|
|||
"cite_reference_link_suffix": "",
|
||||
"cite_references_link_prefix": "cite_note-",
|
||||
"cite_references_link_suffix": "",
|
||||
"cite_reference_backlink_symbol": "↑",
|
||||
"cite_reference_link": "<sup id=\"$1\" class=\"reference\">[[#$2|[$3]]]</sup>",
|
||||
"cite_references_no_link": "<p id=\"$1\">$2</p>",
|
||||
"cite_references_link_one": "<li id=\"$1\"$4><span class=\"mw-cite-backlink\">[[#$2|↑]]</span> $3</li>",
|
||||
"cite_references_link_many": "<li id=\"$1\"$4><span class=\"mw-cite-backlink\">↑ $2</span> $3</li>",
|
||||
"cite_references_link_one": "<li id=\"$1\"$4><span class=\"mw-cite-backlink\">[[#$2|$5]]</span> $3</li>",
|
||||
"cite_references_link_many": "<li id=\"$1\"$4><span class=\"mw-cite-backlink\">$5 $2</span> $3</li>",
|
||||
"cite_references_link_many_format": "<sup>[[#$1|$2]]</sup>",
|
||||
"cite_references_link_many_format_backlink_labels": "a b c d e f g h i j k l m n o p q r s t u v w x y z aa ab ac ad ae af ag ah ai aj ak al am an ao ap aq ar as at au av aw ax ay az ba bb bc bd be bf bg bh bi bj bk bl bm bn bo bp bq br bs bt bu bv bw bx by bz ca cb cc cd ce cf cg ch ci cj ck cl cm cn co cp cq cr cs ct cu cv cw cx cy cz da db dc dd de df dg dh di dj dk dl dm dn do dp dq dr ds dt du dv dw dx dy dz ea eb ec ed ee ef eg eh ei ej ek el em en eo ep eq er es et eu ev ew ex ey ez fa fb fc fd fe ff fg fh fi fj fk fl fm fn fo fp fq fr fs ft fu fv fw fx fy fz ga gb gc gd ge gf gg gh gi gj gk gl gm gn go gp gq gr gs gt gu gv gw gx gy gz ha hb hc hd he hf hg hh hi hj hk hl hm hn ho hp hq hr hs ht hu hv hw hx hy hz ia ib ic id ie if ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq jr js jt ju jv jw jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc ld le lf lg lh li lj lk ll lm ln lo lp lq lr ls lt lu lv lw lx ly lz ma mb mc md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe of og oh oi oj ok ol om on oo op oq or os ot ou ov ow ox oy oz pa pb pc pd pe pf pg ph pi pj pk pl pm pn po pp pq pr ps pt pu pv pw px py pz qa qb qc qd qe qf qg qh qi qj qk ql qm qn qo qp qq qr qs qt qu qv qw qx qy qz ra rb rc rd re rf rg rh ri rj rk rl rm rn ro rp rq rr rs rt ru rv rw rx ry rz sa sb sc sd se sf sg sh si sj sk sl sm sn so sp sq sr ss st su sv sw sx sy sz ta tb tc td te tf tg th ti tj tk tl tm tn to tp tq tr ts tt tu tv tw tx ty tz ua ub uc ud ue uf ug uh ui uj uk ul um un uo up uq ur us ut uu uv uw ux uy uz va vb vc vd ve vf vg vh vi vj vk vl vm vn vo vp vq vr vs vt vu vv vw vx vy vz wa wb wc wd we wf wg wh wi wj wk wl wm wn wo wp wq wr ws wt wu wv ww wx wy wz xa xb xc xd xe xf xg xh xi xj xk xl xm xn xo xp xq xr xs xt xu xv xw xx xy xz ya yb yc yd ye yf yg yh yi yj yk yl ym yn yo yp yq yr ys yt yu yv yw yx yy yz za zb zc zd ze zf zg zh zi zj zk zl zm zn zo zp zq zr zs zt zu zv zw zx zy zz",
|
||||
"cite_references_link_many_sep": " ",
|
||||
|
@ -56,5 +57,20 @@
|
|||
"cite_references_link_accessibility_back_label": "Jump back up",
|
||||
"cite_section_preview_references": "Preview of references",
|
||||
"cite_warning": "Cite warning: $1",
|
||||
"cite_warning_sectionpreview_no_text": "<code><ref></code> tag with name <code>$1</code> cannot be previewed because it is defined outside the current section or not defined at all."
|
||||
"cite_warning_sectionpreview_no_text": "<code><ref></code> tag with name <code>$1</code> cannot be previewed because it is defined outside the current section or not defined at all.",
|
||||
"cite-wikieditor-tool-reference": "Reference",
|
||||
"cite-wikieditor-help-page-references": "References",
|
||||
"cite-wikieditor-help-content-reference-description": "Reference",
|
||||
"cite-wikieditor-help-content-named-reference-description": "Named reference",
|
||||
"cite-wikieditor-help-content-rereference-description": "Additional use of the same reference",
|
||||
"cite-wikieditor-help-content-showreferences-description": "Display references",
|
||||
"cite-wikieditor-help-content-reference-example-text1": "Page text.$1",
|
||||
"cite-wikieditor-help-content-reference-example-text2": "[$1 Link text], additional text.",
|
||||
"cite-wikieditor-help-content-reference-example-text3": "[$1 Link text]",
|
||||
"cite-wikieditor-help-content-reference-example-ref-id": "test",
|
||||
"cite-wikieditor-help-content-reference-example-ref-normal": "<ref>$1</ref>",
|
||||
"cite-wikieditor-help-content-reference-example-ref-named": "<ref name=\"$1\">$2</ref>",
|
||||
"cite-wikieditor-help-content-reference-example-ref-reuse": "<ref name=\"$1\" />",
|
||||
"cite-wikieditor-help-content-reference-example-ref-result": "[$1]",
|
||||
"cite-wikieditor-help-content-reference-example-reflist": "<references />"
|
||||
}
|
||||
|
|
|
@ -47,10 +47,11 @@
|
|||
"cite_reference_link_suffix": "{{notranslate}}",
|
||||
"cite_references_link_prefix": "{{notranslate}}",
|
||||
"cite_references_link_suffix": "{{ignored}}",
|
||||
"cite_reference_backlink_symbol": "{{optional}}\nSymbol used for the reference section, used to link back to where the reference is used.",
|
||||
"cite_reference_link": "{{notranslate}}\n\nParameters:\n* $1 - ref key\n* $2 - references key\n* $3 - link label",
|
||||
"cite_references_no_link": "{{notranslate}}\n\nParameters:\n* $1 - references key\n* $2 - reference text",
|
||||
"cite_references_link_one": "{{notranslate}}\n\nParameters:\n* $1 - references key\n* $2 - ref key\n* $3 - reference text\n* $4 - optional CSS class for direction",
|
||||
"cite_references_link_many": "{{notranslate}}\n\nParameters:\n* $1 - references key\n* $2 - list of links\n* $3 - reference text\n* $4 - optional CSS class for direction",
|
||||
"cite_references_link_one": "{{notranslate}}\n\nParameters:\n* $1 - references key\n* $2 - ref key\n* $3 - reference text\n* $4 - optional CSS class for direction\n* $5 - {{msg-mw|cite_reference_backlink_symbol}}",
|
||||
"cite_references_link_many": "{{notranslate}}\n\nParameters:\n* $1 - references key\n* $2 - list of links\n* $3 - reference text\n* $4 - optional CSS class for direction\n* $5 - {{msg-mw|cite_reference_backlink_symbol}}",
|
||||
"cite_references_link_many_format": "{{notranslate}}\n\nParameters:\n* $1 - reference key\n* $2 - canonical numeric backlink label for the link, always in the form \"1.2\"\n* $3 - optional alternate backlink label as defined via [[MediaWiki:cite_references_link_many_format_backlink_labels]]",
|
||||
"cite_references_link_many_format_backlink_labels": "{{Optional}}",
|
||||
"cite_references_link_many_sep": "{{notranslate}}",
|
||||
|
@ -60,5 +61,20 @@
|
|||
"cite_references_link_accessibility_back_label": "Text for screen readers to describe the jump back to the last citation clicked for citations used in multiple places.",
|
||||
"cite_section_preview_references": "Header for the section providing a preview of references in section preview",
|
||||
"cite_warning": "Used when there are warnings about ref or references tags (less severe than errors).\n\nParameters:\n* $1 - a warning message",
|
||||
"cite_warning_sectionpreview_no_text": "This warning occurs when the tag <code><ref name=\"something\"/></code> is used with the name-option specified but the definition for this named ref is outside of the currently being previewed section, or not defined at all.\n\nParameters:\n* $1 - key of the ref"
|
||||
"cite_warning_sectionpreview_no_text": "This warning occurs when the tag <code><ref name=\"something\"/></code> is used with the name-option specified but the definition for this named ref is outside of the currently being previewed section, or not defined at all.\n\nParameters:\n* $1 - key of the ref",
|
||||
"cite-wikieditor-tool-reference": "Tooltip for the insert reference button in the WikiEditor tool bar.\n\n{{doc-jqueryMsg}}",
|
||||
"cite-wikieditor-help-page-references": "Header for the reference section in WikiEditor's help menu.\n\n{{doc-jqueryMsg}}",
|
||||
"cite-wikieditor-help-content-reference-description": "Row header in WikiEditor's reference help section.\n\n{{doc-jqueryMsg}}",
|
||||
"cite-wikieditor-help-content-named-reference-description": "Row header in WikiEditor's reference help section.\n\n{{doc-jqueryMsg}}",
|
||||
"cite-wikieditor-help-content-rereference-description": "Row header in WikiEditor's reference help section.\n\n{{doc-jqueryMsg}}",
|
||||
"cite-wikieditor-help-content-showreferences-description": "Row header in WikiEditor's reference help section.\n\n{{doc-jqueryMsg}}",
|
||||
"cite-wikieditor-help-content-reference-example-text1": "Short sample text with a reference.\n\nParameters:\n* $1 - a <ref> tag\n\n{{doc-jqueryMsg}}",
|
||||
"cite-wikieditor-help-content-reference-example-text2": "Short sample of something that can be put between <ref> tags.\n\nParameters:\n* $1 - a URL\n\n{{doc-jqueryMsg}}",
|
||||
"cite-wikieditor-help-content-reference-example-text3": "Short sample of external link syntax.\n\nParameters:\n* $1 - a URL\n\n{{doc-jqueryMsg}}",
|
||||
"cite-wikieditor-help-content-reference-example-ref-id": "{{optional}}\nUsed as an example of a name for a reference.",
|
||||
"cite-wikieditor-help-content-reference-example-ref-normal": "{{ignored}}",
|
||||
"cite-wikieditor-help-content-reference-example-ref-named": "{{ignored}}",
|
||||
"cite-wikieditor-help-content-reference-example-ref-reuse": "{{ignored}}",
|
||||
"cite-wikieditor-help-content-reference-example-ref-result": "{{ignored}}",
|
||||
"cite-wikieditor-help-content-reference-example-reflist": "{{ignored}}"
|
||||
}
|
||||
|
|
112
modules/ext.cite.wikiEditor.js
Normal file
112
modules/ext.cite.wikiEditor.js
Normal file
|
@ -0,0 +1,112 @@
|
|||
/**
|
||||
* Add Cite-specific functionality to the WikiEditor toolbar.
|
||||
* Adds a button to insert <ref> tags, and adds a help section
|
||||
* about how to use references to WikiEditor's help panel.
|
||||
*
|
||||
* @author Jon Harald Søby
|
||||
*/
|
||||
|
||||
$( function () {
|
||||
mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) {
|
||||
/* Add the <ref></ref> button to the toolbar */
|
||||
$textarea.wikiEditor( 'addToToolbar', {
|
||||
section: 'main',
|
||||
group: 'insert',
|
||||
tools: {
|
||||
reference: {
|
||||
labelMsg: 'cite-wikieditor-tool-reference',
|
||||
filters: [ 'body.ns-subject' ],
|
||||
type: 'button',
|
||||
oouiIcon: 'reference',
|
||||
action: {
|
||||
type: 'encapsulate',
|
||||
options: {
|
||||
pre: '<ref>',
|
||||
post: '</ref>'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
/* Add reference help to the Help section */
|
||||
var parsedRef = function ( number ) {
|
||||
return $( '<sup>' )
|
||||
.addClass( 'reference' )
|
||||
.append(
|
||||
$( '<a>' )
|
||||
.attr( 'href', '#' )
|
||||
.text(
|
||||
mw.message( 'cite-wikieditor-help-content-reference-example-ref-result', mw.language.convertNumber( number ) ).text()
|
||||
)
|
||||
);
|
||||
};
|
||||
$textarea.wikiEditor( 'addToToolbar', {
|
||||
section: 'help',
|
||||
pages: {
|
||||
references: {
|
||||
labelMsg: 'cite-wikieditor-help-page-references',
|
||||
layout: 'table',
|
||||
headings: [
|
||||
{ textMsg: 'wikieditor-toolbar-help-heading-description' },
|
||||
{ textMsg: 'wikieditor-toolbar-help-heading-syntax' },
|
||||
{ textMsg: 'wikieditor-toolbar-help-heading-result' }
|
||||
],
|
||||
rows: [
|
||||
{
|
||||
description: { html: mw.message( 'cite-wikieditor-help-content-reference-description' ).parse() },
|
||||
syntax: {
|
||||
html: mw.html.escape(
|
||||
mw.message( 'cite-wikieditor-help-content-reference-example-text1', mw.message( 'cite-wikieditor-help-content-reference-example-ref-normal', mw.message( 'cite-wikieditor-help-content-reference-example-text2', 'https://www.example.org/' ).plain() ).plain() ).plain()
|
||||
)
|
||||
},
|
||||
result: {
|
||||
html: mw.message( 'cite-wikieditor-help-content-reference-example-text1', parsedRef( 1 ) ).parse()
|
||||
}
|
||||
},
|
||||
{
|
||||
description: { html: mw.message( 'cite-wikieditor-help-content-named-reference-description' ).parse() },
|
||||
syntax: {
|
||||
html: mw.html.escape(
|
||||
mw.message( 'cite-wikieditor-help-content-reference-example-text1', mw.message( 'cite-wikieditor-help-content-reference-example-ref-named', mw.message( 'cite-wikieditor-help-content-reference-example-ref-id' ).plain(), mw.message( 'cite-wikieditor-help-content-reference-example-text3', 'https://www.example.org/' ).plain() ).plain() ).plain()
|
||||
)
|
||||
},
|
||||
result: {
|
||||
html: mw.message( 'cite-wikieditor-help-content-reference-example-text1', parsedRef( 2 ) ).parse()
|
||||
}
|
||||
},
|
||||
{
|
||||
description: { html: mw.message( 'cite-wikieditor-help-content-rereference-description' ).parse() },
|
||||
syntax: {
|
||||
html: mw.html.escape(
|
||||
mw.message( 'cite-wikieditor-help-content-reference-example-text1', mw.message( 'cite-wikieditor-help-content-reference-example-ref-reuse', mw.message( 'cite-wikieditor-help-content-reference-example-ref-id' ).plain() ).plain() ).plain()
|
||||
)
|
||||
},
|
||||
result: {
|
||||
html: mw.message( 'cite-wikieditor-help-content-reference-example-text1', parsedRef( 2 ) ).parse()
|
||||
}
|
||||
},
|
||||
{
|
||||
description: { html: mw.message( 'cite-wikieditor-help-content-showreferences-description' ).parse() },
|
||||
syntax: {
|
||||
html: mw.message( 'cite-wikieditor-help-content-reference-example-reflist' ).escaped()
|
||||
},
|
||||
result: {
|
||||
html: '<ol class="references">' +
|
||||
'<li><span class="mw-cite-backlink"><a href="#">' +
|
||||
mw.message( 'cite_reference_backlink_symbol' ).parse() + '</a></span> ' +
|
||||
mw.message( 'cite-wikieditor-help-content-reference-example-text2', window.location.href + '#' ).parse() +
|
||||
'</li>' +
|
||||
'<li><span class="mw-cite-backlink"><a href="#">' +
|
||||
mw.message( 'cite_reference_backlink_symbol' ).parse() +
|
||||
'</a></span> ' +
|
||||
mw.message( 'cite-wikieditor-help-content-reference-example-text3', window.location.href + '#' ).parse() +
|
||||
'</li></ol>'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
} );
|
||||
} );
|
||||
}() );
|
|
@ -8,16 +8,36 @@ namespace Cite\Hooks;
|
|||
|
||||
use ApiQuerySiteinfo;
|
||||
use Config;
|
||||
use ExtensionRegistry;
|
||||
use MediaWiki\Api\Hook\APIQuerySiteInfoGeneralInfoHook;
|
||||
use MediaWiki\EditPage\EditPage;
|
||||
use MediaWiki\Hook\EditPage__showEditForm_initialHook;
|
||||
use MediaWiki\ResourceLoader\Hook\ResourceLoaderGetConfigVarsHook;
|
||||
use MediaWiki\Revision\Hook\ContentHandlerDefaultModelForHook;
|
||||
use MediaWiki\User\UserOptionsLookup;
|
||||
use OutputPage;
|
||||
use Title;
|
||||
|
||||
/**
|
||||
* @phpcs:disable MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName
|
||||
*/
|
||||
class CiteHooks implements
|
||||
ContentHandlerDefaultModelForHook,
|
||||
ResourceLoaderGetConfigVarsHook,
|
||||
APIQuerySiteInfoGeneralInfoHook
|
||||
APIQuerySiteInfoGeneralInfoHook,
|
||||
EditPage__showEditForm_initialHook
|
||||
{
|
||||
|
||||
/** @var UserOptionsLookup */
|
||||
private $userOptionsLookup;
|
||||
|
||||
/**
|
||||
* @param UserOptionsLookup $userOptionsLookup
|
||||
*/
|
||||
public function __construct( UserOptionsLookup $userOptionsLookup ) {
|
||||
$this->userOptionsLookup = $userOptionsLookup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the content model of a message that is actually JSON to JSON. This
|
||||
* only affects validation and UI when saving and editing, not loading the
|
||||
|
@ -62,4 +82,29 @@ class CiteHooks implements
|
|||
$results['citeresponsivereferences'] = $module->getConfig()->get( 'CiteResponsiveReferences' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook: EditPage::showEditForm:initial
|
||||
*
|
||||
* Add the module for WikiEditor
|
||||
*
|
||||
* @param EditPage $editPage the current EditPage object.
|
||||
* @param OutputPage $outputPage object.
|
||||
*/
|
||||
public function onEditPage__showEditForm_initial( $editPage, $outputPage ) {
|
||||
if ( $editPage->contentModel !== CONTENT_MODEL_WIKITEXT ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$wikiEditorEnabled = ExtensionRegistry::getInstance()->isLoaded( 'WikiEditor' );
|
||||
|
||||
$user = $editPage->getArticle()->getContext()->getUser();
|
||||
|
||||
if (
|
||||
$wikiEditorEnabled &&
|
||||
$this->userOptionsLookup->getBoolOption( $user, 'usebetatoolbar' )
|
||||
) {
|
||||
$outputPage->addModules( 'ext.cite.wikiEditor' );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -181,7 +181,8 @@ class ReferencesFormatter {
|
|||
$this->anchorFormatter->getReferencesKey( $id ),
|
||||
$backlinkId,
|
||||
$text . $error,
|
||||
$extraAttributes
|
||||
$extraAttributes,
|
||||
$this->messageLocalizer->msg( 'cite_reference_backlink_symbol' )->parse()
|
||||
)->plain();
|
||||
}
|
||||
|
||||
|
@ -206,7 +207,8 @@ class ReferencesFormatter {
|
|||
$this->anchorFormatter->getReferencesKey( $key . '-' . ( $val['key'] ?? '' ) ),
|
||||
$this->listToText( $backlinks ),
|
||||
$text . $error,
|
||||
$extraAttributes
|
||||
$extraAttributes,
|
||||
$this->messageLocalizer->msg( 'cite_reference_backlink_symbol' )->parse()
|
||||
)->plain();
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Cite\Tests;
|
|||
use ApiQuerySiteinfo;
|
||||
use Cite\Hooks\CiteHooks;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\User\StaticUserOptionsLookup;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Cite\Hooks\CiteHooks
|
||||
|
@ -20,7 +21,8 @@ class CiteHooksTest extends \MediaWikiIntegrationTestCase {
|
|||
$vars = [];
|
||||
|
||||
$config = MediaWikiServices::getInstance()->getMainConfig();
|
||||
$citeHooks = new CiteHooks();
|
||||
|
||||
$citeHooks = new CiteHooks( new StaticUserOptionsLookup( [] ) );
|
||||
$citeHooks->onResourceLoaderGetConfigVars( $vars, 'vector', $config );
|
||||
|
||||
$this->assertArrayHasKey( 'wgCiteVisualEditorOtherGroup', $vars );
|
||||
|
@ -38,7 +40,7 @@ class CiteHooksTest extends \MediaWikiIntegrationTestCase {
|
|||
|
||||
$data = [];
|
||||
|
||||
$citeHooks = new CiteHooks();
|
||||
$citeHooks = new CiteHooks( new StaticUserOptionsLookup( [] ) );
|
||||
$citeHooks->onAPIQuerySiteInfoGeneralInfo( $api, $data );
|
||||
|
||||
$this->assertArrayHasKey( 'citeresponsivereferences', $data );
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Cite\Tests\Unit;
|
||||
|
||||
use Cite\Hooks\CiteHooks;
|
||||
use MediaWiki\User\StaticUserOptionsLookup;
|
||||
use Title;
|
||||
|
||||
/**
|
||||
|
@ -19,7 +20,7 @@ class CiteHooksUnitTest extends \MediaWikiUnitTestCase {
|
|||
$title->method( 'getText' )
|
||||
->willReturn( 'Cite-tool-definition.json' );
|
||||
|
||||
$citeHooks = new CiteHooks();
|
||||
$citeHooks = new CiteHooks( new StaticUserOptionsLookup( [] ) );
|
||||
$citeHooks->onContentHandlerDefaultModelFor( $title, $model );
|
||||
|
||||
$this->assertSame( CONTENT_MODEL_JSON, $model );
|
||||
|
|
|
@ -68,7 +68,7 @@ class ReferencesFormatterTest extends \MediaWikiUnitTestCase {
|
|||
],
|
||||
'<div class="mw-references-wrap"><ol class="references">' . "\n" .
|
||||
'<li>(cite_references_link_many|||<span class="reference-text">t</span>' .
|
||||
"\n|)</li>\n</ol></div>"
|
||||
"\n||)</li>\n</ol></div>"
|
||||
],
|
||||
'Ref with extends' => [
|
||||
[
|
||||
|
@ -91,11 +91,11 @@ class ReferencesFormatterTest extends \MediaWikiUnitTestCase {
|
|||
],
|
||||
'<div class="mw-references-wrap"><ol class="references">' . "\n" .
|
||||
'<li>(cite_references_link_many|||<span class="reference-text">t1</span>' . "\n" .
|
||||
'|)<ol class="mw-extended-references"><li>(cite_references_link_many|||' .
|
||||
'<span class="reference-text">t2</span>' . "\n|)</li>\n" .
|
||||
'||)<ol class="mw-extended-references"><li>(cite_references_link_many|||' .
|
||||
'<span class="reference-text">t2</span>' . "\n||)</li>\n" .
|
||||
"</ol></li>\n" .
|
||||
'<li>(cite_references_link_many|||<span class="reference-text">t3</span>' .
|
||||
"\n|)</li>\n" .
|
||||
"\n||)</li>\n" .
|
||||
'</ol></div>'
|
||||
],
|
||||
'Subref of subref' => [
|
||||
|
@ -122,11 +122,11 @@ class ReferencesFormatterTest extends \MediaWikiUnitTestCase {
|
|||
],
|
||||
'<div class="mw-references-wrap"><ol class="references">' . "\n" .
|
||||
'<li>(cite_references_link_many|||<span class="reference-text">t3</span>' . "\n" .
|
||||
'|)<ol class="mw-extended-references"><li>(cite_references_link_many|||' .
|
||||
'||)<ol class="mw-extended-references"><li>(cite_references_link_many|||' .
|
||||
'<span class="reference-text">t1 (cite_error_ref_nested_extends|a|b)</span>' .
|
||||
"\n|)</li>\n" .
|
||||
"\n||)</li>\n" .
|
||||
'<li>(cite_references_link_many|||<span class="reference-text">t2</span>' .
|
||||
"\n|)</li>\n</ol></li>\n" .
|
||||
"\n||)</li>\n</ol></li>\n" .
|
||||
'</ol></div>'
|
||||
],
|
||||
'Use columns' => [
|
||||
|
@ -138,27 +138,27 @@ class ReferencesFormatterTest extends \MediaWikiUnitTestCase {
|
|||
),
|
||||
'<div class="mw-references-wrap mw-references-columns"><ol class="references">' .
|
||||
"\n" . '<li>(cite_references_link_many|||<span class="reference-text">t</span>' .
|
||||
"\n|)</li>\n" .
|
||||
"\n||)</li>\n" .
|
||||
'<li>(cite_references_link_many|||<span class="reference-text">t</span>' .
|
||||
"\n|)</li>\n" .
|
||||
"\n||)</li>\n" .
|
||||
'<li>(cite_references_link_many|||<span class="reference-text">t</span>' .
|
||||
"\n|)</li>\n" .
|
||||
"\n||)</li>\n" .
|
||||
'<li>(cite_references_link_many|||<span class="reference-text">t</span>' .
|
||||
"\n|)</li>\n" .
|
||||
"\n||)</li>\n" .
|
||||
'<li>(cite_references_link_many|||<span class="reference-text">t</span>' .
|
||||
"\n|)</li>\n" .
|
||||
"\n||)</li>\n" .
|
||||
'<li>(cite_references_link_many|||<span class="reference-text">t</span>' .
|
||||
"\n|)</li>\n" .
|
||||
"\n||)</li>\n" .
|
||||
'<li>(cite_references_link_many|||<span class="reference-text">t</span>' .
|
||||
"\n|)</li>\n" .
|
||||
"\n||)</li>\n" .
|
||||
'<li>(cite_references_link_many|||<span class="reference-text">t</span>' .
|
||||
"\n|)</li>\n" .
|
||||
"\n||)</li>\n" .
|
||||
'<li>(cite_references_link_many|||<span class="reference-text">t</span>' .
|
||||
"\n|)</li>\n" .
|
||||
"\n||)</li>\n" .
|
||||
'<li>(cite_references_link_many|||<span class="reference-text">t</span>' .
|
||||
"\n|)</li>\n" .
|
||||
"\n||)</li>\n" .
|
||||
'<li>(cite_references_link_many|||<span class="reference-text">t</span>' .
|
||||
"\n|)</li>\n</ol></div>"
|
||||
"\n||)</li>\n</ol></div>"
|
||||
],
|
||||
];
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ class ReferencesFormatterTest extends \MediaWikiUnitTestCase {
|
|||
[
|
||||
'text' => 't',
|
||||
],
|
||||
'(cite_references_link_many|1-||<span class="reference-text">t</span>' . "\n|)"
|
||||
'(cite_references_link_many|1-||<span class="reference-text">t</span>' . "\n||)"
|
||||
],
|
||||
'With dir' => [
|
||||
1,
|
||||
|
@ -250,7 +250,7 @@ class ReferencesFormatterTest extends \MediaWikiUnitTestCase {
|
|||
'text' => 't',
|
||||
],
|
||||
'(cite_references_link_many|1-||<span class="reference-text">t</span>' .
|
||||
"\n" . '| class="mw-cite-dir-rtl")'
|
||||
"\n" . '| class="mw-cite-dir-rtl"|)'
|
||||
],
|
||||
'Incomplete follow' => [
|
||||
1,
|
||||
|
@ -267,7 +267,7 @@ class ReferencesFormatterTest extends \MediaWikiUnitTestCase {
|
|||
'key' => 5,
|
||||
'text' => 't',
|
||||
],
|
||||
'(cite_references_link_one|1-5|1+5-0|<span class="reference-text">t</span>' . "\n|)"
|
||||
'(cite_references_link_one|1-5|1+5-0|<span class="reference-text">t</span>' . "\n||)"
|
||||
],
|
||||
'Count negative' => [
|
||||
1,
|
||||
|
@ -277,7 +277,7 @@ class ReferencesFormatterTest extends \MediaWikiUnitTestCase {
|
|||
'number' => 3,
|
||||
'text' => 't',
|
||||
],
|
||||
'(cite_references_link_one|5|5+|<span class="reference-text">t</span>' . "\n|)"
|
||||
'(cite_references_link_one|5|5+|<span class="reference-text">t</span>' . "\n||)"
|
||||
],
|
||||
'Count positive' => [
|
||||
1,
|
||||
|
@ -292,7 +292,7 @@ class ReferencesFormatterTest extends \MediaWikiUnitTestCase {
|
|||
'(cite_references_link_many_sep)(cite_references_link_many_format|1+5-1|3.1|' .
|
||||
'(cite_error_references_no_backlink_label))(cite_references_link_many_and)' .
|
||||
'(cite_references_link_many_format|1+5-2|3.2|(cite_error_references_no_backlink_label' .
|
||||
'))|<span class="reference-text">t</span>' . "\n|)"
|
||||
'))|<span class="reference-text">t</span>' . "\n||)"
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue