Module:Variants: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
Im Wired In (talk | contribs) (Fix link output) |
Im Wired In (talk | contribs) (Only link to a page once) |
||
Line 21: | Line 21: | ||
'?Variant name', |
'?Variant name', |
||
'?Version anchor', |
'?Version anchor', |
||
'?-Has subobject #', |
|||
'?#-', |
'?#-', |
||
get_images and '?Image#64px;x64px = Image' or nil, |
get_images and '?Image#64px;x64px = Image' or nil, |
||
Line 37: | Line 38: | ||
local contents |
local contents |
||
if smw_data then |
if smw_data then |
||
local formatted = {} |
local formatted, pageList = {}, {} |
||
for _, entry in ipairs(smw_data) do |
for _, entry in ipairs(smw_data) do |
||
local variant_name = entry['Variant name'] |
local variant_name = entry['Variant name'] |
||
if variant_name then |
if variant_name then |
||
local page = entry[1] |
local page = entry['-Has subobject'] or entry[1] |
||
if page:sub(1, 1 + #variant_name + #' (grade ') == ':' .. variant_name .. ' (grade ' and page:sub(-1) == ')' then |
if page:sub(1, 1 + #variant_name + #' (grade ') == ':' .. variant_name .. ' (grade ' and page:sub(-1) == ')' then |
||
local grade_number = page:sub(2 + #variant_name + #' (grade ', -2) |
local grade_number = page:sub(2 + #variant_name + #' (grade ', -2) |
||
Line 47: | Line 48: | ||
variant_name = 'Grade ' .. grade_number |
variant_name = 'Grade ' .. grade_number |
||
end |
end |
||
local anchor = entry['Version anchor'] and ' § ' .. entry['Version anchor'] or '' |
|||
if not pageList[page] then |
|||
table.insert(formatted, ('[[%s| |
table.insert(formatted, ('[[%s|%s]]'):format(page, variant_name)) |
||
pageList[page] = true |
|||
end |
|||
else |
else |
||
table.insert(formatted, ('[[%s]]'):format(entry[1])) |
table.insert(formatted, ('[[%s]]'):format(entry[1])) |