For each item, either display human-readable and translated text,
or display a technical non-translatable identifier as `<code>`,
with optional localised text in the title attribute.
* Re-format "rights" as a sentence instead of a bullet list. It was
the only one using a bullet list, which made it feel a bit long.
* Re-format "actions" as `<code>` since they are not localised.
* Re-format "contentModels" as `<code>`, and add the localised display
name in a title attribute, same as we do with "rights" already.
ContentHandler::getLocalizedName() is also used already on
Special:ChangeContentModel.
* Fix "contentModels" to set `needLineBreakAfter = true`, otherwise
if a gadget also sets "supportsUrlLoad", then that sentence is
appended to the previous line.
Update phrasing and sorting to be consistent everywhere, and adopt
native PHP types where possible.
In most cases, I made things alphabetical, with the exception of
Special:Gadgets user interface output, and Gadget class methods,
which both follow the order of most recently added feature last
(rights, skins, actions, namespaces, contentmodels, categories).
Highlights:
* Fix namespace IDs type. These can be strings when they are parsed
from the gadget definition text, not always integers.
* Add explicit default for 'category'. In theory not needed because
MediaWikiGadgetsDefinitionRepo has a `$section = '';` default, and
MediaWikiGadgetsJsonRepo uses GadgetDefinitionContentHandler where
`category: ''` is part of both the initial page content, as well
as merged via getDefaultMetadata.
This default benefits simpler test cases, and static analysis,
since the Gadget class constructor does not (yet) require it.
Without this, getCategory() could TypeError due to returning null.
Bug: T63007
Change-Id: I3b2c72a6424d520431d03761d23a5a222518ce3d
Adds a "categories" option to the gadget definition, which takes a
list of category names. Enabled gadgets will only load when the
viewed page is in one of the required categories.
Bug: T204201
Bug: T63007
Change-Id: I0ced9507bdab6cacd0baf2a331859099f35b73e5
== What ==
* Remove the empty Gadget and Gadget_definition namespaces.
* Remove the "gadgets-definition-edit" user right.
* Remove need for custom namespace permissions that previously
had to extend editsitejs to apply to NS_GADGET.
== Why ==
Simplify the (unused) "GadgetDefinitionNamespaceRepo" backend for
Gadgets 2.0 by making it less radically different from the status quo.
The experimental 2.0 branch will now make use of the "gadget definition"
content model via "MediaWiki:Gadgets/<id>.json" pages, instead of
through a dedicated namespace.
When I first worked the Gadgets 2.0 branch, content models
were not a thing in MediaWiki, and interface-admin wasn't a thing yet
either. Now that we have per-page permissions and per-page content
models, we don't really need a separate namespace.
This follows the principle of least surprise, and fits well with other
interface admin and site configuration tools such as:
- Citoid, MediaWiki:Citoid-template-type-map.json,
- VisualEditor, MediaWiki:Visualeditor-template-tools-definition.json,
- AbuseFilter, MediaWiki:BlockedExternalDomains.json,
- the upcoming "Community Config" initiative.
If/when we develop the SpecialPage GUI for editing gadget definitions,
this can save its data to these pages the same as it would in
any other namespace. Similar to how Special:BlockedExternalDomains
operates on MediaWiki:BlockedExternalDomains.json.
See also bf1d6b3e93 (I6ffd5e9467), which recently removed the
gadgets-edit user right in favour of the editsite{css,js,json} rights.
Change-Id: I5b04ab251552e839087d0a8a6923d205adc7f771
* Validate that pages have .js, .css or .json suffixes.
* Validate that namespaces are integers, disallowing doubles.
* Validate that type is either general or styles.
* Validate that targets are either desktop or mobile.
* Fix validation of skins: stop allowing `true` as it isn't actually
allowed - it causes an exception in Gadget::isSkinSupported().
Bug: T298334
Change-Id: Ic59c20172f496d281acd59419f5c760ad29ce317
This requires 1.42 for some new names
Changes to the use statements done automatically via script
Addition of missing use statement done manually
Change-Id: Iacbea33299995c537a7ef77b524614ad02c6a559
As this repo is not used anywhere in production, there is no backward
compatibility. Any scripts, styles, datas specified in existing
definition pages will get ignored.
Gadget::getJSON() no longer checks isPackaged() – that is now left
for callers - only relevant one is in GadgetRLModule. That was done
because validationWarnings() method needs the JSON page list even for
non-package gadgets.
Bug: T353174
Change-Id: Ic820bc4632981369c72f822fb8b9b7195930eaa6
Remove DefinitionDeletionUpdate and DefinitionSecondaryDataUpdate –
both call $repo->handlePageUpdate() which is already being called from
onPageSaveComplete/onPageDeleteComplete hooks.
The chain that made this redundant:
1. Ibe2e26d123, change hooks from hardcoded to GadgetRepo singleton.
2. Ieccc1cae8c, migrate from create-only onPageContentInsertComplete
hook to create-and-edit onPageSaveComplete hook.
3. Ib27fd34fbf, further consolidate handling of create and edit
events with handlePageUpdate, and remove any hook-level
conditionals. At this point, the DateUpdate classes became redundant.
Bug: T31272
Change-Id: I20c2759b219c80571237a73e8422f3128047eb87
… e.g. using modern syntax, or avoiding unnecessarily complex
language features. For example, we don't need to call count() when
all we care about is the boolean "is empty/not empty" information.
Change-Id: I13ae802f64627a79b29d1e57ad71486cb2fb977f
* A fixed license header for the file.
* Move class descriptions, doc tags, author/copyright to the
class block. Remove MW-core specific "ingroup" tags such as
"SpecialPage" which has no meaning in an extension and are not
used by Doxygen.
Ref https://gerrit.wikimedia.org/r/q/message:ingroup
Change-Id: I13d9b0ff7a3150180196c9fa58f8a321b14edd22
Adds a "namespaces" option to the gadget definition, which takes a
list of namespace IDs. Enabled gadgets will only load when the
viewed page is in one of the required namespaces.
Bug: T204201
Bug: T63007
Change-Id: I7f797e35352b242ad78704074e98c6569a1adf91
Gadgets can mark themselves as ES6-only by specifying the requiresES6
boolean attribute. Syntax validation is disabled for them (as the
validator doesn't support ES6 yet), and they are loaded together in a
separate request.
The minifier doesn't reject syntax errors, and thus these would
be passed through to web clients. Hence, communities using this feature
are encouraged to use ESLint or another linter to make sure only
valid ES <= 6 code is being used.
Because of the above, this feature is only made available for
non-default gadgets.
Bug: T75714
Change-Id: Ib98ac0700471554d5721d7ab858d4660e1e0e980
== Motivation ==
On a local dev wiki and in CI, where no gadgets are defined yet,
fetchStructuredList() is called on every load.php request and doing
uncached database look ups. This is because T39228 (stale cache
after Gadgets-definition was empty or created) was fixed by disabling
the cache until the page exists. This seems like a poor solution,
and commit I3092bcb162d032 recognises that the problem was not
understood at the time. I propose to instead cache it always and
purge it when the page is modified in any way.
Cold calling fetchStructuredList() accounted for ~170ms of ~400ms
when trying out debug v2 (T85805), thus making it significantly
slower and causing a chain of dozens of requests to pile up.
== Previously ==
* Legacy repo (MediaWikiGadgetsDefinitionRepo) only implemented
handlePageUpdate.
* handlePageUpdate was called from onPageSaveComplete for both
any page edit, and for creations in the experimental namespace.
* The experimental GadgetDefinitionNamespaceRepo is based on
ContentHandler rather than global hooks. This system does not
have a create-specific callback. It called update for edit/create,
and delete for delete. The experimental repo relied on create being
called from the global hook for the legacy repo, and update was
then called twice.
* There was no global hook for onPageDeleteComplete, thus the
legacy repo did not get purges.
== Changes ==
* Add onPageDeleteComplete hook to fix purges after deletion,
with the legacy repo now implementing handlePageDeletion() and doing
the same as handlePageUpdate().
* Fix handlePageUpdate() docs to reflect that it covers page create,
since onPageSaveComplete() called it either way.
* Fix experimental repo to include its namespace purge in
its handlePageUpdate() method.
* Get rid of now-redundant handlePageCreation().
* Get rid of handlePageDeletion() since its implementations would
now be identical to handlePageUpdate().
All these hooks and handle*() methods are just for a memc key
holding gadget metadata. We don't need to microoptimise this
on a per-page basis. Gadget edits are rare enough that purging them
as a whole each time is fine. We do the same in MediaWiki core
with ResourceLoaderGadgetsModule already.
Bug: T85805
Change-Id: Ib27fd34fbfe7a75c851602c8a93a2e3e1f2c38a0