Обсуждение MediaWiki:Gadgets-definition

Материал из Википедии — свободной энциклопедии
Перейти к навигации Перейти к поиску

Dear friends; please look at the links at user:i18n#useful links. Thanks in advance! Best regards
‫·‏לערי ריינהארט‏·‏T‏·‏m‏:‏Th‏·‏T‏·‏email me‏·‏‬ 23:10, 5 февраля 2008 (UTC)[ответить]

Proposal for GoogleTrans gadget[править код]

Hi there,

Sorry about the English.

I have made a GoogleTrans gadget which has been on the enwiki for around a year now. It is also on 8 other wikipedias including the Serbian, the Macedonian, and the Ukranian.

It functions like the Google toolbar translation feature. When you position the cursor over a word in a webpage and hit the SHIFT key, the Google translation of that word (or of selected text < 500 characters) appears in a popup below the cursor.

The help page for the gadget is at:

http://en.wikipedia.org/wiki/User:Endo999/GoogleTrans

(This has instructions on how to port over to other wikis).

and the code for it is at:

http://en.wikipedia.org/wiki/User:Endo999/GoogleTrans.js

It really works well for people who have intermediate Russian as they can easily look up a word they don't know (every 2 or 3 sentences). This is how I use the tool to read French and Spanish webpages. However, the person who knows no Russian (like me) can simply select a sentence or two and have it translated as well. In each popup there is a link to Google Translation Services. If you click on this link then the whole page is translated.

Good luck with your ruwiki and your postSoviet Russian state.

Endo999 01:46, 9 сентября 2010 (UTC)[ответить]

Architecture[править код]

@Krinkle: hello! I know, you are interested in gadgets extension. We refactored the code last month and what do you think about it (look at the first block of gadgets and our Common.js)? How we can improve it? С уважением, Iniquity 20:40, 4 октября 2017 (UTC)[ответить]

I would like to add that, as one can infer from the gadget list, we're really missing a mechanism that will enable us to run gadgets only on pages with certain action value, certain page name in Special namespace, and certain namespaces. While there is no such, we load these gadgets manually in MediaWiki:Common.js depending on those parameters. One more thing, we noticed that in Chrome, gadgets loaded with mw.loader.using are taken from localStorage subsequently, but Firefox makes a HTTP request for these modules each time. Do you know why this happens? — Джек, который построил дом (обс.) 02:51, 5 октября 2017 (UTC)[ответить]

Moving off of targets[править код]

Hey User:Stjn Russian Wikipedia is only one of two wikis (the other being Hungarian) that are still using this feature.

What do you need to get the scripts you are still targeting to desktop working on the Minerva / mobile skin?

In case it wasn't clear I'm still keen to remove this behaviour, preferably during the course of this year as it's an anti-pattern that I'd like to discourage. For the modules you are retaining - I assume you are using targets rather than skins as you need them to work on Minerva, but only on the desktop skin. What exactly is missing in terms of API to make this happen?

If you are removing them purely for performance, I'd also be interested in any skipFunctions that we could add to support that use case. e.g. Don't load code X when Y.

Thanks in advance for your assistance here. Jon (WMF) (обс.) 20:42, 20 июля 2023 (UTC)[ответить]

  • @Jon: Most of those targets were added in the aftermath of your changes to the targets system where the gadgets were broken for one reason or another. I can list specifics as to why those were added:
    a) collapserefs collapses references for editors that have used a toggle on desktop, where it makes sense, but doesn’t do that on mobile, where the sections are already collapsed. (In my opinion, it is somewhat unneeded, but I do not want to spend time in discussions around it.)
    b) directLinkToCommons broke MediaViewer specifically on the mobile website, see Википедия:Форум/Технический#Картинки в мобильной версии for details.
    c) wikibugs is a gadget that works for desktop site sidebar, but doesn’t work for mobile site sidebar. I suppose since Minerva doesn’t implement actual sidebar navigation, that can be safely changed to skins=.
    d) navboxNavigation is a gadget that provides navigation between navboxes with template links provided inside of them. It makes sense to enable it on desktop website, since it has navboxes, and disable it on mobile website.
    I can elaborate if you have further questions. stjn 22:44, 20 июля 2023 (UTC)[ответить]
    • Thanks @Stjn that's super helpful. I've added these to phab:T342567
    • It does seem like you are having to work around MediaWiki tech debt. I personally would recommend enabling all of these gadgets in the mobile site, and adding checks at the top of the page so that when the upstream bug gets fixed these gadgets will just work™.
    • Here's some specific recommendations:
    • a) How about MediaWiki:Gadget-collapserefs.js checks
if ( $('.collapsible-heading').length ) {
  return;
}
if ( mw.loader.getState('mobile.startup') === 'registered' ) {
  return;
}
    • c) The MediaWiki:Gadget-wikibugs.js looks like the easiest to fix. It seems like a better fit with the toolbox, since it relates to the page, so perhaps it could be moved there (toolbox is supported for logged in users on Russian mobile Wikipedia)
    • d) The MediaWiki:Gadget-navboxNavigation.js could add the following check which would mean the gadget would work if phab:T124168 ever got resolved:
if ( ! $('.navbox' ).length ) {
  return;
}

Jon (WMF) (обс.) 18:57, 24 июля 2023 (UTC)[ответить]

  • @Stjn: thanks for the feedback on phab:T342567#9042292. Given what you said there, does that mean my recommendations here make sense? If not, keen to think about this further! Having wikibugs on mobile in particular seems pretty cool to me as I'd love to give users there more power for raising bugs! Jon (WMF) (обс.) 20:58, 28 июля 2023 (UTC)[ответить]
    • Sorry for not replying here earlier. Yeah, most of these make sense, but on most of these, I think, switching to loading via MediaWiki:Common.js makes more sense. wikibugs.js in particular seems like a thing that shouldn’t have been written to load on all pages despite its actual usage statistics. Same with navboxNavigation (it doesn’t actually need that check with its current code btw, it just doesn’t need to be loaded on pages without navboxes, that’s why I added the check). I’ll do the change to directLinkToCommons now. I don’t see how reducing the payload as described in phab:T340705 can be done via small checks like these, tbh. Seems like a better solution is to move some gadgets to only load in contexts where they’re actually needed. stjn 21:07, 28 июля 2023 (UTC)[ответить]
      • I didn’t check this myself, but mw.loader.getState( 'mobile.startup' ) === 'registered' is true even on desktop. So it needs to be some other check. Currently I’ve just decided to ignore Minerva until we can come up with a better one. stjn 21:37, 28 июля 2023 (UTC)[ответить]
  • > It seems like a better fit with the toolbox, since it relates to the page, so perhaps it could be moved there
    @Jon, that can only be done via adding new code for Minerva (and to a lesser extent) new Vector skins, btw. Currently the link is present in MediaWiki:Sidebar, and doesn’t need to be generated via mw.util.addPortletLink. You cannot add items to toolbox that way, so code would need to be written to add it to that portlet. I can do that, but it’s hard to see a rationale in it while new Vector is not a thing in Russian Wikipedia (thankfully—too many egregious bugs that are going unfixed still) and Minerva doesn’t have tools for anonymous or the majority of users without AMC (AFAIK, that might not be true?). stjn 21:18, 28 июля 2023 (UTC)[ответить]

Права для userrights[править код]

Зачем оно доступно всем? [1] MediaWiki:Gadget-common-special-userrights.js ~~‍~~ Jaguar K · 04:30, 23 декабря 2023 (UTC)[ответить]