Commit graph

696 commits

Author SHA1 Message Date
Brad Jorsch 10bc0f7316 Adds support for JSON encoding and decoding
Provides methods to encode and decode JSON in the mw.text module.

Bug: T47470
Change-Id: I274f2ff13adb616e50600ee30e29b35327f3251e
2015-01-26 15:13:22 -08:00
Brad Jorsch ccfcbfc17f Update unit tests for recent core changes
* I0ede3169 caused Language::fetchLanguageNames() to use 'en' rather than
  null when given an invalid language code. This didn't break Jenkins
  since, without cldr, it always uses null anyway.
* I4bead5f5 caused Language::listToText() to start encoding
  single-quotes in messages such as 'and'.

Bug: T85854
Change-Id: Ic2807be8dad3ef029652e4b0db05e4dd8a6631b9
2015-01-08 23:23:59 +00:00
Jackmcbarn f7fe4881a0 Pass the title's fragment to getExpensiveData
Without this, an error occurs when calling mw.title.new('#foo').exists
(or anything similar).

Change-Id: Id2b60fe3f121af95b4b54da3a7042b490ecbc3fe
2015-01-08 13:19:54 -05:00
Translation updater bot d090e5de30 Localisation updates from https://translatewiki.net.
Change-Id: Ic2c73c2e65fbc78579bdf6fd1a3e510ecdf044d8
2015-01-06 22:27:50 +01:00
Translation updater bot 7dfa59f2b5 Localisation updates from https://translatewiki.net.
Change-Id: I09b50e58e3da5981efc189bd76325226c71fc7c2
2015-01-03 23:04:24 +01:00
Mr. Stradivarius ad34c2bd94 Use protocol-relative URLs in mw.site.interwikiMap
At the moment, in mw.site.interwikiMap, URLs stored in the database
with relative protocols are converted to http or https depending
on the protocol of the user who last requested that the page be parsed.
However, this URL isn't updated for users pulling pages from the page
cache, so they may see links with an incorrect protocol. Module authors
can work round this by using mw.uri objects and the isProtocolRelative
property, but it would be simpler just to use relative URLs from the
outset.

Change-Id: If0a169cfd1597e09706fc0e6d5cdcc821ba8d06a
2014-12-26 20:28:49 +09:00
Mr. Stradivarius c58c528d28 Add mw.site.interwikiMap
This makes the interwiki map available to Lua modules. The code is
based on the API interwiki map code in core (the appendInterwikiMap
method of includes/api/ApiQuerySiteInfo.php.) Everything that the
API includes is added, apart from iw_api and iw_wikiid, which I
couldn't think of a use for from Lua modules.

Accessing the interwiki map would be useful for modules like
enwiki's Module:InterwikiTable,[1] as it would stop module writers
having to duplicate the data.

[1] https://en.wikipedia.org/wiki/Module:InterwikiTable

Change-Id: Ie8ad2582aaf5e422824f7da51714a347bb4041d1
2014-12-24 01:17:48 +09:00
Brad Jorsch ce034c2f92 Normalize newlines before calling preprocessor
The behavior of the different preprocessors differs when given \r or
\r\n newlines.

Bug: T78488
Change-Id: I74faee1d3deb57a70d0c8fb690e5abb388d1f61a
2014-12-22 04:15:52 +00:00
Thiemo Mättig 93579c7363 Add more comments and type hints
Change-Id: I8c4b91d3a6695cc33c9c3d3fb427af5412323ff7
2014-12-19 19:25:53 +00:00
jenkins-bot fbc7437af8 Merge "Handle PTD_FOR_INCLUSION properly" 2014-12-19 03:55:47 +00:00
Jackmcbarn c0c6170108 Handle PTD_FOR_INCLUSION properly
Change handling of PTD_FOR_INCLUSION to match that of the parser (i.e.,
don't set it if text is being expanded in the root frame), so that
frame:getParent():preprocess() will handle <noinclude> etc. correctly.

Change-Id: I13f45e57aa334642d310e9bd5fdd3dbe5922c4e1
2014-12-19 03:46:25 +00:00
Jackmcbarn 4002f43ef2 Use a metatable when os.date("*t") is called
When os.date("*t") or ("!*t") is called, instead of just setting the TTL
to 1 second, create a metatable that sets TTLs as the values are looked
at.

Change-Id: Id1e2df731f182f21cf19708738f9907fa927185c
2014-12-19 03:46:23 +00:00
Jackmcbarn 85ac0ae4bb Make Jenkins tests pass
Something apparently changed in core, and now we need some additional
autoload classes to make tests pass.

Change-Id: I1d4c764d3836b7207831cceca8daacd735288c38
2014-12-18 22:40:33 -05:00
Translation updater bot a3faa9ea61 Localisation updates from https://translatewiki.net.
Change-Id: Ie335c3a42c677710de92b106226fc3398804c1b4
2014-12-18 23:22:27 +01:00
Translation updater bot 98002006fc Localisation updates from https://translatewiki.net.
Change-Id: I1ead87daf115437795773b9238f5b2f7daeda72d
2014-12-13 22:36:14 +01:00
Jackmcbarn 819320ec3b Don't attempt to parse non-Modules in the console
When processing Lua console requests, don't attempt to parse pages that
aren't modules. This allows the Lua console to be successfully loaded
everywhere.

Change-Id: Idfd1985aca4acb6a8f3235d34ac00358e30e361c
2014-12-12 02:37:34 +00:00
Jackmcbarn 15203e9b72 Record a link to pages looked up by ID
If mw.title.new is called with a page ID, record a link to it.

Change-Id: Idc5327d21b780ff8242367878102034413663643
2014-12-11 16:10:42 -05:00
Jackmcbarn ce5ac6611d Avoid unnecessary database queries
Currently, mw.title.new always results in a database query, which holds up
the parse until it finishes. This changes it to not require a database
query if it's not actually necessary.

Bug: T68328
Change-Id: I62f347d4cd9176bd0440215dcbe804c1dc3d4c99
2014-12-11 13:34:06 -05:00
Mr. Stradivarius 98f25aa9a1 Improve error messages in mw.html
Add more information to error messages in mw.html. This includes the
error level, the function name, and the position of the argument in the
argument list. Where possible, use the functions in libraryUtil.lua to
do this.

Some functions in mw.html accept multiple types, so add a checkTypeMulti
function to libraryUtil.lua to make these kinds of functions easy to check.
And while we're at it, add test cases for libraryUtil.lua as well.

Change-Id: If9cf9a52bd4b1bb42cc7f9f1f1096828710cbc52
2014-12-08 17:01:31 +00:00
jenkins-bot ece90ec755 Merge "Improve argument validation in frame:expandTemplate()" 2014-12-07 03:15:48 +00:00
Translation updater bot ba6743a523 Localisation updates from https://translatewiki.net.
Change-Id: I1d214f6cdc989092cf86c1da7a78359eb81f7c35
2014-12-05 23:14:52 +01:00
Brad Jorsch d485b898c3 Improve argument validation in frame:expandTemplate()
Just like the other methods, e shouldn't be allowing passing of things
that aren't numbers or strings here.

For that matter, we should just abstract out the whole "arg key and
value validation" into a separate function instead of repeating it in
four places.

Bug: T76609
Change-Id: Id7e512a988ef9b7a5c5a110c8992dd5d649dcbf9
2014-12-05 10:00:16 -05:00
Jackmcbarn 33fb32f872 Expose file page count, width, and height to Lua
Add a file table to Title objects, containing the number of pages, widths,
and heights, of files.

Change-Id: I9c6b5024ae6b5af393ed7eb1448a297c5c4e5830
2014-12-03 10:44:55 -05:00
jenkins-bot 6f7349dcc8 Merge "Add mw.text.unstripNoWiki, mw.text.killMarkers, fix mw.text.unstrip" 2014-12-01 21:42:17 +00:00
jenkins-bot 58e2a7e63b Merge "Remove unused variable" 2014-12-01 19:22:54 +00:00
Jackmcbarn 553744ab5a Remove unnecessary redefinition
In I019c24d1, an unnecessary variable redefinition was added to
Scribunto_LuaModule, which this removes.

Change-Id: Ib0232a5adcd9ad7ea5c0f4413ba06c42b5506d7b
2014-12-01 10:52:33 -05:00
Jackmcbarn 6ac9669bc5 Remove unused variable
Change-Id: I31c339dd68081a6c3d140011dc7c00eb2ddbef64
2014-12-01 10:21:40 -05:00
Translation updater bot 6608c06c0d Localisation updates from https://translatewiki.net.
Change-Id: I2efe34346fcdd58d28584df8731a62c5c7a05421
2014-11-30 22:14:41 +01:00
Translation updater bot 8ad61e7efc Localisation updates from https://translatewiki.net.
Change-Id: I10c128e22b939621a505927e07d5e306914eb33b
2014-11-25 21:50:58 +01:00
Translation updater bot 9148c79baa Localisation updates from https://translatewiki.net.
Change-Id: I08ca1d010923e49a0682ddaaf5495dd6534f0aaa
2014-11-22 22:42:18 +01:00
jenkins-bot 398713b1a7 Merge "Use Parser::SFH_OBJECT_ARGS class const" 2014-11-18 20:30:06 +00:00
umherirrender 30c38929d2 Use Parser::SFH_OBJECT_ARGS class const
Instead of the global const

Change-Id: Iaf557f0f56964c8b545a4cd1582a852c12183def
2014-11-18 20:56:33 +01:00
Translation updater bot a4b812327c Localisation updates from https://translatewiki.net.
Change-Id: I7928a64f94f501d1703b608831ebd25d4dc070e3
2014-11-16 22:52:35 +01:00
Thiemo Mättig 55fe0b69d0 Add missing visibility keywords everywhere
Change-Id: I270d1dd9b6545e15398c2f8b8e9ae533844cc998
2014-11-14 10:10:23 +01:00
Thiemo Mättig 61af67b819 Fix visibility of setUp/tearDown
Required for Idf44d31.

Change-Id: If6d270549290bed2d1c7617da0fedbd385f3e96c
2014-11-12 12:28:58 +01:00
Translation updater bot 43996d8a95 Localisation updates from https://translatewiki.net.
Change-Id: Id117704e95a71ae9e99d605e383cd7c20af6dcbe
2014-11-09 21:53:39 +01:00
Translation updater bot d6938a0b9e Localisation updates from https://translatewiki.net.
Change-Id: I9ae3f3b962b50b99109c4fbacdc7ec44e61dded0
2014-11-06 21:53:34 +01:00
Translation updater bot 4d82ab4796 Localisation updates from https://translatewiki.net.
Change-Id: I22cafc5818213339dfe7c2e593f5a7b1b4eef29f
2014-11-05 21:47:12 +01:00
Brad Jorsch e5564cf942 Add mw.text.unstripNoWiki, mw.text.killMarkers, fix mw.text.unstrip
mw.text.unstrip is too broad, it's allowing for unstripping things that
cause problems when unstripped (e.g. bug 61268). Since the original
request was only for unstripping <nowiki>, let's add a function that
does only that.

We should also add an interface to StripState::killMarkers(), instead of
requiring everyone to roll their own work-alike.

Then, to fix the bug, we can make mw.text.unstrip be the combination of
the two. This is the most like the original behavior of mw.text.unstrip
(removes all strip markers, replacing them with text where applicable)
without causing issues.

Bug: 61268
Change-Id: I3a151fd678b365d629b71b4f1cb0d5d284b98555
2014-11-05 12:32:35 -05:00
Translation updater bot 32d7dc7ae9 Localisation updates from https://translatewiki.net.
Change-Id: Idbf39f6aa4ad983e91de798f3f1083261ba2d5c8
2014-11-04 23:31:03 +01:00
jenkins-bot 99ad35e755 Merge "Add i18n for API module help and mark ApiScribuntoConsole as internal" 2014-11-03 21:12:45 +00:00
Brad Jorsch 9443fda132 Add i18n for API module help and mark ApiScribuntoConsole as internal
MediaWiki core change I04b1a384 added support for i18n of API module
help. This takes advantage of that while still maintaining backwards
compatibility with earlier versions of MediaWiki.

Once support for MediaWiki before 1.25 is dropped, the methods marked
deprecated in this patch may be removed.

Change-Id: I67395aff48185f3e09da31b51a08aa2541fe6a17
2014-11-03 21:10:19 +00:00
Translation updater bot 7526f0f0fc Localisation updates from https://translatewiki.net.
Change-Id: Iee0697ebdf8e0f8183df9d6555ccfd48c1c9d225
2014-10-31 21:46:48 +01:00
Translation updater bot 24ff77a4a2 Localisation updates from https://translatewiki.net.
Change-Id: I46de71b1d8b7e02bda602415ab3942d1ff2e2e21
2014-10-29 22:07:18 +01:00
Translation updater bot 1a8a2c83bf Localisation updates from https://translatewiki.net.
Change-Id: Ia2334a3271f8786b7f969f4b59137539a997718f
2014-10-27 20:17:29 +01:00
glaisher 4280df5003 Add namespace translations for 'mai'
See https://bugzilla.wikimedia.org/show_bug.cgi?id=72346#c8

Bug: 72346
Change-Id: I4a8c0a2fa92a93117744c3051fb107b8bd47bfc2
2014-10-22 22:56:21 +05:00
Marius Hoch ec019970a1 Fix type hint for Scribunto_LuaEngine::registerInterface
Change-Id: I5f498f6d8fe5811ae7f61591170dd580d4622d49
2014-10-17 01:40:15 +02:00
Reedy 7c38e48c1f Fix file permissions
Bug: 71931
Change-Id: I3b40ab821cafccc30563baa031212f2a24a167a1
2014-10-15 12:17:26 +00:00
Translation updater bot 517fb0242e Localisation updates from https://translatewiki.net.
Change-Id: I3d2169910442f64107a3444931cb25164736425a
2014-10-12 22:18:50 +02:00
Thiemo Mättig d7c173b521 Add missing PHPDoc comments and type hints
There are like a billion things missing in the inline documentation
of this extension. Wow. This is what I can do for now.

Change-Id: I019c24d13cf5cb22dde4d710b86ef8f976e1ec96
2014-10-09 23:23:05 +02:00