https://wiki.f-si.org/index.php?title=Module:Official_website&feed=atom&action=history
Module:Official website - Revision history
2024-03-28T16:01:04Z
Revision history for this page on the wiki
MediaWiki 1.36.1
https://wiki.f-si.org/index.php?title=Module:Official_website&diff=2441&oldid=prev
Admin: 1 revision imported
2022-03-10T14:16:40Z
<p>1 revision imported</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<tr class="diff-title" lang="en">
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 14:16, 10 March 2022</td>
</tr><tr><td colspan="2" class="diff-notice" lang="en"><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>
Admin
https://wiki.f-si.org/index.php?title=Module:Official_website&diff=2440&oldid=prev
wikipedia>Uzume: update to use new mw.wikibase API changes
2021-12-01T02:12:57Z
<p>update to use new mw.wikibase API changes</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 02:12, 1 December 2021</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l45">Line 45:</td>
<td colspan="2" class="diff-lineno">Line 45:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- Get objects for all official sites on Wikidata.</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- Get objects for all official sites on Wikidata.</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local websites = quickPcall(function ()</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local websites = quickPcall(function ()</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> return mw.wikibase.<del style="font-weight: bold; text-decoration: none;">getEntityObject</del>(<del style="font-weight: bold; text-decoration: none;">)</del>.<del style="font-weight: bold; text-decoration: none;">claims</del>.P856</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> return mw.wikibase.<ins style="font-weight: bold; text-decoration: none;">getAllStatements</ins>(<ins style="font-weight: bold; text-decoration: none;">mw</ins>.<ins style="font-weight: bold; text-decoration: none;">wikibase</ins>.<ins style="font-weight: bold; text-decoration: none;">getEntityIdForCurrentPage(), '</ins>P856<ins style="font-weight: bold; text-decoration: none;">')</ins></div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end)</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end)</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l88">Line 88:</td>
<td colspan="2" class="diff-lineno">Line 88:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>local function renderUrl(options)</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>local function renderUrl(options)</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> if not options.url and not options.wikidataurl then</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> if not options.url and not options.wikidataurl then</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> <del style="font-weight: bold; text-decoration: none;">return </del>'<strong class="error">' ..</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> <ins style="font-weight: bold; text-decoration: none;">local qid = mw.wikibase.getEntityIdForCurrentPage()</ins></div></td></tr>
<tr><td colspan="2"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> local result = </ins>'<strong class="error">' ..</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> 'No URL found. Please specify a URL here or add one to Wikidata.' ..</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> 'No URL found. Please specify a URL here or add one to Wikidata.' ..</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> '</strong>'</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> '</strong>'</div></td></tr>
<tr><td colspan="2"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> if qid then</ins></div></td></tr>
<tr><td colspan="2"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> result = result.. ' [[File:OOjs UI icon edit-ltr-progressive.svg |frameless |text-top |10px |alt=Edit this at Wikidata |link=https://www.wikidata.org/wiki/' .. qid .. '#P856|Edit this at Wikidata]]'</ins></div></td></tr>
<tr><td colspan="2"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> end</ins></div></td></tr>
<tr><td colspan="2"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> return result</ins></div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local ret = {}</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local ret = {}</div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l98">Line 98:</td>
<td colspan="2" class="diff-lineno">Line 103:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> )</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> )</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> if options.wikidataurl and not options.url then</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> if options.wikidataurl and not options.url then</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> local <del style="font-weight: bold; text-decoration: none;">entity </del>= mw.wikibase.<del style="font-weight: bold; text-decoration: none;">getEntityObject</del>() <del style="font-weight: bold; text-decoration: none;">or {}</del></div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> local <ins style="font-weight: bold; text-decoration: none;">qid </ins>= mw.wikibase.<ins style="font-weight: bold; text-decoration: none;">getEntityIdForCurrentPage</ins>()</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;"> local qid = entity.id</del></div></td><td colspan="2"></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> if qid then</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> if qid then</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> ret[#ret + 1] = '[[File:<del style="font-weight: bold; text-decoration: none;">Blue pencil</del>.svg |frameless |text-top |10px |alt=Edit this at Wikidata |link=https://www.wikidata.org/wiki/' .. qid .. '#P856|Edit this at Wikidata]]'</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> ret[#ret + 1] = '[[File:<ins style="font-weight: bold; text-decoration: none;">OOjs UI icon edit-ltr-progressive</ins>.svg |frameless |text-top |10px |alt=Edit this at Wikidata |link=https://www.wikidata.org/wiki/' .. qid .. '#P856|Edit this at Wikidata]]'</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> if options.format == 'flash' then</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> if options.format == 'flash' then</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> ret[#ret + 1] = mw.getCurrentFrame():expandTemplate{</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> ret[#ret + 1] = mw.getCurrentFrame():expandTemplate{</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> title = '<del style="font-weight: bold; text-decoration: none;">Link note</del>',</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> title = '<ins style="font-weight: bold; text-decoration: none;">Color</ins>',</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> args = {<del style="font-weight: bold; text-decoration: none;">note = </del>'Requires [[Adobe Flash Player]]'}</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> args = {'<ins style="font-weight: bold; text-decoration: none;">#505050', '(</ins>Requires [[Adobe Flash Player]]<ins style="font-weight: bold; text-decoration: none;">)</ins>'}</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td></tr>
</table>
wikipedia>Uzume
https://wiki.f-si.org/index.php?title=Module:Official_website&diff=289&oldid=prev
Admin: 1 revision imported
2019-01-25T19:45:00Z
<p>1 revision imported</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<tr class="diff-title" lang="en">
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 19:45, 25 January 2019</td>
</tr><tr><td colspan="2" class="diff-notice" lang="en"><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>
Admin
https://wiki.f-si.org/index.php?title=Module:Official_website&diff=288&oldid=prev
wikipedia>Zyxw: If using Wikidata property, add an icon/link in the same format as Module:EditAtWikidata, as per discussion at Template talk:Official website. Tested with sandbox, module and template test cases, and previews in articles.
2018-08-12T16:12:26Z
<p>If using Wikidata property, add an icon/link in the same format as <a href="/index.php?title=Module:EditAtWikidata" title="Module:EditAtWikidata">Module:EditAtWikidata</a>, as per discussion at <a href="/index.php?title=Template_talk:Official_website&action=edit&redlink=1" class="new" title="Template talk:Official website (page does not exist)">Template talk:Official website</a>. Tested with sandbox, module and template test cases, and previews in articles.</p>
<p><b>New page</b></p><div>local makeUrl = require('Module:URL')._url<br />
<br />
local p = {}<br />
<br />
-- Wrapper for pcall which returns nil on failure.<br />
local function quickPcall(func)<br />
local success, result = pcall(func)<br />
if success then<br />
return result<br />
end<br />
end<br />
<br />
-- Gets the rank for a Wikidata property table. Returns 1, 0 or -1, in<br />
-- order of rank.<br />
local function getRank(prop)<br />
local rank = prop.rank<br />
if rank == 'preferred' then<br />
return 1<br />
elseif rank == 'normal' then<br />
return 0<br />
elseif rank == 'deprecated' then<br />
return -1<br />
else<br />
-- No rank or undefined rank is treated as "normal".<br />
return 0<br />
end<br />
end<br />
<br />
-- Finds whether a Wikidata property is qualified as being in English.<br />
local function isEnglish(prop)<br />
local ret = quickPcall(function ()<br />
for i, lang in ipairs(prop.qualifiers.P407) do<br />
if lang.datavalue.value['numeric-id'] == 1860 then<br />
return true<br />
end<br />
end<br />
return false<br />
end)<br />
return ret == true<br />
end<br />
<br />
-- Fetches the official website URL from Wikidata.<br />
local fetchWikidataUrl<br />
fetchWikidataUrl = function()<br />
-- Get objects for all official sites on Wikidata.<br />
local websites = quickPcall(function ()<br />
return mw.wikibase.getEntityObject().claims.P856<br />
end)<br />
<br />
-- Clone the objects in case other code needs them in their original order.<br />
websites = websites and mw.clone(websites) or {}<br />
<br />
-- Add the table index to the objects in case it is needed in the sort.<br />
for i, website in ipairs(websites) do<br />
website._index = i<br />
end<br />
<br />
-- Sort the websites, first by highest rank, and then by websites in the<br />
-- English language, then by the website's original position in the<br />
-- property list. When we are done, get the URL from the highest-sorted<br />
-- object.<br />
table.sort(websites, function(ws1, ws2)<br />
local r1 = getRank(ws1)<br />
local r2 = getRank(ws2)<br />
if r1 ~= r2 then<br />
return r1 > r2<br />
end<br />
local e1 = isEnglish(ws1)<br />
local e2 = isEnglish(ws2)<br />
if e1 ~= e2 then<br />
return e1<br />
end<br />
return ws1._index < ws2._index<br />
end)<br />
local url = quickPcall(function ()<br />
return websites[1].mainsnak.datavalue.value<br />
end)<br />
<br />
-- Cache the result so that we only do the heavy lifting once per #invoke.<br />
fetchWikidataUrl = function ()<br />
return url<br />
end<br />
<br />
return url<br />
end<br />
<br />
-- Render the URL link, plus other visible output.<br />
local function renderUrl(options)<br />
if not options.url and not options.wikidataurl then<br />
return '<strong class="error">' ..<br />
'No URL found. Please specify a URL here or add one to Wikidata.' ..<br />
'</strong>'<br />
end<br />
local ret = {}<br />
ret[#ret + 1] = string.format(<br />
'<span class="official-website">%s</span>',<br />
makeUrl(options.url or options.wikidataurl, options.display)<br />
)<br />
if options.wikidataurl and not options.url then<br />
local entity = mw.wikibase.getEntityObject() or {}<br />
local qid = entity.id<br />
if qid then<br />
ret[#ret + 1] = '[[File:Blue pencil.svg |frameless |text-top |10px |alt=Edit this at Wikidata |link=https://www.wikidata.org/wiki/' .. qid .. '#P856|Edit this at Wikidata]]'<br />
end<br />
end<br />
if options.format == 'flash' then<br />
ret[#ret + 1] = mw.getCurrentFrame():expandTemplate{<br />
title = 'Link note',<br />
args = {note = 'Requires [[Adobe Flash Player]]'}<br />
}<br />
end<br />
if options.mobile then<br />
ret[#ret + 1] = '(' .. makeUrl(options.mobile, 'Mobile') .. ')'<br />
end<br />
return table.concat(ret, ' ')<br />
end<br />
<br />
-- Render the tracking category.<br />
local function renderTrackingCategory(url, wikidataurl)<br />
if mw.title.getCurrentTitle().namespace ~= 0 then<br />
return ''<br />
end<br />
local category<br />
if not url and not wikidataurl then<br />
category = 'Official website missing URL'<br />
elseif not url and wikidataurl then<br />
return ''<br />
elseif url and wikidataurl then<br />
if url:gsub('/%s*$', '') ~= wikidataurl:gsub('/%s*$', '') then<br />
category = 'Official website different in Wikidata and Wikipedia'<br />
end<br />
else<br />
category = 'Official website not in Wikidata'<br />
end<br />
return category and string.format('[[Category:%s]]', category) or ''<br />
end<br />
<br />
function p._main(args)<br />
local url = args[1] or args.URL or args.url<br />
local wikidataurl = fetchWikidataUrl()<br />
local formattedUrl = renderUrl{<br />
url = url,<br />
wikidataurl = wikidataurl,<br />
display = args[2] or args.name or 'Official website',<br />
format = args.format,<br />
mobile = args.mobile<br />
}<br />
return formattedUrl .. renderTrackingCategory(url, wikidataurl)<br />
end<br />
<br />
function p.main(frame)<br />
local args = require('Module:Arguments').getArgs(frame, {<br />
wrappers = 'Template:Official website'<br />
})<br />
return p._main(args)<br />
end<br />
<br />
return p</div>
wikipedia>Zyxw