Jump to content

User:PerfektesChaos/js/filesMetaData

From Wikipedia, the free encyclopedia

JavaScript gadget – show textual metadata on media files and description pages.

Avoid download of hundreds of thumbnail files on regular MediaWiki pages and prepare sortable filtered concise data tables.

Usage

[edit]
  • If your project has registered this as a gadget, just activate on your Preferences page.
  • Otherwise include the following code into your common.js, global.js etc.:
if ( mw.config.get( "wgCanonicalSpecialPageName" ) === "Blankpage"  &&
     mw.config.get( "wgTitle" ).indexOf( "/filesMetaData" ) > 0 ) {
   mw.loader.load( "https://en.wikipedia.org/w/index.php?title=User:PerfektesChaos/js/filesMetaData/r.js&action=raw&bcache=1&maxage=86400&ctype=text/javascript" );
}

Behaviour

[edit]

After installation,

  1. visit Special:Blankpage/filesMetaData,
  2. quickly a brief response should show up,
  3. wait a little while, resources take a few seconds to establish OOjs (like with VisualEditor),
  4. make your choices from the form,
  5. finally use the Go button.

Stay on this page to keep collected data and resources.

Data origin

[edit]

There are three types of sources to provide particular files.

Category

[edit]

Select category mode and provide the category title by input field.

Note that categorization also works if no category description page exists.

Later you can navigate downward to specific subcategories or upward.

Media entries in category will be listed.

Special pages

[edit]

Some special pages list file galleries. If API access for such pages is established their output can be analyzed.

Available
Most linked-to files
Uncategorized files
Unused files
Currently no API
File list
Gallery of new files

See mw:API:Querypage on current state.

Free list and wikitext

[edit]

If you select this mode, you get a text input area.

Basically a list of media identifiers is expected, each in a single line.

A pipe separated list of media identifiers is fine, too.

Media transclusion or file links in double brackets will be recognized anywhere.

Actually it should work to drop the contents of a gallery page in Commons main space into this field and the occurring media will be listed.

Leave the text input field when editing finished.

Refining

[edit]

The desired output may be customized.

Columns

[edit]

Select the types of information you are interested in. Each will be provided in a table column, if available. If meaningful you can sort the rows later.

Thumbnail pictures and contents of description pages are not provided immediately, but if you are interested in a particular file you may request it individually.

On file description pages information is available only if the file is local and not shared; if you work within a certain Wikipedia descriptive information on Commons is not available but media characteristics can be retrieved.

Filtering

[edit]

The basic media identifiers (before the dot) may be restricted by an arbitrary string that shall be contained.

A regular expression can be used for this purpose, in common JavaScript RegExp dialect. The pattern is to be enclosed in / and an i for case-insensitivity may be appended.

  • Example: /[hm]ouse/i will permit house, House, mouse anywhere but reject any other file.

The “file type extensions” may also limit the displayed entries. A space separated list can be provided.

The following groups are supported like MIME specifications:

pixel/* Pixel graphics
vector/* Vector graphics
image/* pixel/* + vector/*
audio/* Audio media
video/* Videos
paged/* Paged media (multi-page text documents)

Both conditions may be inverted.

Options

[edit]

Four figures can be adapted.

They are immediately in effect even during running queries.

  • Minimum number of table rows.
    • If sufficient number of entries available the table will be expanded by this number of rows.
    • When filter conditions are in effect some additional rows might be appended since blocks of entries are retrieved until the requested number of rows has been reached, but some more results in block are consumed as well.
  • API query chunk size, for experienced users.
  • Thumbnail image size.
  • Limitiation of initial length of contents of description page.

Continuation

[edit]

While further entries can be expected a button allows extension of the existing table by a block of more files.

Otherwise the general input form may be expanded again and a new run can be configured and started.

Retrieved data are collected in a cache. Subsequent calls for the same files will try to recycle known data. If action is taken based on the evaluation and during the session file properities are significantly changed, the properties might become outdated. A button to clear the gadget cache is offered.

Internationalization

[edit]

Suggestions on foreign languages may be offered, as well as a translation of this page.

Codes

[edit]
Source code
ResourceLoader
Namespaces -1
Cookies
mw.libs (filesMetaData)
mw.hook
  • filesMetaData.ready
    When code has been loaded.
MediaWiki 1.30