Jump to content

User:NguoiDungKhongDinhDanh/GadgetsDefinitionEditor

From Meta, a Wikimedia project coordination wiki

GadgetsDefinitionEditor (GDE) is a user script that helps with editing the Gadgets-definition page. It is fully written in TypeScript. A mirror of the original repository can be found on GitHub. GadgetsDefinitionEditor.js contains a transpiled, minified copy.

Everyone can use it, though non-interface-admins will only be able to copy the text.

Tested on Legacy Vector (that is, in light mode). If your browser was released in 2024 or earlier, you are on your own.

Installation

[edit]

Add the following to your common.js or global.js:

mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:NguoiDungKhongDinhDanh/GadgetsDefinitionEditor.js/load.js&action=raw&ctype=text/javascript');

Usage

[edit]

Visit the MediaWiki:Gadgets-definition page of the current wiki. Select Edit with form in the More menu. A form will then open.

The editor part of the form is divided into rows, each row corresponds to a segment of the page's content. There are three kinds of segments: wikitext, heading and definition.

Segments

[edit]

Wikitext editors have one field: content. Only wikitext segments can be multiline.

Heading editors have two fields: level and name. The level field controls how many equal signs the heading has. Note that only headings whose names are syntactically valid message names are parsed as headings; those invalid are treated as wikitext.

Definition editors have four fields: level, name, options and pages. The level field controls how many asterisks the definition has. The options field cannot be edited directly, only via a dialog that is triggered using the button placed right next to the field. If you need to edit the options manually for some reason, switch the editor to wikitext mode.

The new page content is the textual values of all segment editors, joined back together with the newline character as separator.

Row toolbox

[edit]

Each row also contains a toolbox. The tools are as follows:

  • Switcher: Allows switching between segment editor types. A heading editor can't be switched to a definition editor and vice versa. A wikitext editor can only be switched to either of the other two if the content is valid as a heading or a definition, respectively.
  • Adders: Add a new, empty segment editor below the current one. Each button corresponds to an editor type.
  • Movers: Move the current segment editor up or down one place.
  • Remover: Removes the current editor. Once performed, this action cannot be undone. You will have to re-add the removed segment manually.

Format settings

[edit]

Format settings specify how the content of the page should be formatted. Click the Format settings at the end of the form to trigger the settings panel.

Known problems

[edit]

Attached comments

[edit]

GDE reimplements the extension's parser, with a minor catch: It cannot handle "attached" comments. An attached comment is one that starts and/or ends on a line that is otherwise a heading or a definition. For example:

== Heading ==<!-- This is an attached comment. -->
== <!-- This is an attached comment. -->Heading ==
<!-- This is an attached comment. -->== Heading ==

* name[opt=ions]|pages.js<!-- This is an attached comment. -->
* name[opt=<!-- This is an attached comment. -->ions]|pages.js
<!-- This is an attached comment. -->* name[opt=ions]|pages.js

* name[opt=ions]|pages.js<!-- This is an attached comment.
* name[opt=ions]|pages.js
-->

<!-- This is an attached comment.
* name[opt=ions]|pages.js
-->* name[opt=ions]|pages.js

When a heading or definition line contains such a comment, it is always parsed as wikitext.

Improvements

[edit]

Feel free to ask for bugfixes and other improvements on the talk page.

See also

[edit]