Difference between revisions of "Ref2"
From Sega Retro
(3 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}}}}<!-- 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}}{{#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>[[#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> |