Commit graph

37 commits

Author SHA1 Message Date
Bartosz Dziewoński
aa00a3e838 ResourceLoaderImageModule for icons
ResourceLoaderImageModule needs a set of SVG files and some data in
the module definition, and produces styles for a set of CSS classes,
one for each image, optionally with differently colored variants,
generated in SVG and PNG, data-URI-embedded if possible, compatible
with all browsers, and generally slick.

The intended usage is to ship icon libraries with MediaWiki that can
be used throughout the pages with no additional code.

* ResourceLoaderImageModule implements all of the logic for data
  parsing and CSS generation.
* ResourceLoaderImage implements the logic for SVG image colorization
  (for variants) and rasterization.
* ResourceLoader and ResourceLoaderContext were extended to serve a
  new kind of load.php request that delivers a single image file. This
  is used for fallback PNG images served to browsers that don't
  understand SVG.

See change Ic6a76bfb for a demo.

Bug: T76473
Co-Authored-By: Trevor Parscal <trevorparscal@gmail.com>
Co-Authored-By: Bartosz Dziewoński <matma.rex@gmail.com>
Change-Id: Idf6ff4eb8e94f45946f15d283d34108b881fae6e
2014-12-09 20:11:07 +01:00
Kunal Mehta
e7a0759f20 resourceloader: Add ResourceLoaderContext::getUserObj and replace use of $wgUser
Introduces ResourceLoaderContext::getUserObj(), which gets
a (possibly cached) User object for the context's username.

Use this instead of the $wgUser global.

Change-Id: Ifd9f634db145381625ab68067ae67791a3f494b8
2014-10-23 14:09:30 -07:00
Kunal Mehta
1d9d9b4d76 resourceloader: Pass a Config to the ResourceLoader constructor
Instead of relying on the default being main, which is deprecated.

Change-Id: I200e2c2dc922ae1fa5fa68d449403d0287e41786
2014-09-05 22:59:45 +00:00
Kunal Mehta
6a09d25aee Require a ResourceLoader instance is passed to ResourceLoaderContext
Change-Id: Ie1e5453b47349fc00664325827f88a1e7a6de43f
2014-08-10 11:36:59 +01:00
Kunal Mehta
4b1a87c96e includes/resourceloader/: Use Config instead of globals
Change-Id: Iaa1f4ae9c397575c9bb86dacbc342456e6f5f532
2014-08-07 18:47:34 +01:00
Kunal Mehta
126fb8d157 OutputPage: Support foreign module sources in makeResourceLoaderLink
To do so, created ResourceLoader::createLoaderURL(), which takes a
ResourceLoaderContext object. ResourceLoader::makeLoaderURL() was
deprecated.

While reviewing usage of the old function, many of the callers only
differed by one or two parameters from their respective
ResourceLoaderContext object. To simplify that use case, I created
DerivativeResourceLoaderContext, based of off DerivativeContext for
IContextSource.

Change-Id: I961c641ab953153057be3e3b8cf6c07435e9a0b0
2014-07-19 23:44:00 +00:00
Siebrand Mazeland
0b2fcf3785 Pass phpcs-strict on includes/resourceloader/
Change-Id: I5c63e0612c2aae240abcdbf21da9cdadd80dee31
2014-05-10 10:39:37 +02:00
umherirrender
dcf6955e5c Fixed some @params documentation (includes/*)
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.

Change-Id: Ifbb1da2a6278b0bde2a6f6ce2e7bd383ee3fb28a
2014-04-20 23:33:05 +02:00
Timo Tijhof
451a929c87 resourceloader: Sanitize lang code before creating Language object
Bug: 62849
Change-Id: I6af7818c4d8d2201ac4e1a4050b92fea56d90306
2014-03-19 22:41:18 +01:00
Bartosz Dziewoński
a6eea84baf Remove a HTML backwards-compatibility hack from 2011
This reverts r97607.

Change-Id: Ic0659e42e54dd1f08a4dd36d32adb356c3c18ae8
2014-02-17 03:54:42 +00:00
Henning Snater
85652b908f ResourceLoader: Prevent prefixless modules from overwriting others
Expanding prefixless modules should not overwrite the result set
of expanded modules.

Change-Id: Ic6e0e1c9e3fe7a585d34de21c532ee5ac3e7fdc5
2013-05-28 10:25:18 +00:00
Tyler Anthony Romeo
4dcc7961df Fixed @param tags to conform with Doxygen format.
Doxygen expects parameter types to come before the
parameter name in @param tags. Used a quick regex
to switch everything around where possible. This
only fixes cases where a primitve variable (or a
primitive followed by other types) is the variable
type. Other cases will need to be fixed manually.

Change-Id: Ic59fd20856eb0489d70f3469a56ebce0efb3db13
2013-03-11 13:15:01 -04:00
umherirrender
d63121016d fix some spacing
Added/removed spaces around logical/arithmetic operator
Reduced multiple empty lines to one empty line
Removed wrong tabs before comments at end of line
Removed too many spaces in assigments

Change-Id: I2bba4e72f9b5f88c53324d7b70e6042f1aad8f6b
2013-03-07 17:53:21 +01:00
Aaron
e302c675a2 [ResourceLoader] Use getLanguage() accessor as the field is lazy-loaded.
Change-Id: I6a106d1557366f6ff4586c9604fd324be51d7e1f
2012-05-25 14:52:39 -07:00
Max Semenik
cd7923ac16 Introduced the concept of raw ResourceLoader modules
This is needed for mobile scripts that are supposed to work on dumb
devices and as such can't rely on client-side RL, but still can take
advantage of server-side minification and concatenation.

Patchset 2: Allow loading raw modules with &raw=true appended to URL.

Change-Id: I9410ffbf6633075e07bd06b10a98a4d12d9b6106
2012-05-16 01:03:12 +04:00
Alexandre Emsenhuber
7d9016943d Added missing GPLv2 headers in some places.
Also made file/class documentation more consistent.

Change-Id: I1815587ab2eeb24623ce4bf1c695088bd3f1c2ea
2012-04-30 09:16:10 +02:00
Roan Kattouw
75b865cf87 In ResourceLoaderContext, normalize invalid skin names to $wgDefaultSkin . This should help a lot with the pollution of the module_deps table, which is currently littered with invalid skin names from people trying to hack the site. I found 3,897 (!!) distinct values for md_skin
Sample from the query result:

| md_module                   | md_skin                          |
|-----------------------------|----------------------------------|
| ext.vector.collapsibleNav   | vector'                          |
| ext.vector.collapsibleNav   | vector' and 1=1--                |
| ext.vector.collapsibleNav   | vector' and 1=2--                |
| ext.vector.collapsibleNav   | vector')waitfor delay'0:0:20'--  |
| ext.vector.collapsibleNav   | vector',0)waitfor delay'0:0:20'- |
| ext.vector.collapsibleNav   | vector',0,0)waitfor delay'0:0:20 |
| ext.vector.collapsibleNav   | vector',0,0,0)waitfor delay'0:0: |
| ext.vector.collapsibleNav   | vector'waitfor delay'0:0:20'--   |
| ext.vector.collapsibleNav   | vector../../../../../../../../.. |
[...]
| ext.vector.sectionEditLinks | vector<script src=               |
| ext.vector.sectionEditLinks | vector?.tri.co.id/               |
| ext.vector.sectionEditLinks | vector??id=jCustomerWAPProv      |
| ext.vector.sectionEditLinks | vector??id=wap.mauj.com....      |
| ext.vector.sectionEditLinks | vector?id=202.87.41.147....      |
| ext.vector.sectionEditLinks | vector?java                      |
| ext.vector.sectionEditLinks | vector?m.vuclip.com/             |
| ext.vector.sectionEditLinks | vector?toyota.co.id              |
| ext.vector.sectionEditLinks | vectorGET                        |
| ext.vector.sectionEditLinks | vector]]>>                       |
| ext.vector.sectionEditLinks | vector`ping -c 20 127.0.0.1`     |
| ext.vector.sectionEditLinks | vector|echo 9e7f7fd5750593ab cef |
| ext.vector.sectionEditLinks | vector|ping -c 20 127.0.0.1||x   |
2012-02-27 22:41:20 +00:00
Sam Reed
f8a0e34ca1 Documentation
Trim trailing whitespace

Make returns return values where appropriate (ie other paths in the same method do)
2011-10-14 08:06:54 +00:00
Roan Kattouw
7ef9760879 Accept ResourceLoader URLs containing '!' in '.' for backwards compatibility with a hack that existed in MediaWiki at some point (was in trunk and 1.17wmf1 but never in any release). This is needed because Squid-cached HTML at Wikimedia still contains such URLs. 2011-09-20 09:13:41 +00:00
Roan Kattouw
bcf236eddb Document the fact that some ResourceLoaderContext methods may return null 2011-09-13 20:15:00 +00:00
Roan Kattouw
418be34ddf Remove type hint that broke r95975 2011-09-01 13:07:27 +00:00
Roan Kattouw
84361c0962 Add ResourceLoaderContext::newDummyContext() function 2011-09-01 13:02:20 +00:00
Robin Pepermans
7c624542f0 (bug 6100; follow-up to r91315) Being bold and removing $wgBetterDirectionality (and dependent wfUILang) in core, as most or all work is finished.
Also:
* Introduce classes mw-float-end, mw-float-start so we don't have to use inline css depending on wfUILang()/$wgLang (see HistoryPage and SpecialFileDuplicateSearch)
* Add direction mark to protection log
* Remove specialpageattributes as it is obsoleted by this commit (also fixes bug 28572)
* Add two direction marks in wfSpecialList, which makes ltr links on rtl wiki (and vice versa) display nicely as well (only on those special pages however)
* Revert r91340 partially: use mw-content-ltr/rtl class anyway in shared.css. Both ways have their [dis]advantages...
* Set the direction of input fields by default to the content language direction (except buttons etc.) in shared.css
2011-07-06 02:26:06 +00:00
Robin Pepermans
932c44fd3e (part of bug 6100) Set the directionality based on user language instead of content language (as in r81622, but only when $wgBetterDirectionality is enabled) 2011-06-17 11:32:42 +00:00
Roan Kattouw
8dab43f703 (bug 28840) URLs with dots break because of IE6 security check
* Replace the overly paranoid regex with a function that simulates IE6's behavior
* Remove the UA check in isPathInfoBad(), was causing more problems than it was worth
* Revert r87711, going back to using dots for dots in ResourceLoader URLs, instead of exclamation marks
* Append &* to ResourceLoader URLs. * is an illegal character in extensions, and putting it at the end of the URL ensures that both IE6 and our detection function will deem the URL to have no extension (unless something like .html? appears in the query string, but in that case we're screwed no matter what)
2011-05-26 09:49:45 +00:00
Sam Reed
16c194d0ae Fixup/add documentation
Remove trailing whitespace
2011-05-21 17:45:20 +00:00
Roan Kattouw
a5de04f24a Fix bug in r87497, reported in CR: &modules=foo,bar,baz would look for '.foo', '.ar' and '.az' . Now handling prefixless modules correctly 2011-05-14 13:34:03 +00:00
Roan Kattouw
950cf2cb86 (bug 28840) Commit patch by bawolff that encodes dots in ResourceLoader module names as exclamation marks in the generated URLs, so as to avoid triggering the recently added IE security measure and causing a blank 403 response. This broke RL in various ways for IE users.
This is by no means intended to be permanent, but it's the best way to unbreak RL for IE users while we work out how to fix this properly.
2011-05-09 13:10:06 +00:00
Roan Kattouw
7fee86c38e Per bug 28738 comment 4, pack ResourceLoader URLs by encoding foo.bar|foo.baz|bar.baz|bar.quux as foo.bar,baz|bar.baz,quux
* Expand these URLs in ResourceLoaderContext
* Build and emit these URLs in OutputPage::makeResourceLoaderLink() and in mw.loader
* Throw an exception in ResourceLoader::register() for module names that contain pipe characters or commas. Commas need to be forbidden for this packing feature to work. Pipes were already forbidden but weren't checked for
2011-05-05 13:46:47 +00:00
Roan Kattouw
4d196860f7 Fix logic error in r73204 (!) causing ResourceLoaderContext::getHash() to always return null 2011-02-19 16:48:05 +00:00
Tim Starling
0f821f0dcb Use the content language to set the skin direction, instead of the user language. This makes the content readable and the UI messed up, instead of vice versa.
It's not ideal, but at least it's no worse than it was in 1.16. It's preferable because the content area is more likely to have bidirectional text than the UI area. The UI is split up into short strings, generally in a consistent language, so there is less chance of the UBA moving fragments of text around. 

Ideally, the direction of each div would be set according to the language of the text it contains.
2011-02-07 12:39:10 +00:00
Sam Reed
50b04942e4 Remove some unused variables and globals 2010-11-28 16:13:13 +00:00
Tim Starling
ec2acb239b * In ResourceLoaderContext, lazy-load $this->direction and $this->language, to avoid loading the whole English localisation for load.php requests which never call getHash().
* Interpreted some Trevor-speak in the doc comment of ResourceLoader::preloadModuleInfo().
* Made setMsgBlobMtime() (called from preloadModuleInfo()) actually work, by making getMsgBlobMtime() use the cached blob times if they are available.
2010-11-19 06:52:38 +00:00
Tim Starling
06b2b1bd66 Resource loader minor changes. Fix for r73668 etc.
* Break long lines.
* Convert long or unnecessary ternary operator usages to if/else.
* Fixed excessively clever assignment expressions.
* Rename $cache to $cacheEntry.
* Removed unnecessary web invocation guards. Their perlish form was making me uncomfortable. BTW, unlike in Perl, die() is not a function, it's a special case in the PHP grammar which very roughly simulates the Perl syntax:

die "x"; // works
0 || die("x"); // works
0 || (die); // works
0 || (die "x"); // fail!
2010-11-03 07:58:03 +00:00
Roan Kattouw
3517d951ba Some comment fixes: be consistent between # and //, fix grammar, remove information about internals from Doxygen comment (those are about what the function does, not how). Also make $modules argument to makeModuleResponse() default to array() instead of null 2010-10-20 14:58:35 +00:00
Antoine Musso
9adfb4f0a9 documentation, a couple notes about code and some whitespaces adjustements to make code easier to read. 2010-10-19 20:45:02 +00:00
Trevor Parscal
ef6baa91de Moved ResourceLoader classes to their own folder, preparing to also split ResourceLoaderModule.php into multiple files (it's getting a bit long now) 2010-10-19 18:21:38 +00:00
Renamed from includes/ResourceLoaderContext.php (Browse further)