Frontend standards group/2014-11-07-Weekly

From MediaWiki.org
Jump to navigation Jump to search

Updates[edit]

  • ResourceLoader Image module is in a functional but not production state
    • Bartosz is still working on it
  • OOUI documenation - we have a new technical writer
    • [LINK]
  • OOUI PHP code is ready to go into core
    • In security review right now
  • Mobile and Flow are using templates in core now
    • Next step is to get mustache into core

Discussion[edit]

Style-only modules and dependencies[edit]

  • OOjs UI's PHP needs to work without JS, so we need to break oojs-ui into oojs-ui and oojs-ui-styles, and then use addModuleStyles( 'oojs-ui-styles' ) to statically add them to the page.
  • The problem is that currently we don't mark modules added to the page via addModuleStyles as loaded, so when including the oojs-ui module which depends on oojs-ui-styles it will load it again
    • We can assume oojs-ui-styles is always loaded and not have oojs-ui depend on it
    • We can somehow mark the oojs-ui-styles module as loaded on the client
      • Maybe using a data attributes on the link tags that we ResourceLoader generates on the server that we can scan on the client and mark things loaded accordingly
        • This changes the consequence of using both addModules and addModuleStyles from loading the styles 2x to not loading the scripts - we don't know that this will affect any production code, but it is a change in behavior that is unlikely to be awesome
    • We probably need style-only modules and to deprecate the use of addModuleStyles.

Timo/Trevor/Roan:

  • We need ResourceLoader to know which modules have been style-loaded.
    • Solution: Add them to the mw.loader.state({ .. "ready") call, like we do with other statically loaded modules. But that means we need to catch bad uses of addModuleStyles.
  • Have addModuleStyles to throw a warning when mis-used.
    • Solution: Automatically toggle the "allow style only" flag in FileModule constructor when module only contains styles.

Jon's proposal:

  • Calling addModuleStyles on a module with JS/messages should thrown an exception.
  • addModuleStyles should register the module
  • Mobile has this problem (search - js and watchlist - php share styles)

ResourceLoaderImageModule[edit]

Code: https://gerrit.wikimedia.org/r/#/c/165922/

  • Does this look crazy?
  • What about the entry point for raster images?

Questions:

  • Trevor: How do we handle clashes between icon IDs from different image modules? They all produce "oo-ui-icon-<id>" class names.
    • Allow image modules to add a CSS class prefix, which can namespace them if you want to
      • How would this work? 'prefix' property? Or just make it possible to extend class and override prefix variable?
        • I'd recommened 'prefix' property. How about also throwing a warnign for conflicts at register time, like we do for modules with the same name? (Hm.. difficult since that info is only known when it's instantiated/loaded or in startup).
  • Timo: Where does it cache the PNG image? (for persistent caching and for third-arty setups without Varnish; we cache minified in objectcache, should we store binary in there, too?)
    • Outcome: add &version= parameters to the URLs in the generated CSS, and then caching is taken care of by existing RL stuff. Right, because even without Varnish, ResourceLoader also supports FileCache.
  • DJ: Any concerns about response headers etc ? Can we know everything we need to output here ?
    • I believe we can. Do we not?
  • Trevor: How do we specify in RL which parameters we pass to the svg rendering libraries? (e.g. pass parameter "x" if using rsvg, and pass parameter "y" if using imagemagick)
    • Timo: Could be declared with a configuration setting that provides defaults for a few popular ones and allows third-parties to use different ones (just like for core's SVGHandler), something like (simplified) $wgRLIconSVGBin = array( 'imagemagick', '--foo' );
    • Roan: Talk to Aaron