Commit graph

15 commits

Author SHA1 Message Date
Timo Tijhof
b6a2e22acd resourceloader: Improve coverage of SkinModule
* Ignore getLogoData() which is a one-line proxy to ::getLogo,
  that can't really be tested because static methods can't be stubbed.
  It exists so that this method can be stubbed instead. The actual
  method is already covered.

* Simplify @covers for getStyles() to allow indirect coverage within
  the class because it's intended as a higher-level integration tests.
  The other tests in the suite still cover a specific method only.

Change-Id: I1445a016c1f12a6d8ceaaf745023a28cf20e5371
2018-05-04 17:31:04 +01:00
Paladox
66b13d1ba8 Add support for SVGs to $wgLogoHD with PNG fallback
SVGs could already be used through $wgLogo. However, if a PNG fallback
is desired for older browsers, using SVGs was previously not possible.

This commit adds support for using an SVG image in $wgLogoHD and,
using $wgLogo as the fallback image.

Usage example:

> $wgLogo = '/path/to/png';
> $wgLogoHD = [
>     'svg' => 'path/to/svg',
> ];

Note: When the 'svg' key is set in $wgLogoHD, any '1.5x' and '2x' keys will
no longer be used because SVGs can render optimally on any screen sizes.

@Reedy, @Krinkle and @Brion VIBBER helped me alot with this.

Bug: T86229
Change-Id: I6197d96ce9110f4711ef2c4b198445bc5c6ae110
2017-10-24 17:51:28 +00:00
Timo Tijhof
171bcfaae9 ResourceLoaderSkinModule: Fix SkinStyles extending of known media queries
If any of the styles given in its module definition (in the
'styles' or 'skinStyles' properties) used the same media queries
as the module's own CSS (e.g. 'all'), the module would fail with
"PHP Fatal error: [] operator not supported for strings" because
FileModule defaults to merging all the stylesheets into a single
string.

Fix this by ensuring they are arrays before trying to extend them.

This previously made it impossible to use $wgResourceModuleSkinStyles
for modules that use SkinModule (instead of plain FileModule), such as
the 'mediawiki.skinning.interface' module.

Bug: T168088
Change-Id: I3effcaa4982728e707fbf9efeec4e5e78fc8aab6
2017-07-10 19:53:00 +02:00
jdlrobson
2f1050622a resourceloader: Allow mobile target by default on SkinModule
If a skin is using this class, it's likely to be pretty new.
The targets system was mostly created for older code.

Let's make this the default so skins don't need to do anything
additional to work on mobile.

This simple change makes the Timeless skin work on mobile
when MobileFrontend is installed: ?useformat=mobile&useskin=timeless
It looks beautiful :)

Change-Id: I2ab8a1a634bdc0b5b2084d227c7388b5382e93e8
2017-06-30 21:49:13 +00:00
Timo Tijhof
45d8cd2926 Ensure logo preload transforms urls if needed
Follows-up 5f55e9c9c2.

If the logo url is from within /w, then ResourceLoaderSkinModule
will (as it should) apply a file hash query to it.

The preloader didn't do that, so it specified the wrong url.

Refactored SkinModule to make this logic re-usable.

Bug: T100999
Change-Id: I1ba11f7c70d1a725ad72754fee4a3f33c2a4c1be
2017-04-12 21:34:31 +00:00
Gilles Dubuc
5f55e9c9c2 Preload the logo using link rel="preload" http header
This greatly increases the priority of loading
the logo on browsers that support rel="preload".

Bug: T100999
Change-Id: I0738fcc0a575153dab65016fa87faaa9b8b97a9d
2017-04-11 19:08:53 -07:00
Timo Tijhof
20b445e22f resourceloader: Avoid deprecated getModifiedHash() in SkinModule
Use getDefinitionSummary instead, which uses a single serialisation
pass instead of requiring every stage to be a string. This way
we don't need to call json_encode and md5() multiple times.

getModifiedHash() was deprecated in MediaWiki 1.26.

Change-Id: If9e9caa3d12976c99543ad53ab280355b70acb17
2017-03-28 22:37:24 +01:00
Ricordisamoa
e64035522d Fix and standardize Doxygen tags
* Use "@param datatype $paramname description" format

* String → string, Integer → int etc.

* @return $string → @return string

Change-Id: I860d222382cb4c5699d313b0600bd22503c8c385
2016-04-30 12:10:17 +02:00
Timo Tijhof
419db58c8b Centralise url handling for urls to static resources
Keep in CSSMin as-is for back-compat and to ensure library remains
independent of MediaWiki.

Moved down a few lines as there is no need to compute the md5 hash when we're
returning a data URI. Previously md5_file was called twice during module builds
(once for the fallback url, and another time when producing the embedded data uri).

Applied to logo in SkinModule as example. To be applied elsewhere as needed.
Without it, fallback is current behaviour (no cache invalidation).

Bug: T99096
Change-Id: I7f38bfc1bea5c241bc4f8ec4f4b640fd65f2c04f
2016-02-02 23:26:16 +00:00
Timo Tijhof
afcfc3290c resourceloader: Consistently refer to the framework as ResourceLoader
Change-Id: Ia59e4eac9662723e80d62f7cfcb9e4292e3ee4de
2015-10-28 03:24:40 +00:00
umherirrender
d8821f2b0b Fixed spacing
- Removed space after casts
- Removed spaces in array index
- Added spaces around string concat
- Added space after words: switch, foreach
- else if -> elseif
- Removed parentheses around require_once, because it is not a function
- Added newline at end of file
- Removed double spaces
- Added spaces around operations
- Removed repeated newlines

Bug: T102609
Change-Id: Ib860222b24f8ad8e9062cd4dc42ec88dc63fb49e
2015-06-17 20:22:32 +00:00
Timo Tijhof
64ecc77422 resourceloader: Remove redundant getModifiedTime implementations
Follows-up f37cee996e which replaced the getHashMtime() and
getDefinitionMtime() methods with dummies that always return 1.

These getModifiedTime() implementations were only tracking the
definition summary or custom hash, which is already tracked
by getVersionHash().

Notes:
* SpecialCharacterDataModule: This one was odd as it was tracking
  both the mtime *and* the file contents.

* UserCSSPrefsModule/UserOptionsModule: Remove redundant caching.
  Already taken care of by getVersionHash() as of f37cee996e.

Bug: T94074
Change-Id: I6e37c3c2f85ef4599a8643b0efabc18de2f51ec4
2015-06-03 14:27:38 +00:00
isarra
b5f2cf2db1 Add support for HD versions of the wiki logo in MonoBook-like skins.
Done using an array $wgLogoHD, which expects something like the following:

$wgLogoHD = array(
	"1.5x" => "path/to/1.5x_version.png",
	"2x" => "path/to/2x_version.png"
);

This is still horrible, but I dunno how to make it less horrible. Help.

Bug: T37337
Change-Id: Iee3e73c1f96b81c2094418986cf1c267d93d1bdd
2015-03-13 06:20:00 +00:00
Ricordisamoa
f86a5590aa Always use 'bool' instead of 'boolean' after '@param' and '@return'
The former is by far the most common.

Skipped:
* resources/lib/jquery.ui/jquery.ui.datepicker.js
* resources/src/mediawiki.special/mediawiki.special.upload.js

Change-Id: I73c93797e745128ba703e4865080c36784caa474
2014-12-10 11:57:31 +00:00
tholam
c24ef26d68 Set site logo in mediawiki.skinning.interface module instead of inline styles
Requires skins use the 'mw-wiki-logo' class on the logo element for the styles
to apply and to load the 'mediawiki.skinning.interface' module (or implement
their own skin module that uses the ResourceLoaderSkinModule class).

This is backwards compatible with skins using inline styles as the class only
applies when used.

Bug: 56257
Change-Id: I4e6db89a688843ac24539f8fd1b408c0d04881b3
2014-09-26 21:09:22 +00:00