Commit graph

70 commits

Author SHA1 Message Date
Umherirrender 88d0b22359 Improve some parameter docs
Change-Id: I268aaa13d07985b0915774e83c487cd22568b161
2017-08-27 16:07:08 +02:00
Kunal Mehta fd09887a48 build: Updating mediawiki/mediawiki-codesniffer to 0.10.1
Change-Id: I38ce5579c75d58f0ab1adfe3883732813fad938f
2017-07-23 00:23:06 -07:00
Kunal Mehta 837c8403fd build: Updating mediawiki/mediawiki-codesniffer to 0.9.0
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.FunctionComment.MissingParamComment
* MediaWiki.Commenting.FunctionComment.MissingParamName
* MediaWiki.Commenting.FunctionComment.MissingParamTag
* MediaWiki.Commenting.FunctionComment.MissingReturn
* MediaWiki.Commenting.FunctionComment.ParamNameNoMatch
* MediaWiki.FunctionComment.Missing.Protected
* MediaWiki.FunctionComment.Missing.Public
* MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment

Change-Id: I38d7f39d2d00e8d26dad4c6281885b54203b23b7
2017-06-20 00:06:01 -07:00
Umherirrender f102194baf Add phpcs and make pass
Change-Id: I02b7f85f54ffaf8a1c9d5bed6fa20abb1627afe5
2017-05-31 16:36:45 +02:00
Timo Tijhof 3dd92c6f76 Remove duplicate loading of styles (assume type=general if content is mixed)
Follows-up dc834f3, dc4ea6c.

Bug: T92459
Bug: T42284
Change-Id: I94dbdb052a78bbbc3c1b7b8bb8805a5f327670d9
2017-05-12 21:44:42 +00:00
Timo Tijhof dc4ea6cb21 Implement 'peers' feature for loading extra styles-type gadgets
Ref discussion on T42284.

Test plan:
* Create gadget A with a .css file only. (Maybe mark as 'hidden')
* Create gadget B with .js file, and peers=A.
* Verify that enabling B will result in B being loaded as general module,
  and A being loaded as page style module.

Change-Id: Ib6207e72c576ff387ecdba685a063bdfbb828199
2017-01-02 14:45:09 +01:00
Fomafix 1a569b590b Convert PHP syntax from array() to []
Performed using:
find . -name \*.php -exec php ~/convert.php -w "{}" \;

Script from:
https://github.com/thomasbachem/php-short-array-syntax-converter

And convert syntax in comments manually.

Change-Id: I7ea9e57f9ab1250c8687885ad9e010771603bf78
2016-12-28 13:51:30 +01:00
Fomafix 75d7d07f6b Change documentation and comments from HTTP to HTTPS
This change avoids redirects from HTTP to HTTPS.

Change-Id: I2eb3b14e5bc8255f30ae557f842bfc512fc33a79
2016-12-23 18:26:43 +01:00
Timo Tijhof 846b979578 Remove redundant 'position', 'top', and getPosition() code
Unused as of bc374082fa in MediaWiki core (T109837).

Change-Id: Idcec3c4fa2bc3bc05ac417062139794880040a6d
2016-11-18 13:55:30 -08:00
Timo Tijhof 906aaeeb82 Default to type=general for styles-only gadgets having dependencies
Bug: T147726
Change-Id: I4153851b0e2f5cc067b1f31a7cd80f73d0620d7c
2016-11-16 17:53:10 -08:00
Timo Tijhof dc834f3933 Implement support for specifying type=styles
T87871 formally introduced the concept of a styles module,
which sets mw.loader.state to "ready" when loaded through addModuleStyles().

Previously, addModuleStyles couldn't safely do that because a module may
contain scripts also, in which case mw.loader must still load the (rest)
of the module (causes styles to load twice).

In MediaWiki core or extensions this is easily avoided by calling not
calling both addModules() and addModuleStyles().

For Gadgets we call both as a workaround to allow users to provide styles
(without a FOUC), but also to provide scripts+styles. Since we don't declare
which one is intended (and some gadgets do both), we loaded them both ways.
This will no longer be allowed in the future (see T92459).

The new 'type=styles' Gadget attribute promises to ResourceLoader that a
gadget only contains styles.

Impact:

* [Bug fix] When mw.loader requires a styles module that already loaded,
            it will not load again.

* [Feature] It is possible for a general scripts+styles gadget to depend on
            a styles gadget. Previously this caused the styles to load twice.

* Specifying type=styles will load the module through addModuleStyles() only.

  Use this for modules that contain styles that relate to elements already
  on the page (e.g. when customising the skin, layout, or article content).

* Specifying type=general will load the module through addModules() only.

  Use this if your module contains both scripts and styles and the styles
  only relate to elements created by the script. This means the styles do not
  need to be loaded separately through addModuleStyles() and will not apply
  to noscript mode.

Effective difference:

* Gadgets with only styles: We assume type=styles.

  This fixes the main bug (styles loading twice) and requires no migration!

* Gadgets with only scripts: We assume type=general.

  This requires no migration! (And: No more empty stylesheet request)

* Gadgets with scripts (with or without styles): We assume type=general, but
  unless type=general was explicitly set we'll still load it both ways so
  that the styles apply directly on page load.

  If this is not needed, set type=general.

  If this is needed, it should become two separate modules. We do not support
  a single module having two purposes (1: apply styles to the page,
  2: provide scripts+styles). The styles module should be separate.
  It can be made hidden, and listed as dependency of the other module.

The latter case is detected on page load and results in a console warning
with a link to T42284.

Bug: T42284
Bug: T92459
Change-Id: Ia3c9ddee243f710022144fc2884434350695699a
2016-09-30 10:43:29 +00:00
Kunal Mehta 519f30355e Implement Gadgets definition namespace repo
Implements:
* Gadget definition content and content handler
* Basic validation for gadget definition content
* GadgetDefinitionNamespace implementation of GadgetRepo
* DataUpdates upon editing/deletion of Gadget definition pages
* EditFilterMerged hook for improved error messages
* 'GadgetsRepoClass' option to switch GadgetRepo implementation used
* Lazy-load the GadgetResourceLoaderModule class so we don't need to
load each individual gadget object unless its needed

Note that Special:Gadgets's export feature intentionally doesn't work
yet, and will be fixed in a follow up patch.

Bug: T106177
Change-Id: Ib11db5fb0f7b46793bfa956cf1367f1dc1059b1c
2015-11-20 12:01:21 -06:00
Kunal Mehta b105abff1b Remove unused variable
Change-Id: Ib3237e16a332072c2a5840b27c391e89dcac3a69
2015-10-06 13:26:26 -07:00
Southparkfan dbecdaee62 chmod 644 for php and json files
Bug: T111743
Change-Id: I3ebc7c05f4a598a702cbd2948147dade3323e994
2015-09-08 18:06:35 +02:00
Kunal Mehta 152484566d Add support for 'messages' and 'hidden' gadgets
In the backend, allow:
* Adding dependencies on messages
* Marking gadgets as hidden so they don't show in preferences

These cannot be used by MediaWiki:Gadgets-definition gadgets, but will
be used by Gadgets 2.0 gadgets.

Change-Id: I55e97de9d631ae001ccc0164db172ba9c5689a34
2015-08-08 00:43:16 +00:00
Kunal Mehta adcb193a1b Move GadgetResourceLoaderModule class to separate file
Change-Id: Ic7dde135168a04fc5916e5f44acd6b8639c8ce1a
2015-08-01 15:10:15 -07:00
Kunal Mehta e858bda308 Add abstract GadgetRepo and MediaWikiGadgetsDefinition implementation
GadgetRepo is an abstract class based off of the implementation in the
RL2 branch.

It is a singleton that provides basic methods to construct and interact
with Gadget objects.

The MediaWikiGadgetsDefinition class is an implementation of GadgetsRepo
that parses the "MediaWiki:Gadgets-definition" page for gadget
definitions.

Tests were left in place to demonstrate that no functional changes have
been made aside from relocation of code. Some tests should be moved to
separate files in the future.

Bug: T106176
Change-Id: I3e802889f6f495783f4dbac65c2a8cefa824a778
2015-08-01 15:10:07 -07:00
Aaron Schulz 2bd2ef99c5 Removed caching config variables and always enable caching
* APC will be used if around as a tier 1 cache
* This also makes it easier to have mixed zend/hhvm servers

Bug: T106743
Change-Id: Ie9f234753f78215441474dddc4eadedbd2b76ad7
2015-07-23 15:26:06 -07:00
Kunal Mehta d537e50256 Refactor Gadget construction process
The current method of setting private properties prevents the Gadget
object from being constructed by another class (like a GadgetRepo).

Instead, lets pass in arguments in an array.

Change-Id: I86853c72dfb323fb3e54be9ecff85973e30fe781
2015-07-18 02:26:25 -05:00
Alex Monk ca8880a634 Set 644 file permissions on .php files
Bug: T104039
Change-Id: I5a040819ae53ce9e4da7ed542ed1f74253129a86
2015-06-27 18:50:31 +01:00
Andrew Green da30614641 Update GadgetResourceLoaderModule::getDependencies method signature
This change is for compatibility with Iee61e5b527 in MediaWiki.

Change-Id: I0a10fb0cbf17d095ece493e744296caf13dcee02
2015-06-09 02:28:53 +01:00
Aaron Schulz 68b8b406aa Added a blind 10 second TTL to loadStructuredList() for local caching
Change-Id: Ieb1e91f3fbabb279969017d741ae2825502b2ad5
2015-05-29 14:35:46 -07:00
Gilles Dubuc 3b141e7276 Acknowledge that gadgets have their position explicitly defined
Bug: T97410
Change-Id: Ie5dff4f63a0068f47daf4e6d1fcc7a99d008ca52
2015-05-26 12:08:01 +02:00
Aaron Schulz 11e1c51d6b Conversion to using WAN cache
* Bumped the key version due to key wrapping
* Removed isValidList() gived the key versioning
* Follow up ba1311c323 by making APC viable;
  previously, definition purges would not work

Bug: T93141
Change-Id: I6da3eede044bf4b840b3f9656a1ae8105941dc6b
2015-05-23 23:04:06 +00:00
Ori Livneh ba1311c323 Make the ObjectCache implementation used for Gadget def's configurable
Add a configuration option, 'GadgetsCacheType', which may be used to specify
the ObjectCache type to use for gadget definitions.

Change-Id: I1e02f7b6c470c5fffa014c6247c71f43a69420b6
2015-05-11 18:17:36 -07:00
Chad Horohoe fb5c2ba40e Remove obvious function-level profiling
Change-Id: If6ce3558357a64ce5054a40e493d65a07956f471
2015-02-12 11:48:44 -08:00
Kunal Mehta 61f04bab01 Fix $wgGadgetsCaching = false;
Bug: 71988
Change-Id: Ib1012b4d0b0eeabb62812f35b61882bbf9733f3d
2014-10-12 17:26:13 -07:00
jenkins-bot aa84226d0e Merge "Ability to disable gadget caching" 2014-09-07 22:37:21 +00:00
Max Semenik 1e5c7917a7 Ability to disable gadget caching
Change-Id: Ic1653ae896ac0fd7c0165ecee76f807feea6edcf
2014-09-05 15:47:08 -07:00
Max Semenik 3abd0ebf4f Don't save gadget class versions, cache key is already versioned
Change-Id: I00c200c237f35d6e3934ce432271bd4fa968b175
2014-09-05 14:30:41 -07:00
Kunal Mehta b7b52a9029 Check Gadget name is a valid ResourceLoader module name
When loading the Gadget list, check against ResourceLoader::isValidModuleName
to avoid MWExceptions being thrown.

This will lower the max length of a gadget name from 248 bytes to
244 since ResourceLoader requires <= 255 bytes, and we add a
"ext.gadget." prefix in front of the name.

Bug: 19410
Change-Id: Ib74c0866bb333885c747d318418e2c8685ae339c
2014-09-02 17:27:39 +00:00
helderwiki c0e952120e Add space before closing parenthesis
Change-Id: Iea95227e70f87e54efb20dfac70ae7147e3186d2
2014-08-08 17:07:26 -03:00
Max Semenik 0ee165bce8 Move hooks to a separate file
Change-Id: I2cb53bd4beae247c1b983dc8c4482af682acab64
2013-08-30 03:35:07 +04:00
Roan Kattouw 17c820f364 Add 'top' flag to allow Gadgets to top-load
Obviously this should be used sparingly, but it's needed for some
initialization stuff like registering plugins with VisualEditor.

Change-Id: Ifeed524a53601a47b3a945ca0a324bbbead0f1f5
2013-07-23 21:02:19 -07:00
Marius Hoch 4f65685257 Don't cache the gadget-defintion in case no gadgets were found
After some investigation I could only find a few unlike
possibilities which eventually could lead to the issues
described in the bug. In the end I decided that it would
be the easiest and probably most robust solution to simply
don't cache in case no gadgets were found, even if the
MediaWiki page exists.
This shouldn't cause any performance issues as we already
don't cache in case no gadgets could be found in all paths
of this function except after trying to parse the gadget
definition.

Bug: 37228
Change-Id: I3092bcb162d032282fbe263c7f14f4d1ce9163ab
2013-07-14 18:01:37 +02:00
Liangent 867ccb19b4 Gadget-definitions: Make comment matching non-greedy
Change-Id: I1b92e4d84d11ff7493a2ec684815d19f0937caa7
2013-05-24 09:18:09 +00:00
Max Semenik 192d37b19a Allow disabling of legacy gadgets (Mobile support)
The mobile environment differs from the desktop environment so various
gadgets may not work as expected. ResourceLoader deals with this for
normal modules by enforcing a 'targets' property that requires
javascript that wants to run on mobile to specify a mobile target.

This change
* Allow other extensions to disallow legacy gadgets
* Allow specifying module targets in similar way to RL, effectively
creating mobile gadgets

Bug: 44918

Change-Id: I9ee852e33412826608b6039fa01a2b0027b35e7b
2013-05-01 01:48:28 +00:00
Timo Tijhof eca021ed61 tests: Rename file to end in Test.php
Though the hook registration was working fine, the run from
Jenkins was failing.

Jenkins runs like this:

 $ php tests/phpunit/phpunit.php extensions/Gadgets

Which bypasses UnitTestsList and uses auto-discovery within the
given directory of "*.Test.php" files.

Renamed to file to match PHPUnit's internal discovery pattern
and updated the onUnitTestsList callback to use this pattern
as well.

Also updated documentation applied recent code conventions in
this area (extend MediaWikiTestCase).

Change-Id: Iaa52a5eafdebf1529dd02fb1bed89d27c298e0d3
2013-05-01 03:20:39 +02:00
Max Semenik f8cceadc00 Typo in comment
Change-Id: I2ea2a363ea42e690386ba662b201b9a56fbe35f1
2012-11-16 20:58:52 +04:00
Siebrand Mazeland bf416b175a Maintenance for Gadgets extension.
* Use Message class.
* Redice globals usage.
* Update .gitignore.

Change-Id: I087c8209b1a7ccf63171a2c14c8809eed90a297b
2012-08-17 11:28:09 +02:00
Sam Reed df866a5f21 Documentation, code updates, removal of direct member variable access 2012-02-17 21:23:46 +00:00
Roan Kattouw 9009f36e81 Revert r106007 (Split Gadget modules into two, one for scripts and one for styles): I like the concept of having multiple modules, and I'll probably implement this in the RL2 branch, but this specific implementation has issues (subclassing OutputPage, building its own head items) that were pointed out on CR but never fixed. 2012-02-02 19:04:52 +00:00
Liangent f0f203bbba Followup r100509: Don't validate skin names written in the definition page. 2012-01-18 02:44:37 +00:00
Robin Pepermans f6e96b17e9 Bug 30182: add dir="auto" as a workaround for untranslated gadget descriptions 2011-12-13 18:03:00 +00:00
Liangent cbef9a4faf Followup r100497, r101827: use another way which doesn't look that hacky to load styles in gadgets before documents. Also avoid double loading of the same stylesheet.
Now a gadget generates up to three modules:
* The first is known as meta module which still use its original name to keep B/C. It contains no contents, with dependencies of ones specified by user, scripts module, and styles module. See below.
* The second is known as scripts module whose name ends with ".scripts". It contains all scripts in this gadgets, with dependencies specified by user
* The third is known as styles module whose name ends with ".styles". It contains all styles in this gadgets and loaded before documents. After its load it's instantly marked as ready without dependencies resolved (which is the same as dependencies of .scripts but may not be used at all)

The meta module is loaded as if there's only one module under that name, and it's safe for users to reuse that name. The styles module is loaded and marked as ready in <head>, as described above. Normally the scripts and styles modules shouldn't be used by users.

A possible bug that dependency-only gadgets (ie. no scripts or styles) may not be loaded is fixed.
2011-12-13 10:41:51 +00:00
Liangent fadacf486f Followup r101827: It doesn't need to extends OutputPage anymore 2011-11-03 16:12:11 +00:00
Liangent f2478673ee Followup r100497: Fix stuff described there 2011-11-03 16:11:04 +00:00
Liangent 7bdf6f5ca2 Followup r100509: Increase GADGET_CLASS_VERSION 2011-10-24 12:49:33 +00:00
Liangent b9aa1fea37 (bug 31414) Skin specific gadgets 2011-10-22 19:09:25 +00:00
Liangent fb4ad3cac6 Followup r100497: Indention tweak 2011-10-22 05:59:55 +00:00