Template talk:Sec link

From Wikipedia, the free encyclopedia
  (Redirected from Template talk:Sec link auto)
Jump to: navigation, search

About ((sec link)), ((sec link auto)) and ((sec link image))[edit]

These templates were inspired by code created by Dispenser. Thanks Dispenser!

In the code of these templates I use a rather odd method to URL-encode the secure link. So to aid future editors of this template, here is the explanation:

Consider the case that a link should go to a page named "Project:São Paulo" on some other Wikimedia project. That page has a space " " and an unusual character "ã". The space has to be encoded as an underscore "_", otherwise the link breaks. While Wikimedia have no problem with the "ã". mw:Help:Magic words lists several functions for handling URL data:

{{urlencode:Project:São Paulo}} = Project%3AS%C3%A3o+Paulo
{{anchorencode:Project:São Paulo}} = Project:S.C3.A3o_Paulo
{{localurl:Project:São Paulo}} = /wiki/Wikipedia:S%C3%A3o_Paulo
{{FULLPAGENAMEE:Project:São Paulo}} = Wikipedia:S%C3%A3o_Paulo

Oddly enough, if we feed the output of {{urlencode}} or {{anchorencode}} to a Wikimedia server then things break. So the only two methods that come close to encode the string the way we need is {{localurl}} and {{FULLPAGENAMEE}}. We can use the ParserFunction #titleparts to strip away the "/wiki/" part from the output of {{localurl}}, but {{FULLPAGENAMEE}} already produces the same result. But both {{localurl}} and {{FULLPAGENAMEE}} converted the namespace "Project:" to "Wikipedia:", which is the name for that namespace here on Wikipedia. But "Wikipedia:" doesn't work if the link is to for instance Wiktionary. So we have to do a trick, we pad on "Template:". Like this:

{{PAGENAMEE:Template:Project:São Paulo}} = Project:S%C3%A3o_Paulo

And we instead used {{PAGENAMEE}} since it strips away the "Template:" part. And it only strips away the first namespace, since it considers the rest to just be a part of the pagename.

For comparison, consider a link from another project to the English Wikipedia, to my other user page "User:David Göthberg":

{{PAGENAMEE:Template:User:David Göthberg}} = User:David_G%C3%B6thberg

On the non-English Wikipedias "User:" is called something else, so it would be converted to another word. But with the padding of "Template" we prevent that. And the really nice part is that "Template:" is the generic MediaWiki name for template space, so that stripping works on all projects. So our code is now fully portable!

--David Göthberg (talk) 18:32, 27 November 2009 (UTC)

These templates do not per default override the "plainlinks" class. This means that when inside templates such as mboxes, navboxes and infoboxes then these templates don't get the padlock unless you set "padlock=yes". That might seem impractical, but this approach has some benefits:

  • The default padlock can be styled in CSS.
  • Entire areas of a page can be made to not show the padlock by using class="plainlinks".
  • The CSS inserted padlock is part of the link and thus clickable.

We could override by using the "link-https" class to get a padlock that can be styled in CSS. That class is available in all Wikimedia projects, but some user scripts damage that class, so using it is unstable. And if we use the "link-https" class, then the padlock will not be part of the link and thus not be clickable. So these templates instead use the default CSS inserted padlock, and when needed you can set "padlock=yes" and then these templates instead insert the padlock as a normal image.

--David Göthberg (talk) 10:56, 3 December 2009 (UTC)

Copying to other projects[edit]

If you copy these templates to another project then there are some things you need to know:

If copying to another language edition of Wikipedia then these templates can be used as is, no code changes are needed.

If copying to a non-Wikipedia project like Wiktionary or Wikibooks, then you need to update one line of code in each of the two sub-templates {{sec link/secure url}} and {{sec link/normal url}}. That line of code is marked with a comment telling it is the one that needs changing. No changes are needed to other templates or sub-templates here.

I will probably add a more complete description about this later on. If I haven't, poke me on my talk page.

--David Göthberg (talk) 23:50, 26 December 2009 (UTC)

Wrong capitalization for Wiktionary[edit]

This template does not respect lowercase capitalization for articles on Wiktionary. It always capitalizes the first letter, which directs to the wrong page. Please fix.

wiktionary:estate wiktionary:grenade wiktionary:ram

-- (talk) 21:47, 4 February 2011 (UTC)

Hello? Anyone here? This is a very serious issue, as the Template:Wiktionary template uses this template (the "sec link auto" version) for its link, and I bet 95+% of links to Wiktionary are for lowercase words, which basically means that the Wiktionary template will be pretty much broken for people on secure servers. -- (talk) 05:30, 8 February 2011 (UTC)
Hi, you asked me to come here since I made these templates. You are right, it is a bug. Thanks for your very clear bug report.
I have now looked into it. It is the magic word {{PAGENAMEE}} that we use to convert the page name to valid URL format that unfortunately also uppercases the first character. (See the top section on this talk page for more on the URL-encoding if you are curios.) I am currently testing different ways to solve this, but all methods I've tested so far fails under some circumstances. But one of the methods at least fails in a nice way so we can probably use that one. I'll keep working on it.
--David Göthberg (talk) 05:49, 10 February 2011 (UTC)
I have just come across this, too, thanks to a user post on my talkpage. As a workaround, pages which use explicit page name, but lowercased, as parameter 1, can have it removed. This will hit the search special, and go to the correct page.
We could test the parameter 1 against lc(pagename) and if it matches lc the result of PAGENAMEE. Rich Farmbrough, 19:33, 23 April 2011 (UTC).
Fixed. {{Case preserving encode}} does the job. Rich Farmbrough, 21:15, 23 April 2011 (UTC).
Thanks Rich for fixing so this template also works for the Wiktionary links. I see you used the same solution that I was thinking of. As far as I can see that is the best we can do, and it works well enough for the Wiktionary links. Sorry that I didn't get around to apply this fix. (Due to personal reasons I have not had much time to edit Wikipedia the last year or so.) So again, thanks Rich for fixing this.
--David Göthberg (talk) 04:26, 18 September 2011 (UTC)

Template:Sec link/secure url[edit]

Please copy the content of Template:Sec link/secure url/sandbox to Template:Sec link/secure url. It adds a missing curly bracket . (diff) --fryed-peach (talk) 15:18, 4 October 2011 (UTC)

 Done -- WOSlinker (talk) 20:07, 4 October 2011 (UTC)

{{sec link auto|wiktionary|…}} corrupts non-Latin initial letters[edit]

This link leads, as requested, to a lowercase word, but this one does not. It is a bug. Incnis Mrsi (talk) 18:08, 23 July 2012 (UTC)

Now obsolete; no use in article namespace[edit]

Templates {{sec link}}, {{sec link auto}} and {{sec link image}} are not transcluded in the Article Namespace at all any more. We can now drop them from Wikipedia:Cascade-protected items, and possibly paste them {{deprecated template-inline}}. --Ahora (talk) 05:56, 1 January 2013 (UTC)

Mark this and sections of related pages historical?[edit]

Based on the above comment and the "As of 2015..." line in Wikipedia:Secure server (a page that I've already marked historical), Shouldn't we add Template:Historical to this page? Or is there still a use and the documentation needs to be updated? Thanks!

Note that this also affects Help:Interwikimedia links § Interproject links using the secure server. I don't know what else it affects, but in general, should we delete any sections mentioning this template and/or link to Wikipedia:Secure server with a mention that it's obsolete?

Sorry all I can do is point this out, but my real-life limitations are getting in the way of doing this myself and I might not make it back here. Thanks in advance if you can work on this! — Geekdiva (talk) 13:34, 30 December 2015 (UTC)

Yes check.svg DoneMr. Stradivarius ♪ talk ♪ 09:25, 31 December 2015 (UTC)