https://de.wikipedia.org/w/index.php?action=history&feed=atom&title=Modul%3APageAttributes Modul:PageAttributes - Versionsgeschichte 2025-06-23T08:15:41Z Versionsgeschichte dieser Seite in Wikipedia MediaWiki 1.45.0-wmf.6 https://de.wikipedia.org/w/index.php?title=Modul:PageAttributes&diff=223481607&oldid=prev PerfektesChaos: 2022-06-06 2022-06-06T13:44:49Z <p>2022-06-06</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="de"> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Nächstältere Version</td> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Version vom 6. Juni 2022, 15:44 Uhr</td> </tr><tr> <td colspan="2" class="diff-lineno">Zeile 1:</td> <td colspan="2" class="diff-lineno">Zeile 1:</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 PageAttributes = { suite = "PageAttributes",</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 PageAttributes = { suite = "PageAttributes",</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> serial = "2022-<del style="font-weight: bold; text-decoration: none;">05</del>-<del style="font-weight: bold; text-decoration: none;">25</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> serial = "2022-<ins style="font-weight: bold; text-decoration: none;">06</ins>-<ins style="font-weight: bold; text-decoration: none;">06</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> item = <del style="font-weight: bold; text-decoration: none;">0</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> item = <ins style="font-weight: bold; text-decoration: none;">112249306</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>Assign attributes to pages or entire namespaces</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>Assign attributes to pages or entire namespaces</div></td> </tr> <tr> <td colspan="2" class="diff-lineno">Zeile 60:</td> <td colspan="2" class="diff-lineno">Zeile 60:</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 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>PageAttributes.f = function ( ask, another )</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>PageAttributes.f = function ( ask, another )</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> -- Retrieve <del style="font-weight: bold; text-decoration: none;">versioning</del> <del style="font-weight: bold; text-decoration: none;">and check for compliance</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> -- Retrieve <ins style="font-weight: bold; text-decoration: none;">page</ins> <ins style="font-weight: bold; text-decoration: none;">attributes</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> -- Precondition:</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> -- Precondition:</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> -- ask -- string, with submodule name</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> -- ask -- string, with submodule name</div></td> </tr> <tr> <td colspan="2" class="diff-lineno">Zeile 78:</td> <td colspan="2" class="diff-lineno">Zeile 78:</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 s = type( another )</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 s = type( another )</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 s == "string" 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 s == "string" then</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></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 id = another:match( "^%s*#(%d+)%s*$" )</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></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> page = mw.title.new( id or another )</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></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> elseif s == "number" 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> page = mw.title.new( another )</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> page = mw.title.new( another )</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> elseif s == "table" and</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> elseif s == "table" and</div></td> </tr> <tr> <td colspan="2" class="diff-lineno">Zeile 102:</td> <td colspan="2" class="diff-lineno">Zeile 105:</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 colspan="2" class="diff-empty diff-side-deleted"></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> r = r or false</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" 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 r<del style="font-weight: bold; text-decoration: none;"> or false</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> return r</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 -- PageAttributes.f()</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 -- PageAttributes.f()</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> </table> PerfektesChaos https://de.wikipedia.org/w/index.php?title=Modul:PageAttributes&diff=223465846&oldid=prev PerfektesChaos: Setup 2022-06-05T23:29:40Z <p>Setup</p> <p><b>Neue Seite</b></p><div>local PageAttributes = { suite = &quot;PageAttributes&quot;,<br /> serial = &quot;2022-05-25&quot;,<br /> item = 0 }<br /> --[==[<br /> Assign attributes to pages or entire namespaces<br /> ]==]<br /> local Failsafe = PageAttributes<br /> local GlobalMod = PageAttributes<br /> <br /> <br /> <br /> local foreignModule = function ( access, advanced, append, alt, alert )<br /> -- Fetch global module<br /> -- Precondition:<br /> -- access -- string, with name of base module<br /> -- advanced -- true, for require(); else mw.loadData()<br /> -- append -- string, with subpage part, if any; or false<br /> -- alt -- number, of wikidata item of root; or false<br /> -- alert -- true, for throwing error on data problem<br /> -- Postcondition:<br /> -- Returns whatever, probably table<br /> -- 2020-01-01<br /> local storage = access<br /> local fun, lucky, r<br /> if advanced then<br /> fun = require<br /> else<br /> fun = mw.loadData<br /> end<br /> if append then<br /> storage = string.format( &quot;%s/%s&quot;, storage, append )<br /> end<br /> lucky, r = pcall( fun, &quot;Module:&quot; .. storage )<br /> if not lucky then<br /> local suited<br /> GlobalMod.globalModules = GlobalMod.globalModules or { }<br /> suited = GlobalMod.globalModules[ access ]<br /> if not suited and<br /> type( alt ) == &quot;number&quot; and<br /> alt &gt; 0 then<br /> suited = string.format( &quot;Q%d&quot;, alt )<br /> suited = mw.wikibase.getSitelink( suited )<br /> GlobalMod.globalModules[ access ] = suited or true<br /> end<br /> if type( suited ) == &quot;string&quot; then<br /> storage = suited<br /> if append then<br /> storage = string.format( &quot;%s/%s&quot;, storage, append )<br /> end<br /> lucky, r = pcall( fun, storage )<br /> end<br /> if not lucky and alert then<br /> error( &quot;Missing or invalid page: &quot; .. storage )<br /> end<br /> end<br /> return r<br /> end -- foreignModule()<br /> <br /> <br /> <br /> PageAttributes.f = function ( ask, another )<br /> -- Retrieve versioning and check for compliance<br /> -- Precondition:<br /> -- ask -- string, with submodule name<br /> -- another -- string or mw.title (optional), with page name<br /> -- default: current page<br /> -- Postcondition:<br /> -- Returns string, number, boolean<br /> local r<br /> if type( ask ) == &quot;string&quot; then<br /> local props = foreignModule( PageAttributes.suite,<br /> false,<br /> ask,<br /> PageAttributes.item )<br /> if type( props ) == &quot;table&quot; then<br /> local page<br /> if another then<br /> local s = type( another )<br /> if s == &quot;string&quot; then<br /> page = mw.title.new( another )<br /> elseif s == &quot;table&quot; and<br /> type( another.namespace ) == &quot;number&quot; and<br /> type( another.id ) == &quot;number&quot; then<br /> page = another<br /> end<br /> end<br /> page = page or mw.title.getCurrentTitle()<br /> if type( props.rooms ) == &quot;table&quot; then<br /> r = props.rooms[ page.namespace ]<br /> end<br /> if type( props.pageids ) == &quot;table&quot; then<br /> local q = props.pageids[ page.id ]<br /> if q ~= nil then<br /> r = q<br /> end<br /> end<br /> if type( r ) == &quot;string&quot; then<br /> r = mw.text.trim( r )<br /> if r == &quot;&quot; then<br /> r = false<br /> end<br /> end<br /> end<br /> end<br /> return r or false<br /> end -- PageAttributes.f()<br /> <br /> <br /> <br /> Failsafe.failsafe = function ( atleast )<br /> -- Retrieve versioning and check for compliance<br /> -- Precondition:<br /> -- atleast -- string, with required version<br /> -- or wikidata|item|~|@ or false<br /> -- Postcondition:<br /> -- Returns string -- with queried version/item, also if problem<br /> -- false -- if appropriate<br /> -- 2020-08-17<br /> local since = atleast<br /> local last = ( since == &quot;~&quot; )<br /> local linked = ( since == &quot;@&quot; )<br /> local link = ( since == &quot;item&quot; )<br /> local r<br /> if last or link or linked or since == &quot;wikidata&quot; then<br /> local item = Failsafe.item<br /> since = false<br /> if type( item ) == &quot;number&quot; and item &gt; 0 then<br /> local suited = string.format( &quot;Q%d&quot;, item )<br /> if link then<br /> r = suited<br /> else<br /> local entity = mw.wikibase.getEntity( suited )<br /> if type( entity ) == &quot;table&quot; then<br /> local seek = Failsafe.serialProperty or &quot;P348&quot;<br /> local vsn = entity:formatPropertyValues( seek )<br /> if type( vsn ) == &quot;table&quot; and<br /> type( vsn.value ) == &quot;string&quot; and<br /> vsn.value ~= &quot;&quot; then<br /> if last and vsn.value == Failsafe.serial then<br /> r = false<br /> elseif linked then<br /> if mw.title.getCurrentTitle().prefixedText<br /> == mw.wikibase.getSitelink( suited ) then<br /> r = false<br /> else<br /> r = suited<br /> end<br /> else<br /> r = vsn.value<br /> end<br /> end<br /> end<br /> end<br /> end<br /> end<br /> if type( r ) == &quot;nil&quot; then<br /> if not since or since &lt;= Failsafe.serial then<br /> r = Failsafe.serial<br /> else<br /> r = false<br /> end<br /> end<br /> return r<br /> end -- Failsafe.failsafe()<br /> <br /> <br /> <br /> -- Export<br /> local p = { }<br /> <br /> function p.f( frame )<br /> local sub = frame.args[ 1 ]<br /> local r<br /> if sub then<br /> sub = mw.text.trim( sub )<br /> if sub ~= &quot;&quot; then<br /> local s = frame.args[ 2 ]<br /> if s then<br /> s = mw.text.trim( s )<br /> if s == &quot;&quot; then<br /> s = false<br /> end<br /> end<br /> r = PageAttributes.f( sub, s )<br /> end<br /> end<br /> if type( r ) == &quot;boolean&quot; then<br /> r = ( r and &quot;1&quot; ) or &quot;&quot;<br /> end<br /> return r<br /> end -- f<br /> <br /> p.failsafe = function ( frame )<br /> -- Versioning interface<br /> local s = type( frame )<br /> local since<br /> if s == &quot;table&quot; then<br /> since = frame.args[ 1 ]<br /> elseif s == &quot;string&quot; then<br /> since = frame<br /> end<br /> if since then<br /> since = mw.text.trim( since )<br /> if since == &quot;&quot; then<br /> since = false<br /> end<br /> end<br /> return Failsafe.failsafe( since ) or &quot;&quot;<br /> end -- p.failsafe<br /> <br /> setmetatable( p, { __call = function ( func, ... )<br /> setmetatable( p, nil )<br /> return Failsafe<br /> end } )<br /> <br /> return p</div> PerfektesChaos