Add help message that explains what the inline toggle does when you click
it.
Remove 'diff-table-format-label` text since it is not being used.
Bug: T346429
Change-Id: Idc3aefffd03d491a573b27c7e18b337f68bbc9cf
Infusing just the toggle widget, without the layout wrapping it,
causes them to get disconnected, which breaks some accessibility
features, including lack of "aria-labelledby" and no support for
activating the toggle by clicking on its label.
Bug: T346132
Change-Id: I227f47d4e6c25e19b4c02a16c287fc481efc2bf4
Add logic that renders the new OOUI/ToggleSwitchWidget (just added to
OOUI) in PHP for the inline switch. This will provide no-JS support, and will get rid of the flash when loading the page for JS users.
Bug: T341955
Change-Id: Ifc8104937cd23e9b85208b7f283db238a0e6849d
This class is used heavily basically everywhere, moving it to Utils
wouldn't make much sense. Also with this change, we can move
StatusValue to MediaWiki\Status as well.
Bug: T321882
Depends-On: I5f89ecf27ce1471a74f31c6018806461781213c3
Change-Id: I04c1dcf5129df437589149f0f3e284974d7c98fa
Have Article opt in to inline toggle switch display, so that random
callers of DifferenceEngine::showDiffPage() do not receive a
non-functional format selector.
Bug: T342158
Change-Id: Id4e38c2a20b5381e5f70b1244304da2895eaf8e7
* Add an API-only user preference for diff type
* Retain query parameter stickiness but fix it so that the diff-type
from user preferences does not leak into the query string. So the
no-JS control continues to work. If a no-JS user has the inline
preference set, respect it on the initial load, but add an explicit
diff-type=table to the query string of the table link so that the
preference can be overridden.
* Get the diff type from the initial state of the no-JS button. Infuse
the widget to access the active property using the OOUI public API.
* For a logged-in user, when the JS toggle is clicked, fetch the new
diff body and update the user preference.
* For an anonymous user, when the JS toggle is clicked, update the
prev/next links to include the correct diff-type query parameter.
Bug: T336713
Change-Id: Ie409d79ac8222dfa6ec8fd170b76be088be80b3a
It makes sense for SlotDiffRenderer to localize the diffs that it
returns.
DifferenceEngine can't conveniently use this right now since it stores
all slot diffs concatenated together in a cache entry. It can't break
the string apart again to call the right SlotDiffRenderer on each
slot diff. So it assumes there must be a text diff in there somewhere
and calls TextDiffer over the whole thing.
EntitySchema does not have this problem and can benefit from this
method.
Bug: T342209
Change-Id: Ie06e100bb0e945de5dbe3dade14b2e6b706e078d
* Follow the TODO comment in TextSlotDiffRenderer
::getTextDiffInternal() by moving the code out to three parallel
implementations, namely ExternalTextDiffer, PhpTextDiffer and
Wikidiff2TextDiffer.
* Add a container/factory class ManifoldTextDiffer to glue them
together and collate available formats.
* Move the inline legend to Wikidiff2TextDiffer. Not the toggle since
the ability to toggle depends on the available format, not the current
format.
* Update the diff cache keys so that ManifoldTextDiffer can store the
engine=>format map it used to generate the diff.
* Drop support for the second parameter to TextSlotDiffRenderer
::setEngine(), since nothing used it anymore.
* Provide a format batch API, since some engines are able to efficiently
generate multiple formats. This might be used by DifferenceEngine in
future.
Needs risky change notification for the cache key change.
Bug: T339184
Depends-On: I8a35b9b8ec1622c9a36d2496bdd24f51bc52c85f
Change-Id: I5c506e39162855aff53dd420dd8145156739059c
segmentForDiff() is supposed to allow character-level diffing of Chinese
text, by adding spaces and then removing them after the diff is
complete. But when I tested it for I2d0a6996b02d37a3, unsegmentForDiff()
failed to remove the spaces, since there was an <ins> tag between the space
and the Chinese character.
So instead, use formfeed characters to separate the Chinese characters,
and strip them unconditionally instead of relying on them being next to
Chinese characters.
Add test.
Change-Id: I230d8261bbda34ad313785a1f7c31d4db7bf989b
Fix fixme by sending the language code to SlotDiffRenderer as an option.
Note that this is the language used for word segmentation of the
content, not the UI language.
Change-Id: I2d0a6996b02d37a3f2d8fefa851244803025bb6c
And remove commented-out code also dating from 1.32 with no near-term
prospect of being implemented.
Change-Id: I526c558b2efae4b77ae38d0b5bb8127c8b31c280
Using the OOUI class name is an established pattern outside of
OOUI widgets, so it's easier to stick with it for the diff page
hiding and showing (switching to and from inline/table diffs, etc.).
Bug: T324759
Change-Id: I805b6b71d8e137eaa3e000b15455557df42af838
getTablePrefix() is used to show the inline legend and inline switcher.
It is not yet part of a released stable interface.
Theoretically there may be multiple text slots on a page, and we don't
want multiple inline legends. There was already a fragment assembly
system, for the benefit of hook handlers, so move that up to the page
level, so that it can also deduplicate prefix fragments coming from
each slot.
Add tests.
Bug: T324759
Change-Id: I9baa5c24128c63bc318ba13e83a024843f4ab15e
Add a switch that allows toggling between inline and two-column format
when Wikidiff2 is installed.
Inline toggle should also support no-JS toggling
The legend should toggle when switching from table to inline after the
first load.
Introduced a temporary feature flag to show this inline toggle so that
we can merge and easily continue the improvements. It will be removed
when ready for production.
Bug: T336712
Bug: T330229
Change-Id: Ie6a48e495f2bb299d8b984e7c40363d534c7915b
When the old and new revisions have identical content in a given slot,
do not include the relevant SlotDiffRenderer in the return value of
DifferenceEngine::getSlotDiffRenderers(), so that the relevant table
prefixes and modules will be omitted.
Also:
* In TextSlotDiffRenderer::getTextDiff(), return an empty string when
the inputs are equal, instead of invoking the diff engine. Previously,
the inline format would produce a <tr> element in this case, causing
the diff-empty message to be omitted.
* Clarify the doc comment up the stack, indicating SlotDiffRenderer may
return zero <tr> tags, it doesn't have to be one or more.
* Fix the documented return type of getSlotContents() so that @var is
not needed in the caller.
* Don't convert the return value of SlotDiffRenderer::getDiff() to
boolean. It's always a string so compare it to the empty string.
Note that the cache key for inline empty diffs will change, because
TextSlotDiffRenderer::getExtraCacheKeys() is not called anymore for
empty diffs.
Bug: T338670
Change-Id: I0774ba0b159ac43ec214403cf2d06740f6d067cd
Add a legend at the top of the inline diff display, showing the
meanings of the colours of the inserted and deleted highlighting.
Also add the same text as tooltips on the highlighted elements.
The legend is added as part of a new area above the diff table
that can be modified via a new TextSlotDiffRendererTablePrefix
hook, so that extensions can add other buttons etc. there as
required.
This is a follow-up to the previous attempt, which added the
legend in DifferenceEngine::showDiff() and was called from
too many places. This patch moves it to be called in
DifferenceEngine::showDiffPage().
Bug: T324759
Change-Id: I2a3c67bcfa47313dee597e602a62073e4e298cd2
Follow-up: I6de30bf79eb5ac262285951792782b870d075e00
The functions returning null or the class property is set explict null
Found by phan strict checks
Change-Id: I4a271093fb6526564d8083a08249c64cb21f2453
This helps phan to detect unreachable code and also impossible types
after the functions.
It helps phan to avoid false positives for array keys
when the keys are checked before
Bug: T240141
Change-Id: I895f70e82b3053a46cd44135b15437e6f82a07b2
This is micro-optimization of closure code to avoid binding the closure
to $this where it is not needed.
Created by I25a17fb22b6b669e817317a0f45051ae9c608208
Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
A long time ago, returning false from the predecessor of this
method (done on filesystem error when trying to generate a diff
via an external executable) meant the diff result was treated as
an internal error and not cached, but I2f8a9db broke that.
There is not much point in trying to fail softly on tempfile
creation errors anyway, so just replace it with exception throwing.
Change-Id: Idb15a0e1f67cb1ccbf7c47788f4eecbaa8176665
Added:
- ContentHandlerFactory
Tests:
- PHPUnit
Changed
- Calls of changed and deprecated
- DI for some service/api
Deprecated:
- ContentHandler::* then similar to ContentHandlerFactory
- ContentHandler::getForTitle
- ContentHandler::$handlers
Bug: T235165
Change-Id: I59246938c7ad7b3e70e46c9e698708ef9bc672c6
A new inline mode is provided for diffs.
It is only available when wikidiff2 is installed.
There is no PHP implementation (one can be added later if
necessary)
For now, it is accessed by passing diff-type as a query string parameter
e.g ?diff-type=inline
A control for switching between the two is added as a follow up.
see Ie9bb17789d90b7492559782021937f3f3e4356f8
* The final method getSlotDiffRenderer now takes a second parameter
options
* The method `getSlotDiffRendererInternal` is deprecated and
replaced with the more flexible `getSlotDiffRendererWithOptions`
This has potential to be a breaking change but is unlikely to impact
any existing clients.
Note: PHP implementation can be added later if necessary
Bug: T117279
Change-Id: I4f81c8ccf253dd4aa6cf43c3fad257b4b0dd1ebd
UnknownContentHandler can be configued to handle models that
belong to extensions that have been undeployed:
$wgContentHandlers['xyzzy'] = 'UnknownContentHandler';
This way, no errors will be thrown when trying to access
pages with the unsupported model. Instead, an error message is
shown, and editing is prevented.
This patch also improves handling of non-editable content in
EditPage and in DifferenceEngine.
Bug: T220608
Change-Id: Ia94521b786c0a5225a674e4dc3cb6761a723d75b
Since we changed the signature back to 3 arguments in wikidiff2 verion
1.8.0, the warning is invalid.
Bug: T220217
Bug: T203069
Bug: T194272
Change-Id: Ia326c67de28a4e9b024466c62097b4e1e1096007
This might hint at an edge-case in the PHP CodeSniffer sniff that should
detect if methods are separated by a single empty line. Feel free to
investigate. I, personally, can't invest more time in this than
suggesting this quick fix.
Change-Id: Ib3c60eac76f255b4fe929f7933de256222716576
The config parameter handling in wikidiff2 will migrate completely to
phpini values. Due to that we will remove the php config variable
wgWikiDiff2MovedParagraphDetectionCutoff and its usage.
In the process of deleting the 4th parameter in the wikidiff2_do_diff()
method, this exception is added so deployment can be handled separately.
On the long run these exceptions will be removed completely and the
(then) current mediawiki will depend on wikdiff2 > 1.8.0
Bug: T194272
Depends-On: I673d2489d5bce1a24a6ea83e168704948564661b
Change-Id: I30262412b0784b84af88ffab6ed0694a08b671e9
Move logic for rendering a diff between two content objects out of
DifferenceEngine, into a new SlotDiffRenderer class. Make
DifferenceEngine use multiple SlotDiffRenderers, one per slot.
This separates the class tree for changing high-level diff properties
such as the header or the revision selection method (same as before:
subclass DifferenceEngine and override ContentHandler::getDiffEngineClass
or implement GetDifferenceEngine) and the one for changing the actual
diff rendering for a given content type (subclass SlotDiffRenderer and
override ContentHandler::getSlotDiffRenderer or implement
GetSlotDiffRenderer). To keep B/C, when SlotDiffRenderer is not overridden
for a given content type but DifferenceEngine is, that DifferenceEngine
will be used instead.
The weak point of the scheme is overriding the DifferenceEngine methods
passing control to the SlotDiffRenderers (the ones calling
getDifferenceEngines), without calling the parent. These are:
showDiffStyle, getDiffBody, getDiffBodyCacheKeyParams. Extensions doing
that will probably break in unpredictable ways (most likely, only
showing the main slot diff). Nothing in gerrit does it, at least.
A new GetSlotDiffRenderer hook is added to modify rendering for content
models not owned by the extension, much like how GetDifferenceEngine
works.
Also deprecates public access to mNewRev/mOldRev and creates public
getters instead. DifferenceEngine never supported external changes to
those properties, this just acknowledges it.
Bug: T194731
Change-Id: I2f8a9dbebd2290b7feafb20e2bb2a2693e18ba11
Depends-On: I04e885a33bfce5bccc807b9bcfe1eaa577a9fd47
Depends-On: I203d8895bf436b7fee53fe4718dede8a3b1768bc