HomePhabricator

Revamp classic edit toolbar not to hardcode paths in HTML

Tags
None
Referenced Files
None
Subscribers
None

Description

Revamp classic edit toolbar not to hardcode paths in HTML

Also, try out a way to have per-module LESS variables defined in PHP.
This might come in handy in the future… Maybe for skin theme support?

(I recommend reviewing the file changes in the order below. :D)

includes/resourceloader/ResourceLoaderFileModule.php

  • Pass the context (ResourceLoaderContext) deeper down via readStyleFiles() and readStyleFile(). We need it to compile the .less files for the right language.
  • Extract LESS compiler creation to getLessCompiler().
  • Allow passing a LESS compiler instance to compileLessFile(), rather than getting one after the method is called.

    All of the changes are backwards-compatible.

includes/resourceloader/ResourceLoaderEditToolbarModule.php

  • New module to support getting the language data and passing it to LESS variables.

    It might be a good idea to factor out a reusable class for a LESS module with additional variables, but that would require more attention to design than I gave it.

resources/src/mediawiki.action/mediawiki.action.edit.toolbar/mediawiki.action.edit.toolbar.less

  • Glue code to use the language data defined by the module above and put it in final CSS.

includes/EditPage.php

  • Do not hardcode image URLs in output HTML, as they are provided in CSS now. This gets rid of some usage of globals.

    In fact, we should be able to finally move the inline JavaScript calls out of getEditToolbar(), but I'm already introducing too many changes for one patch. That can be done later.

languages/Language.php

  • Add getImageFiles() to complement existing getImageFile() method. Misleadingly named, it returns paths for images for the toolbar only (and no other ones at all).

skins/common/ → resources/src/mediawiki.action/mediawiki.action.edit.toolbar/

  • Moved all of the button images to new location.

    Also, boring cleanup that was harder before because we treated the paths as public API:
  • Placed default ones in en/ subdirectory.
  • Renamed cyrl/ to ru/.
  • Renamed ksh/button_S_italic.png → ksh/button_italic.png.

languages/messages/

  • Adjusting paths and filenames for the changes above.

resources/src/mediawiki.action/mediawiki.action.edit.css
resources/src/mediawiki.action/mediawiki.action.edit.js

  • Added styles and updated the script to make it possible to have non-<img> elements as toolbar buttons.
  • Consolidated styles that were already required, but defined somewhere else:
    • cursor: pointer; (from shared.css)
    • vertical-align: middle; (from commonElements.css)

Bug: 69277
Change-Id: I39d8ed4258c7da0fe4fe4c665cdb26c86420769c