Content deleted Content added
Roughing out an overall RD section module. I'm not sure if there are basic theoretical flaws because I'm not sure all the ways the page is used. |
Wikipedia:Good articles/Summary |
||
(22 intermediate revisions by 5 users not shown) | |||
Line 1:
local p = {}
p.main = function (frame)
local NNN = 2 -- provide counts only over this threshold
local args = require("Module:Arguments").getArgs(frame)
-- expect args.shortcut e.g. GA/H, args.type e.g. History, args.text a long list
local subpage = frame:preprocess("{{SUBPAGENAME}}") -- I never did look up if there's a better way to do this...
local header,
local type = args.type or "error: specify type = Good Articles type"
local shortcuts = ""▼
if (subpage == type or args.override) then -- I haven't figured out how to deal with missing shortcut so why pretend
shortcuts = frame:expandTemplate{ title = 'shortcut', args = { args.shortcut } }
header = frame:expandTemplate{ title = 'Wikipedia:Good articles/
end
local xxxx, links = mw.ustring.gsub(t, "(%[%[[^%[%]]-%]%])", "%1", nil) -- count how many links
if links >= NNN then
t = t .. "<small> (" .. tostring(links) .. " articles)</small>"
end
return t .. "\n"
end
local sectionfooter = [===[
</div>
</div>
<!-- end of list -->]===]
-- comments in the text below are historical from the page's own markup
local output = header .. [===[
__NOTOC__
<div style="clear:both;">
Line 23 ⟶ 33:
</div>
<div style="clear:both;">
<span id="
<div style="padding:5px 5px 8px 5px; background-color:#66CC66; text-align:left; font-size:larger;">
<div style="text-align:left;">
</div>
</div>
]===] .. introtext
local section = 0
local finaltext = ''
<div class="NavHead" style="padding:2px 2px 2px 30px; background-color:#FFFAF0; text-align:left; font-size:larger;">[[Image:Noia 64 apps kworldclock.png |22px|left]]World history</div>▼
repeat
<div class="NavContent" style="text-align:left;">▼
local wrap = true
section = section + 1
local text = (args['section' .. tostring(section)] or args[section] or '')
local title = args['title' .. tostring(section)]
if (not title) then
if (text == '') then
break
else
local wrap = false
output = output .. text -- sections without headers go in unwrapped
end
else
local image = args['image' .. tostring(section)]
text = mw.ustring.gsub(text .. "\n=", "(==.-)\n%s*%f[=]", replace)
text = mw.ustring.sub(text,1,-2) -- ditching "=" mark from line above
if (image) then
image = '[[' .. image .. '|22px|left]]'
else
image = '' -- make section without an image
end
output = output .. [===[<div class="mw-collapsible" style="clear:both;padding: 4px;border: 1px solid #a2a9b1;font-size: 95%;">
▲<div
==­ ==
]===] .. text .. end
until false
return output
end
function p.subsection(frame)
if not mw.ustring.find( (frame.args[1] or frame:getParent().args[1] or '') ,'[[',1,true) then
return '<small>(0 articles)</small>'
else
local linkList, count = mw.ustring.gsub(mw.text.trim(frame.args[1] or frame:getParent().args[1]), '\n', ' –\n')
return linkList .. '<small> (' .. (count + 1) .. ' article' .. ( (count ~= 0) and 's' or '') .. ')</small>'
end
end
|