[Wikitech-l] ResourceLoader support question: how to construct a value in CSS from PHP
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 ? ___ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Re: [Wikitech-l] ResourceLoader support question: how to construct a value in CSS from PHP
On Tue, Jul 2, 2013 at 11:52 PM, Thomas Gries 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', '.oauth { color: red; }' ); return true; }; ___ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Re: [Wikitech-l] ResourceLoader support question: how to construct a value in CSS from PHP
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', '.oauth { color: red; }' ); 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', '#openid_provider_Google_icon { background-image: url(skin/icons/Google_large.png); } ' ); return true; }; ___ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Re: [Wikitech-l] ResourceLoader support question: how to construct a value in CSS from PHP
On Jul 3, 2013, at 4:47 AM, Ori Livneh wrote: > On Tue, Jul 2, 2013 at 11:52 PM, Thomas Gries 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', '.oauth { color: red; > }' ); > 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
Re: [Wikitech-l] ResourceLoader support question: how to construct a value in CSS from PHP
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 | tylerro...@gmail.com On Sun, Aug 25, 2013 at 12:51 PM, Krinkle wrote: > On Jul 3, 2013, at 4:47 AM, Ori Livneh wrote: > > > On Tue, Jul 2, 2013 at 11:52 PM, Thomas Gries 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', '.oauth { color: red; > > }' ); > > 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