On Jul 3, 2013, at 4:47 AM, Ori Livneh ori@wikimedia.org wrote:
On Tue, Jul 2, 2013 at 11:52 PM, Thomas Gries mail@tgries.de wrote:
Question:
How to contruct the background-image filename from a value in one of the OpenID PHP modules ?
For a single rule, you can get away with something like:
$wgHooks[ 'BeforePageDisplay' ][ ] = function ( &$out, &$skin ) { $out->addHeadItem( 'oauth-provider', '<style>.oauth { color: red; }</style>' ); return true; };
Please don't. Adding additional script or style tags with must be avoided.
Even for "just one" this is imho not acceptable for new code under any circumstances.
For dynamically generated css, create a RL module that returns the generated CSS instead of the contents from a file on disk.
RL modules specifically allow this. In fact, the module base class make no assumptions about being associated with a file, only the ResourceLoaderFileModule implements this. For example ResourceLoaderUserCSSPrefsModule generates it as part of the module, and ResourceLoaderWikiModule loads it from wikipage content.
Though there are more benefits, here's a few that should be convincing enough to never use raw <style> again. The first two being most important as they aren't enhancements but actual bugs that can arise as a result of not using ResourceLoader:
* Not being cached as part of the page output. * Automatically being run through CSSJanus for proper RTL-flipping.
* Keeps the output page smaller, by sharing a common cache (the load.php request with 30 days+ cache expiration). * Automatically being run through CSSMin for compression. * Better gzip compression for the css selectors (e.g. class name "mw-oauth-button") and rules (e.g. phrase "background-image" used in other stylesheets as well) by being part of a request that also includes other stylesheets and scripts.
-- Krinkle