Re: [Wikitech-l] ResourceLoader support question: how to construct a value in CSS from PHP

2013-08-25 Thread Krinkle
On Jul 3, 2013, at 4:47 AM, Ori Livneh o...@wikimedia.org wrote:

 On Tue, Jul 2, 2013 at 11:52 PM, Thomas Gries m...@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

Re: [Wikitech-l] ResourceLoader support question: how to construct a value in CSS from PHP

2013-08-25 Thread Tyler Romeo
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 krinklem...@gmail.com wrote:

 On Jul 3, 2013, at 4:47 AM, Ori Livneh o...@wikimedia.org wrote:

  On Tue, Jul 2, 2013 at 11:52 PM, Thomas Gries m...@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 mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

[Wikitech-l] ResourceLoader support question: how to construct a value in CSS from PHP

2013-07-03 Thread Thomas Gries
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

2013-07-03 Thread Ori Livneh
On Tue, Jul 2, 2013 at 11:52 PM, Thomas Gries m...@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;
};
___
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

2013-07-03 Thread Thomas Gries
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;
};





___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l