Editing Module:Variants
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 12: | Line 12: | ||
local variant_name = args.variant or mw.title.getCurrentTitle().fullText |
local variant_name = args.variant or mw.title.getCurrentTitle().fullText |
||
local query = { |
local query = { |
||
'[[Variant of::'..variant_name..']]', |
|||
'?Profession A #', -- Adding a # to this query makes it return plaintext instead of a link |
|||
'?Profession B #', |
|||
'?Profession Level A', |
|||
'?Profession Level B', |
|||
'?Profession Level A High', |
|||
'?Profession Level B High', |
|||
'?Variant name', |
|||
⚫ | |||
'?Version anchor', |
|||
⚫ | |||
'?-Has subobject #', |
|||
} |
|||
'?#-', |
|||
⚫ | |||
⚫ | |||
} |
|||
local smw_data = mw.smw.ask(query) |
local smw_data = mw.smw.ask(query) |
||
if not smw_data then |
if not smw_data then |
||
Line 38: | Line 35: | ||
local contents |
local contents |
||
if smw_data then |
if smw_data then |
||
local formatted = {} |
|||
for _, entry in ipairs(smw_data) do |
|||
if entry['Variant name'] then |
|||
local page = entry[1] |
|||
if variant_name then |
|||
local pipe = page:find('|') |
|||
if pipe then |
|||
if page:sub(1, 1 + #variant_name + #' (grade ') == ':' .. variant_name .. ' (grade ' and page:sub(-1) == ')' then |
|||
page = page:sub(3, pipe-1) |
|||
else |
|||
mw.log('"' .. grade_number .. '"') |
|||
page = page:sub(3, -3) |
|||
variant_name = 'Grade ' .. grade_number |
|||
end |
|||
⚫ | |||
else |
|||
if not pageList[page] then |
|||
table.insert(formatted, entry[1]) |
|||
end |
|||
pageList[page] = true |
|||
end |
|||
⚫ | |||
else |
|||
⚫ | |||
end |
|||
end |
|||
⚫ | |||
else |
else |
||
contents = '[[Category:Empty variant list]]' |
contents = '[[Category:Empty variant list]]' |
||
Line 125: | Line 118: | ||
:tag('td') |
:tag('td') |
||
:css{ ['border-left'] = 'none' } |
:css{ ['border-left'] = 'none' } |
||
:wikitext |
:wikitext(entry[1]) |
||
:done() |
:done() |
||
:tag('td') |
:tag('td') |