Commit graph

139 commits

Author SHA1 Message Date
wfan 2b41719f96 Migrate MediaWiki.discussiontools.addReplyLinks to statslib
Bug: T359463
Change-Id: I93f7872818a27e5a5aac6ed4c44302bdc78b0613
2024-05-05 13:59:04 +00:00
Bartosz Dziewoński 3cffe1190e Clean up handling of <span class="mw-headline">
The PHP code should never see a `<span class="mw-headline">` node
since MediaWiki change If04d72f427ec3c3730e757cbb3ade8840c09f7d3,
but we have to support it for our old integration tests (T363031).

Improve code comments to explain this and move the handling to
one place, so that it can be deleted more easily in the future.

Follow-up to 08f61b2609.

Change-Id: I5ab9d3373a6911c1456c30d844b66576b278a1b5
2024-04-20 00:16:45 +00:00
jenkins-bot 03a3c4b42c Merge "Remove DTSUBSCRIBELINK cached HTML compat" 2024-04-17 15:22:33 +00:00
Ed Sanders a70f411ee1 Setup grunt-tyops and fix
Change-Id: I372c3cc5bedaf800716bff68cadb2846a399a42a
2024-03-27 14:01:18 +00:00
Bartosz Dziewoński e2309342ce Remove DTSUBSCRIBELINK cached HTML compat
Follow-up to Ie3348671c486de5bbd9f286772a8d145e3609bd5.

Change-Id: Ia4cd4f5d26e95b3557cae6f80f49fa5da138890f
2024-03-26 23:39:53 +01:00
Bartosz Dziewoński dacef1a97a Clean up subscribe links/buttons
* Don't generate `<!--__DTSUBSCRIBELINK__...-->` placeholder comments
  (follow-up to Idb23b0f5e438d35ed74569ff50302c7fad5ba688)
* Remove unused method parameter
* Remove unnecessary pass-by-reference (only $tocInfo needs it)

Change-Id: Ie3348671c486de5bbd9f286772a8d145e3609bd5
2024-03-25 01:13:59 +01:00
jenkins-bot f22dabfb80 Merge "Move some doc comments to real type hints" 2024-03-23 01:36:33 +00:00
jenkins-bot bd09ad6801 Merge "Move [subscribe] links outside of <h2> tags" 2024-03-11 17:07:14 +00:00
Bartosz Dziewoński d2d2d914ce Move some doc comments to real type hints
Change-Id: I64e3f7123c803ae2576c8b05824698d78a691018
2024-03-11 14:13:17 +01:00
Bartosz Dziewoński 69e8e948b2 Remove now redundant PHPDoc blocks
MediaWiki's PHPCS plugin requires documentation comments on all
methods, unless those methods are fully typed (all parameters and
return value).

It turns out that almost all of our methods are fully typed already.

Procedure:

1. Find: \*(\s*\*\s*(@param \??[\w\\]+(\|null)? &?\$\w+|@return \??[\w\\]+(\|null)?)\n)+\s*\*/
   Replace with: */
   This deletes type annotations, except those not representable
   as PHP type hints such as union types `a|b` or typed arrays `a[]`,
   or those with documentation beyond type hints, or those on
   functions with any other annotations.

2. Find: /\*\*/\n\s*
   Replace with nothing
   This deletes the remaining comments on methods that had no prose
   documentation.

3. Undo all changes that PHPCS complains about (those comments
   were not redundant)

4. Review the diff carefully, these regexps are imprecise :)

Change-Id: Ic82e8b23f2996f44951208dbd9cfb4c8e0738dac
2024-03-10 23:53:04 +00:00
Bartosz Dziewoński 9c9512ecf5 Move [subscribe] links outside of <h2> tags
Place the "[subscribe]" links used when the 'VISUALENHANCEMENTS'
feature is disabled in the same DOM position as the "🔔 Subscribe"
buttons used when it is enabled.

Recent changes in MediaWiki core caused them to move inside the
`<span class="mw-headline">`, breaking some gadgets (T13555#9615648).
Moving them all the way outside should avoid problems.

I don't remember why we placed them inside the `<h2>` tags, but there
doesn't seem to be any reason to do it now. It must have been easier
that way before we introduced the `<div class="mw-heading">` wrappers.

Note that I'm keeping the `<!--__DTSUBSCRIBELINK__...-->` placeholder
comments in case it turns out there is a reason, and we need to revert
this change. If everything goes well, they can be cleaned up in change
Ie3348671c486de5bbd9f286772a8d145e3609bd5 later.

Bug: T13555
Change-Id: Idb23b0f5e438d35ed74569ff50302c7fad5ba688
2024-03-08 21:18:53 +01:00
Bartosz Dziewoński 4958416caf Only include one set of DiscussionTools buttons in the page HTML
We no longer need to support toggling visual enhancements without
reloading the page, so we can remove the extraneous set of buttons
to reduce HTML size.

Bug: T322457
Change-Id: I54e57c754c54b7e611069f9832d1ebabf141a396
2024-03-01 16:51:17 +00:00
Novem Linguae 3436e2d9e9 Refactor CommentFormatter->addTopicContainer()
To get ready for the subtopic subscriptions feature, this patch
separates the code that adds the topic container from the code
that adds the subscribe button.

The idea is that in the future, an H3 would need a subscribe
button, but not a topic container. Whereas an H2 would need both.

Bug: T275943
Change-Id: I6a82773ed200dcb4083ac38a4d41838f639c097e
2023-12-24 13:34:30 -08:00
Bartosz Dziewoński 6f92654137 CommentFormatter: Do not add wrapper if the heading has attributes
Bug: T353489
Change-Id: Idf49b40cd745b804dbad3c09960507790be20ae3
2023-12-20 16:56:12 +01:00
Umherirrender 64bcb583e9 Use namespaced classes
Done automatically via script
Change to extension.json done manually

Change-Id: Ied7bbddd357290ac6be6bf480be0ee9116e77365
2023-12-11 16:38:02 +01:00
Ed Sanders 4733eb0362 Show new location of missing comments in notification
Bug: T304579
Change-Id: I5c9229a25875f0bb73c2a4dbfd0e1ac25f9c893e
2023-12-06 18:39:27 +00:00
Ed Sanders 40ce262d7e Check language fallbacks in isLanguageRequiringReplyIcon
Bug: T352289
Change-Id: I0a1466c871143af85e7eeb07572021c387074705
2023-12-01 13:57:08 +00:00
Subramanya Sastry bea2b1478d Work around Parsoid's messy handling of some extensions
* See T351461#9358034 for details

Bug: T351461
Change-Id: If438e99284018e3b78f4c2fc22ce714322877cf7
2023-11-28 03:00:27 +00:00
Ed Sanders be02707e10 Document generated messages
Change-Id: If91a32a48055b5f7d408151c7d2845f07ebd5e27
2023-11-02 16:29:54 +00:00
Ed Sanders c68081ada5 Remove old -ellipsisButton CSS class
Change-Id: I7e6fbcf6f81e9c94b7099824eaa94de34819bf70
2023-10-18 22:34:33 +01:00
Ed Sanders f8b76afef3 [BREAKING CHANGE] Remove isSectionEditable from overflow hook
Instead make isUneditableSection an optional property of
ContentHeadingItem.

Change-Id: Icfddf28aa789b5014ac183ff9f9699f38d78c121
2023-10-18 12:56:46 +01:00
Kosta Harlan 36c0b20c66 overflow menu: Display next to comments on desktop
Why:

- Per T338534, we want to display the overflow menu next to topics and
  comments. Supporting topic-level placement is a little more
  complicated, so just go with comments for now.

What:

- Rework the is-mobile check to allow the code to run on desktop/mobile,
  while excluding topic-level replacement on desktop (T342627)

Bug: T338534
Bug: T342625
Change-Id: I520c377120e16aa3a6fedcc8c39075958a942e4c
2023-10-18 11:37:18 +00:00
Ed Sanders 52db0af5cf OverflowMenus: Don't pass 'editable' data to reply button overflows
'editable' refers to the section being editable, and is only for
use by heading items, not individual comments.

Change-Id: I3fb5841609c40a928071cea8987cf035ade464c2
2023-10-11 16:55:46 +01:00
Ed Sanders 4447b6d201 Always pass whole OutputPage (as IContextSource) to postprocess functions
Change-Id: I07b312b8c00f9b5d20e285874ed0a0153949dd18
2023-10-09 15:41:28 +01:00
Kosta Harlan 351891a063 overflow menu: Display menu next to comments on mobile
Why:

- We want to provide contextual actions adjacent to comments, not just
  topic headings.

What:

- Consolidate the logic for embedding the overflow menu button HTML into
  a function, and add this for both topic and comment items.
- For this patch, this is done only for mobile; in a follow-up patch, we
  can add support for desktop
- This doesn't use a feature flag as 1) no one is implementing the
  DiscussionTools hook yet, 2) the 'edit' menu item is disabled at the
  comment level. Merging this change would be a no-op until an extension
  implements the DiscussionToolsAddOverflowMenuItemsHook.

Bug: T342251
Change-Id: I15a151f151e2fa04398876b559d93d45c42f6ef6
2023-10-05 15:50:38 +01:00
Kosta Harlan c6c7dd2fb0 overflow menu: Add hooks for registering and interacting with items
Why:

- We want to allow extensions to register interactive menu items in the
  overflow menu.

What:

- Create a PHP hook to allow extensions to provide menu items
  for rendering in the overflow menu
  - The hook allows for registering resource loader modules required by
    the menu item
  - The hook passes in some contextual information, like the thread
    item data, context source object, and if the page is editable
- Create a JS hook that fires when a user selects one of the menu items
- Example implementation: Ie9afbedb4f24cbd75eb48bb21dc9f6d8d732d853

Misc:

- Remove b/c code that existed to handle a transitional period where
  JSON encoded overflow menu data did not necessarily exist in the
  parser cache
- Rename code instances of ellipsis button / data / menu to refer to
  "overflow menu"
  - Some renames will have to wait until parser cache is updated; these
    are noted with TODOs

Bug: T342251
Change-Id: I5f2a51791f8ba7619d1399a4b93111e9bb44e172
2023-10-05 15:50:33 +01:00
Ed Sanders b63884f561 Turn comment timestamps into permalinks
Bug: T275729
Change-Id: Ica9cfd9743a67fce170e8b078016fa79bf6fbb84
2023-10-02 14:53:47 +01:00
Ed Sanders 2c44828564 Hide ellipsis menu when the section is uneditable
Bug: T316388
Change-Id: I4a4f0888245ffa0c74935d24d8a64d2ed78080b7
2023-09-06 00:30:35 +02:00
gerritbot dfb413ed81 Replace some moved Title class uses, now MediaWiki\Title\Title
Bug: T321681
Change-Id: I688fe73f46ecc2bbd8f4c59fc42b8e85fadf7689
2023-08-19 04:14:36 +00:00
C. Scott Ananian 0de3f468c3 Remove unnecessary use of Parser
Change-Id: Ib86ed6300ae85d7d69557a11bbd8f7b409e11d6c
2023-08-12 00:23:49 +02:00
Ed Sanders dda86f8ebf Always use the strict equality flag when using in_array
Change-Id: Ia09f5aadc3bbf64645ba174f047e53db49e07925
2023-06-06 13:08:00 +01:00
Bartosz Dziewoński 355c6b2e7b Remove no-JavaScript topic subscriptions cached HTML compat
Bug: T321431
Change-Id: Iae3defa220762ca8edd45f461b062987b17e4f5f
2023-04-25 16:18:31 +00:00
Bartosz Dziewoński 316e741868 Support topic subscriptions when JavaScript is disabled
Unsubscribing was already available from Special:TopicSubscriptions
when JavaScript is disabled.

* Add links to subscribe/unsubscribe in CommentFormatter
* Update links in skin navigation
* Add support for subscribing in the actions

Bug: T321431
Change-Id: If3c4bf7df309d0d98237c3b7b9c129cc2f72cda3
2023-04-10 21:30:19 +02:00
Bartosz Dziewoński 18689b370a Add optional tracking category for comments in the lede section (before first heading)
The tracking category is disabled by default and has to be
enabled by overriding the localisation message
'MediaWiki:Discussiontools-comments-before-first-heading-category'.

Bug: T324139
Change-Id: I6e4818e9421f76aec814444b2da9f5d8585c75fd
2023-03-28 01:32:04 +02:00
Bartosz Dziewoński 6bf128cf2d Use setExtensionData() instead of marker comments where possible (3/3)
We started using marker comments (HTML comments with special content
inserted into the page) for the reply buttons back in the day, because
we needed to indicate their location in the HTML. Later we used the
same idea for things which aren't actually tied to a specific location
in the HTML, such as boolean data like __DTEMPTYTALKPAGE__. There is a
better way to do this.

This commit stop writing the HTML comments, which are no longer used,
and cleans up the tests.

Bug: T328980
Change-Id: I37541356830945cc9abcc79d4c445ff6f2449759
(cherry picked from commit ab40ef62c0)
2023-03-21 00:13:01 +01:00
Bartosz Dziewoński 5d3d3cf687 Use setExtensionData() instead of marker comments where possible (2/3)
We started using marker comments (HTML comments with special content
inserted into the page) for the reply buttons back in the day, because
we needed to indicate their location in the HTML. Later we used the
same idea for things which aren't actually tied to a specific location
in the HTML, such as boolean data like __DTEMPTYTALKPAGE__. There is a
better way to do this.

This commit starts reading from ParserOutput::getExtensionData(),
which was generated by the previous commit, and should be present
in all cached ParserOutput objects by the time we merge this.

Bug: T328980
Change-Id: I9f7a907836b86f25567fd4b352464d62d76e20e4
(cherry picked from commit 0ac420ecbc)
2023-02-11 21:16:03 -06:00
DLynch fb08abe062 Revert "Use setExtensionData() instead of marker comments where possible (2/3)"
This reverts commit 0ac420ecbc.

Reason for revert: this was supposed to be merged later; revert it now and reapply in a bit

Change-Id: I33fb07856152c2401b3a071c143f27f1e9753287
2023-02-12 02:57:31 +00:00
Bartosz Dziewoński 0ac420ecbc Use setExtensionData() instead of marker comments where possible (2/3)
We started using marker comments (HTML comments with special content
inserted into the page) for the reply buttons back in the day, because
we needed to indicate their location in the HTML. Later we used the
same idea for things which aren't actually tied to a specific location
in the HTML, such as boolean data like __DTEMPTYTALKPAGE__. There is a
better way to do this.

This commit starts reading from ParserOutput::getExtensionData(),
which was generated by the previous commit, and should be present
in all cached ParserOutput objects by the time we merge this.

Bug: T328980
Change-Id: I4bf81ef3fd904f4d920d0756370c9bfa0a10a774
2023-02-11 19:33:20 +00:00
Bartosz Dziewoński 8fb467896f Use setExtensionData() instead of marker comments where possible (1/3)
We started using marker comments (HTML comments with special content
inserted into the page) for the reply buttons back in the day, because
we needed to indicate their location in the HTML. Later we used the
same idea for things which aren't actually tied to a specific location
in the HTML, such as boolean data like __DTEMPTYTALKPAGE__. There is a
better way to do this.

This commit starts writing data to ParserOutput::setExtensionData(),
which will be used in a later commit to be merged separately to avoid
issues with cached ParserOutput objects.

Bug: T328980
Change-Id: Ieb7bc3f83a402f9ebb096ed63336c77073bd2e7c
2023-02-11 20:19:55 +01:00
Bartosz Dziewoński fce317ace4 Move TOC metadata generation to a post-processing step
Instead of generating the TOC HTML additions immediately, store
the data we need using ParserOutput::setExtensionData(), and use
the OutputPageParserOutput hook to fetch it and generate the HTML.

We check that the stored data is present before using it to avoid
issues with cached ParserOutput objects.

Bug: T328122
Change-Id: I7d4988cd568f10b7995a4d744e0ec6e7ce081b0e
2023-02-07 02:39:11 +01:00
Ed Sanders 3c04944a86 Remove __DTLATESTCOMMENTPAGE__ comment from output
Other DT markers are removed because we return the body text, but
in this case we return subtitle text to be inserted elsewhere.

Instead pass $text by reference so it can be modified directly.

Change-Id: I9fe4194681cd3737661dca3c8a16e30a6001bd73
2023-02-02 12:51:11 +00:00
C. Scott Ananian 086ce6550f Don't rely on ParserOutput::getTOCHTML() to determine if ToC is present
ParserOutput::getTOCHTML() is being deprecated, and all skins are now
generating the TOC from the TOCData returned by
ParserOutput::getTOCData().  The SHOW_TOC flag was introduced in core
to determine if the TOC should be shown, but Vector-2022 *may* begin to
use other heuristics to determine whether to show the TOC (T315862).
We're conservatively going to process the TOC as long as there is
TOC present to process.

Bug: T328072
Change-Id: I38b439c6752157dbee9b09c9f5443a740dbaabf4
2023-01-27 09:58:47 +00:00
jenkins-bot 1f342306b4 Merge "Update exception handling for new code conventions" 2023-01-23 15:32:40 +00:00
Bartosz Dziewoński 48fd5e09bb Remove 'DiscussionToolsLegacyHeadingMarkup' config option
Bug: T314714
Change-Id: Ie268d1282f81c81c5a18d5858dcf7023515101b7
2023-01-22 19:24:36 +01:00
Bartosz Dziewoński af68c835bb Update exception handling for new code conventions
Change code to match the documented consensus formed on T321683:
https://www.mediawiki.org/wiki/Manual:Coding_conventions/PHP#Exception_handling

* Do not directly throw Exception, Error or MWException
* Document checked exceptions with @throws
* Do not document unchecked exceptions

For this extension, I think it makes sense to consider DOMException an
unchecked exception too (in addition to the usual LogicException and
RuntimeException).

Depends-On: Id07e301c3f20afa135e5469ee234a27354485652
Depends-On: I869af06896b9757af18488b916211c5a41a8c563
Depends-On: I42d9b7465d1406a22ef1b3f6d8de426c60c90e2c
Change-Id: Ic9d9efd031a87fa5a93143f714f0adb20f0dd956
2023-01-22 18:17:11 +00:00
Bartosz Dziewoński 228ad6f457 Update generating DiscussionTools TOC additions after parser changes
Depends-On: I8329864535f0b1dd5f9163868a08d6cb1ffcb78f
Depends-On: I1b267d23cf49d147c5379b914531303744481b68
Bug: T326677
Change-Id: Id59b946f4a3618a75dfaaef8a0043423b768b21c
2023-01-19 13:29:16 -05:00
David Lynch c706562ce9 VisualEnhancements: in some languages put an arrow by the reply button
New config: DiscussionTools_visualenhancements_reply_icon_languages

Config is set up with a provide_default merge strategy so we can remove
items from it quickly if need be.

Bug: T323537
Change-Id: Ib748897a2162bb233000f7364e30b268932f4c4a
2022-12-13 00:11:08 -06:00
Bartosz Dziewoński b4475801fd Don't collapse the lede section when it has comments
Bug: T324139
Change-Id: I14e1dae0fef4177f5a6a223bc9b663e99c9f741c
2022-11-30 20:25:22 +01:00
Bartosz Dziewoński 4cebf20e76 CommentFormatter: Fix condition for lede button to consider table of contents
(Also fix some related CSS that was accidentally moved in
Ie5198e902ec3fa7a7eba56cef6c6f0ef71ef7314)

Bug: T323241
Change-Id: I1fa67965a1b6b827c500a9de63f5b5295bee840d
2022-11-16 22:18:11 +01:00
Bartosz Dziewoński 0432eaf1e3 CommentFormatter: Fix condition for lede button to consider new wrappers
Bug: T323171
Change-Id: I3125f98e57bf410f19ece07b8376c92ae619d0ea
2022-11-15 23:39:45 +01:00