https://en.wikipedia.org/w/index.php?action=history&feed=atom&title=Module%3ATeam_appearances_list%2Fshow Module:Team appearances list/show - Revision history 2025-06-08T14:31:30Z Revision history for this page on the wiki MediaWiki 1.45.0-wmf.4 https://en.wikipedia.org/w/index.php?title=Module:Team_appearances_list/show&diff=751504798&oldid=prev Johnuniq: use sandbox module if parameter specifies sandbox data 2016-11-26T03:39:13Z <p>use sandbox module if parameter specifies sandbox data</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;">← Previous revision</td> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 03:39, 26 November 2016</td> </tr><tr> <td colspan="2" class="diff-lineno">Line 63:</td> <td colspan="2" class="diff-lineno">Line 63:</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>local function main(frame)</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 main(frame)</div></td> </tr> <tr> <td class="diff-marker"><a class="mw-diff-movedpara-left" title="Paragraph was moved. Click to jump to new location." href="#movedpara_3_1_rhs">&#x26AB;</a></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><a name="movedpara_1_0_lhs"></a> local lister = require('Module:Team appearances list')._main</div></td> <td colspan="2" class="diff-empty diff-side-added"></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 title = frame.args[1]</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 title = frame.args[1]</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 title == nil or title == '' 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 title == nil or title == '' 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> return 'Error: Parameter 1 must specify name of data module'</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> return 'Error: Parameter 1 must specify name of data module'</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> local sandbox = title:find('sandbox', 1, true) and '/sandbox' or ''</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker"><a class="mw-diff-movedpara-right" title="Paragraph was moved. Click to jump to old location." href="#movedpara_1_0_lhs">&#x26AB;</a></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><a name="movedpara_3_1_rhs"></a> local lister = require('Module:Team appearances list'<ins style="font-weight: bold; text-decoration: none;"> .. sandbox</ins>)._main</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 lines = Collection.new()</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 lines = Collection.new()</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 current_games</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 current_games</div></td> </tr> </table> Johnuniq https://en.wikipedia.org/w/index.php?title=Module:Team_appearances_list/show&diff=751335699&oldid=prev Johnuniq: test Module:Team appearances list by processing items in Module:Team appearances list/data; see talk for results 2016-11-25T00:21:00Z <p>test <a href="/wiki/Module:Team_appearances_list" title="Module:Team appearances list">Module:Team appearances list</a> by processing items in <a href="/wiki/Module:Team_appearances_list/data" title="Module:Team appearances list/data">Module:Team appearances list/data</a>; see talk for results</p> <p><b>New page</b></p><div>-- For testing, show results using data from [[Module:Team appearances list/data]].<br /> <br /> local Collection = {}<br /> Collection.__index = Collection<br /> do<br /> function Collection:add(item)<br /> if item ~= nil then<br /> self.n = self.n + 1<br /> self[self.n] = item<br /> end<br /> end<br /> function Collection:join(sep)<br /> return table.concat(self, sep)<br /> end<br /> function Collection:sort(comp)<br /> table.sort(self, comp)<br /> end<br /> function Collection.new()<br /> return setmetatable({n = 0}, Collection)<br /> end<br /> end<br /> <br /> local function get_page_content(page_title)<br /> local t = mw.title.new(page_title)<br /> if t then<br /> local content = t:getContent()<br /> if content then<br /> if content:sub(-1) ~= &#039;\n&#039; then<br /> content = content .. &#039;\n&#039;<br /> end<br /> return content<br /> end<br /> end<br /> error(&#039;Could not read wikitext from &quot;[[&#039; .. page_title .. &#039;]]&quot;.&#039;, 0)<br /> end<br /> <br /> local function make_data(modname)<br /> -- Return a list of tables for each competition/team in the order used in<br /> -- the data module, based on a hope that the data module is consistently<br /> -- indented with one tab before competitions and two or more before teams,<br /> -- and quotes (&quot;) are used for strings (not apostrophes).<br /> local content = get_page_content(modname)<br /> local lnum = 0<br /> local current_games<br /> local items = Collection.new()<br /> for line in string.gmatch(content, &#039;(.-)\n&#039;) do<br /> lnum = lnum + 1<br /> local indent, title = line:match(&#039;^(\t+)%[&quot;(.-)&quot;%]&#039;)<br /> if indent then<br /> if indent == &#039;\t&#039; then<br /> current_games = title<br /> else<br /> items:add({<br /> competition = current_games,<br /> team = title,<br /> line = lnum,<br /> })<br /> end<br /> end<br /> end<br /> return items<br /> end<br /> <br /> local function main(frame)<br /> local lister = require(&#039;Module:Team appearances list&#039;)._main<br /> local title = frame.args[1]<br /> if title == nil or title == &#039;&#039; then<br /> return &#039;Error: Parameter 1 must specify name of data module&#039;<br /> end<br /> local lines = Collection.new()<br /> local current_games<br /> for _, item in ipairs(make_data(title)) do<br /> if current_games ~= item.competition then<br /> current_games = item.competition<br /> lines:add(&#039;==&#039; .. current_games .. &#039;==&#039;)<br /> end<br /> lines:add(item.team .. &#039; (line &#039; .. item.line .. &#039;) &#039; .. lister(item))<br /> end<br /> return lines:join(&#039;\n&#039;)<br /> end<br /> <br /> return { main = main }</div> Johnuniq