Template talk:PDFlink

From Wikipedia, the free encyclopedia

Contents

[edit] Changing the icon and using it for *all* PDF links

See MediaWiki talk:Common.css/Archive_2#Similar for PDF files? for similar discussion.

  1. Can we use a less ugly icon? These are all free for use: LGPL/CC2.5, designed for MediawikiLGPLcopyrighted, but can be used for any purposefrom GPL software...Creative Commons 2.5Image:Crystal Clear app acroread.pngLGPL
  2. Can this template somehow be merged with the css rules that put the icon next to all PDF files? Yes we can. Here is how:

I proposed a long time ago on the Common.css talk page to add some code to the site-wide CSS which will replace the external link icon with a PDF icon after any link on the entire site that has ".pdf" in it:

#bodyContent a[href$=".pdf"], 
#bodyContent a[href*=".pdf?"], 
#bodyContent a[href*=".pdf#"], 
#bodyContent span.PDFlink a {
   background: url(http://upload.wikimedia.org/wikipedia/en/thumb/7/79/Adobepdfreader7_icon.png/15px-Adobepdfreader7_icon.png) center right no-repeat !important;
   padding-right: 15px;
}

Unfortunately, this only works in Firefox, since IE doesn't support the advanced CSS selectors. Still, it would be helpful to Firefox (and Opera?) users. Then I noticed this template, which manually puts an icon after a link. We should combine these two ideas for maximum benefit:

Currently you can use this template either after a link:

  • [http://www.example.org link]{{PDFlink}}

or around a link:

  • {{PDFlink|[http://www.example.org link]}}

If we mandate the "around a link" format, remove the image from the template, and add a <span class="PDFlink"> inside it, we will be applying the correct CSS class to PDF links to make them display the PDF icon, which does work in IE. So if we make these two changes:

  • In browsers that support the advanced CSS selectors, like Firefox, all PDF links will have the external link arrow turned into a PDF icon, regardless of this template.
  • In IE, links that are surrounded by this template will have the external link arrow turned into a PDF icon.

Not perfect, but it will be better than either just using this template or just using the CSS change. And when the Mediawiki software is updated (sometime next century, no doubt...) to support many other file types, no changes will be necessary (since that will mesh perfectly with the CSS class we already created.) — Omegatron 23:18, 23 August 2006 (UTC)

I made these changes. — Omegatron 01:10, 28 August 2006 (UTC)

The template now works as shown:

  • [http://www.example.org/Link.pdf Link]
  • {{PDFlink|[http://www.example.org/Link.pdf Link]}}
  • {{PDFlink|[http://www.example.org/Link.pdf Link]|32 [[KiB]]}}

If you're using a browser that supports it, the first link will have an icon, too. — Omegatron 18:09, 15 October 2006 (UTC)

[edit] URLs with equal signs

This template will not work if the text contains an equals sign, it maybe be possible in some instances to escape the URL with &#61;—70.111.227.89 17:44, 14 October 2006 (UTC)

This probably happens with all templates. — Omegatron 18:16, 14 October 2006 (UTC)
This indeed happens with all templates that use numbered parameters (see m:Help:Templates#Restrictions_on_parameter_values). In this case, the parameter must be made explicit like this (entierly ficticious example):
{{PDFlink|1=[http://www.example.org/bla?a=xy/Link.pdf Link]|32KB}}.
This problem is one of the reasons why I prefer named over numbered parameters :/. --Ligulem 23:01, 14 October 2006 (UTC)
Couldn't this be avoided with some template magic that escapes equal signs in URLs? — Omegatron 01:25, 15 October 2006 (UTC)
Mabye (urlencode comes to mind). But certainly not with the current design of the template. A requirement (but I can't say if this is sufficent) would be to have the url as an isolated parameter — not packaged inside the external wikilink construct. A lot simpler and a safe bet is to use easy to remember and easy to type named parameters like "url=". --Ligulem 09:53, 15 October 2006 (UTC)

The 1= template does not work. See Template:PDFlink/doc#Limitations. Could the template be made to work with both an unnamed parameter and a url=parameter? Then people could use the url= when the unnamed didn't work. — Omegatron 14:46, 10 November 2006 (UTC)

[edit] Other link templates

Is there a template such as Template:Videolink when linking to real player or windows media file. I have create the link but I wanted to knos if such a template could create an icon such as a film projector, like this template created the Adobe icon? thanks Ccson 07:54, 18 October 2006 (UTC)

We could certainly create one for every file type if desired. We have {{PDFlink}}, {{DOClink}}, {{RTFlink}} so far.
We should combine all the talk pages into one, so that discussion is centralized and changes made to one are made to all. We should also create a more specific category for them, like Category:External link file type templates, which would be a subcategory of Category:External link templates. We are effectively circumventing a bug with this, though, which could be seen as bad. See my comments in the next section. — Omegatron 14:46, 10 November 2006 (UTC)

[edit] PDFbot

I was think that that this project should use some sort of bot to add the file size attribute to all the links using this template. It would make the template more useful than the IE and the LinkThatDon'tContain.PDFInThem fix that it mostly is. The bot does not even need to download the entire PDF as most servers send a Content-Length along with the PDF mimetype in their HTTP response. Do a bit of math to get either the SI prefix or the Binary prefix to two or three sig figs and correct links that use {{PDFlink}} without arguments. –70.111.223.241 03:51, 23 October 2006 (UTC)

That could be a great idea. We're effectively circumventing Bugzilla: 1578, of course, by creating all these templates. But if the developers aren't going to do it, and everyone wants it done, why not? It can always be removed by a bot after they implement the change in software (if they ever do).
We should discuss this with more people before implementing all these templates, though. — Omegatron 14:46, 10 November 2006 (UTC)
Alright, almost done with the bot it working it was through approval. User:PDFbot is running on the pywikipedia framework, it's already made one edit.
See also: Wikipedia:Bots/Requests for approval/PDFbot. --Dispenser 21:55, 14 February 2007 (UTC)

[edit] External link icon

This template no longer works to change the external link icon. Links such as CGI-Redirects to PDFs no longer show an icon. This is related to this diff on MediaWiki:Common.css, however the replacement css doesn't apply have the css property that we use. Should we work to returning this functionality back or scrape the idea of adding icons with this code? --Dispenser 09:08, 3 January 2007 (UTC)

It should be put back into Common.css. There is a discussion on the talk page. — Omegatron 15:17, 3 January 2007 (UTC)

[edit] Format tag in cite templates

Often, the template alone was placed in the "format=" section of the various cite templates. This new functionality makes all those pages show up in Category:PDFlink without a parameter AND it would not allow its stand alone use in the cite tags. Another strike against it, IMO. -- Avi 08:29, 17 January 2007 (UTC)

I will write a bot latter this week to examine the category for the pages that were incorrectly formatted. I've seen people use it to display the filesize. IMO, the filesize should included as a parameter for the citation templates since this template is a workaround for the icon. --Dispenser 17:37, 17 January 2007 (UTC)
'Support - After thinking about it: if there's a need then the citation people can implement part of PDFlink if there's a need for the IE hack. I will post about this in the Citing sources. --Dispenser 03:05, 18 January 2007 (UTC)


[edit] Microsoft Program (Office/Windows) Icons

FYI -- here's a link to Icon images for various Microsoft Office and Windows programs

http://www.seoconsultants.com/windows/icons/microsoft/

--Hoggwild5 02:06, 18 February 2007 (UTC)

[edit] Bug?

*{{PDFlink|[http://www.birmingham.gov.uk/Media?MEDIA_ID=33361 2001 Population Census results theme tables]}} gives:

Andy Mabbett 10:43, 18 June 2007 (UTC)
That's the typical unnamed parameter bug, discussed above in #URLs with equal signs and documentation Limitations section on the documentation page. Just leave it be and PDFbot will come along and fix. —Dispenser 12:46, 18 June 2007 (UTC)

[edit] PDFLink with Citation Templates

Could somebody give me an advice how to use the PDFlink together with the template {{cite book}} or {{cite web}}? When I do not use it, than the Cite web template produces something like this:

The Games of the XVII Olympiad - The Official Report of the Organizing Committee. 

But when I use PDFlink, it produces the link separately from the title, and it is put into square brackets, like this:

[http://www.la84foundation.org/6oic/OfficialReports/1960/OR1960v2.pdfPDF The Games of the XVII Olympiad - The Official Report of the Organizing Committee]. 

Is there any way how to handle this? Jan.Kamenicek 21:33, 9 September 2007 (UTC)

If your trying to indicate that the file is a PDF then use the parameter format = PDF. The icon will show up on any link ending with .pdf for browsers that support CSS2 selectors. If it is file size functionality that your after, then see the discussion PDFbot with Cite web. —Dispenser 00:24, 10 September 2007 (UTC)
Thanks. Jan.Kamenicek 19:37, 10 September 2007 (UTC)