The extension OpenID loads a CSS file via RL:
$myResourceTemplate = array( 'localBasePath' => $path . '/skin', 'remoteExtPath' => 'OpenID/skin', 'group' => 'ext.openid', ); ... $wgResourceModules['ext.openid.icons'] = $myResourceTemplate + array( 'styles' => 'openid.css', 'dependencies' => array( 'ext.openid' ) );
openid.css comprises lines such as #openid_provider_OpenID_icon { /*@embed*/background-image: url(icons/OpenID_large.png); }
Question: ========= How to contruct the background-image filename from a value in one of the OpenID PHP modules ?
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; };
Am 03.07.2013 13:47, schrieb Ori Livneh:
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; };
50% okay, but there's a remaining problem for my specific construct, because the script path is needed to fetch the image, but it is the article path in that hook context:
"index.php/skin/icons/Google_large.png"
which of course fails to load the image.
Is there any help ? How can the script path be used (instead of the article path) ? ===================
$wgHooks[ 'BeforePageDisplay' ][ ] = function ( &$out, &$skin ) { $out->addHeadItem( 'openidstyle', '<style>#openid_provider_Google_icon { background-image: url(skin/icons/Google_large.png); } </style>' ); return true; };
I found the solution ( $wgExtensionAssetsPath )
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( 'openidstyle', '<style>#openid_provider_Google_icon { background-image: url(' . $wgExtensionAssetsPath .'/OpenID/skin/icons/Google_large.png); } </style>' ); return true; };
On Wed, Jul 3, 2013 at 3:27 PM, Thomas Gries mail@tgries.de wrote:
I found the solution ( $wgExtensionAssetsPath )
Why do you need this? You shouldn't need this. Paths relative to the CSS file should be remapped automatically and should Just Work.
Roan
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
Just for the record, the associated change with this inquiry is https://gerrit.wikimedia.org/r/55287
*-- * *Tyler Romeo* Stevens Institute of Technology, Class of 2016 Major in Computer Science www.whizkidztech.com | tylerromeo@gmail.com
On Sun, Aug 25, 2013 at 12:51 PM, Krinkle krinklemail@gmail.com wrote:
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
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
wikitech-l@lists.wikimedia.org