Vikipedio:Aldonaĵoj/ImageAnnotator/Instalado

El Vikipedio, la libera enciklopedio

The Commons is running

Version 2.2

of this gadget.

Ĉi tio estas kopio de commons:Help:Gadget-ImageAnnotator/Installation, celante kontroli ĉu la instalado de ĉi tiu aldonaĵo estis ĝuste farita ĉi tie. Ĝi funkcias de la 10a de decembro 2010

ImageAnnotator is a JavaScript extension of the MediaWiki user interface, allowing users to place comments onto images shown on file description pages, similar to the "photo notes" on Flickr. This works on all image files for which the MediaWiki software displays a preview image on the file description page, i.e., PNG, JPG, GIF, and SVG files.

Image notes are only visible when the ImageAnnotator gadget is installed and activated (either by default for all users, or the viewing user has the gadget enabled). This means that notes added here at the Commons are not visible at other Wikis unless the gadget is installed there, too.

To install ImageAnnotator on a wiki, you need to be an administrator at that wiki; non-admin users cannot add the gadget.

Installing from scratch[redakti fonton]

Note: if you want to upgrade an existing installation to the latest version, do not follow these steps. Follow the steps in the section "Upgrading an installation" below.

General prerequisites:

  • Install the ParserFunctions extensions on your wiki, if it isn't already installed. Without it, the templates used by ImageAnnotator will not work as they should.
  • Make sure that the read API is enabled: set $wgEnableAPI to true in LocalSettings.php. You do not need to enable the write API.
  • ImageAnnotator was developed on MW 1.16alpha-wmf. It is known to work on MW 1.15.2. I do not know whether it works with older versions. It certainly won't work with MediaWiki versions lower than MW 1.12.

To install the gadget on another Wiki, follow these steps:

  1. Copy the following files from the Commons onto your own Wiki:
  2. Change the variable LAPI_file_store at the beginning of MediaWiki:LAPI.js on your wiki to match the image URLs served by your Wiki. For WMF wikis, no change should be necessary. Beware: if your wiki generates local URLs for images (not starting with a protocol/server part, but just containing the path, e.g. "/some/directory/images/b/bd/Test.jpg"), then make sure that the protocol/server part in that variable is optional, like this: "(https?://my\\.server\\.org)?/some/directory/images".
  3. Adapt the configuration MediaWiki:ImageAnnotatorConfig.js on your wiki as needed.
  4. Set up MediaWiki:Gadget-DisableImageAnnotator.js as a gadget on your Wiki: copy MediaWiki:Gadget-DisableImageAnnotator to your Wiki and add the line "DisableImageAnnotator|DisableImageAnnotator.js" to MediaWiki:Gadgets-definition on your Wiki.
  5. To set up ImageAnnotator as a gadget, write a description of it at MediaWiki:Gadget-ImageAnnotator on your Wiki, and add the line "ImageAnnotator|ImageAnnotator.js" to MediaWiki:Gadgets-definition (also on your Wiki).
  6. To enable the gadget for everyone, you may skip the previous step and instead add the line "if (wgNamespaceNumber != -1) importScript ('MediaWiki:Gadget-ImageAnnotator.js');" to MediaWiki:Common.js on your Wiki. (Or take a look at our MediaWiki:Common.js to see how we do this and copy that code over to your Wiki.)
  7. Copy the templates Ŝablono:ImageNote, Ŝablono:ImageNoteEnd, and Ŝablono:ImageWithNotes to your Wiki and protect them. Don't forget to adapt the category and the namespace selector (replace "File" as appropriate) in Ŝablono:ImageNote.
  8. Copy the templates Ŝablono:ImageAnnotations, Ŝablono:InlineImageAnnotations, Ŝablono:ImageNoteControl, and Ŝablono:ImageNoteColors to your Wiki.
  9. Copy the templates MediaWiki:ImageAnnotatorTexts, MediaWiki:ImageAnnotatorUITexts, and MediaWiki:ImageAnnotatorEditSummaries to your Wiki.
  10. Modify MediaWiki:ImageAnnotatorTexts to adapt it to your Wiki's default language. Replace the string lang="en" (one occurrence) as appropriate; e.g. at the Arabic Wikipedia, use lang="ar".
  11. Translate the texts in the edit summaries into the content language of your wiki.
  12. If you want, also create user interface texts in your language in the MediaWiki-messages noted on the help page. The messages in the default language of the Wiki always go into the pages without suffix. For other languages, use suffixes. On the Arabic Wikipedia, for instance, you'd put Arabic text at MediaWiki:ImageAnnotatorEditorLabel and the English text at MediaWiki:ImageAnnotatorEditorLabel/en.

The gadget will work for files uploaded locally on your Wiki exactly as it does for files here at the Commons. For non-local files (files hosted here at the Commons, but viewed on your Wiki), the script will enable viewing of the notes (if there are any), but will not allow modifying them. Modification of notes is possible only if the user views the file at the Wiki where the file actually resides.

Note: the above instructions assume that you want to install the gadget on another WMF project. If you are using a MediaWiki installation that does not serve wikibits.js, you are on your own. You will have to modify the scripts to use whatever environment your Wiki provides (in particular script loading and getElementsByClassName).

Upgrading an installation[redakti fonton]

If you want to upgrade an existing installation, some care has to be taken to make sure that the script doesn't break for some users but keeps working all the time. In particular, you have to account for client-side caching of scripts. The WMF projects are configured to make clients (i.e., the browsers of our users) cache scripts for 30 days). If your Wiki sets a different client-side cache timeout for scripts, adapt the instructions below accordingly.

Upgrading from version 1 to version 2[redakti fonton]

In version 1, the file MediaWiki:Gadget-ImageAnnotator.js had no version information. In version 2, there is a line saying "THIS IS ImageAnnotator VERSION 2" at the top of the file.

  1. Copy MediaWiki:Tooltips.js, MediaWiki:TextCleaner.js, and MediaWiki:LAPI.js to your Wiki. Make sure that in LAPI, the variable LAPI_file_store (near the top of the file) is set correctly. (The new versions of these libraries are backwards-compatible and will work fine with an old installation of ImageAnnotator.)
  2. Add <span class="wpImageAnnotatorOwnPageLink"> around the "fullurl" links in all subpages of MediaWiki:ImageAnnotatorSaveError on your Wiki.
  3. Create new messages on your Wiki:
  4. Copy MediaWiki:ImageAnnotatorEditSummaries to your wiki
  5. Copy the templates Ŝablono:ImageAnnotations, Ŝablono:InlineImageAnnotations, and Ŝablono:ImageNoteColors to your Wiki.
  6. Update MediaWiki:ImageAnnotatorUITexts and MediaWiki:ImageAnnotatorTexts. See this diff and this diff for the changes needed.

At that point, you'll have an ImageAnnotator version 1 running with version 2 libraries, and you'll have prepared the new interface texts. 31 days later you can be sure that everyone has got the new libraries, and you can roll out version 2 of ImageAnnotator. You must wait for the client-side cache interval to expire, otherwise ImageAnnotator may break for some users, who would then have to explicitly refresh their browser's cache to get it to work again.

  1. Copy MediaWiki:ImageAnnotatorConfig.js to your wiki. Adapt it as needed.
  2. Copy MediaWiki:Gadget-ImageAnnotator.js to your wiki.

At that point, the installation of version 2 is complete. Optionally, you may after another 31 days delete the message MediaWiki:ImageAnnotatorDeleteConfirm and all its translations, and remove it from MediaWiki:ImageAnnotatorUITexts.

Upgrading from version 2 to version 2.1[redakti fonton]

In version 2.1, there is a line saying "THIS IS ImageAnnotator VERSION 2.1" at the top of MediaWiki:Gadget-ImageAnnotator.js.

  1. Get the newest MediaWiki:TextCleaner.js. It contains a localization improvement; the change is transparent.
  2. Get the newest MediaWiki:LAPI.js — it should have a function called loadImage in LAPI.DOM. This version or any younger version will do.
  3. Copy the new interface text MediaWiki:ImageAnnotatorCannotEditMsg (plus its translations, if you want), and include it in MediaWiki:ImageAnnotatorUITexts.
  4. Copy Ŝablono:ImageNoteControl to your wiki and protect it.
  5. Wait until 31 days after the last change to your copy of MediaWiki:LAPI.js on your wiki.
  6. Copy the new MediaWiki:ImageAnnotatorConfig.js, and adapt it to your wiki as needed.
  7. Wait for at least 4 hours.
  8. Copy the new MediaWiki:Gadget-ImageAnnotator.js.

The waiting (31 days, 4 hours) is again to let client-side cache times expire naturally, so that users can have uninterrupted service. Otherwise, some people will have new versions of MediaWiki:Gadget-ImageAnnotator.js but still an old version of MediaWiki:LAPI.js in their cache, which won't work.

Upgrading from version 2 or 2.1 to version 2.2[redakti fonton]

In version 2.2, there is a line saying "THIS IS ImageAnnotator VERSION 2.2" at the top of MediaWiki:Gadget-ImageAnnotator.js.

If starting from version 2, follow the steps above, but make sure you get a MediaWiki:LAPI.js from March 5, 2010, or younger. This version or any younger version will do.

If upgrading from V2.1:

  1. Copy MediaWiki:LAPI.js, version from March 5, 2010 or younger; this version or any younger version. You do not have to wait 31 days before continuing; the changes are minor and do not affect the function of ImageAnnotator on most sites. (There's a small bugfix for IE for loading images from wikis that do not automatically generate missing thumbnails via a 404 handler. If you didn't experience any problems loading the zoom images on IE until now, you don't need the fix.)
  2. Copy MediaWiki:ImageAnnotatorConfig.js (version from March 5, 2010 or younger; this version or any younger version).
  3. Wait at least four hours.
  4. Copy the new MediaWiki:Gadget-ImageAnnotator.js.

Upgrading from version 1 to version 2.1 or 2.2[redakti fonton]

Follow the steps for upgrading to version 2, but:

Then wait 31 days, then do the final two steps.

Brief version history[redakti fonton]

Version 1
Initial release (August 2009). Editing and display of image annotations on image description pages, as well as on other pages through {{ImageWithNotes}}.
Version 2
End of October 2009. Display of image notes also on images included anywhere in articles.
Version 2.1
December 2009/January 2010: some minor improvements concerning zoom image loading; avoids ActiveX prompts on IE with some strange "security settings"; plus the things marked as of Version 2.1 on the help page.
Version 2.2
March 2010: internal cleanup, fix a few minor bugs nobody had noticed yet, plus configurations for the deletion reason prompt.