Page MenuHomePhabricator

Document/tidy up how MobileFormatter sectionifies the document
Closed, DuplicatePublic

Description

Context

MobileFormatter is responsible for, among other things, sectionifying the document.

It's covered in unit tests but its documentation is lacking. Moreover, the configuration variable that affects the sectionifying behaviour the most isn't self-documenting.

$wgMFMobileFormatterHeadings allows an administrator to specify the following:

  1. The rank of heading that starts a new section.
  2. The ranks of headings that should be marked as editable.
LocalSettings.php
$wgMFMobileFormatterHeadings = [ 'h2', 'h3', 'h4' ];

For example, the above should be read as follows:

Second rank headings, i.e. h2 elements, start new sections and h2, h3, and h4 elements should be marked as editable.

My recommendation would be to deprecate $wgMFMobileFormatterHeadings in favour of:

  • string $wgMFTopLevelSectionHeading = 'h2';
  • string[] $wgMFEditableSectionHeadings = [ 'h2', 'h3', 'h4' ];

Open Questions

AC

  • There is a top-level document, i.e. docs/sectionifying.{txt,md,wikitext}, describing this behaviour.
  • $wgMobileFormatterHeadings is deprecated in favour of $wgMFCollapsibleSectionHeading and $wgMFEditableSectionHeadings.
  • If $wgMFEditableSectionHeadings is set in LocalSettings.php, then its value is not modified (see T146918#2768110 and T146918#2689252).
  • The in-block class is renamed to in-collapsible-section
    • in-collapsible-section is a provisional name.
  • PENDING Sections that are marked as editable are tagged with the is-editable CSS class.

Original Task

Visiting https://en.m.wikipedia.org/wiki/President_of_Republika_Srpska you'll see an in-block class on h2 elements. This should only apply to headings inside a given section.

Looking closely it seems that the value of MFMobileFormatterHeadings is merging incorrectly.

Defining

$wgMFMobileFormatterHeadings = array( 'h2', 'h3', 'h4', 'h5', 'h6' );

... in LocalSettings.php will yield the value

array(11) { [0]=> string(2) "h1" [1]=> string(2) "h2" [2]=> string(2) "h3" [3]=> string(2) "h4" [4]=> string(2) "h5" [5]=> string(2) "h6" [6]=> string(2) "h2" [7]=> string(2) "h3" [8]=> string(2) "h4" [9]=> string(2) "h5" [10]=> string(2) "h6" }

I suspect this is related to the move to extension.json but it's an array so I'm not sure what's happening here.

Event Timeline

Jdlrobson triaged this task as Medium priority.Mar 29 2016, 5:11 PM

This is a regression. We may need help from @Legoktm to make sense of this.

Jdlrobson renamed this task from MFMobileFormatterHeadings config variable merge strategy is wrong to Regression: MFMobileFormatterHeadings config variable merge strategy is wrong.Jul 28 2016, 8:27 PM
Jdlrobson added a project: Regression.
Jdlrobson moved this task from Incoming to Needs Prioritization on the Web-Team-Backlog board.

So I looked into this and it doesn't seem a config issue but more a problem with how we add the 'in-block' class.
We use the in-block class to work out where to show edit icons.

Do we know what the in-block class is for? It seems like a bad class name if nothing else.
Given we use .collapsible-block and .open-block on the div that the heading controls the collapsing of I would expect in-block to only apply to headings inside a collapsed block, however if this happened, according to this code we wouldn't show edit icons alongside subsections.

I don't think we need spike T146918 - I think we just need to repurpose this card to work out how it's supposed to be...

So I looked into this and it doesn't seem a config issue but more a problem with how we add the 'in-block' class.

Unfortunately, it's both of these things.

$wgMFMobileFormatterHeadings allows an administrator to specify the following:

  1. The rank of heading that starts a new section; and
  2. The ranks of headings that should be marked as editable

    $wgMFMobileFormatterHeadings = [ 'h2', 'h3', 'h4' ];

For example, the above should be read as follows:

Second rank headings, i.e. h2 elements, start new sections and h2, h3, and h4 elements should be marked as editable.

My recommendation would be to deprecate $wgMFMobileFormatterHeadings in favour of:

  • string $wgMFTopLevelSectionHeading = 'h2';
  • string[] $wgMFEditableSectionHeadings = [ 'h2', 'h3', 'h4' ];

Both of which need little explanation – nor do the names allude to the internals of MobileFrontend.

Do we know what the in-block class is for? It seems like a bad class name if nothing else.

[As I noted in the DocBlock of the function responsible for adding this class, in-block makes little sense](https://github.com/wikimedia/mediawiki-extensions-MobileFrontend/blob/master/includes/MobileFormatter.php#L541-L542).

I'd be happy to repurpose this task to something like "document, discuss, and tidy up how we sectionify the document", of which changing in-block to something more meaningful would be a part.

@phuedx can you repurpose this and move this to triaged but future?

phuedx renamed this task from Regression: MFMobileFormatterHeadings config variable merge strategy is wrong to Document/tidy up how MobileFormatter sectionifies the document.Nov 3 2016, 1:35 PM
phuedx updated the task description. (Show Details)
phuedx moved this task from Needs Prioritization to Triaged but Future on the Web-Team-Backlog board.
phuedx removed phuedx as the assignee of this task.Nov 4 2016, 7:03 AM

There are still open questions. Let's analyse what this task means a little more.

Jdlrobson lowered the priority of this task from Medium to Low.Jul 5 2017, 11:42 PM
Jdlrobson updated the task description. (Show Details)