Commit graph

100 commits

Author SHA1 Message Date
Roan Kattouw
ef26c7ad4f Followup 1cf5a6e: use $wgResourceBasePath to refer to resources/assets, not $wgScriptPath
Bonus: actually make $wgResourceBasePath default to $wgScriptPath, rather than
special-casing it in ResourceLoaderFileModule.

Change-Id: I608435cef00d3e77a5bbdb0a0122d3e7e1a4eb78
2014-09-17 16:21:28 -07:00
Bartosz Dziewoński
285c52039b Revamp classic edit toolbar not to hardcode paths in HTML
Also, try out a way to have per-module LESS variables defined in PHP.
This might come in handy in the future… Maybe for skin theme support?

(I recommend reviewing the file changes in the order below. :D)

includes/resourceloader/ResourceLoaderFileModule.php
  * Pass the context (ResourceLoaderContext) deeper down via
    readStyleFiles() and readStyleFile(). We need it to compile the
    .less files for the right language.
  * Extract LESS compiler creation to getLessCompiler().
  * Allow passing a LESS compiler instance to compileLessFile(), rather
    than getting one after the method is called.

  All of the changes are backwards-compatible.

includes/resourceloader/ResourceLoaderEditToolbarModule.php
  * New module to support getting the language data and passing it to
    LESS variables.

  It might be a good idea to factor out a reusable class for a LESS
  module with additional variables, but that would require more
  attention to design than I gave it.

resources/src/mediawiki.action/mediawiki.action.edit.toolbar/mediawiki.action.edit.toolbar.less
  * Glue code to use the language data defined by the module above and
    put it in final CSS.

includes/EditPage.php
  * Do not hardcode image URLs in output HTML, as they are provided in
    CSS now. This gets rid of some usage of globals.

  In fact, we should be able to finally move the inline JavaScript
  calls out of getEditToolbar(), but I'm already introducing too many
  changes for one patch. That can be done later.

languages/Language.php
  * Add getImageFiles() to complement existing getImageFile() method.
    Misleadingly named, it returns paths for images for the toolbar
    only (and no other ones at all).

skins/common/ → resources/src/mediawiki.action/mediawiki.action.edit.toolbar/
  * Moved all of the button images to new location.

  Also, boring cleanup that was harder before because we treated the
  paths as public API:
  * Placed default ones in en/ subdirectory.
  * Renamed cyrl/ to ru/.
  * Renamed ksh/button_S_italic.png → ksh/button_italic.png.

languages/messages/
  * Adjusting paths and filenames for the changes above.

resources/src/mediawiki.action/mediawiki.action.edit.css
resources/src/mediawiki.action/mediawiki.action.edit.js
  * Added styles and updated the script to make it possible to have
    non-<img> elements as toolbar buttons.
  * Consolidated styles that were already required, but defined
    somewhere else:
    * `cursor: pointer;` (from shared.css)
    * `vertical-align: middle;` (from commonElements.css)

Bug: 69277
Change-Id: I39d8ed4258c7da0fe4fe4c665cdb26c86420769c
2014-09-13 23:16:23 +02:00
jenkins-bot
08e50bcecd Merge "Make "/*@noflip*/ /*@embed*/" annotation work" 2014-08-29 19:45:06 +00:00
Bartosz Dziewoński
1538edce7b ResourceLoaderFileModule: Do not separately cache .less files
We used to have a second level of caching for them – when a module's
cache was invalidated, individual .less files that comprise it would
only be recompiled (with all their @imports) if their mktime changed
(or if $wgResourceLoaderLESSVars changed).

Given that practice has shown that RL modules including .less files
usually just include one file that @imports tons of stuff, and given
that RL already is very careful about invalidating caches, I think
this is unnecessary at best and harmful at worst.

The behavior proved problematic when I tried to implement support for
per-module LESS variables, values of which were language-dependent –
files would not be recompiled for different languages, and
getLessCacheKey() is called several levels deep in code that doesn't
have access to the context in which the module is being compiled.

Change-Id: I667f063507583e4cd3a669e32398d440f1431f7e
2014-08-20 20:26:46 +02:00
Bartosz Dziewoński
cd22ba020e Consistently use 'Less' rather than 'LESS' in function names
PHP function names are case-insensitive, so this is a fully
backwards-compatible change.

Change-Id: Ide04ad542ac5c3a26b6064093ae272cf9aeef2d1
2014-08-20 18:48:10 +02:00
Bartosz Dziewoński
2d842f1425 Make "/*@noflip*/ /*@embed*/" annotation work
To do it, just remove /*@noflip*/ annotations in CSSJanus after
we're done processing. They are not needed anymore and some obscure
interactions with CSSMin logic for preserving comments caused
`/*@noflip*/ /*@embed*/ background-image: url(…)` not to work
correctly (it would not be embedded).

This also requires us to always do CSSJanus processing, even when we
don't need flipping, to consistently handle the annotations.
I'm not entirely sure if this is worth it, but I still greatly prefer
doing it to documenting this stupid limitation. :)

Bug: 69698
Change-Id: I311b12b08b2dff9d45efb584db08cf4a11318f59
2014-08-18 17:40:51 +02:00
umherirrender
c2de24efcd Add missing @param to function docs
Change-Id: Ib7ac94d05a04490f25dfd40b46b27973cbab582c
2014-08-14 19:38:57 +00:00
Alexandre Emsenhuber
cc03986ca1 resourceloader: Fix undefined variable in ResourceLoaderFileModule::getSkipFunction
Follows-up 75c08916b0. Looking at the call chain of
validateScriptFile() up to JSTokenzier, the first parameter is the file
name, otherwise "[inline]" is used; so that variable should be $localPath.

Bug: 69214
Change-Id: If7f36449cb352f50ba795a6d306e5d949a3dbd29
2014-08-12 22:25:20 +00:00
jenkins-bot
2268ae08a0 Merge "includes/resourceloader/: Use Config instead of globals" 2014-08-08 17:25:42 +00:00
Kunal Mehta
4b1a87c96e includes/resourceloader/: Use Config instead of globals
Change-Id: Iaa1f4ae9c397575c9bb86dacbc342456e6f5f532
2014-08-07 18:47:34 +01:00
Kunal Mehta
0d051f6a4f ResourceLoaderFileModule::extractBasePaths: Simplify if condition
Change-Id: I69f090595629dabefaa0c6ddaa9a793a2f86ecfd
2014-08-07 11:27:36 +01:00
umherirrender
473b7d925e Fixed docs
- Use short form of boolean
- Use capital at begin of doc text

Change-Id: Ic5afacfa7298b1938d3b45ffd0cac5ce01f2f9db
2014-08-04 12:00:15 +02:00
Bartosz Dziewoński
3971d0646c resourceloader: Allow skins to provide additional styles for any module
The newly introduced $wgResourceModuleSkinStyles global enables skins to
provide additional stylesheets to existing ResourceLoader module.

This both makes it easier (or at all possible) to override default
styles and lowers the style footprint by making it possible not to
load styles unused on most pages.

----

Example:

Use the file 'foo-styles.css' for the 'mediawiki.foo' module when using
the MySkin skin:

  $wgResourceModuleSkinStyles['myskin'] = array(
    'mediawiki.foo' => 'foo-styles.css',
    'remoteSkinPath' => 'MySkin',
    'localBasePath' => __DIR__,
  );

For detailed documentation, see the doc comment in DefaultSettings.php.
For a practical usage example, see Vector.php.

----

Implementation notes:

* The values defined in $wgResourceModuleSkinStyles are embedded into
  the modules as late as possible (in ResourceLoader::register()).
* Only plain file modules are supported, setting module skin styles
  for other module types has no effect.
* ResourceLoader and ResourceLoaderFileModule now support loading
  files from arbitrary paths to make this possible, defined using
  ResourceLoaderFilePath objects.
  * This required some adjustments in seemingly unrelated places for
    code which didn't handle the paths fully correctly before.
* ResourceLoader and ResourceLoaderFileModule are now a bit more
  tightly coupled than before :(
* Included a tiny example change for the Vector skin, a lot more of
  similar cleanup is possible and planned for the future.
* Many of the non-essential mediawiki.* modules defined in
  Resources.php should be using `'skinStyles' => array( 'default' => … )`
  instead of `'styles' => …` to allow more customizations, this is
  also planned for the future after auditing which ones would actually
  benefit from this.

Change-Id: Ica4ff9696b490e35f60288d7ce1295766c427e87
2014-07-29 00:53:41 +02:00
umherirrender
dd8921c9d9 Cleanup some docs (includes/[m-r])
- Swap "$variable type" to "type $variable"
- Added missing types
- Fixed spacing inside docs
- Makes beginning of @param/@return/@var/@throws in capital
- Changed some types to match the more common spelling

Change-Id: I8ebfbcea0e2ae2670553822acedde49c1aa7e98d
2014-07-24 19:43:25 +02:00
Sam Smith
0bb3d2a499 Make ResourceLoaderFileModule#getAllStyleFiles include all skin styles
* Add the ResourceLoaderFileModule#getAllSkinStyleFiles method,
  which returns all of the skinStyles files for a given module
* The LessFileCompilationTest and checkLess.php script, which use
  the #getAllStyleFile method, now validate all LESS style files

Bug: 63343
Change-Id: Ib2eb5761919c648aea4ae58f8d0531799fe7982b
2014-06-17 19:38:58 +00:00
Daniel Friesen
07b80668be ResourceLoaderFileModule: Implement remoteSkinPath option
remoteSkinPath works the same as remoteExtPath but is relative to skins/ instead of extensions/

This will allow skins to register modules using:
 $wgResourceModules['skin.myskin'] = array(
   // ...
   'localBasePath' => __DIR__,
   'remoteSkinPath' => 'myskin',
 );

Instead of using:
 'remoteBasePath' => $GLOBALS['wgStylePath'] . '/myskin', // or
 'remoteBasePath' => &$GLOBALS['wgStylePath'],

Change-Id: I0e8c4a37a224e9528c9c5aa5417f0f56dbb89b97
2014-06-17 16:05:19 +02:00
Timo Tijhof
75c08916b0 resourceloader: Implement "skip function" feature
A module can be registered with a skip function. Such function,
if provided, will be invoked by the client when a module is
queued for loading. If the function returns true, the client will
bypass any further loading action and mark the module as 'ready'.

This can be used to implement a feature test for a module
providing a shim or polyfill.

* Change visibility of method ResourceLoader::filter to public.

So that it can be invoked by ResourceLoaderStartupModule.

* Add option to suppress the cache key report in ResourceLoader::filter.

We usually only call the minifier once on an entire request
reponse (because it's all concatenated javascript or embedded
javascript in various different closures, still valid as one
large script) and only add a little bottom line for the cache
key. When embedding the skip function we have to run the minifier
on them separately as they're output as strings (not actual
functions). These strings are typically quite small and blowing
up the response with loads of cache keys is not desirable in
production.

* Add method to clear the static cache of ResourceLoader::inDebugMode.

Global static state is evil but, as long as we have it, we at
least need to clear it after switching contexts in the test suite.

Also:
* Remove obsolete setting of 'debug=true' in the FauxRequest in
  ResourceLoaderTestCase. It already sets global wgResourceLoaderDebug
  in the setUp() method.

Bug: 66390
Change-Id: I87a0ea888d791ad39f114380c42e2daeca470961
2014-06-12 03:48:26 +02:00
Timo Tijhof
0888ccbcad Installer: Re-use ResourceLoader methods instead of duplicating
Also:
* Fix incorrect documentation comment of ResourceLoaderModule::getStyles(),
  it doesn't return a string, it never has.
* Remove spurious space in count() call.
* Fix spelling of in "proper".

Change-Id: I000393636f7b9015ad1bacfbb3eb8a6ad8695d72
2014-06-07 10:02:55 +02: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
66b736e5fb resourceloader: Fix broken skinStyles loop in #getModifiedTime
The way we interpret the 'skinStyles' array in #getModifiedTime
is broken. For comparision, look at the loop in #getStyleFiles
which we use for the creation of the actual stylesheets (which
works fine).

It mixed up the logic causing it to always end up with an empty
array. So it's not so much that it fails to detect the files
having changed after an update, it never included mtimes of these
files in the first place. If there'd be a module with only
skinStyles resources, it would have timestamp 0 (1970).

Bug: 62068
Change-Id: I2e772a13183e66e4bfbf95057ebfd7f5e0d817ec
2014-02-28 19:24:51 +00:00
umherirrender
add8b9a976 Unroll array_map in ResourceLoaderFileModule::readStyleFiles
ResourceLoaderFileModule::readStyleFile can throw exceptions which
produces warnings when using array_map.

Produces useful stacktraces when there are issues with style file like LESS compilation errors

Bug: 47844
Bug: 59858
Change-Id: I7c48b2c94752eee81f0eeb8e00d1f2b526d80dfc
2014-02-13 06:27:17 +00:00
umherirrender
073abe3e12 No variable assignment on return statement
Split the variable assignment and the return statement in two lines for
better readability.

When there was two return statements in one method the logic was swapped
to have only one return statement.

Change-Id: Id7a01b4a2df96036435f9e1a9be5678dd124b0af
2014-01-02 09:43:35 +00:00
Timo Tijhof
d3bdda3221 resourceloader: Add definition hashing to improve cache invalidation
Currently we invalidate module caches based on timestamps from
various places (including message blob, file mtimes and more).

This meant that when a module changes such that the maximum
detectable timestamp is still the same, the cache would not
invalidate.

Module classes can now implement a method to build a summary.
In most cases this should be (a normalised version of) the
definition array originally given to ResourceLoader::register
(such as $wgResourceModules items).

The most common scenarios this addresses:

* File lists (scripts, styles) being re-ordered.
* Files being removed when more recently changed files remain
  part of the module (e.g. removing an older file).
* Files or messages being added to a module while other more
  recently changed things are already part of the module.
  E.g. you create a message and use it in a js file, but forget
  to add the message to the module. Then later you add the msg
  key. This last update would be ignored, because the mtime of
  the message is no newer than the total which already included
  the (same) mtime of the js file added in the previous update.
* Change the concatenation order of pages in a Gadget definition.

Bug: 37812
Change-Id: I00cf086c981a84235623bf58fb83c9c23aa2d619
2013-12-02 21:45:33 -08:00
umherirrender
0bc583af2c Move closing parenthesis from multi line if and function to own line
The Line continuation Coding conventions prefers the closing parenthesis
on the same line than the beginning curly braces. This is done for ifs
and functions.
Also move some boolean operator from the end of a line to the beginning
and changed some indentation to make the condition hopefully better
readable.

Change-Id: Id0437b06bde86eb5a75bc59eefa19e7edb624426
2013-12-01 21:39:00 +01:00
umherirrender
f153998317 Fixed spacing
- Removed double spaces
- Added space after if/switch/foreach
- Removed space on elseif
- Added space around parentheses
- Added newline at end of file
- Removed space before semicolon at end of line

Change-Id: Id40b87e04786c6111e6686d7f7eea1e588bdf37d
2013-11-19 19:03:54 +01:00
Timo Tijhof
f46f21915a resourceloader: Use state "error" instead of "missing" in case of exceptions
Changes:
* If we catch an exception while making the response for a module, set its
  client state to "error" instead of "missing".
  State "missing" should only be used if the module could not be
  found in the registry.
  This matches the behaviour of the client.

Clean up:
* Merge the two mw.loader.state calls into one.
* Add @throws documentation for compileLESSFile (follows-up cdc8b9e).
* Don't use 3 different ways to assert an array being empty,
  using 1 and sticking to it.
  - !$arr
  - $arr === array()
  - count( $arr )

Change-Id: I54c3de6d836702ffbe3044bc58a38e83e758bc33
2013-11-15 02:32:48 +01:00
Timo Tijhof
cdc8b9e011 resourceloader: Don't catch LESS error in ResourceLoaderFileModule
Instead let it throw up to ResourceLoader::makeModuleResponse.. By using
the central logic for exception handling the parse error becomes more
discoverable and obvious.

* The module is marked as in "error" state (currently it would still serve
  the result of file A and C, even if file B has a parse error).
  This matches the behaviour of the javascript checker we have.
* The exception comment is produced on top of the load.php response
  (where users expect it) instead of buried somewhere between the
  different modules and the different files within the modules.
* The exception comment will not be stripped out by CSSMin.
* DRY :)

Without this, debugging less parse errors is harder than it should be.

Bug: 55442
Change-Id: I6510b43f02cf82568b7fd2421209a8e636d5e115
2013-10-14 17:49:21 +00:00
Max Semenik
4d80400cdf Fix comment typos from 5c51cb96ea
Change-Id: I56f37010bce8a325af65eab62e7add232df108f4
2013-10-01 19:32:33 +00:00
Max Semenik
5c51cb96ea Maintenance script to check LESS files for validity
A reworked version of script from I068686854ad79e2f63a08d81b1af02f373110613

Move leccs instantiation code to ResourceLoader because it doesn't depend on any
particular module's state.

Change-Id: I733b53171dca77f50a30e5bd0bd5f1b456e4c85d
2013-09-30 21:37:13 +04:00
Timo Tijhof
93cb656139 less: Use new addParsedFile method, replacing embeddedFiles hack
Follows-up b67b9e1, lessphp now has a public method to add to the
list of files for compilation cache.

Change-Id: I62a6c7cdeb34ea742fa7547e3ca10e24ee484b97
2013-09-29 05:16:00 +00:00
Timo Tijhof
e09c4d952d less: Add '@since 1.22' comments
Change-Id: I673705423cf7618e207c0ee47b01761d6c89ce5f
2013-09-28 06:23:01 +00:00
Ori Livneh
565b0fae81 Rename lessc->embeddedImages to lessc->embeddedFiles
'embeddedImages' is a custom property we set on lessc compiler instances to
track the set of files that were embedded in the generated source as data URIs.
This is so done so we know to regenerate the CSS if the source file for an
embedded asset changes. (If my pull request[1] is merged, we won't have to use
a custom property at all.)

I realized that the property name should be 'embeddedFiles' rather than
'embeddedImages', because it's not just images that can be usefully embedded in
CSS, but fonts as well.

  [1]: https://github.com/leafo/lessphp/pull/472

Change-Id: Ief3afaa23e4532f4a536e0dfef943d4fa20db80d
2013-09-23 14:46:41 -07:00
Ori Livneh
b67b9e1b48 Support LESS stylesheets in ResourceLoader
This patch adds support for the LESS stylesheet language to ResourceLoader.
LESS is a stylesheet language that compiles into CSS. The patch includes
lessphp, a LESS compiler implemented in PHP. The rationale for choosing LESS is
explained in a MediaWiki RFC which accompanies this patch, available at
<https://www.mediawiki.org/wiki/Requests_for_comment/LESS>.

LESS support is provided for ResourceLoader file modules. It is triggered by
the presence of the '.less' extension in stylesheet filenames. LESS files are
compiled by lessc, and the resultant CSS is subjected to the standard set of
transformations (CSSJanus & CSSMin). The immediate result of LESS compilation
is encoded as an array, which includes the list of LESS files that were
compiled and their mtimes. This array is cached. Cache invalidation is
performed by comparing the cached mtimes with the mtimes of the files on disk.
If the compiler itself throws an exception, ResourceLoader constructs a
compilation result which consists of the error message encoded as a CSS
comment. Failed compilation results are cached too, but with an expiration time
of five minutes. The expiration time is required because the full list of
referenced files is not known.

Three configuration variables configure the global environment for LESS
modules: $wgResourceLoaderLESSVars, $wgResourceLoaderLESSFunctions, and
$wgResourceLoaderLESSImportPaths. $wgResourceLoaderLESSVars maps variable names
to CSS values, specified as strings. Variables declared in this array are
available in all LESS files. $wgResourceLoaderLESSFunctions is similar, except
it maps custom function names to PHP callables. These functions can be called
from within LESS to transform values. Read more about custom functions at
<http://leafo.net/lessphp/docs/#custom_functions>. Finally,
$wgResourceLoaderLESSImportPaths specifies file system paths in addition to the
current module's path where the LESS compiler should look up files referenced
in @import statements.

The issue of handling of /* @embed */ and /* @noflip */ annotations is left
unresolved. Earlier versions of this patch included an @embed analog
implemented as a LESS custom function, but there was enough ambiguity about
whether the strategy it took was optimal to merit discussing it in a separate,
follow-up patch.

Bug: 40964
Change-Id: Id052a04dd2f76a1f4aef39fbd454bd67f5fd282f
2013-09-23 12:55:19 -07:00
Ori Livneh
71e7e64001 Consistently follow conventions for documenting parameters
Per MW:CC/PHP, the type goes before the variable name, and built-in types are
not uppercase.

Change-Id: Ibb753acd9529ace3579d57654adc47673fa49719
2013-09-12 21:50:45 -07:00
Timo Tijhof
bce48e9420 resourceloader: Consistently use 'resourceloader' log group
Some were using generic wfDebug().

Removed obsolete new-line which is already added by wfDebugLog.

Bug: 44018
Change-Id: I9907b374fa868c04ff2ce40964238936b9084a4a
2013-05-20 19:35:11 +00:00
Timo Tijhof
8dbe77db6c phpcs: Pass includes/resourceloader/
- A cast statement must not be followed by a space.
- The method parameter $context is never used.
- Avoid function calls in a FOR loop test part.
- Opening brace should be on the same line as closing parenthesis.

Change-Id: I0eba7fcc9ceab372003d1134857346690c525e87
2013-04-03 02:16:02 +02: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
be90ce07b3 fix some spacing
Change-Id: I93f0a87ba7129bc336083e7289247d3150feb606
2013-02-04 19:54:07 +00:00
Catrope
e2e8461fd2 (bug 31044) Make ResourceLoader behave in read-only mode
When the database is in read-only mode or writes fail for some other
reason, ResourceLoader should make every attempt to still serve JS and
CSS correctly.

* Surround a bunch of DB write code in MessageBlobStore.php in try-catch
  blocks.
* Surround the DB write in ResourceLoaderFileModule.php in a try-catch
  block rather than checking wfReadOnly(), because the DB may fail for
  other reasons.
* In ResourceLoader::respond() and helpers, set a short cache timeout on
  responses that include commented-out error messages.

Change-Id: Idc83a0fe042806263f9337c40ade8c38c56aa3cd
2013-01-16 03:10:26 +00:00
Matthew Flaschen
a5d257e861 Fix typo in ResourceLoaderFileModule.
Change-Id: Ia4460fb8bba7e08f235016fa8b59adf97e48a4d3
2012-12-27 13:05:53 -05:00
Timo Tijhof
799db0b44b ResourceLoader: Move safeFilemtime() to ResourceLoaderModule.
This is a useful method not just for inside and sub classes of
ResourceLoaderFileModule (i.e. it could've been useful in
VisualEditor's ResourceLoaderModule class as well)

Also moved up getTargets() to be in the right section (looking at
the file as a whole).

Change-Id: If696ffbdc5aa7f0a51603bcf9d52adab38b9c686
2012-12-16 23:13:04 +01:00
jeroendedauw
11feec4c56 Remove duplicate files, no point in loading them twice
Change-Id: I52df1ee1cfeda240e8546fa303b65116183d09e7
2012-10-21 23:06:00 +02:00
Brion Vibber
4b3a426ae0 Work in progress on ResourceLoader mobilification
Goes along with MobileFrontend changes: https://gerrit.wikimedia.org/r/28434

Adds 'targets' option to module definitions, defaulting to 'desktop'.
Only a couple more modules are whitelisted into both desktop and mobile for now.

Startup module takes a 'target' parameter (defaults to 'desktop') to filter
the resource module registration list. Only modules matching the filter get
registered, and thus will be loadable from client-side RL.

Change-Id: Ifb772d4995b8e2ec4b63776fe0bb5b0214f82e04
2012-10-18 00:55:54 +00:00
Reedy
505c5cbfe3 Use wfDebugLog() not wfErrorLog()
Change-Id: I98dca32d788a4ff3ea102afe358e91b9ff4b06a5
2012-10-15 21:32:20 +01:00
Reedy
4fbbe15778 Add wfErrorLog() call before throwing an exception in readStyleFile
Due to the stupid PHP bug, this just gets rendered as a warning.

Then we have no idea what is actually wrong...

Change-Id: I38a2c6df2dc09ef67ff23537f867efa2ce2e3b54
2012-10-15 18:12:10 +01:00
Siebrand Mazeland
d4b046a893 Update docs for return and exception info
* Removed some inline tabs in the process.
* IDE fixed some incorrect leading spaces, too.

Change-Id: Ic9303eff6db4424ac3f1fa2816839692b43e6190
2012-10-09 09:41:58 +00:00
Timo Tijhof
ff594d3b0a ResourceLoader: Refactor style loading
Fixes:
* bug 31676: Work around IE stylesheet limit.
* bug 35562: @import styles broken in modules that combine
  multiple stylesheets.
* bug 40498: Don't output empty "@media print { }" blocks.
* bug 40500: Don't ignore media-type for urls in debug mode.

Approach:
* Re-use the same <style> tag so that we stay under the 31
  stylesheet limit in IE. Unless the to-be-added css text from
  the being-loaded module contains @import, in which case we do
  create a new <style> tag and then re-use that one from that
  point on (bug 31676).

* Return stylesheets as arrays, instead of a concatenated string.
  This fixes bug 35562, because @import only works when at the
  top of a stylesheet. By not unconditionally concatenating files
  within a module on the server side already, @import will work
  in e.g. module 'site' that contains 2 wiki pages.

  This is normalized in ResourceLoader::makeCombinedStyles(),
  so far only ResourceLoaderWikiModule makes use of this.

Misc. clean up and bug fixes:
* Reducing usage of jQuery() and mw.html.element() where
  native DOM would be very simple and faster. Aside from
  simplicity and speed, this is also working towards a more
  stand-alone ResourceLoader.
* Trim server output a little bit more
  - Redundant new line after minify-css (it is now an array, so
    no need to keep space afterwards)
  - Redundant semi-colon after minify-js if it ends in a colon
* Allow space in styleTest.css.php
* Clean up and extend unit tests to cover for these features
  and bug fixes.
* Don't set styleEl.rel = 'stylesheet'; that has no business
  on a <style> tag.
* Fix bug in mw.loader's addStyleTag(). It turns out IE6
  has an odd security measure that does not allow manipulation
  of elements (at least style tags) that are created by a
  different script (even if that script was served from the same
  domain/origin etc.). We didn't ran into this before because
  we only created new style tags, never appended to them. Now
  that we do, this came up. Took a while to figure out because
  it was created by mediawiki.js but it calls jQuery which did
  the actual dom insertion. Odd thing is, we load jquery.js and
  mediawiki.js in the same request even...
  Without this all css-url related mw.loader tests would fail
  in IE6.
* mediawiki.js and mediawiki.test.js now pass jshint again.

Tested (and passing qunit/?module=mediawiki; 123 of 123):
* Chrome 14, 21
* Firefox 3.0, 3.6, 4, 7, 14, 15, 16beta
* IE 6, 7, 8, 9
* Safari 4.0, 5.0, 5.1
* Opera 10.0, 11.1, 11.5, 11.6, 12.0, 12.5beta
* iPhone 3GS / iOS 3.0 / Mobile Safari 4.0
  iPhone 4 / iOS 4.0.1 / Mobile Safari 4.0.5
  iPhone 4S / iOS 6.0 Beta / Mobile Safari 6.0

Change-Id: I3e8227ddb87fd9441071ca935439fc6467751dab
2012-10-03 00:23:16 +02: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