Commit graph

364 commits

Author SHA1 Message Date
Brad Jorsch ba09ba3fde Add mw.message library
Change-Id: I12ca84f848c34f1227ee8acdc8bc04bdfd0b2d97
2013-02-26 22:20:04 -08:00
Translation updater bot 07d6ed437a Localisation updates from http://translatewiki.net.
Change-Id: I9347f23807bc0ae76633cb3e17b8733b7be72b2a
2013-02-26 20:52:32 +00:00
Brad Jorsch 2b08f5a5c0 Fix NaN unit test in phpunit 3.7.14
In phpunit 3.6.10, assertEquals considered two NaNs to be equivalent.
Somewhere between that and phpunit 3.7.14, this behavior changed so NaNs
are no longer considered equivalent.

Change-Id: I2c664498eb34cf5119a2eaaa96a6be57b821ab94
2013-02-25 16:56:15 -08:00
jenkins-bot bf689b7758 Merge "Add French namespace aliases" 2013-02-25 22:58:13 +00:00
Translation updater bot 36eb8c0fb6 Localisation updates from http://translatewiki.net.
Change-Id: I0c8512ce296944d93c46ce4351de60a1478e810a
2013-02-24 20:44:10 +00:00
Siebrand Mazeland cd43c9ffb5 Use XHTML <hr /> tag
Change-Id: Ia818d24e1070087c6571556172213307dfb9a723
2013-02-24 16:28:09 +01:00
Translation updater bot 1bbfcf3fcb Localisation updates from http://translatewiki.net.
Change-Id: I645cf954e5d17d940c765642de3cdb2957a00d79
2013-02-23 20:40:46 +00:00
Translation updater bot 8adf901706 Localisation updates from http://translatewiki.net.
Change-Id: I9724ddf2213914c5da262352a18307231cdc8bee
2013-02-22 20:13:41 +00:00
Brad Jorsch 30a75fb0f1 Add module documentation support
Add the ability for modules to be documented using a /doc subpage, which
is automatically transcluded onto the module page.

To get the transcluding to work right, I wound up having to change from
the deprecated-in-1.21 ArticleViewCustom hook to ContentHandler, as
there didn't seem to be any other way to get the ParserOutput into the
links tables. Which means Scribunto now needs MediaWiki 1.21 rather
than 1.20.

Change-Id: Id487097c2a505c11f92a3404f5d3ee98beb2570c
2013-02-22 05:01:29 +00:00
Brad Jorsch 00d4b711ed Add mw.loadData, for static data loading
People sometimes want to load large tables of constant data from a
module. Using require(), this has to be reparsed every time, which can
be slow.

mw.loadData() will load the just data once, and return a table with a
metatable cleverly designed to give read-only access to the loaded data.

Change-Id: Icec192bdbe6cfca7902fd5cb5d0e217bd8399637
2013-02-21 23:03:53 +00:00
jenkins-bot 7c6f9cca5f Merge "Enable subpages" 2013-02-21 22:28:26 +00:00
Translation updater bot 5f8c96aa3d Localisation updates from http://translatewiki.net.
Change-Id: Ia9abe0cf88192dd494b68796214b0f84ce28ba82
2013-02-21 20:20:46 +00:00
Brad Jorsch d20af1dce4 Enable subpages
Subpages should probably be enabled by default for the Module namespace,
considering that we're planning on using /doc subpages for
documentation.

Change-Id: Ie9d192f807e8d5cd04484f6418fd5fa64e0d3117
2013-02-20 21:53:47 -05:00
Translation updater bot 3f575edd66 Localisation updates from http://translatewiki.net.
Change-Id: Ia10472ba3e9b9f0ea770ff8c1596665914f7b71d
2013-02-19 20:39:54 +00:00
Jérémie Roquet 6173f4b92d Add French namespace aliases
Change-Id: I428661ec09b07309ba5e0038598f4693151374c1
2013-02-19 14:37:21 +01:00
Translation updater bot d1c42ed5c7 Localisation updates from http://translatewiki.net.
Change-Id: Ic4eaf1ddbb827df5d2cc6e32f186ad8f7ab2d876
2013-02-18 20:59:06 +00:00
Tim Starling 96615c97b0 Explicitly destroy the loadedLibraries array
Otherwise there is a circular reference and the engine is not destroyed
until the end of the request.

Change-Id: I9c98fe449c19d22e771e11d485e5516059c45329
2013-02-18 10:41:12 +11:00
Brad Jorsch 2d36fbc492 Scribunto language library
Added a language library. Introduced functions which are easy and safe,
most of them already have parser function interfaces.

Change-Id: I4465150f3e16493a15a056f7ddb7787bdf3b0373
2013-02-18 10:41:12 +11:00
Translation updater bot 799440eb4f Localisation updates from http://translatewiki.net.
Change-Id: Ic733b6784390a9bb9b9b6e95a6b97a4d620b05c0
2013-02-17 20:49:33 +00:00
Brad Jorsch 4ff1dbd6a7 Document Scribunto_LuaEngine
Some parts of this that really should be documented aren't. Fix that.

Change-Id: I058f47a08a7529a8d2a70e5b50e4532db7bdb720
2013-02-15 18:42:07 -05:00
Translation updater bot 60949bbfd4 Localisation updates from http://translatewiki.net.
Change-Id: I21f4d1dfe8aaff5d55117bd267a4615bb8544b27
2013-02-15 20:37:00 +00:00
jenkins-bot 2980cf4c11 Merge "Fix mw.ustring.gmatch and patterns with '^'" 2013-02-15 08:22:11 +00:00
Brad Jorsch 1efe182e40 Hide mw.makeProtectedEnvFuncs from modules
Allowing a module to call mw.makeProtectedEnvFuncs() lets it bypass the
allowEnvFuncs setting. It can also be used to manipulate the global
tables that other modules' sandboxes will be copied from.

And for paranoia's sake, let's tighten up what setfenv is allowed to
set. This requires changing a unit test, because it is no longer
sane to do something like

 env.setfenv, env.getfenv = mw.makeProtectedEnvFuncs( { [env] = true }, {} )

Nothing real does this, it was only in the unit test.

Change-Id: I8e0d83bb0980ee869af3ac4413afd211717ca92f
2013-02-14 16:49:15 -05:00
Translation updater bot 14455fec4c Localisation updates from http://translatewiki.net.
Change-Id: I6eaf5f10aa1eacf917aca7a4160e560ee9ed9ce2
2013-02-14 20:32:06 +00:00
Brad Jorsch 4dcac2fcd9 Fix mw.ustring.gmatch and patterns with '^'
The Lua manual says this:

 For this function, a '^' at the start of a pattern does not work as an
 anchor, as this would prevent the iteration.

I had interpreted that to mean that a pattern starting with '^' would
never match in gmatch. But further testing reveals that the '^' is just
treated as a literal character: string.gmatch( "foo ^bar baz", "^%a+" )
will match "^bar".

Change-Id: Id91d6ee2db753ce1d6a4f6ae27764691d9e9fdc4
2013-02-14 14:25:55 -05:00
Chad Horohoe c98cc64545 Allow extensions to add libraries
Wikidata has already requested the ability to add libraries into Lua. We
do this in a simple way: add a $wgScribuntoExtraLibraries global, and
load whatever modules someone puts there.

Change-Id: I460b4e7b968eb02dd86620f1e4b50daf1be9e901
2013-02-14 12:38:03 -05:00
Brad Jorsch e66ccb89b4 Test for leaked global variables
It's easy to forget a 'local' somewhere and accidentally leak a global
variable. Add a unit test to catch that.

Change-Id: I3a8dda22f108d88039f9562a1da7a739850bb14b
2013-02-14 04:02:48 +00:00
Translation updater bot aeb3360bd6 Localisation updates from http://translatewiki.net.
Change-Id: I70aa102b496adf1923058c362ce50dedd2df38dd
2013-02-13 21:46:14 +00:00
Translation updater bot 228dcc45ef Localisation updates from http://translatewiki.net.
Change-Id: Ic4a130e871ced2a18cb1d9eeee74290bdab614f0
2013-02-13 21:05:03 +00:00
Tim Starling ce062407ab Fix further non-local effects of library registration
Fixed several accidental leaks to the global namespace due to missing
"local" declaration. Removed extension of the string table by mw.uri,
same justification as I5d0ddb70.

Change-Id: Iba1bf8e651d4ce05812e4a9a7a074cb6679297a0
2013-02-13 15:40:18 +11:00
Tim Starling f2f866cbdd Remove global side-effects from mw.ustring library registration
The point of putting the unicode library in mw.ustring instead of
ustring was to avoid conflicts with future upstream work, and with other
libraries. It rather defeats the purpose if you then modify the global
string table during module startup.

Users can always set up local aliases if they feel "mw.ustring" is too
much to type.

Change-Id: I5d0ddb70d999aeb6e36e6ddbcdb19922d0274a39
2013-02-13 15:05:22 +11:00
Tim Starling 2d9e3c74ba Merge "Lua ustring implementation" 2013-02-13 03:32:43 +00:00
jenkins-bot 9f86e1490a Merge "Handle session loss in the console" 2013-02-12 23:21:54 +00:00
Translation updater bot ff8102549d Merge "Localisation updates from http://translatewiki.net." 2013-02-12 20:34:33 +00:00
Translation updater bot b228d5e60a Localisation updates from http://translatewiki.net.
Change-Id: Ic547180375f173024c63913f107ca021d5901451
2013-02-12 20:27:17 +00:00
Brad Jorsch 0a8757baba Lua ustring implementation
This is a reimplementation of Lua's string library with support for
UTF-8.

The entire ustring library is implemented in pure Lua. PHP callbacks are
also available for overrides: in LuaSandbox these are used for almost
all functions, while in LuaStandalone they are used only for the pattern
matching. Also, ustring.upper and ustring.lower are overridden using
mw.language's .uc and .lc if available.

It also includes a bunch of unit tests.

Note that if you download the normalization tests, they may fail under
LuaSandbox if you have PHP's intl extension installed and libicu on your
system is too old.

Change-Id: Ie76fdf8d3a85d0a3d2a41b0d3b7afe433f247af0
2013-02-12 14:26:29 -05:00
Brad Jorsch d6116fa6ba Make pairs and ipairs work with frame.args
Using the 5.2 compatability added in I37efc59a, we can now make
pairs( frame.args ) work.

Change-Id: Iefdca8805b08ea222251f28514b2c92182a7feb3
2013-02-12 06:41:33 +00:00
Brad Jorsch e878314048 Handle session loss in the console
If the session data gets lost, the console forgets the content and
previous commands. Detect this situation and handle it.

Change-Id: I82fb5e111c09091d4f9a87d2e1b1c245eced1420
2013-02-11 13:23:10 -05:00
Brad Jorsch fddf05c056 Make our loader work like Lua's built-in loaders
Our loader for lua files distributed with the extension doesn't work
like Lua's built-in loaders. Fix that.

Change-Id: I7576f0e173c10a589f7ebf2c121230ed66b538fe
2013-02-08 14:20:32 -05:00
Brad Jorsch ce46700ec9 Fix unit tests after I62259b76
The unit tests never set the title on the engine.

Change-Id: Iefa11cacd4f10a1daa185b2e2a0d9620bbbfa6c6
2013-02-07 15:59:38 -05:00
Chad Horohoe 3055ac6aa3 Clean up title handling for defaultUrl
getParser() sometimes returns null (eg: on saving edits), so use
the engine's title instead.

Change-Id: I62259b76d6960a934b5e208fdaacbbfc7c2d057c
2013-02-07 15:45:49 -05:00
Brad Jorsch db9fd2b39b Add mw.uri library
Change-Id: I1d94a8c288537ada038f24f2ec26922d95f14785
2013-02-07 13:31:24 -05:00
Brad Jorsch 49ec3cee05 Fix title passed to API scribunto-console
The title should be passed with the proper namespace.

Change-Id: If63ebd707420ca600590f38b29d0e3c839b1f1b6
2013-02-07 12:37:14 -05:00
Chad Horohoe 04b207829e $wgServerName doesn't exist anymore
This is a followup to I944938f9. I had kind of forgotten that
we removed $wgServerName.

Change-Id: I846cba6853f1a3a09f4e2d362960fea5f60bfcc3
2013-02-06 10:24:59 -05:00
Brad Jorsch bd03237246 Add mw.site library
Contains various constants and functions to access site info.

Change-Id: I944938f9af0203c16d1a3fb2046f332045dec4d9
2013-02-06 09:20:59 -05:00
Brad Jorsch 337abb295f Make Lua engine tests modular
Rework the LuaEngine tests to be entirely modular, so that every library
need not add itself to one monolithic file. This also allows other
extensions that add Lua modules to make unit tests without having to
somehow inject them into a test class owned by Scribunto.

The approach taken is similar to that used for Selenium for running
tests against multiple browsers.

Change-Id: I294b2a8195759c0e4fa211f879305a8eb66d9c9a
2013-02-06 09:10:57 -05:00
Ori Livneh b2d340bf71 (Bug 37957) php_sapi_name() => PHP_SAPI
Change-Id: I8ccb645fa11f001fc1ca1c95f4e9476f84870714
2013-02-04 20:27:01 -08:00
Brad Jorsch 8b27dc742d Add incrementExpensiveFunctionCount() methods
To allow Lua libraries to mark functions as expensive, add an
incrementExpensiveFunctionCount() method to Scribunto_LuaEngine that
will call the corresponding Parser method and throw an error if the
limit is exceeded.

Also allow libraries to do the same thing from Lua by calling
mw.incrementExpensiveFunctionCount().

Change-Id: I56fded32b1077eff3980371e9abc9b3b7581f7b5
2013-02-01 15:55:16 -05:00
Brad Jorsch 4c69b1350e Lua library support functions
Adds a base class for libraries with some utility functions in PHP, and a
Lua library with utility functions for use from Lua.

Change-Id: I3d67b1de8bc50488fe3a722e4e2de5849285d127
2013-01-31 12:40:39 -05:00
Brad Jorsch 0a8a07de2f Fix package.loaded and other cleanups
The listing of the standard modules in package.loaded seems to have been
removed to avoid leaking information to loaded modules. However, since
the *entire* environment is cloned, *including* package.loaded itself,
this does not seem to actually be a problem. But for good measure, also
add a unit test to verify that the version of the standard module tables
referenced from package.loaded is the same as that in _G.

This change also cleans up some unused local variables and an unused
local function from the package module.

Change-Id: I7ec8227b3273059e8f65ad735c215bfd0c623e64
2013-01-30 17:24:09 +00:00