Page MenuHomePhabricator

Take over gadgets/templates which create additional links to "Add a new topic"
Closed, ResolvedPublic

Description

Many wikis have a gadgets or for adding additional "Add a new topic" links to the page, for example:

Also templates can add extra "Add new topic" links, such as here:

newtopic.gif (651×1 px, 155 KB)

This is a subset of the problem of taking over ?action=edit&section=new links in general (T282204). These links are just for adding a topic to the page you already on, and so a duplication of the "Add a topic" button at the top of the page.

Done

Event Timeline

As there isn't a reliable event when these links are added to the page, we either have to capture every link click and inspect the URL, or go in and fix all the gadgets.

First approach:

js
$('a').click( function() {
  // Check if current link is action=edit&section=new

Second approach:

  • Expose a public method for starting the new topic tool
  • Modify gadgets to call this method if it exists

If we do this, then we probably also want to take over the links in the wikitext of the page, e.g. on https://en.wikipedia.org/wiki/Wikipedia:Village_pump_(technical):

image.png (997×3 px, 396 KB)

And if we do that, then I think we should do the first approach, since that would handle both cases. We can use delegated events to handle dynamically added links:

$( 'body' ).on( 'click', 'a', function () { … } )

This is a subset of the problem of taking over ?action=edit&section=new links in general (task ??).

Task T269310 I guess. The patch there https://gerrit.wikimedia.org/r/c/mediawiki/extensions/DiscussionTools/+/650007 actually implements this (but not using delegated events).

Esanders renamed this task from Take over gadgets which add links to "Add a new topic" to Take over gadgets/templates which create additional links to "Add a new topic".Mar 24 2021, 2:43 PM
Esanders updated the task description. (Show Details)
Esanders added subscribers: iamjessklein, ppelberg.

ahhh thanks for this ticket! so great @Esanders

I see you also magically merged a task which I didn't even realize was possible.
Can you say a bit more what "Expose a public method for starting the new topic tool" means here?

Can you say a bit more what "Expose a public method for starting the new topic tool" means here?

It doesn't refer to any user interface changes (I realize now that it sounds a bit like that) – "public method" is a technical term for something other code may use to interact with our code.

Change 701454 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/extensions/DiscussionTools@master] Take over extra links to add a new topic added by gadgets/templates

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

Change 701454 merged by jenkins-bot:

[mediawiki/extensions/DiscussionTools@master] Take over extra links to add a new topic added by gadgets/templates

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

Ryasmeen subscribed.

If we do this, then we probably also want to take over the links in the wikitext of the page, e.g. on https://en.wikipedia.org/wiki/Wikipedia:Village_pump_(technical):

image.png (997×3 px, 396 KB)

And if we do that, then I think we should do the first approach, since that would handle both cases. We can use delegated events to handle dynamically added links:

$( 'body' ).on( 'click', 'a', function () { … } )

This is a subset of the problem of taking over ?action=edit&section=new links in general (task ??).

Task T269310 I guess. The patch there https://gerrit.wikimedia.org/r/c/mediawiki/extensions/DiscussionTools/+/650007 actually implements this (but not using delegated events).

@matmarex: I checked this on the following two pages where it now opens the New Discussion tool:

https://fr.wikipedia.org/wiki/Discussion_Wikip%C3%A9dia:Le_Bistro

https://fi.wikipedia.org/wiki/Keskustelu_Wikipediasta:Etusivu

But it seems like it's not working on the page you mentioned when I click on New Post: https://en.wikipedia.org/wiki/Wikipedia:Village_pump_(technical)

But it seems like it's not working on the page you mentioned when I click on New Post: https://en.wikipedia.org/wiki/Wikipedia:Village_pump_(technical)

Thanks for testing, indeed it isn't.

This is because that page now uses a link like this:

…instead of this:

I didn't realize that's even an option. And in my defense, the page was not using it until this edit, after my comments here ;) https://en.wikipedia.org/w/index.php?title=Template:Village_pump_page_header&diff=1018482681&oldid=957742389&diffmode=source

Change 706743 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/extensions/DiscussionTools@master] Recognize links to add a new topic that use Special:NewSection

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

To clarify the relationship between this task and T282204: Handle URLs for starting new sections: the patch for T282204 would have also resolved this task, even if none of the patches here were written. However, if we did that, then following a link added by gadget/template would require the whole page to be reloaded. The patches here allow us to do it without reloading the page, which is faster.

Change 706743 merged by jenkins-bot:

[mediawiki/extensions/DiscussionTools@master] Recognize links to add a new topic that use Special:NewSection

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

Change 710337 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/extensions/DiscussionTools@master] When opening new topic tool using any link, always activate the link in page tabs too

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

I've noticed that the "Add topic" tab was not getting activated when using the additional links. This (hopefully final) patch fixes that issue.

Change 710337 merged by jenkins-bot:

[mediawiki/extensions/DiscussionTools@master] When opening new topic tool using any link, always activate the link in page tabs too

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