Difference between revisions of "Ref2"

From Sega Retro

 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
<includeonly>{{#vardefine:reflink|}}{{#if: {{#pos:{{{1}}}|http://}}{{#pos:{{{1}}}|https://}}{{#pos:{{{1}}}|ftp://}}
 
<includeonly>{{#vardefine:reflink|}}{{#if: {{#pos:{{{1}}}|http://}}{{#pos:{{{1}}}|https://}}{{#pos:{{{1}}}|ftp://}}
 
|{{#vardefine:refcontent|{{{1}}}}}<!-- Ref is a link. Use text as-is. -->
 
|{{#vardefine:refcontent|{{{1}}}}}<!-- Ref is a link. Use text as-is. -->
|{{#vardefine:refcontent|File:{{{1}}}{{#if:{{{page|}}}|, page {{{page}}}}}}}<!-- Ref is a file. -->
+
|{{#switch: {{fileext|{{{1}}}}} | png|jpg|jpeg|zip|7z|pdf={{#vardefine:refcontent|File:{{{1}}}{{#if:{{{page|}}}|, page {{{page}}}}}}}<!-- Ref is a file. -->
 +
|#default={{#vardefine:refcontent|[[{{{1}}}]]}}<!-- Ref is an internal link. -->
 +
}}
 
}}{{#loop:i
 
}}{{#loop:i
 
|1
 
|1
 
|{{#var:refcount|1}}
 
|{{#var:refcount|1}}
 
|{{#ifeq:{{#var:refcontent}}|{{#var:ref_{{#var:i}}}}
 
|{{#ifeq:{{#var:refcontent}}|{{#var:ref_{{#var:i}}}}
  |{{#vardefine:reflink|{{#var:i}}}}{{incvar|refuses_{{#var:reflink}}}}<!-- Match found with previously used ref. -->
+
  |{{#vardefine:reflink|{{#var:i}}}}{{incvar|refuses_{{#var:reflink}}}}{{#vardefine:thisrefuse|{{#var:refuses_{{#var:reflink}}}}}}<!-- Match found with previously used ref. -->
 
  |
 
  |
 
  }}
 
  }}
 
}}{{#if: {{#var:reflink}}
 
}}{{#if: {{#var:reflink}}
 
|
 
|
|{{incvar|refcount}}{{incvar|refuses_{{#var:refcount}}}}{{#vardefine:ref_{{#var:refcount}}|{{#var:refcontent}}}}{{#vardefine:reflink|{{#var:refcount}}}}<!-- This is a new ref. Add it to the list. -->
+
|{{incvar|refcount}}{{incvar|refuses_{{#var:refcount}}}}{{#vardefine:ref_{{#var:refcount}}|{{#var:refcontent}}}}{{#vardefine:reflink|{{#var:refcount}}}}{{#vardefine:thisrefuse|1}}<!-- This is a new ref. Add it to the list. -->
}}<sup id="refback_{{#var:reflink}}">[[#ref_{{#var:reflink}}|[{{#var:reflink}}]]]</sup></includeonly><noinclude>
+
}}<sup id="refback_{{#var:reflink}}_{{#var:thisrefuse}}">[[#ref_{{#var:reflink}}|[{{#var:reflink}}]]]</sup></includeonly><noinclude>
  
 
==Usage==
 
==Usage==
 
This is an example.{{ref2|http://google.com}} And another example.{{ref2|http://en.wikipedia.org}} Same as first.{{ref2|http://google.com}} Third.{{ref2|http://sonicretro.org}}
 
This is an example.{{ref2|http://google.com}} And another example.{{ref2|http://en.wikipedia.org}} Same as first.{{ref2|http://google.com}} Third.{{ref2|http://sonicretro.org}}
  
This is a fileref.{{ref2|CVG UK 090.pdf|page=12}} Fileref without page.{{ref2|Sonic1 title.png}}
+
This is a fileref.{{ref2|CVG UK 090.pdf|page=12}} Fileref without page.{{ref2|Sonic1 title.png}} Internal ref.{{ref2|Sega Master System}}
  
 
{{#var:refcount}}
 
{{#var:refcount}}
 
{{refs}}
 
{{refs}}
 +
[[Category:Experimental templates]]
 
</noinclude>
 
</noinclude>

Latest revision as of 09:47, 19 July 2018


Usage

This is an example.[1] And another example.[2] Same as first.[1] Third.[3]

This is a fileref.[4] Fileref without page.[5] Internal ref.[6]

6

  1. 1.1 1.2  http://google.com
  2. http://en.wikipedia.org
  3. http://sonicretro.org
  4. File:CVG UK 090.pdf, page 12Media:CVG UK 090.pdf
  5. File:Sonic1 title.pngMedia:Sonic1 title.png
  6. Sega Master System