Difference between revisions of "Template:Links to/testcases"

From blackwiki
Jump to navigation Jump to search
imported>Cpiral
(→‎top: external links to test, and the regex notes to make the tests)
imported>Cpiral
(→‎top: finish external-links-style table and recording observations (mw:extension:linksearch is deprecated))
Line 25: Line 25:
 
{|class=wikitable
 
{|class=wikitable
 
|+ Patterns of external-style links to [[../doc#Purpose]].
 
|+ Patterns of external-style links to [[../doc#Purpose]].
! For regexp template code, the unfolding text patterns
+
! Unfolding text patterns. Use to make regex.
 
! Notes
 
! Notes
  
 
|-
 
|-
|{{canonicalurl:Template:Linksto/doc#Purpose}} (Works)<br/>
+
|{{canonicalurl:Template:Linksto/doc#Purpose}}<br/>
 
{<nowiki/>{canonicalurl:Template:Linksto/doc#Purpose}}
 
{<nowiki/>{canonicalurl:Template:Linksto/doc#Purpose}}
|
+
| Works without [square brackets]
  
 
|-
 
|-
| [{{fullurl:Template:linksto/doc#Purpose}}] (Works)<br/>
+
|[{{canonicalurl:Template:Linksto/doc#Purpose}}] <br/>
 +
[{<nowiki/>{canonicalurl:Template:Linksto/doc#Purpose}}]
 +
| Canonicalurl works with or without square brackets.
 +
 
 +
|-
 +
| [{{fullurl:Template:linksto/doc#Purpose}}]<br/>
 
&#91;{<nowiki/>{fullurl:Template:linksto/doc#Purpose}}] &rarr;<br/>
 
&#91;{<nowiki/>{fullurl:Template:linksto/doc#Purpose}}] &rarr;<br/>
 
&#91;{{fullurl:Template:linksto/doc#Purpose}}]  
 
&#91;{{fullurl:Template:linksto/doc#Purpose}}]  
|  
+
| {{fullurl:Template:linksto/doc#Purpose}} <br/>
 +
Does not work without square brackets
 +
 
 +
|-
 +
|[https://en.wikipedia.org/wiki/template:linksto/doc#Purpose]<br/>
 +
[<nowiki/>https:/<nowiki/>/en.wikipedia.org/wiki/template:linksto/doc#Purpose]
 +
| Hand typed, with lower-case first letter of namespace and pagename
  
 
|-
 
|-
| [{{fullurl:{{urlencode:Template:linksto/doc#Purpose}}}}] (Works)<br/>
+
| [//en.wikipedia.org/wiki/template:linksto/doc#Purpose]<br/>
&#91;{<nowiki/>{fullurl:{<nowiki/>{urlencode:Template:linksto/doc#Purpose}}}}] &rarr;<br/>
+
[/<nowiki/>/en.wikipedia.org/wiki/template:linksto/doc#Purpose]
 +
| Hand typed, with lower-case first letter of namespace and pagename
 +
 
 +
|-
 +
| [{{fullurl:{{urlencode:Template:linksto/doc#Purpose}}}}] <br/>
 +
&#91;{<nowiki/>{fullurl:{<nowiki/>{urlencode:Template:linksto/doc#Purpose}}}}] &rarr; <br/>
 
&#91;{{fullurl:{{urlencode:Template:linksto/doc#Purpose}}}}]  
 
&#91;{{fullurl:{{urlencode:Template:linksto/doc#Purpose}}}}]  
| urlencod could be placed elsewhere
+
| Urlencode could be placed elsewhere.
 
 
  
 
|-
 
|-
| [{{fullurl:{{anchorencode:Template:linksto/doc#Purpose}}}}] (Not!)<br/>
+
| [{{fullurl:Template:linksto{{urlencode:/doc#Purpose}}}}] <br/>
&#91;{<nowiki/>{fullurl:{<nowiki/>{anchorencode:Template:linksto/doc#Purpose}}}}] &rarr;<br/>
+
[{<nowiki/>{fullurl:Template:linksto{<nowiki/>{urlencode:/doc#Purpose}}}}] <br/>
&#91;{{fullurl:{{anchorencode:Template:linksto/doc#Purpose}}}}]  
+
[<nowiki/>{{fullurl:Template:linksto{{urlencode:/doc#Purpose}}}}]  
| Does '''not''' link to a section<br/>Creates pagenames with # &rarr; .23
+
| Urlencode placed to start with the slash / char
  
 
|}
 
|}
  
Regex pattern matching notes:
+
Regex pattern matching observations for the external-style links:
* urlencode can go in various places and still work
+
* <code>{{Urlencode</code> can go in various places and still work.
* localurl and anchorencode are not in question, they will not work with #
+
* <code>{{Localurl</code> and <code>{{anchorencode</code> are not in question: they will not work with the number # sign.
* fullurl:fullpagename|paramwith parameters is not in question: {{fullurl:fullpagename|huh}}
+
* <code>{{Fullurl:fullpagename|param</code> with parameters is not in question, I mean... look at it: {{fullurl:fullpagename|param}}
* canonical url does not need [brackets], but could have them
+
* <code>{{canonicalurl</code> does not need [brackets], but could have them [{{canonicalurl:{{FULLPAGENAME}}}}
* fullurl must be [fullurl] not [ fullurl ]
+
* <code>{{fullurl</code> must be <code>[{{fullurl]</code> not <code>[ {{fullurl ]</code> with spaces
* Match the template, or the hand-typed intermediate form.  Both work, but both work with [Pp]agename the first letter.
+
* Match the template, or the hand-typed intermediate form.  Hand-typed ones work with [Pp]agename the first letter.
  
 
== [[Template:{{TEMPLATENAME|testcases}}/sandbox|Sandbox version]] ==
 
== [[Template:{{TEMPLATENAME|testcases}}/sandbox|Sandbox version]] ==

Revision as of 02:34, 9 December 2015

Each test says "On behalf of the parent page (namespace:basename, Template:Linksto), what links to section X"? There is no section X at Template:Linksto, but the query only ever looks for the pattern #X. It relies on the high probability that if a page is found to link "here" and it has also one of my section names, and preceded by a # sign, it probably does.

Required links, or patterns that simulate links, linksto on this page to work:

  1. Section link Template:Linksto Question [../|sublinks]]?
  2. Section link Template:Linksto Question "tick" marks?
  3. Section link Template:Linksto THis has/all/ the issues
  4. Section link Template:Linksto THis has" all the issues
  5. Section link Template:Linksto THis has all the_issues
  6. Section link Template:Linksto THis_has_all_the_issues
  7. Section link Template:Linksto THis has/all the issues
  8. Section link Template:Linksto THis "has" all the issues
  9. Section link Template:Linksto THis "has"/all the_issues
Patterns of external-style links to Template:Links to/doc#Purpose.
Unfolding text patterns. Use to make regex. Notes
https://blackwiki.org/index.php?title=Template:Linksto/doc#Purpose

{{canonicalurl:Template:Linksto/doc#Purpose}}

Works without [square brackets]
[1]

[{{canonicalurl:Template:Linksto/doc#Purpose}}]

Canonicalurl works with or without square brackets.
[2]

[{{fullurl:Template:linksto/doc#Purpose}}] →
[https://blackwiki.org/index.php?title=Template:Linksto/doc#Purpose]

https://blackwiki.org/index.php?title=Template:Linksto/doc#Purpose

Does not work without square brackets

[3]

[https://en.wikipedia.org/wiki/template:linksto/doc#Purpose]

Hand typed, with lower-case first letter of namespace and pagename
[4]

[//en.wikipedia.org/wiki/template:linksto/doc#Purpose]

Hand typed, with lower-case first letter of namespace and pagename
[5]

[{{fullurl:{{urlencode:Template:linksto/doc#Purpose}}}}] →
[https://blackwiki.org/index.php?title=Template:Linksto/doc#Purpose]

Urlencode could be placed elsewhere.
[6]

[{{fullurl:Template:linksto{{urlencode:/doc#Purpose}}}}]
[https://blackwiki.org/index.php?title=Template:Linksto/doc#Purpose]

Urlencode placed to start with the slash / char

Regex pattern matching observations for the external-style links:

Sandbox version

Via {{Section link}}: success means this page shows up in the search link.


Via [[fullpagename#section name]]:
Success means that the search link highlights the match corresponds to the simulated section link. The number signs (that make the ordered list) satisfy the regexp that simulates linksto mechanism.

  1. THis "has"/all the_issues Template:Links to#THis "has"/all the issues:  Template:Plain link · Template:Plain link
  1. THis "has" all the issues Template:Links to#THis "has" all the issues:  Template:Plain link · Template:Plain link
  1. THis has/all the issues Template:Links to#THis has/all the issues:  Template:Plain link · Template:Plain link
  1. THis_has_all_the_issues Template:Links to#THis has all the issues:  Template:Plain link · Template:Plain link
  1. THis has all the_issues Template:Links to#THis has all the issues:  Template:Plain link · Template:Plain link
  1. THis has" all the issues Template:Links to#THis has" all the issues:  Template:Plain link · Template:Plain link
  1. THis has/all/ the issues Template:Links to#THis has/all/ the issues:  Template:Plain link · Template:Plain link
  1. Question "tick" marks? Template:Links to#Question "tick" marks?:  Template:Plain link · Template:Plain link
  1. Question [../|sublinks]]? Template:Links to#Question [../|sublinks]]?:  Template:Plain link · Template:Plain link


Main template

Linksto template has two parts:

  1. linksto part links to a fullpagename, in this case Template:Links to.
  2. regex part links to the following patterns (# char required).

Via {{Section link}}: success means this page shows up in the search link


Via wikilink: The number signs (that make the ordered list) satisfy the regexp.

  1. THis "has"/all the_issues Template:Links to#THis "has"/all the issues:  Template:Plain link · Template:Plain link
  1. THis "has" all the issues Template:Links to#THis "has" all the issues:  Template:Plain link · Template:Plain link
  1. THis has/all the issues Template:Links to#THis has/all the issues:  Template:Plain link · Template:Plain link
  1. THis_has_all_the_issues Template:Links to#THis has all the issues:  Template:Plain link · Template:Plain link
  1. THis has all the_issues Template:Links to#THis has all the issues:  Template:Plain link · Template:Plain link
  1. THis has" all the issues Template:Links to#THis has" all the issues:  Template:Plain link · Template:Plain link
  1. THis has/all/ the issues Template:Links to#THis has/all/ the issues:  Template:Plain link · Template:Plain link
  1. Question "tick" marks? Template:Links to#Question "tick" marks?:  Template:Plain link · Template:Plain link
  1. Question [../|sublinks]]? Template:Links to#Question [../|sublinks]]?:  Template:Plain link · Template:Plain link


Together the above link to the basepagename plus the pattern, simulate the success mechanism. Success means activating the search link and seeing corresponding, highlighted, pattern match.