Help:Gadget-GalleryDetails

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Gallery details is an extensible gadget that can be used to display extended information on multiple images on a page. It is designed to work on all pages containing galleries (that includes category pages), on the result pages from a search, and on the list of most recent uploads. If the Pretty log gadget is also enabled, Gallery details will also work on all log pages.

User interface[edit]

The gadget installs a link in the sidebar.

On pages where Gallery details can do something, it adds a "Gallery details" in the sidebar (also in the old skins, or in the footer for the classic skin). On the list of most recent uploads, the gadget runs by default automatically and thus does not add that sidebar link. See "Configuration" below on how to change this behavior.

When that link is clicked, the gadget retrieves from the server information about all the images in all galleries present and then displays this information, together with some convenience links for common actions.

The gadget retrieves (and displays in its default view) the following information of the latest upload of a file:

  • Image dimensions
  • Upload date and time
  • Uploader
  • Whether it's an original upload or overwriting an earlier upload

Additionally, the gadget retrieves and displays the categories and the wikitext of the latest revision of the image description page.

The convenience links provided to users include links to

  • open a deletion request on the image,
  • mark the image as having no source,
  • mark the image as having no license,
  • mark the image as lacking an OTRS permission,
  • mark the image as a copyright violation.
  • search for the image on Tineye.

All these "action links" automatically edit the image description page, adding the right templates, and then also edit the uploader's talk page to notify them of the problem. For opening a deletion request and reporting a copyright violation, the script first prompts for a reason. If that reason is empty, or the input is cancelled, nothing happens.

Editing is done by opening the pages in new browser windows or tabs and only works if popups are not blocked in your browser for commons.wikimedia.org.

Administrators additionally get action links to quickly delete a file, to notify an uploader of a speedy deletion, and for marking an image as having passed Flickr review.

Determining the uploader[edit]

The gadget always tries to find the real user who uploaded a file. Notifications are then sent to this real user, not to a bot who might have been used to upload the file. Currently, the gadget can figure out the real user for file uploaded by User:Rotatebot, User:Cropbot, User:FlickrLickr, User:Flickr upload bot, and User:File Upload Bot (Magnus Manske). Notifications are sent to these bots only if the gadget cannot determine who instructed the bot to upload the file.

Default view[edit]

The default view reformats gallery tables. This image shows the action links for non-administrators. Note how URLs in the wikitext on the right side are hotlinked.

In its default confiiguration, the gadget reformats the galleries such that they display an image thumbnail and the information in one row each. On search result pages and on log pages (if Pretty log is also enabled), the additional information is displayed below the existing image row.

In the default view, clicking the gadgets sidebar link again hides the extended file information and restores the original galleries. Further clicks toggle between the normal view and the display of the file details.

Note how the gadget uses colored boxes to indicate problems: red are files that definitely have a problem (are already tagged as "no source", "copyvio", or similar tags, or have already an open deletion request). Green are files that have "good" license tags. Yellow are files where the script could not determine whether they're fine or not, or that require human interaction (such as a Flickr review).

Note, however, that a green border just means "the file is properly tagged". When patrolling uploads, verification by a human is still needed. Just because a file is tagged {{PD-self}} that doesn't mean all was fine; we get enough copyright violations tagged as "own work"...

Alternate view[edit]

This view adds color-coded borders and small icons.
When the icon is clicked, the information is displayed in a popup. Here, the speedy deletion links for administrators are visible.

There exists an already written extension to this Gadget that implements an alternate view. To enable this alternate view, add the following line to your common.js:

importScript ('MediaWiki:GalleryDetails-Tooltips.js');

This alternate implementation does not reformat galleries. Instead, it adds a small icon in the upper left corner of the image thumbnail. If that icon is clicked, it will display a popup containing all the information and links, together with the thumbnail and the upload comment. The popup can be closed in three ways:

  • by clicking the icon again
  • by clicking any other icon
  • by hitting the ESC-key on the keyboard (may not work in IE6)
  • by clicking the close button in the upper right corner of the popup, if present.

Additionally, this alternate view also adds the same color-coded borders around the image thumbnails to give some indication even before the icon is clicked.

The advantage of this alternate view is that it doesn't produce such a long table, and that one only sees the information of those images one is really interested in.

If the PrettyLog gadget is also enabled, this alternate view will, on log pages, also add the camera info and file creation time extracted from the file's metadata (EXIF), if present, directly to the log entry such that it is visible without having to click the icon.

Configuration[edit]

The gadget can be configured in two dimensions: behavioral configuration, and internationalization.

Behavior[edit]

Two behavioral aspects of the gadget can be configured:

  • By default, the gadget runs automatically on Special:NewFiles. If you don't like that, add the following line to your common.js:
var gallery_details_newfiles_run = false;
  • When one of the action links is clicked, the gadget edits pages by opening new windows (or tabs, in a properly configured tabbed browser). By default, it does not close these windows or tabs. If you'd like the gadget to automatically close them once the edit is done, add the following line to your user script file for the skin you're using:
var gallery_details_close_windows = true;
Note that this option is somewhat unsafe because you won't notice any edit conflicts or other problems that might occur upon saving an edit. In practice, however, experience has shown that such edit conflicts are rare.
Admins should additionally set
var image_links_close_windows = true;
if they want this behavior also for their extra links.

Internationalization[edit]

The gadget can be localized by overwriting some default texts (in English) in subpages of MediaWiki:Gadget-GalleryDetails.js. For instance, you'd place German interface string declarations at MediaWiki:Gadget-GalleryDetails.js/de. These subpages must again be valid Javascript. The following definitions from the gadget can be redefined:

  • The sidebar link text and its tooltip (gallery_details_sidebar)
  • The link texts, tooltips for the action links, and the prompt text for the "Open a deletion request" action link (gallery_details_nom_links)
  • The link texts, tooltips, and edit summaries for the speedy deletion links for administrators (gallery_details_admin_links)

The edit summaries of the "no source", "no license", "no permission", and "copyvio" action links can be configured in a similar way at subpages of MediaWiki:Notifier.js.

Note: the "\xa0" used in these interface strings is a non-breaking space, corresponding to the character entity  .

Some extra links (notable the "Tineye" link, but also the admin links) are generated by MediaWiki:ImageLinks.js and must therefore be localized at subpages of that script, for instance at MediaWiki:ImageLinks.js/de.

Extending the gadget with new views[edit]

To extend the gadget with a new view, you'd implement the new view in a separate Javascript file. To activate the new view, you'd then include this new file instead of any other view extension in your monobook.js.

The new view should be implemented as a derivation of the abstract implementation GalleryDetailsView already present in file MediaWiki:Gadget-GalleryDetails.js.

Technical information
var GalleryDetailsMyViewer = function () {};

GalleryDetailsMyViewer.prototype = new GalleryDetailsViewer; // "Subclass"...

GalleryDetailsMyViewer.prototype.display =
  function (model)
  {
    // Your code here
  }

GalleryDetailsMyViewer.prototype.toggle =
  function (model)
  {
    // Your code here
  }
  
// Redefine the factory method
GalleryDetailsLoader.getViewer =
  function ()
  {
    return new GalleryDetailsMyViewer ();
  };

The model passed to the display or the toggle methods has the following structure:

{
  root       : // reference to the original DOM object of the gallery table
  nof_images : // int, number of entries in image_list
  image_list : // array of image objects (described below), may be empty
}

Each entry in image_list has the following properties:

{
  name       : // string, name of the file without namespace prefix
  box        : // reference to the original DOM element used for the thumbnail display.
  done       : // boolean (true or false). If false, the request to the server failed.
               // If true, it succeeded.
  page       : // The information returned by the server. If null, file not found on server.
               // (May have been deleted.)
  categories : // Array of category names (strings), including the namespace prefix.
               // May be empty.
  status     : // integer, one of GalleryDetails.GOOD_FILE, GalleryDetails.BAD_FILE,
               // or GalleryDetails.ACTION_NEEDED.
  users      : // array of uploader information. At most two entries, one for the most recent
               // upload, and possibly a second one for the previous upload.
}

Each entry in users has this format:

{
  user : // User name (without namespace prefix) of the uploading user
  real : // If the uploader was a file upload bot account, the real user who was operating that bot
}

The property real, if set, gives the real user name to which for instance notifications should be sent. As an example, consider someone uploading a file through the Flickr2Commons service. Files uploaded in this way are actually uploaded here by User:File Upload Bot (Magnus Manske). That bot, however, notes and reports the original Commons account that instructed it to upload the file. Similar for the other upload bot accounts such as User:FlickrLickr or User:Flickr upload bot.

For a description of the structure of the page property, see the MediaWiki API documentation.

The abstract "super class" GalleryDetailsViewer provides some convenience methods that you can use to construct your own view without having to deal too much with the internals of these data structures:

GalleryDetailsViewer.prototype =
{
  check_info : function (info)
  {
    // Not shown here. If the request failed or no information was returned for the
    // file described by "info", return a DOM TextNode describing the failure.
    // Otherwise return null. (I.e., if it returns null, "info" is valid.) 
  },
  
  get_exif_data : function (info)
  {
    // Not shown here. If info contains EXIF metadata on the file, extract some
    // information, format each item as XHTML spans, and return an array of all
    // these spans. If no info found, return null or an array of length zero.
    // Called by create_details_box, but can be useful if you want to use this
    // data elsewhere.
  },

  create_details_box : function (info)
  {
    // Not shown here. Return a DOM div node encapsulating all the file details and
    // the action links.
  },
  
  create_page_box : function (info)
  {
    // Not shown here. Returns a DOM div node encapsulating the rendering of the
    // wikitext of the latest revision of the image description page.  
  }
}

If you need more details, please study the source code of MediaWiki:Gadget-GalleryDetails.js and MediaWiki:GalleryDetails-Tooltips.js. The author of these files cannot give any support for developing your own views.

Browser compatibility[edit]

Gallery details has been tested and is known to work on the following browsers:

Firefox 3 OK FF 3.0.5 on Win XP Pro, SP2
Firefox 2 unknown presumed OK
Internet Explorer 8 unknown
Internet Explorer 7 OK
Internet Explorer 6 OK Win XP Pro, SP2
Konqueror unknown
Opera OK Opera 9.50 on Win XP, SP2
Safari 3/Mac unknown presumed OK
Safari 3/Win OK Safari 3.0.4 & 3.1.1 on Win XP Pro, SP2
Safari 2/Mac unknown
Safari 2/Win don't care Early Safari versions for Windows are known to be buggy.
We don't cater to broken browsers (well, except IE :-)
Users should upgrade their browsers to Safari 3.
Firefox 1.5 unknown needed?
IE/Mac unknown needed?
IE 5.5 unknown needed?

Additionally, the script has been tested on the monobook, standard, cologneblue, and modern skins using Firefox 3.

Like for many other scripts at WikiMedia projects, a DOM Level 2 compatible browser is a prerequisite. Ajax is used to retrieve the image information from the server.

Dependencies on other scripts[edit]

This gadget makes use of the following other Javascripts:

Script Type of
dependency
Purpose
MediaWiki:Notifier.js static Implementation of the action links for opening a deletion request, marking as lacking a source, etc.
MediaWiki:ImageLinks.js static Implementation of the "Tineye" link and of the admin links.
MediaWiki:Gadget-DelReqHandler.js run-time Transitive dependency from MediaWiki:ImageLinks.js: execution of speedy deletions for administrators. Note: the links work even for administrators who do not have the DelReqHandler gadget enabled.
MediaWiki:QuickModify.js static Transitive dependency from MediaWiki:Notifier.js: support for editing pages
MediaWiki:TextCleaner.js static Transitive dependency from MediaWiki:Notifier.js: support for sanitizing user input
MediaWiki:QuickMod.js run-time Editing pages. Transitive dependency from MediaWiki:Notifier.js
MediaWiki:AjaxSubmit.js run-time Submitting forms and closing their windows. Transitive dependency from MediaWiki:QuickMod.js and from MediaWiki:Gadget-DelReqHandler.js

Problems?[edit]

If you have any problems with Gallery details, report them at MediaWiki talk:Gadget-GalleryDetails.js.