https://nordiclarp.org/w/index.php?title=Module:Ns_has_subpages&feed=atom&action=historyModule:Ns has subpages - Revision history2024-03-29T06:42:37ZRevision history for this page on the wikiMediaWiki 1.34.2https://nordiclarp.org/w/index.php?title=Module:Ns_has_subpages&diff=9336&oldid=prevJohannes Axner: Protected "Module:Ns has subpages" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))2018-12-29T23:50:34Z<p>Protected "<a href="/wiki/Module:Ns_has_subpages" title="Module:Ns has subpages">Module:Ns has subpages</a>" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))</p>
<table class="diff diff-contentalign-left" data-mw="interface">
<tr class="diff-title" lang="en">
<td colspan="1" style="background-color: #fff; color: #222; text-align: center;">← Older revision</td>
<td colspan="1" style="background-color: #fff; color: #222; text-align: center;">Revision as of 23:50, 29 December 2018</td>
</tr><tr><td colspan="2" class="diff-notice" lang="en"><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>Johannes Axnerhttps://nordiclarp.org/w/index.php?title=Module:Ns_has_subpages&diff=7482&oldid=prevJohannes Axner: 1 revision imported2018-12-29T01:20:26Z<p>1 revision imported</p>
<table class="diff diff-contentalign-left" data-mw="interface">
<tr class="diff-title" lang="en">
<td colspan="1" style="background-color: #fff; color: #222; text-align: center;">← Older revision</td>
<td colspan="1" style="background-color: #fff; color: #222; text-align: center;">Revision as of 01:20, 29 December 2018</td>
</tr><tr><td colspan="2" class="diff-notice" lang="en"><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>Johannes Axnerhttps://nordiclarp.org/w/index.php?title=Module:Ns_has_subpages&diff=7481&oldid=preven>Mr. Stradivarius: Protected Module:Ns has subpages: High-risk Lua module ([Edit=Allow only template editors and admins] (indefinite) [Move=Allow only template editors and admins] (indefinite))2014-12-10T06:37:29Z<p>Protected Module:Ns has subpages: <a href="/w/index.php?title=WP:High-risk_templates&action=edit&redlink=1" class="new" title="WP:High-risk templates (page does not exist)">High-risk Lua module</a> ([Edit=Allow only template editors and admins] (indefinite) [Move=Allow only template editors and admins] (indefinite))</p>
<p><b>New page</b></p><div>-- This module implements [[Template:Ns has subpages]].<br />
-- While the template is fairly simple, this information is made available to<br />
-- Lua directly, so using a module means that we don't have to update the<br />
-- template as new namespaces are added.<br />
<br />
local p = {}<br />
<br />
function p._main(ns, frame)<br />
-- Get the current namespace if we were not passed one.<br />
if not ns then<br />
ns = mw.title.getCurrentTitle().namespace<br />
end<br />
<br />
-- Look up the namespace table from mw.site.namespaces. This should work<br />
-- for a majority of cases.<br />
local nsTable = mw.site.namespaces[ns]<br />
<br />
-- Try using string matching to get the namespace from page names.<br />
-- Do a quick and dirty bad title check to try and make sure we do the same<br />
-- thing as {{NAMESPACE}} in most cases.<br />
if not nsTable and type(ns) == 'string' and not ns:find('[<>|%[%]{}]') then<br />
local nsStripped = ns:gsub('^[_%s]*:', '')<br />
nsStripped = nsStripped:gsub(':.*$', '')<br />
nsTable = mw.site.namespaces[nsStripped]<br />
end<br />
<br />
-- If we still have no match then try the {{NAMESPACE}} parser function,<br />
-- which should catch the remainder of cases. Don't use a mw.title object,<br />
-- as this would increment the expensive function count for each new page<br />
-- tested.<br />
if not nsTable then<br />
frame = frame or mw.getCurrentFrame()<br />
local nsProcessed = frame:callParserFunction('NAMESPACE', ns)<br />
nsTable = nsProcessed and mw.site.namespaces[nsProcessed]<br />
end<br />
<br />
return nsTable and nsTable.hasSubpages<br />
end<br />
<br />
function p.main(frame)<br />
local ns = frame:getParent().args[1]<br />
if ns then<br />
ns = ns:match('^%s*(.-)%s*$') -- trim whitespace<br />
ns = tonumber(ns) or ns<br />
end<br />
local hasSubpages = p._main(ns, frame)<br />
return hasSubpages and 'yes' or ''<br />
end<br />
<br />
return p</div>en>Mr. Stradivarius