⧼social-icons-mobile-buttons⧽

Template:ColTilesRemote: Difference between revisions

From Tsadra Commons
(Images via filepath: absolute URLs, so they load on the consuming wiki)
(VSCode edit)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<includeonly><!--
<includeonly>{{#ifeq: {{{#userparam|}}} | rtz.tsadra.org ||{{SiteTile
One row of cards, one per Tibetan collection wiki, rendered here and shown
on every collection site. It lives on commons so the list is written ONCE:
a new collection going live is one edit here, not one edit per wiki.
 
It is fetched with an #ask carrying source=commons, and a remote #ask
resolves its row template on the SOURCE wiki -- so both this page and
Template:SiteTile have to be here, and so do the images.
 
The calling site passes its own hostname as userparam. It arrives under the
HASH-PREFIXED name -- see the documentation below; the plain name and the
numbered slots are never set. Each card compares it against its own host=
and renders nothing when they match, so a site never advertises itself. A
caller that passes nothing gets all four.
 
No braces in this comment: the preprocessor counts them even inside one, so
a triple-brace parameter named here leaves an unbalanced opener and
swallows the rest of the template. That is exactly what happened when this
page was first written -- it rendered four tiles as raw text and zero when
transcluded.
 
Add a collection by adding a SiteTile call. Upload its image HERE, on
commons, and pass it as imageurl=filepath:NAME|240 -- NOT as image=.
 
That matters. A File: link renders against the wiki the markup lands on,
and commons emits its own relative /thumb.php path, which 404s everywhere
else. filepath: resolves here, where the file is native, and returns an
ABSOLUTE https://commons.tsadra.org/... URL that works from any wiki.
With no image the card falls back to the title's first letter.
-->{{#ifeq: {{{#userparam|}}} | rtz.tsadra.org ||{{SiteTile
|url=https://rtz.tsadra.org
|url=https://rtz.tsadra.org
|name=Rinchen Terdzö
|name=Rinchen Terdzö
Line 34: Line 5:
|note=The Great Treasury of Rediscovered Teachings
|note=The Great Treasury of Rediscovered Teachings
|host=rtz.tsadra.org
|host=rtz.tsadra.org
|imageurl={{filepath:Jamgon kongtrul.jpg|240}}
|imagefile=Jamgon kongtrul.jpg
|imgpos=50% 35%
|imgpos=50% 35%
}}}}{{#ifeq: {{{#userparam|}}} | dnz.tsadra.org ||{{SiteTile
}}}}{{#ifeq: {{{#userparam|}}} | dnz.tsadra.org ||{{SiteTile
Line 42: Line 13:
|note=The Treasury of Precious Instructions
|note=The Treasury of Precious Instructions
|host=dnz.tsadra.org
|host=dnz.tsadra.org
|imageurl={{filepath:Shing rta brgyad-01-Nyingma.jpg|240}}
|imagefile=Shing rta brgyad-01-Nyingma.jpg
|imgpos=50% 45%
|imgpos=50% 45%
}}}}{{#ifeq: {{{#userparam|}}} | khyentselineage.tsadra.org ||{{SiteTile
}}}}{{#ifeq: {{{#userparam|}}} | khyentselineage.tsadra.org ||{{SiteTile
Line 50: Line 21:
|note=Collected Works of the Masters
|note=Collected Works of the Masters
|host=khyentselineage.tsadra.org
|host=khyentselineage.tsadra.org
|imageurl={{filepath:Jamyang Khyentse Wangpo cropped.jpg|240}}
|imagefile=Jamyang Khyentse Wangpo cropped.jpg
|imgpos=50% 35%
|imgpos=50% 35%
}}}}{{#ifeq: {{{#userparam|}}} | dudjom.tsadra.org ||{{SiteTile
}}}}{{#ifeq: {{{#userparam|}}} | dudjom.tsadra.org ||{{SiteTile
Line 58: Line 29:
|note=The New Treasures of Dudjom
|note=The New Treasures of Dudjom
|host=dudjom.tsadra.org
|host=dudjom.tsadra.org
|imageurl={{filepath:Dudjom portrait.jpg|240}}
|imagefile=Dudjom portrait.jpg
}}}}</includeonly><noinclude>
}}}}</includeonly><noinclude>
The cards for '''Tsadra's Tibetan collection wikis''', written once and shown on all of them.
The cards for '''Tsadra's Tibetan collection wikis''', written once and shown on all of them.
Line 76: Line 47:
'''To add a collection''', add a {{tl|SiteTile}} call above, wrapped in the same <code>#ifeq</code>. Upload its image '''here''', not on the collection wiki — a remote <code>#ask</code> resolves everything on this wiki.
'''To add a collection''', add a {{tl|SiteTile}} call above, wrapped in the same <code>#ifeq</code>. Upload its image '''here''', not on the collection wiki — a remote <code>#ask</code> resolves everything on this wiki.


Pass the image as <code><nowiki>|imageurl={{filepath:NAME.jpg|240}}</nowiki></code>, never as <code>image=</code>. A <code>File:</code> link is resolved against whichever wiki the markup ends up on, and commons emits a site-relative <code>/thumb.php?f=…</code> path that returns 403 anywhere else — so every image in the row would break. <code>filepath:</code> runs here, where the file is native, and yields an absolute URL that any wiki can load.
Pass the image as <code>|imagefile=NAME.jpg</code> — a bare file name, never <code>image=</code> and never a <code>[[File:…]]</code> link.
 
A <code>File:</code> link is resolved against whichever wiki the markup ends up on, and this wiki sets <code>$wgThumbnailScriptPath</code>, so its thumbnails are site-relative <code>/thumb.php?f=…</code> paths that return 403 anywhere else — every image in the row would break. <code>imagefile=</code> instead goes through <code><nowiki>{{filepath:}}</nowiki></code>, which runs here where the file is native and yields an absolute URL at the right width, and then through {{tl|RemoteImage}} — a Widget, because its output escapes the sanitiser: in running text MediaWiki autolinks a bare URL, and a raw <code>&lt;img&gt;</code> written in wikitext is escaped.


Note <code>{{{#userparam}}}</code> is hash-prefixed. <code>{{{userparam}}}</code> and the numbered slots are never set; this was tested against a remote query before the template was written.
Note <code>{{{#userparam}}}</code> is hash-prefixed. <code>{{{userparam}}}</code> and the numbered slots are never set; this was tested against a remote query before the template was written.


[[Category:Custom Templates]]</noinclude>
[[Category:Custom Templates]]</noinclude>

Latest revision as of 12:28, 14 September 2026

The cards for Tsadra's Tibetan collection wikis, written once and shown on all of them.

Each collection site renders this row with:

{{#ask:[[Template:ColTilesRemote]]
	|source=commons
	|format=template
	|template=ColTilesRemote
	|link=none
	|userparam={{SERVERNAME}}
}}

Passing commons.tsadra.org is what stops a site advertising itself: the value arrives as {{{#userparam}}} and each card compares it with its own host=.

To add a collection, add a {{SiteTile}} call above, wrapped in the same #ifeq. Upload its image here, not on the collection wiki — a remote #ask resolves everything on this wiki.

Pass the image as |imagefile=NAME.jpg — a bare file name, never image= and never a File:… link.

A File: link is resolved against whichever wiki the markup ends up on, and this wiki sets $wgThumbnailScriptPath, so its thumbnails are site-relative /thumb.php?f=… paths that return 403 anywhere else — every image in the row would break. imagefile= instead goes through {{filepath:}}, which runs here where the file is native and yields an absolute URL at the right width, and then through {{RemoteImage}} — a Widget, because its output escapes the sanitiser: in running text MediaWiki autolinks a bare URL, and a raw <img> written in wikitext is escaped.

Note {{{#userparam}}} is hash-prefixed. {{{userparam}}} and the numbered slots are never set; this was tested against a remote query before the template was written.