Àdàkọ:PDFlink

Lát'ọwọ́ Wikipedia, ìwé ìmọ̀ ọ̀fẹ́
Jump to navigation Jump to search

PDFlink must be run with an argument{{{1}}}PDF ({{{2}}})

Ìwé-alàyé àdàkọ[ìwò] [àtúnṣe] [ìtàn] [ìfọnù]

{{PDFlink}} highlights that a link points to a PDF document (on some systems PDF files may take time to download and display within the browser, and their use on many websites is not compliant with the Web Content Accessibility Guidelines).

Usage[àtúnṣe àmìọ̀rọ̀]

The following lines:

{{PDFlink|[http://www.example.org/Link.pdf Link]}}
{{PDFlink|[http://www.example.org/Link.pdf Link]|32&nbsp;KB}} 
{{PDFlink|[http://www.example.org/fileserver/239349 Link]|1.4 MB}}

yield:

LinkPDF
LinkPDF (32 KB)
LinkPDF (1.4 MB)

Note: It was previously possible to add the icon with {{PDFlink}} by itself, but the functionality has changed, making this no longer work in Internet Explorer. You must surround it with the template as shown above to work correctly in Internet Explorer.Àdàkọ:Clarify See #Use in citation templates, below, for how to do this now without boogering IE.

Units: Per WP:Manual of Style (dates and numbers), use KB and MB (kilobytes and megabytes), not KiB and MiB (kibibytes and mibibytes), as very few readers have ever even heard of the latter units.

PDFbot[àtúnṣe àmìọ̀rọ̀]

An unassisted bot, User:PDFbot, has been created to add and keep file size information current. In addition, it will fix many mistakes and the limitation as described in the section below.

Note: the bot will replace the contents of the second parameter when updating the file size.

Icon[àtúnṣe àmìọ̀rọ̀]

The icon is added using CSS and is found in MediaWiki:Common.css, the relevant portion that applies the icon is:

/* Change the external link icon to an Adobe icon anywhere the PDFlink class
   is used (notably Template:PDFlink). This works in IE, unlike the above. */
#content span.PDFlink a,
#mw_content span.PDFlink a {
    background: url("http://upload.wikimedia.org/wikipedia/commons/2/23/Icons-mini-file_acrobat.gif") center right no-repeat;
    padding-right: 18px;
}

Limitations and easy workarounds[àtúnṣe àmìọ̀rọ̀]

The problematic "=" character[àtúnṣe àmìọ̀rọ̀]

When this template is used with unnamed parameters, links containing the "=" (equals sign) character will cause the link to not display at all. Workarounds available are:

  • Use explicitly numbered parameters, |1= and |2=, for the URL and the file size, respectively

or

  • Use {{=}} as a replacement for =

or


Bad example
{{PDFlink|[http://example.org/bla?a=xy|Link.pdf Link to a PDF]|32&nbsp;KB}}
32 KBPDF


Good examples
{{PDFlink|[http://example.org/bla?a&#61;xy&#124;Link.pdf Link to a PDF]|32&nbsp;KB}}
Link to a PDFPDF (32 KB)
{{PDFlink|1=[http://example.org/bla?a=xy{{!}}Link.pdf Link to a PDF]|2=32&nbsp;KB}}
Link to a PDFPDF (32 KB)

Use in citation templates[àtúnṣe àmìọ̀rọ̀]

This template is not instantly compatible with citation templates such as {{cite book}} and {{cite web}}, which put URLs in their own parameter, without markup. Two kinds of usage need two different workarounds, both using the invisible but existent "no-width space" numeric character entity reference, &#8203;.


URLs ending in ".pdf" or ".PDF"

The workaround is to not use an actual URL (and no [square brackets]) in the {{PDFlink}} first parameter, but just the &#8203; entity:

 |title=Some Article
 |url=http://www.example.org/fileserver/Link.pdf
 |format={{PDFlink|&#8203;|1.4 MB}}

renders as something like:

Some Article (PDF (1.4 MB))

in the spaces that the parameters fill. (Exact spacing, punctuation, etc., depends on the specific citation template used). This prevents the appearance of a PDF icon auto-generated by MediaWiki being followed by one generated by {{PDFlink}}.

Doing this, however:

 |title=Some Article
 |url=http://www.example.org/fileserver/Link.pdf
 |format={{PDFlink|[http://www.example.org/fileserver/Link.pdf &#8203;]|1.4 MB}}

would result in:

Some Article (PDF (1.4 MB))

This trick needs to be done with the character entity, because leaving the first parameter blank will simply get the page categorized in a cleanup category for pages that misuse this template, and a bot will "fix" the page's use of the template (i.e., it will cause problems).


URLs not ending in ".pdf" or ".PDF"

The workaround is to repeat the URL used in |url= in {{PDFlink}} inside |format= as a square-backeted link, and use &#8203; as the link text (note that numbered parameters are often required because of "=" characters in such URLs):

 |title=Some Article
 |url=http://www.example.org/fileserver&file=2234234
 |format={{PDFlink|1=[http://www.example.org/fileserver&file=2234234 &#8203;]|2=1.4 MB}}

yields:

Some Article (PDF (1.4 MB))

I.e., it produces a PDF icon that links to the same target as the URL given in the citation template's |url= parameter, without creating new link text, and meanwhile MediaWiki did not know this was a PDF file and so did not autogenerate a duplicative icon.
https://yo.wikipedia.org/wiki/%C3%80d%C3%A0k%E1%BB%8D:PDFlink
yo.wikipedia.org
crawl=CC-MAIN-2020-40
64043
application/http; msgtype=response
sha1:WVPAUZXGIPL54VMK3MZZ65XJ2AFLMQBV
<urn:uuid:55dd4d2d-8fe5-4755-b1c2-ca5ecff3d7e7>
2020-09-24T06:08:13Z
208.80.153.224
text/html
sha1:BE25YFTRATGVL2Q3VYRJK3KEYZJQWY5A
<urn:uuid:ac2f1ed3-e483-484d-9a14-dc35359032f3>
https://yo.wikipedia.org/wiki/%C3%80d%C3%A0k%E1%BB%8D:PDFlink
response
<urn:uuid:124ff835-c528-465a-a29d-a43d685cc5c7>
isPartOf: CC-MAIN-2020-40
publisher: Common Crawl
description: Wide crawl of the web for September 2020
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-17.ec2.internal
software: Apache Nutch 1.17 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.2-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: http://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/