Movatterモバイル変換


[0]ホーム

URL:


Jump to content
Wikimedia Commons
Search

Help:Gadget-ACDC

From Wikimedia Commons, the free media repository
Translate this page
Other languages:

Shortcut:COM:ACDC

This is the documentation forAC/DC, a JavaScript gadget which can be enabled or disabled inyour Preferences. The script itself is located atMediaWiki:Gadget-ACDC.js.
AC/DC [publish changes button]; Files to edit: [six filenames]; Statements to add: depicts Caroline Zhang with expression, gesture or body pose Biellmann spin; [add statement button]
Screenshot of the gadget.

AC/DC orACDC, short forAdd to Commons / Descriptive Claims, is a gadget to add a collection ofstructured data statements to a set of files.

Installation

[edit]

Enable the gadget inyour preferences. It looks like this:

Add to Commons / Descriptive Claims (ACDC): Add a collection of structured data statements to a set of files.[documentation / talk] 

 Try it without installing
JavaScript is disabled in your browser.

Usage

[edit]

The gadget adds a “AC/DC” link to the Tools section of the sidebar; click it to open the main dialog. Enter the names of the files you want to edit in the input field, and edit the statements below it, using the regular structured commons user interface elements. When you’re ready, click the big blue button at the top (“publish changes” in English, but it may be translated) to start adding these statements to all the listed files. Do not close the browser window/tab until the dialog is done and closes itself (a progress bar should have appeared at the top).

You can paste multiple titles into the file list (with or without the “File:” prefix, or even full URLs), separated by pipe (|), tab or line break characters. After pressingEnter, they will be split up accordingly. Note, however, that this gadget does not scale well with lots of files; there’s no hard limit, but just adding several hundred titles to the input will hang the browser for some seconds, and I have not yet tried actually making edits at that scale. Most likely, it would just take ages, and you would have to keep your device running and your browser open for that entire time.

You can also add all the files in acategory or aPagePile, by clicking theellipsis icon and then the “Load category” or “Load PagePile” buttons, then entering the category title or PagePile ID into the dialog that opens afterwards; alternatively, paste the category or PagePile URL directly into the input field. The same considerations as in the previous paragraph apply – this will likely not scale well to thousands of files. (The user interface also becomes somewhat unwieldy if the list of files is too long, so you probably want to define the statements to add first, and only load the category or PagePile at the end.)

IfCat-a-lot is enabled, then you can also use it to select some files, and those files will be added when you open AC/DC. (You can still add more files to AC/DC afterwards as described above.)

If a statement with the same value as one you want to add already exists on a file, then any missing qualifiers will be added to the existing statement, and it will be marked as prominent if you specified so. Otherwise, a new statement will be added.

By default, AC/DC will start out with a field for “depicts” statements, so that you can directly add depicted items, or add other properties for which you want to add statements. You can customize this by configuring thewindow.acdcFavoriteProperties inyour common.js; for example, to start out with the propertiesdepicts(P180),creator(P170) andcopyright license(P275), add the following code:

window.acdcFavoriteProperties=['P180','P170','P275',];

If you always want to select the properties yourself, you can remove the default properties with:

window.acdcFavoriteProperties=[];

There is also preliminary support for removing statements. If you add the linewindow.acdcEnableRemoveFeature = true; toyour common.js (example), then a second section of statements to remove will appear below the statements to add; on the listed files, every statement with a matching property and value will be removed. (This feature will eventually be enabled by default, but the user interface may be improved first.) The aforementionedwindow.acdcFavoriteProperties applies to both statement sections together; to modify the list of properties in only one of the sections, you can usewindow.acdcFavoritePropertiesToAdd andwindow.acdcFavoritePropertiesToRemove instead.

Usage in user scripts

[edit]

AC/DC includes some features intended to make it easier for user scripts to interact with the gadget.The starting points are twohooks that user scripts can add handlers for,gadget.acdc.loaded andgadget.acdc.opened.For more details, see also thegadget’s source code, especially at the end.

gadget.acdc.loaded is fired as soon as AC/DC has finished loading (after adding the link to theTools menu).It is called with one argument, the “exports” of AC/DC, an object containing theopenAcdc() function.You can call this function to open AC/DC at any time; it returns aPromise for an object containing the AC/DC dialog as thestatementsDialog member.You can mostly interact with the dialog as soon as the promise resolves,but thestatementToAddWidgets andstatementToRemoveWidgets will not be initialized yet;in general, it’s usually a better idea to use thegadget.acdc.opened hook instead,and ignore the return value ofopenAcdc().

gadget.acdc.opened is fired as soon as the AC/DC has been fully opened and the widgets to add and remove statements have been initialized.It is called with one argument, an object containing thestatementsDialog.Useful methods that you can call includestatementsDialog.filesWidget.loadCategory( 'Category:...' ),statementsDialog.filesWidget.loadPagePile( 12345 ),andstatementsDialog.addStatementToAddWidget( 'P180', 'wikibase-item' );see thegadget’s source code for details.

The following example prepares AC/DC to addinstance of(P31)test data(Q7705759) to all files inCategory:Test images:

mw.hook('gadget.acdc.loaded').add(({openAcdc})=>{openAcdc();mw.hook('gadget.acdc.opened').add(async({statementsDialog})=>{constrequire=awaitmw.loader.using(['wikibase.datamodel']);const{Claim,EntityId,PropertyValueSnak,Statement,StatementList,}=require('wikibase.datamodel');conststatementWidget=statementsDialog.addStatementToAddWidget('P31','wikibase-item');awaitstatementWidget.setData(newStatementList([newStatement(newClaim(newPropertyValueSnak('P31',newEntityId('Q7705759'),))),]));statementWidget.setEditing(true);awaitstatementsDialog.filesWidget.loadCategory('Category:Test images');console.log('Done!');});});


Localization

[edit]

Translations for the user interface are defined atMediaWiki:Gadget-ACDC-i18n.json. (Onlyadministrators andinterface administrators can edit that page, so you may need to use{{Edit request}} and/or pingthe developer.)

Development

[edit]

Development takes placeon GitHub.

Known issues

[edit]

In general, this gadget is coupled rather tightly to WikibaseMediaInfo internals and implementation details, and as a result may break in unintended ways. If you notice something wrong, please notifythe developer as soon as possible.

Monitoring

[edit]

Since 19 September 2019, edits made through this gadget have been tagged as “AC/DC”; you can find them in therecent changes. (Prior to that date, there was no certain way to find or distinguish ACDC edits.)

Since 10 February 2022, anedit group is automatically created when ten or more files are edited at once. The edit group offers a convenient place to discuss the edits, or revert them all if necessary.

Features
Tools
Adding data
Querying data
Displaying data
About
GLAM
Discussion
Technical aspects
Historical
Related
Retrieved from "https://commons.wikimedia.org/w/index.php?title=Help:Gadget-ACDC&oldid=1147575178"
Categories:
Hidden category:

[8]ページ先頭

©2009-2026 Movatter.jp