Vés al contingut

Mòdul:Wikidata/addpencil/en/ús

De la Viquipèdia, l'enciclopèdia lliure

The pencil icon links directly to the statement on Wikidata. With future mw:Wikidata Bridge (currently a pilot on ca.wiki for string values) it enables a pop-up dialog box for editing Wikidata from an infobox.

Enabling the feature addpencil of module:Wikidades, from version 20200129, involves some requirements that must be met by the templates that use it, specially created for prior versions of the module. The feature is enabled in a template adding the parent parameter editicon=true. It can be enabled also for a wiki adding to Module:Wikidades/i18n the value ["addpencil"] = true. Additionally, it can be disabled on each invoke using the parameter editicon=false.

The module adds, after the returned content, a pencil icon linked to the Wikidata statement. If it is a multivalue, it will only add a pencil at the end of the list. Using formatting = table, the pencil is added after all values ​​in all iterations; if the table contains HTML tags, the pencil is added before the last closing tags (formatted with

tags the pencil is included in the last cell). It works properly if content returned is directly displayed, not further treated by the template. Oherwise, if content returned by the module is part of any operation, the content + the linked icon can produce errors or inexpected results. The module does not add any pencil in the following cases:
  • If you add the parameter editicon = false (or = no).
  • If you use the parameter formatting = raw.
    Note: Any of both options is needed when the retrieved value is passed to another template that processes it. In fact, it can be stated that any content edited after Wikidata invoke should not have the pencil icon.
  • The value is type coordinates and it is not formatted with $lan and $lon patterns.
    Note: Maps do not have any pencil, it is the coordinates that may have it.
  • The value is type Commons file and no formatting is used with the $1 pattern.
Required revisions:
situation solution
Images: If only filename is fetched, without any formatting, it is considered as a raw request and no pencil is added. Used with format [[File:<value>|200px....]] the pencil would break the File syntax. Likewise if the return value is passed to some template like {{InfoboxImage}}.

This situation affects any image used in an infobox, such as signature, flag, coat of arms, etc.

For including the pencil:

For images without caption, use a syntax like formatting=[[File:$1|200px]] in the Wikidata invoke. This will allow the module to format the image and add the pencil afterwards. For images with caption, use a syntax for both the filename and the caption like: {{#invoke:Wikidades | claim | property=P18 | qualifier=P2096 | formatting=table | list=false | rowformat=[[File:$0|300x300px]]<br />$1}}. This adds the pencil in the caption, even if the caption is empty.

Sound files: Similar situation as the images. In some cases, specific templates are used to format the sound playback bar. No additional template is needed to generate the playback bar. Just use for exemple formatting=[[File:$1|center]] with the appropiate File syntax. For adding a caption, include it in the formatting parameter so the pencil with be added afterwards. For example: formatting = [[File:$0|100px]]<center>Voice sample of {{{name|}}}</center>
Coordinates: If fetched with formatting=$lat,$lon to be treated later, you need to add editicon=no to avoid errors. If no further treatment is needed and you want just to display the coordinates with template:coord, use formatting = {{((}}coord <nowiki>{{!}} $lat {{!}} $lon {{!}} display {{=}} inline {{))}}, so the formatting is done by the module and the pencil is added afterwards.
URLs: Weblinks are sometimes formatted using template:URL or similar ones. The returned value with the pencil icon will provoke errors or inexpected outputs. If you want to format the weblink, include it in the formatting parameter, for example: formatting = [$1 link-label].

Alternatively, you can use formatting=weblink which generates an external link labelled with the website, without the http(s):// prefix and without www, with ellipsis if the link includes a particular web page ([http://www.website.domain/webpage website.domain...]).

lc: An invoke wrapped with {{#lc: {{#invoke: Wikidades ...}}}}} converts the pencil link to lowercase breaking the anchor to the property. Analize if it is really necessary and if any alternative can be applied.