Module:SiteList: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
PeaceDeadC (talk | contribs) No edit summary |
PeaceDeadC (talk | contribs) No edit summary |
||
| Line 5: | Line 5: | ||
local link = 'N/A' |
local link = 'N/A' |
||
local siteLabel = 'N/A' |
local siteLabel = 'N/A' |
||
if siteInfo then |
if siteInfo then |
||
-- проверка наличия sceneid |
|||
| ⚫ | |||
link = string.format(siteInfo.sceneFormat, sceneid) |
link = string.format(siteInfo.sceneFormat, sceneid) |
||
-- если sceneid нет, проверка наличия id |
|||
| ⚫ | |||
elseif id ~= "" then |
|||
link = string.format(siteInfo.idFormat, id) |
link = string.format(siteInfo.idFormat, id) |
||
-- если нет и sceneid, и id, использование defaultLink |
|||
else |
else |
||
link = siteInfo.defaultLink |
link = siteInfo.defaultLink |
||
end |
end |
||
-- форматирование ссылки для вывода |
|||
siteLabel = string.format("[%s %s]", link, siteInfo.name) |
siteLabel = string.format("[%s %s]", link, siteInfo.name) |
||
else |
else |
||
| Line 26: | Line 30: | ||
local siteType = args[1] or 'N/A' |
local siteType = args[1] or 'N/A' |
||
local site = args.site or 'N/A' |
local site = args.site or 'N/A' |
||
-- использование пустых строк вместо 'N/A', если значения не установлены |
|||
local id = args.id or '' |
local id = args.id or '' |
||
local sceneid = args.sceneid or '' |
local sceneid = args.sceneid or '' |
||
local alias = args.alias or 'N/A' |
local alias = args.alias or 'N/A' |
||
local notes = args.notes or 'N/A' |
local notes = args.notes or 'N/A' |
||
return buildRow(siteType, site, id, sceneid, alias, notes) |
return buildRow(siteType, site, id, sceneid, alias, notes) |
||
end |
end |
||
Revision as of 16:21, 21 July 2023
Documentation for this module may be created at Module:SiteList/doc
local p = {}
local function buildRow(siteType, site, id, sceneid, alias, notes)
local siteInfo = mw.loadData('Module:SiteDictionary')[site:lower()]
local link = 'N/A'
local siteLabel = 'N/A'
if siteInfo then
-- проверка наличия sceneid
if sceneid ~= "" then
link = string.format(siteInfo.sceneFormat, sceneid)
-- если sceneid нет, проверка наличия id
elseif id ~= "" then
link = string.format(siteInfo.idFormat, id)
-- если нет и sceneid, и id, использование defaultLink
else
link = siteInfo.defaultLink
end
-- форматирование ссылки для вывода
siteLabel = string.format("[%s %s]", link, siteInfo.name)
else
siteLabel = siteType
end
return string.format('|-\n| style="text-align:center;vertical-align:middle;" | %s\n| style="text-align:center;vertical-align:middle;" | %s\n| style="text-align:center;vertical-align:middle;" | %s\n| style="text-align:center;vertical-align:middle;" | %s\n', siteType, siteLabel, alias or 'N/A', notes or 'N/A')
end
function p.siteList(frame)
local args = frame:getParent().args
local siteType = args[1] or 'N/A'
local site = args.site or 'N/A'
-- использование пустых строк вместо 'N/A', если значения не установлены
local id = args.id or ''
local sceneid = args.sceneid or ''
local alias = args.alias or 'N/A'
local notes = args.notes or 'N/A'
return buildRow(siteType, site, id, sceneid, alias, notes)
end
return p