Editing Module:Variants

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

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..']]',
'[[Variant of::'..variant_name..']]',
'?Profession A #', -- Adding a # to this query makes it return plaintext instead of a link
'?Profession A #', -- Adding a # to this query makes it return plaintext instead of a link
'?Profession B #',
'?Profession B #',
'?Profession Level A',
'?Profession Level A',
'?Profession Level B',
'?Profession Level B',
'?Profession Level A High',
'?Profession Level A High',
'?Profession Level B High',
'?Profession Level B High',
get_images and '?Image#64px;x64px = Image' or nil,
'?Variant name',
limit = args.limit or 500,
'?Version anchor',
}
'?-Has subobject #',
'?#-',
get_images and '?Image#64px;x64px = Image' or nil,
limit = args.limit or 500,
}
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 34:
local contents
local contents
if smw_data then
if smw_data then
local formatted, pageList = {}, {}
local formatted = {}
for _, entry in ipairs(smw_data) do
for _, entry in ipairs(smw_data) do
table.insert(formatted, entry[1])
local variant_name = entry['Variant name']
end
if variant_name then
contents = table.concat(formatted, ' • ')
local page = entry['-Has subobject'] or entry[1]
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)
mw.log('"' .. grade_number .. '"')
variant_name = 'Grade ' .. grade_number
end

if not pageList[page] then
table.insert(formatted, ('[[%s|%s]]'):format(page, variant_name))
pageList[page] = true
end
else
table.insert(formatted, ('[[%s]]'):format(entry[1]))
end
end
contents = table.concat(formatted, ' • ')
else
else
contents = '[[Category:Empty variant list]]'
contents = '[[Category:Empty variant list]]'
Line 125: Line 106:
:tag('td')
:tag('td')
:css{ ['border-left'] = 'none' }
:css{ ['border-left'] = 'none' }
:wikitext(('[[%s]]'):format(entry[1]))
:wikitext(entry[1])
:done()
:done()
:tag('td')
:tag('td')
Please note that all contributions to Brighter Shores Wiki are considered to be released under the CC BY-NC-SA 3.0 (see Brighter Shores:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)
Preview page with this template

This page is a member of a hidden category: