Page MenuHomePhabricator

Add diff-style parameter to Compare API
Closed, ResolvedPublic3 Estimated Story Points

Description

When Wikidiff2 is installed, users have the ability to use the inline diff format. We should expose this in the Compare API.

When loading a diff, the HTML is already present on page load. In this example, we have the inline option set via the URL parameter. In this case, the dropdown we'll be introducing (T330229) will have inline already selected. If the user were to then select two-column, we'd make a request to the Compare API with difftype=two-column, and vice versa if the on page load the diff type was two-column.

The new difftype parameter could instead be a boolean parameter, such as diffinline, but perhaps it's better to leave it open for other diff types, say if VisualEditor-VisualDiffs were to ever make it to Core.

Acceptance criteria

  • If wikidiff2 is installed, the action=compare endpoint should offer a difftype parameter (we'll use difftype instead of diff-type because seemingly all multi-word action API parameters don't have hyphens).
  • The difftype parameter should accept two values: inline or table (wikidiff2 calls the latter source but I think that's a bit confusing).
  • If no difftype is provided, table should be the default (later this will go by user preference)
  • If an invalid difftype is provided, the API should return a badvalue error

Event Timeline

β€’ HMonroy renamed this task from Inline: implement functionality to allow inline toggling to Expose two-column and inline formats when wikidiff2 is installed.Apr 4 2023, 8:11 PM
MusikAnimal renamed this task from Expose two-column and inline formats when wikidiff2 is installed to Add diff-style parameter to Compare API.Apr 4 2023, 8:42 PM
MusikAnimal claimed this task.
MusikAnimal updated the task description. (Show Details)
MusikAnimal set the point value for this task to 3.

Change 906749 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/core@master] ApiComparePages: expose 'difftype' param if wikidiff2 is installed

https://gerrit.wikimedia.org/r/906749

Change 906749 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/core@master] ApiComparePages: expose 'difftype' param if wikidiff2 is installed

https://gerrit.wikimedia.org/r/906749

@HMonroy given this is just exposing pre-existing functionality (iff wikidiff2 is installed), I'm fairly confident this is okay to +2. Could you just confirm that, or should we hold off like we are with some other patches?

[...] Could you just confirm that, or should we hold off like we are with some other patches?

Confirmed off-phab, +2'd

Change 906749 merged by jenkins-bot:

[mediawiki/core@master] ApiComparePages: expose 'difftype' param if wikidiff2 is installed

https://gerrit.wikimedia.org/r/906749

@MusikAnimal @HMonroy Looks like it's good to go. I will move this to Done. Thanks!

Difftype options

T334011_API_Diffs_DifftypeOptions.png (1,402Γ—863 px, 97 KB)

Table

T334011_API_Diffs_Table.png (3,422Γ—582 px, 525 KB)

Inline

T334011_API_Diffs_Inline.png (3,430Γ—328 px, 291 KB)

Error

T334011_API_Diffs_Error.png (3,057Γ—250 px, 100 KB)

@MusikAnimal @HMonroy Actually just notice a very minor possible issue on the Monobook skin for the Difftype field. The box is white but the rest of the skins, are greyed. The only time it's white is when you hover it but under the Monobook skin, it's defaulted to white. Not sure if you wanted Monobook to be light grey or all the other skins to be white since the other fields are white when selected.

Monobook

T334011_API_BetterDiffs_Monobook_Difftype.png (1,115Γ—857 px, 96 KB)

Skins -Vector 2022, 2010, Minerva & Timeless

T334011_API_BetterDiffs_OtherSkins_Difftype.png (1,121Γ—937 px, 106 KB)

@MusikAnimal @HMonroy Actually just notice a very minor possible issue on the Monobook skin for the Difftype field. The box is white but the rest of the skins, are greyed. The only time it's white is when you hover it but under the Monobook skin, it's defaulted to white. Not sure if you wanted Monobook to be light grey or all the other skins to be white since the other fields are white when selected.

That's just normal skin variation. All dropdowns would look like that in MonoBook I assume, and they may look different in other skins too, but that's totally fine (and expected) unless they fail to actually function.

Regardless though, there were no visual changes as part of this task, so no need to check other skins :) Thanks for doing so anyway, though!

@MusikAnimal Ok sounds good, then it's good to go from when I first said in https://phabricator.wikimedia.org/T334011#8780488. Thanks!

OS: macOS 13.2, Windows 11
Browser: Chrome 112, Edge 112, Firefox 111, Safari 16.3
Skins: Vector 2022, Vector 2010, Minerva, Timeless, Monobook

Change 959275 had a related patch set uploaded (by Reedy; author: MusikAnimal):

[mediawiki/core@REL1_40] ApiComparePages: expose 'difftype' param if wikidiff2 is installed

https://gerrit.wikimedia.org/r/959275

Change 959275 merged by jenkins-bot:

[mediawiki/core@REL1_40] ApiComparePages: expose 'difftype' param if wikidiff2 is installed

https://gerrit.wikimedia.org/r/959275

Change 959311 had a related patch set uploaded (by Reedy; author: MusikAnimal):

[mediawiki/core@REL1_39] ApiComparePages: expose 'difftype' param if wikidiff2 is installed

https://gerrit.wikimedia.org/r/959311

Change 959311 merged by jenkins-bot:

[mediawiki/core@REL1_39] ApiComparePages: expose 'difftype' param if wikidiff2 is installed

https://gerrit.wikimedia.org/r/959311