Template:Clean URL: Difference between revisions

From stencil.wiki
No edit summary
No edit summary
Line 3: Line 3:


== Usage ==
== Usage ==
The URL should be passed as the only parameter of template.
The URL should be passed as the only parameter of template. While the link itself will remain unchanged, the protocol, subdomains of www, and trailing slashes will all be cut from the text displayed.


<pre>{{clean URL|https://www.riso.co.jp/}}</pre>
<pre>{{clean URL|https://www.riso.co.jp/}}</pre>
Line 19: Line 19:
{{clean URL|https://web.archive.org/web/19990508115212/http://www4.mediagalaxy.co.jp/riso/}}
{{clean URL|https://web.archive.org/web/19990508115212/http://www4.mediagalaxy.co.jp/riso/}}


''This template can be edited to facilitate additional pattern matches as needed.''
== TemplateData ==
<templatedata>
{
"params": {
"1": {
"label": "URL",
"description": "The URL to clean",
"type": "url",
"required": true
}
},
"description": "An external URL display simplifier."
}
</templatedata>
</noinclude><includeonly><!--
</noinclude><includeonly><!--
-->{{#ifexpr:{{#invoke:String|find|{{lc:{{{1|}}}}}|instagram.com}}>0
-->{{#ifexpr:{{#invoke:String|find|{{lc:{{{1|}}}}}|instagram.com}}>0
|[{{{1|}}} @{{#rmatch:{{{1|}}}|/^(?:https?:\/\/)?(?:www\.)?(?:instagram.com\/)(.+?)\/?$/|\1}}]
|[{{{1|}}} @{{#rmatch:{{{1|}}}|/^(?:https?:\/\/)?(?:www\.)?(?:instagram.com\/)(.+?)\/?$/|\1}}]
|{{#ifexpr:{{#invoke:String|find|{{lc:{{{1|}}}}}|archive.org}}>0
|{{#ifexpr:{{#invoke:String|find|{{lc:{{{1|}}}}}|archive.org}}>0
   |[{{{1|}}} \[archived\]]
   |[{{{1|}}} <nowiki>[archived]</nowiki>]
   |[{{{1|}}} {{#rmatch:{{{1|}}}|/^(?:https?:\/\/)?(?:www\.)?(.+?)\/?$/|\1}}]
   |[{{{1|}}} {{#rmatch:{{{1|}}}|/^(?:https?:\/\/)?(?:www\.)?(.+?)\/?$/|\1}}]
   }}
   }}
}}</includeonly>
}}</includeonly>

Revision as of 17:39, 17 December 2024

This template cleans up the display of external URLs, to simplify how they are shown on the wiki.

Usage

The URL should be passed as the only parameter of template. While the link itself will remain unchanged, the protocol, subdomains of www, and trailing slashes will all be cut from the text displayed.

{{clean URL|https://www.riso.co.jp/}}

riso.co.jp

Pattern recognition

Certain domains are recognized by this template, with custom simplification.

Instagram

{{clean URL|https://www.instagram.com/risokagaku/}}

@risokagaku

Archive.org

{{clean URL|https://web.archive.org/web/19990508115212/http://www4.mediagalaxy.co.jp/riso/}}

[archived]

This template can be edited to facilitate additional pattern matches as needed.

TemplateData

An external URL display simplifier.

Template parameters[Edit template data]

ParameterDescriptionTypeStatus
URL1

The URL to clean

URLrequired